From: wolf Date: Fri, 21 May 1999 13:55:02 +0000 (+0000) Subject: Interpolate boundary values in 1d. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37862a7db35b7c6c6d0a73530cc63182b4bee5fc;p=dealii-svn.git Interpolate boundary values in 1d. git-svn-id: https://svn.dealii.org/trunk@1349 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/numerics/vectors.cc b/deal.II/deal.II/source/numerics/vectors.cc index 691d7e3d66..253f1ec0b1 100644 --- a/deal.II/deal.II/source/numerics/vectors.cc +++ b/deal.II/deal.II/source/numerics/vectors.cc @@ -94,9 +94,10 @@ VectorTools::interpolate(const DoFHandler &high_dof, } } -#if deal_II_dimension == 1 +#if deal_II_dimension == 1 + template <> void VectorTools<1>::project (const DoFHandler<1> &, const ConstraintMatrix &, @@ -248,11 +249,58 @@ void VectorTools::create_right_hand_side (const DoFHandler &dof, template <> void -VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &, - const FunctionMap &, - map &) +VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &dof, + const FunctionMap &dirichlet_bc, + map &boundary_values) { - Assert (false, ExcNotImplemented()); + Assert (dirichlet_bc.find(255) == dirichlet_bc.end(), + ExcInvalidBoundaryIndicator()); + + const FiniteElement<1> &fe = dof.get_fe(); + Assert (fe.dofs_per_vertex == 1, ExcInvalidFE()); + + // check whether boundary values at the + // left boundary of the line are requested + if (dirichlet_bc.find(0) != dirichlet_bc.end()) + { + // first find the leftmost active + // cell by first traversing the coarse + // grid to its left end and then going + // to the children + DoFHandler<1>::cell_iterator leftmost_cell = dof.begin(0); + while (leftmost_cell->neighbor(0).state() == valid) + leftmost_cell = leftmost_cell->neighbor(0); + + while (leftmost_cell->has_children()) + leftmost_cell = leftmost_cell->child(0); + + // now set the value of the leftmost + // degree of freedom + boundary_values[leftmost_cell->vertex_dof_index(0,0)] + = dirichlet_bc.find(0)->second->operator()(leftmost_cell->vertex(0)); + }; + + // same for the right boundary of + // the line are requested + if (dirichlet_bc.find(1) != dirichlet_bc.end()) + { + // first find the leftmost active + // cell by first traversing the coarse + // grid to its left end and then going + // to the children + DoFHandler<1>::cell_iterator rightmost_cell = dof.last(0); + while (rightmost_cell->neighbor(1).state() == valid) + rightmost_cell = rightmost_cell->neighbor(1); + + while (rightmost_cell->has_children()) + rightmost_cell = rightmost_cell->child(1); + + // now set the value of the rightmost + // degree of freedom + boundary_values[rightmost_cell->vertex_dof_index(1,0)] + = dirichlet_bc.find(1)->second->operator()(rightmost_cell->vertex(1)); + }; + }; template <>