[cig-commits] [commit] master: Update minimum refinement function to always read in 3 variables. (d8d98d4)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Mon Aug 4 03:20:12 PDT 2014


Repository : https://github.com/geodynamics/aspect

On branch  : master
Link       : https://github.com/geodynamics/aspect/compare/cf143473b5c2b534ac8c3bfde3cad6477de32b26...b473495171cd1e5aff77c7f34a6444b14134b19f

>---------------------------------------------------------------

commit d8d98d42d9edbb1de3b00797941190098c8c29e2
Author: Rene Gassmoeller <R.Gassmoeller at mailbox.org>
Date:   Sat Aug 2 03:41:59 2014 -0700

    Update minimum refinement function to always read in 3 variables.


>---------------------------------------------------------------

d8d98d42d9edbb1de3b00797941190098c8c29e2
 doc/modules/changes.h                              |  6 +++
 .../mesh_refinement/minimum_refinement_function.h  | 10 ++---
 .../mesh_refinement/minimum_refinement_function.cc | 47 +++++++++++++---------
 tests/minimum_refinement_function.prm              | 14 ++++++-
 4 files changed, 52 insertions(+), 25 deletions(-)

diff --git a/doc/modules/changes.h b/doc/modules/changes.h
index 0c409bf..471027e 100644
--- a/doc/modules/changes.h
+++ b/doc/modules/changes.h
@@ -7,6 +7,12 @@
  *
  * <ol>
  *
+ * <li> Changed: The minimum refinement function now always declares
+ * three variables. In the 'depth' option only the first one is
+ * set to the depth, the other variables are set to zero.
+ * <br>
+ * (Rene Gassmoeller, 2014/08/04)
+ *
  * <li> New: There are now function parser plugins for the
  * gravity model and boundary temperature model. Gravity can
  * be prescribed in dependence of position and boundary temperature
diff --git a/include/aspect/mesh_refinement/minimum_refinement_function.h b/include/aspect/mesh_refinement/minimum_refinement_function.h
index 696daa9..3961e37 100644
--- a/include/aspect/mesh_refinement/minimum_refinement_function.h
+++ b/include/aspect/mesh_refinement/minimum_refinement_function.h
@@ -80,12 +80,12 @@ namespace aspect
         } coordinate_system;
 
         /**
-         * A function object representing the minimum refinement level. Which
-         * of the two functions is actually evaluated is determined by the
-         * 'Coordinate dependence' input parameter.
+         * A function object representing the minimum refinement level. The
+         * function always depends on 3 variables, although in the case of the
+         * 'depth' coordinate system only the first is used to evaluate the
+         * function.
          */
-        Functions::ParsedFunction<1> min_refinement_level_depth;
-        Functions::ParsedFunction<dim> min_refinement_level_position;
+        Functions::ParsedFunction<dim> min_refinement_level;
 
     };
   }
diff --git a/source/mesh_refinement/minimum_refinement_function.cc b/source/mesh_refinement/minimum_refinement_function.cc
index 413552a..8c128de 100644
--- a/source/mesh_refinement/minimum_refinement_function.cc
+++ b/source/mesh_refinement/minimum_refinement_function.cc
@@ -52,8 +52,9 @@ namespace aspect
                   if (coordinate_system == depth)
                     {
                       const double depth = this->get_geometry_model().depth(vertex);
-                      const Point<1> point(depth);
-                      minimum_refinement_level = min_refinement_level_depth.value(point);
+                      Point<dim> point;
+                      point(0) = depth;
+                      minimum_refinement_level = min_refinement_level.value(point);
                     }
                   else if (coordinate_system == spherical)
                     {
@@ -66,11 +67,11 @@ namespace aspect
                       for (unsigned int i = 0;i<dim;++i)
                         point[i] = spherical_coordinates[i];
 
-                      minimum_refinement_level = min_refinement_level_position.value(point);
+                      minimum_refinement_level = min_refinement_level.value(point);
                     }
                   else if (coordinate_system == cartesian)
                     {
-                      minimum_refinement_level = min_refinement_level_position.value(vertex);
+                      minimum_refinement_level = min_refinement_level.value(vertex);
                     }
 
                   if (cell->level() <= rint(minimum_refinement_level))
