]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Interpolate boundary values in 1d.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 21 May 1999 13:55:02 +0000 (13:55 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 21 May 1999 13:55:02 +0000 (13:55 +0000)
git-svn-id: https://svn.dealii.org/trunk@1349 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 691d7e3d66d70488cb2e2f2a8f0079d685697461..253f1ec0b169cf7ec0155e3386b1729e48e8041b 100644 (file)
@@ -94,9 +94,10 @@ VectorTools<dim>::interpolate(const DoFHandler<dim>    &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<dim>::create_right_hand_side (const DoFHandler<dim>    &dof,
 
 template <>
 void
-VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &,
-                                            const FunctionMap &,
-                                            map<int,double>   &)
+VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &dof,
+                                            const FunctionMap &dirichlet_bc,
+                                            map<int,double>   &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 <>

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.