]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implement the interpolation of boundary values for certain components only.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 27 Oct 1999 09:06:55 +0000 (09:06 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 27 Oct 1999 09:06:55 +0000 (09:06 +0000)
git-svn-id: https://svn.dealii.org/trunk@1799 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/numerics/vectors.h
deal.II/deal.II/source/numerics/vectors.cc

index 6cbb45f2ec16c8fa6393f753526591986f587ced..cc70c314cb650d0d3f84fb116b69d7d5b42d2df3 100644 (file)
@@ -367,6 +367,22 @@ class VectorTools
                                      * of the boundary part to be projected
                                      * on already was in the variable.
                                      *
+                                     * The flags in the last
+                                     * parameter, #component_mask#
+                                     * denote which components of the
+                                     * finite element space shall be
+                                     * interpolated. If it is left as
+                                     * specified by the default value
+                                     * (i.e. an empty array), all
+                                     * components are
+                                     * interpolated. If is different
+                                     * from the default value, it is
+                                     * assumed that the number of
+                                     * entries equals the number of
+                                     * components in the boundary
+                                     * functions and the finite
+                                     * element.
+                                     *
                                      * It is assumed that the number
                                      * of components of the functions
                                      * in #dirichlet_bc# matches that
@@ -378,7 +394,8 @@ class VectorTools
                                      */
     static void interpolate_boundary_values (const DoFHandler<dim> &dof,
                                             const FunctionMap     &dirichlet_bc,
-                                            map<int,double>       &boundary_values);
+                                            map<int,double>       &boundary_values,
+                                            const vector<bool>    &component_mask = vector<bool>());
 
                                     /**
                                      * Project #function# to the boundary
index 6597ff783b7448431ae67f6aea8f9e71eadac86b..4eaf3a3f93970b5882bd5be9c054ed267e6959da 100644 (file)
@@ -467,7 +467,8 @@ template <>
 void
 VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &dof,
                                             const FunctionMap   &dirichlet_bc,
-                                            map<int,double>     &boundary_values)
+                                            map<int,double>     &boundary_values,
+                                            const vector<bool>  &component_mask_)
 {
   Assert (dirichlet_bc.find(255) == dirichlet_bc.end(),
          ExcInvalidBoundaryIndicator());
@@ -476,6 +477,15 @@ VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &dof,
   Assert (fe.n_components == dirichlet_bc.begin()->second->n_components,
          ExcComponentMismatch());
   Assert (fe.dofs_per_vertex == fe.n_components,
+         ExcComponentMismatch());
+
+                                  // set the component mask to either
+                                  // the original value or a vector
+                                  // of #true#s
+  const vector<bool> component_mask ((component_mask_.size() == 0) ?
+                                    vector<bool> (fe.n_components, true) :
+                                    component_mask_);
+  Assert (count(component_mask.begin(), component_mask.end(), true) > 0,
          ExcComponentMismatch());
   
                                   // check whether boundary values at the
@@ -493,11 +503,16 @@ VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &dof,
       while (leftmost_cell->has_children())
        leftmost_cell = leftmost_cell->child(0);
 
-                                      // now set the value of the leftmost
-                                      // degree of freedom
+                                      // now set the value of the
+                                      // leftmost degree of
+                                      // freedom. setting also
+                                      // created the entry in the map
+                                      // if it did not exist
+                                      // beforehand
       for (unsigned int i=0; i<fe.dofs_per_vertex; ++i)
-       boundary_values[leftmost_cell->vertex_dof_index(0,i)]
-         = dirichlet_bc.find(0)->second->value(leftmost_cell->vertex(0), i);
+       if (component_mask[fe.face_system_to_component_index(i).first])
+         boundary_values[leftmost_cell->vertex_dof_index(0,i)]
+           = dirichlet_bc.find(0)->second->value(leftmost_cell->vertex(0), i);
     };
 
                                   // same for the right boundary of
@@ -518,8 +533,9 @@ VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &dof,
                                       // now set the value of the rightmost
                                       // degree of freedom
       for (unsigned int i=0; i<fe.dofs_per_vertex; ++i)
-       boundary_values[rightmost_cell->vertex_dof_index(1,i)]
-         = dirichlet_bc.find(1)->second->value(rightmost_cell->vertex(1), i);
+       if (component_mask[fe.face_system_to_component_index(i).first])
+         boundary_values[rightmost_cell->vertex_dof_index(1,i)]
+           = dirichlet_bc.find(1)->second->value(rightmost_cell->vertex(1), i);
     };
   
 };
@@ -533,7 +549,8 @@ template <int dim>
 void
 VectorTools<dim>::interpolate_boundary_values (const DoFHandler<dim> &dof,
                                               const FunctionMap     &dirichlet_bc,
-                                              map<int,double>       &boundary_values)
+                                              map<int,double>       &boundary_values,
+                                              const vector<bool>    &component_mask_)
 {
   Assert (dirichlet_bc.find(255) == dirichlet_bc.end(),
          ExcInvalidBoundaryIndicator());
@@ -545,6 +562,15 @@ VectorTools<dim>::interpolate_boundary_values (const DoFHandler<dim> &dof,
   Assert (n_components == dirichlet_bc.begin()->second->n_components,
          ExcInvalidFE());
 
+                                  // set the component mask to either
+                                  // the original value or a vector
+                                  // of #true#s
+  const vector<bool> component_mask ((component_mask_.size() == 0) ?
+                                    vector<bool> (fe.n_components, true) :
+                                    component_mask_);
+  Assert (count(component_mask.begin(), component_mask.end(), true) > 0,
+         ExcComponentMismatch());
+
   typename FunctionMap::const_iterator function_ptr;
 
                                   // field to store the indices of dofs
@@ -581,8 +607,9 @@ VectorTools<dim>::interpolate_boundary_values (const DoFHandler<dim> &dof,
                                             // enter into list
            
            for (unsigned int i=0; i<face_dofs.size(); ++i)
-             boundary_values[face_dofs[i]]
-               = dof_values_system[i](fe.face_system_to_component_index(i).first);
+             if (component_mask[fe.face_system_to_component_index(i).first])
+               boundary_values[face_dofs[i]]
+                 = dof_values_system[i](fe.face_system_to_component_index(i).first);
          }
        else
                                           // fe has only one component,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.