[cig-commits] commit 2010 by heister to /var/svn/dealii/aspect

dealii.demon at gmail.com dealii.demon at gmail.com
Fri Nov 8 12:57:30 PST 2013


Revision 2010

new option to prescribe the velocity only for certain

U   trunk/aspect/doc/modules/changes.h
U   trunk/aspect/include/aspect/simulator.h
U   trunk/aspect/source/simulator/core.cc
U   trunk/aspect/source/simulator/parameters.cc


http://www.dealii.org/websvn/revision.php?repname=Aspect+Repository&path=%2F&rev=2010&peg=2010

Diff:
Modified: trunk/aspect/doc/modules/changes.h
===================================================================
--- trunk/aspect/doc/modules/changes.h	2013-11-04 22:19:14 UTC (rev 2009)
+++ trunk/aspect/doc/modules/changes.h	2013-11-08 20:57:28 UTC (rev 2010)
@@ -8,6 +8,11 @@
 </p>
 
 <ol>
+  <li>New: It is now possible to prescribe the velocity only for certain
+  components in the 'Prescribed velocity boundary indicators' parameter.
+  <br>
+  (Timo Heister 2013/11/08)
+
   <li>New: the "iterated Stokes" nonlinear solver will now stop iterating
   if the residual is smaller than the new "Nonlinear solver tolerance".
   <br>

Modified: trunk/aspect/include/aspect/simulator.h
===================================================================
--- trunk/aspect/include/aspect/simulator.h	2013-11-04 22:19:14 UTC (rev 2009)
+++ trunk/aspect/include/aspect/simulator.h	2013-11-08 20:57:28 UTC (rev 2010)
@@ -187,8 +187,13 @@
         std::set<types::boundary_id> fixed_temperature_boundary_indicators;
         std::set<types::boundary_id> zero_velocity_boundary_indicators;
         std::set<types::boundary_id> tangential_velocity_boundary_indicators;
-        std::map<types::boundary_id, std::string> prescribed_velocity_boundary_indicators;
         /**
+         * map from boundary id to a pair "components", "velocity boundary type",
+         * where components is of the format "[x][y][z]" and the velocity type
+         * is mapped to one of the plugins of velocity boundary conditions (e.g. "function")
+         */
+        std::map<types::boundary_id, std::pair<std::string,std::string> > prescribed_velocity_boundary_indicators;
+        /**
          * @}
          */
 

Modified: trunk/aspect/source/simulator/core.cc
===================================================================
--- trunk/aspect/source/simulator/core.cc	2013-11-04 22:19:14 UTC (rev 2009)
+++ trunk/aspect/source/simulator/core.cc	2013-11-08 20:57:28 UTC (rev 2010)
@@ -146,7 +146,8 @@
             parameters.tangential_velocity_boundary_indicators,
             std::set<types::boundary_id>()
           };
-      for (std::map<types::boundary_id,std::string>::const_iterator
+
+      for (std::map<types::boundary_id,std::pair<std::string, std::string> >::const_iterator
            p = parameters.prescribed_velocity_boundary_indicators.begin();
            p != parameters.prescribed_velocity_boundary_indicators.end();
            ++p)
@@ -187,7 +188,7 @@
            p != parameters.fixed_temperature_boundary_indicators.end(); ++p)
         AssertThrow (all_boundary_indicators.find (*p)
                      != all_boundary_indicators.end(),
-                     ExcMessage ("One of the boundary indicators listed in the input file "
+                     ExcMessage ("One of the fixed boundary indicators listed in the input file "
                                  "is not used by the geometry model."));
     }
 
@@ -231,14 +232,14 @@
     geometry_model->create_coarse_mesh (triangulation);
     global_Omega_diameter = GridTools::diameter (triangulation);
 
-    for (std::map<types::boundary_id,std::string>::const_iterator
+    for (std::map<types::boundary_id,std::pair<std::string,std::string> >::const_iterator
          p = parameters.prescribed_velocity_boundary_indicators.begin();
          p != parameters.prescribed_velocity_boundary_indicators.end();
          ++p)
       {
         VelocityBoundaryConditions::Interface<dim> *bv
           = VelocityBoundaryConditions::create_velocity_boundary_conditions
-            (p->second,
+            (p->second.second,
              prm,
              *geometry_model);
         if (dynamic_cast<SimulatorAccess<dim>*>(bv) != 0)
@@ -450,11 +451,36 @@
            std_cxx1x::bind (&VelocityBoundaryConditions::Interface<dim>::boundary_velocity,
                             p->second,
                             std_cxx1x::_1));
+
+          // here we create a mask for interpolate_boundary_values out of the 'selector'
+          std::vector<bool> mask(introspection.component_masks.velocities.size(), false);
+          Assert(introspection.component_masks.velocities[0]==true, ExcInternalError()); // in case we ever move the velocity around
+          const std::string & comp = parameters.prescribed_velocity_boundary_indicators[p->first].first;
+
+          if (comp.length()>0)
+            {
+              for (std::string::const_iterator p=comp.begin();p!=comp.end();++p)
+                {
+                  AssertThrow(*p>='x' && *p<='z', ExcMessage("Error in selector of prescribed velocity boundary component"));
+                  AssertThrow(dim==3 || *p!='z', ExcMessage("for dim=2, prescribed velocity component z is invalid"))
+                  mask[*p-'x']=true;
+                }
+              for (unsigned int i=0;i<introspection.component_masks.velocities.size();++i)
+                mask[i] = mask[i] & introspection.component_masks.velocities[i];
+            }
+          else
+            {
+              for (unsigned int i=0;i<introspection.component_masks.velocities.size();++i)
+                  mask[i]=introspection.component_masks.velocities[i];
+
+              Assert(introspection.component_masks.velocities[0]==true, ExcInternalError()); // in case we ever move the velocity down
+            }
+
           VectorTools::interpolate_boundary_values (dof_handler,
                                                     p->first,
                                                     vel,
                                                     current_constraints,
-                                                    introspection.component_masks.velocities);
+                                                    mask);
         }
       current_constraints.close();
     }