@@ -112,18 +113,14 @@ namespace aspect
                              "A selection that determines the assumed coordinate "
                              "system for the function variables. Allowed values "
                              "are 'depth', 'cartesian' and 'spherical'. 'depth' "
-                             "requires a function expression that only "
-                             "depends on one variable, which is interpreted to "
-                             "be the depth of the point (in meters). 'spherical' coordinates "
+                             "will create a function, in which only the first "
+                             "variable is non-zero, which is interpreted to "
+                             "be the depth of the point. 'spherical' coordinates "
                              "are interpreted as r,phi or r,phi,theta in 2D/3D "
                              "respectively with theta being the polar angle.");
           /**
            * Let the function that describes the minimal level of refinement
-           * as a function of position declare its parameters. This is actually
-           * not the one that parses the parameters in case the user choose
-           * 'depth' as coordinate dependence, but the parameters of the depth
-           * function are a subset of the parameters of this one so everything
-           * should work out ok.
+           * as a function of position declare its parameters.
            * This defines the minimum refinement level each cell should have,
            * and that can not be exceeded by coarsening.
            */
@@ -153,10 +150,7 @@ namespace aspect
 
           try
             {
-              if (coordinate_system == depth)
-                min_refinement_level_depth.parse_parameters (prm);
-              else
-                min_refinement_level_position.parse_parameters (prm);
+              min_refinement_level.parse_parameters (prm);
             }
           catch (...)
             {
@@ -186,9 +180,24 @@ namespace aspect
                                               "explicit formula with the depth or position "
                                               "as argument. Which coordinate representation "
                                               "is used is determined by an input parameter. "
-                                              "Note that the order of spherical coordinates "
-                                              "is r,phi,theta and not r,theta,phi, since this "
-                                              "allows for dimension independent expressions. "
+                                              "Whatever the coordinate system chosen, the "
+                                              "function you provide in the input file will "
+                                              "by default depend on variables 'x', 'y' and "
+                                              "'z' (if in 3d). However, the meaning of these "
+                                              "symbols depends on the coordinate system. In "
+                                              "the Cartesian coordinate system, they simply "
+                                              "refer to their natural meaning. If you have "
+                                              "selected 'depth' for the coordinate system, "
+                                              "then 'x' refers to the depth variable and 'y' "
+                                              "and 'z' will simply always be zero. If you "
+                                              "have selected a spherical coordinate system, "
+                                              "then 'x' will refer to the radial distance of "
+                                              "the point to the origin, 'y' to the azimuth "
+                                              "angle and 'z' to the polar angle measured "
+                                              "positive from the north pole. Note that the "
+                                              "order of spherical coordinates is r,phi,theta "
+                                              "and not r,theta,phi, since this allows for "
+                                              "dimension independent expressions. "
                                               "After evaluating the function, its values are "
                                               "rounded to the nearest integer.")
   }
diff --git a/tests/minimum_refinement_function.prm b/tests/minimum_refinement_function.prm
index 2325c05..bc8b09b 100644
--- a/tests/minimum_refinement_function.prm
+++ b/tests/minimum_refinement_function.prm
@@ -157,8 +157,20 @@ subsection Mesh refinement
   set Time steps between mesh refinement       = 1
   subsection Minimum refinement function
     set Function constants  = 
+
+    # This is in fact the default value
+    set Coordinate system   = depth
+
+    # The following lines are equal to set the line:
+    # set Function expression = 4 + 2*sin(x*pi/250000)
+    # which implies:
+    # set Variable names    = x,y
+    # because that is the default value for Variable names.
+    # To illustrate the possibility to rename function variables
+    # in your favourite naming scheme we use the following:
+    set Variable names      = depth,not_used1
     set Function expression = 4 + 2*sin(depth*pi/250000)
-    set Variable names      = depth
+
   end
 end
 



More information about the CIG-COMMITS mailing list