From f17279c60abc6070a24e9338fb7025f41fc3df54 Mon Sep 17 00:00:00 2001 From: wolf Date: Wed, 27 Oct 1999 09:06:55 +0000 Subject: [PATCH] Implement the interpolation of boundary values for certain components only. git-svn-id: https://svn.dealii.org/trunk@1799 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/numerics/vectors.h | 19 ++++++++- deal.II/deal.II/source/numerics/vectors.cc | 47 +++++++++++++++++----- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/deal.II/deal.II/include/numerics/vectors.h b/deal.II/deal.II/include/numerics/vectors.h index 6cbb45f2ec..cc70c314cb 100644 --- a/deal.II/deal.II/include/numerics/vectors.h +++ b/deal.II/deal.II/include/numerics/vectors.h @@ -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 &dof, const FunctionMap &dirichlet_bc, - map &boundary_values); + map &boundary_values, + const vector &component_mask = vector()); /** * Project #function# to the boundary diff --git a/deal.II/deal.II/source/numerics/vectors.cc b/deal.II/deal.II/source/numerics/vectors.cc index 6597ff783b..4eaf3a3f93 100644 --- a/deal.II/deal.II/source/numerics/vectors.cc +++ b/deal.II/deal.II/source/numerics/vectors.cc @@ -467,7 +467,8 @@ template <> void VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &dof, const FunctionMap &dirichlet_bc, - map &boundary_values) + map &boundary_values, + const vector &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 component_mask ((component_mask_.size() == 0) ? + vector (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; ivertex_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; ivertex_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 void VectorTools::interpolate_boundary_values (const DoFHandler &dof, const FunctionMap &dirichlet_bc, - map &boundary_values) + map &boundary_values, + const vector &component_mask_) { Assert (dirichlet_bc.find(255) == dirichlet_bc.end(), ExcInvalidBoundaryIndicator()); @@ -545,6 +562,15 @@ VectorTools::interpolate_boundary_values (const DoFHandler &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 component_mask ((component_mask_.size() == 0) ? + vector (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::interpolate_boundary_values (const DoFHandler &dof, // enter into list for (unsigned int i=0; i