Modified: trunk/aspect/source/simulator/parameters.cc
===================================================================
--- trunk/aspect/source/simulator/parameters.cc	2013-11-04 22:19:14 UTC (rev 2009)
+++ trunk/aspect/source/simulator/parameters.cc	2013-11-08 20:57:28 UTC (rev 2010)
@@ -290,7 +290,7 @@
                          "velocity (although there is a force that requires the flow to "
                          "be tangential).");
       prm.declare_entry ("Prescribed velocity boundary indicators", "",
-                         Patterns::Map (Patterns::Integer(0, std::numeric_limits<types::boundary_id>::max()),
+                         Patterns::Map (Patterns::Anything(),
                                         Patterns::Selection(VelocityBoundaryConditions::get_names<dim>())),
                          "A comma separated list denoting those boundaries "
                          "on which the velocity is tangential but prescribed, i.e., where "
@@ -299,9 +299,14 @@
                          "overlying plates."
                          "

"
                          "The format of valid entries for this parameter is that of a map "
-                         "given as ``key1: value1, key2: value2, key3: value3, ...'' where "
-                         "each key must be a valid boundary indicator and each value must "
-                         "be one of the currently implemented boundary velocity models."
+                         "given as ``key1 [selector]: value1, key2 [selector]: value2, key3: value3, ...'' where "
+                         "each key must be a valid boundary indicator (which is an integer) "
+                         "and each value must be one of the currently implemented boundary "
+                         "velocity models. selector is an optional string given as a subset "
+                         "of the letters 'xyz' that allows you to apply the boundary conditions "
+                         "only to the components listed. As an example, '1 y: function' applies "
+                         "the type 'function' to the y component on boundary 1. Without a selector "
+                         "it will effect all components of the velocity."
                          "

"
                          "Note that the no-slip boundary condition is "
                          "a special case of the current one where the prescribed velocity "
@@ -615,28 +620,39 @@
       for (std::vector<std::string>::const_iterator p = x_prescribed_velocity_boundary_indicators.begin();
            p != x_prescribed_velocity_boundary_indicators.end(); ++p)
         {
-          // split the pair "key:value"
-          AssertThrow (p->find(":") != std::string::npos,
-                       ExcInternalError());
+          // each entry has the format (white space is optional):
+          // <id> [x][y][z] : <value (might have spaces)>
+          std::string comp = "";
+          std::string value = "";
 
-          std::string key = *p;
-          key.erase (key.find(":"), std::string::npos);
-          while ((key.length() > 0) && (std::isspace (key[key.length()-1])))
-            key.erase (key.length()-1, 1);
-          const types::boundary_id boundary_id = Utilities::string_to_int(key);
+          std::stringstream ss(*p);
+          int b_id;
+          ss >> b_id; // need to read as int, not char
+          types::boundary_id boundary_id = b_id;
 
-          std::string value = *p;
-          value.erase (0, value.find(":")+1);
-          while ((value.length() > 0) && (std::isspace (value[0])))
-            value.erase (0, 1);
+          char c;
+          while (ss.peek()==' ') ss.get(c); // eat spaces
 
+          if (ss.peek()!=':')
+            {
+              std::getline(ss,comp,':');
+              while (comp.length()>0 && *(--comp.end())==' ')
+                comp.erase(comp.length()-1); // remove whitespace at the end
+            }
+          else
+            ss.get(c); // read the ':'
 
+          while (ss.peek()==' ') ss.get(c); // eat spaces
+
+          std::getline(ss,value); // read until the end of the string
+
           AssertThrow (prescribed_velocity_boundary_indicators.find(boundary_id)
                        == prescribed_velocity_boundary_indicators.end(),
-                       ExcMessage ("Boundary indicator <" + key +
+                       ExcMessage ("Boundary indicator <" + Utilities::int_to_string(boundary_id) +
                                    "> appears more than once in the list of indicators "
                                    "for nonzero velocity boundaries."));
-          prescribed_velocity_boundary_indicators[boundary_id] = value;
+          prescribed_velocity_boundary_indicators[boundary_id] =
+              std::pair<std::string,std::string>(comp,value);
         }
     }
     prm.leave_subsection ();


More information about the CIG-COMMITS mailing list