]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
FunctionMap removed in interpolate_boundary
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 17 Nov 1999 22:29:02 +0000 (22:29 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 17 Nov 1999 22:29:02 +0000 (22:29 +0000)
git-svn-id: https://svn.dealii.org/trunk@1887 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/numerics/vectors.h
deal.II/deal.II/source/numerics/base.cc
deal.II/deal.II/source/numerics/vectors.cc
tests/deal.II/wave-test-3.cc

index cc70c314cb650d0d3f84fb116b69d7d5b42d2df3..c0add050cd742b5ed10063de4d0450958275cce0 100644 (file)
@@ -356,6 +356,7 @@ class VectorTools
                                        Vector<double>           &rhs_vector);
     
                                     /**
+                                     * Prepare Dirichlet boundary conditions.
                                      * Make up the list of nodes subject
                                      * to Dirichlet boundary conditions
                                      * and the values to be
@@ -367,6 +368,11 @@ class VectorTools
                                      * of the boundary part to be projected
                                      * on already was in the variable.
                                      *
+                                     * The parameter #boundary_component# corresponds
+                                     * to the number #boundary_indicator# of the face.
+                                     * 255 is an illegal value, since it is reserved
+                                     * for interior faces.
+                                     *
                                      * The flags in the last
                                      * parameter, #component_mask#
                                      * denote which components of the
@@ -384,8 +390,8 @@ class VectorTools
                                      * element.
                                      *
                                      * It is assumed that the number
-                                     * of components of the functions
-                                     * in #dirichlet_bc# matches that
+                                     * of components of the function
+                                     * in #boundary_function# matches that
                                      * of the finite element used by
                                      * #dof#.
                                      *
@@ -393,10 +399,13 @@ class VectorTools
                                      * information.
                                      */
     static void interpolate_boundary_values (const DoFHandler<dim> &dof,
-                                            const FunctionMap     &dirichlet_bc,
+                                            unsigned char          boundary_component,
+                                            const Function<dim>   &boundary_function,
                                             map<int,double>       &boundary_values,
                                             const vector<bool>    &component_mask = vector<bool>());
 
+//TODO: Update project_boundary_values for more components
+//TODO: Replace FunctionMap
                                     /**
                                      * Project #function# to the boundary
                                      * of the domain, using the given quadrature
@@ -408,18 +417,18 @@ class VectorTools
                                      * on already was in the variable.
                                      *
                                      * It is assumed that the number
-                                     * of components of the functions
-                                     * in #boundary_functions#
+                                     * of components of
+                                     * #boundary_function#
                                      * matches that of the finite
                                      * element used by #dof#.
                                      *
                                      * See the general documentation of this
                                      * class for further information.
                                      */
-    static void project_boundary_values (const DoFHandler<dim>    &dof,
-                                        const FunctionMap        &boundary_functions,
-                                        const Quadrature<dim-1>  &q,
-                                        map<int,double>          &boundary_values);
+    static void project_boundary_values (const DoFHandler<dim>  &dof,
+                                        const FunctionMap      &boundary_function,
+                                        const Quadrature<dim-1>&q,
+                                        map<int,double>        &boundary_values);
     
                                     /**
                                      * Compute the error of the finite element solution.
index 3a9b43a0629c75c65f590bd6da53966e98c66ebc..4d1d23afee79b895eac4164107b1a9f5468914f9 100644 (file)
@@ -74,7 +74,8 @@ template <int dim>
 void ProblemBase<dim>::assemble (const Equation<dim>      &equation,
                                 const Quadrature<dim>    &quadrature,
                                 const UpdateFlags         update_flags,
-                                const FunctionMap        &dirichlet_bc) {
+                                const FunctionMap        &dirichlet_bc)
+{
   Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected());
   
   system_sparsity.reinit (dof_handler->n_dofs(),
@@ -123,8 +124,13 @@ void ProblemBase<dim>::assemble (const Equation<dim>      &equation,
                                   // apply Dirichlet bc as described
                                   // in the docs
   map<int, double> boundary_value_list;
-  VectorTools<dim>::interpolate_boundary_values (*dof_handler, dirichlet_bc, 
-                                                boundary_value_list);
+
+  for (FunctionMap::const_iterator dirichlet = dirichlet_bc.begin() ;
+       dirichlet != dirichlet_bc.end() ; ++dirichlet)
+    VectorTools<dim>::interpolate_boundary_values (*dof_handler,
+                                                  dirichlet->first,
+                                                  *(dirichlet->second), 
+                                                  boundary_value_list);
   MatrixTools<dim>::apply_boundary_values (boundary_value_list,
                                           system_matrix, solution,
                                           right_hand_side);  
@@ -134,7 +140,8 @@ void ProblemBase<dim>::assemble (const Equation<dim>      &equation,
 
 
 template <int dim>
-void ProblemBase<dim>::solve () {
+void ProblemBase<dim>::solve ()
+{
   Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected());
   
   SolverControl                    control(4000, 1e-16);
index 4eaf3a3f93970b5882bd5be9c054ed267e6959da..42b21152369808571b26ea034c1b08c6daecef25 100644 (file)
@@ -466,15 +466,16 @@ void VectorTools<dim>::create_right_hand_side (const DoFHandler<dim>    &dof,
 template <>
 void
 VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &dof,
-                                            const FunctionMap   &dirichlet_bc,
+                                            unsigned char        boundary_component,
+                                            const Function<1>   &boundary_function,
                                             map<int,double>     &boundary_values,
                                             const vector<bool>  &component_mask_)
 {
-  Assert (dirichlet_bc.find(255) == dirichlet_bc.end(),
+  Assert (boundary_component != 255,
          ExcInvalidBoundaryIndicator());
 
   const FiniteElement<1> &fe = dof.get_fe();
-  Assert (fe.n_components == dirichlet_bc.begin()->second->n_components,
+  Assert (fe.n_components == boundary_function.n_components,
          ExcComponentMismatch());
   Assert (fe.dofs_per_vertex == fe.n_components,
          ExcComponentMismatch());
@@ -490,7 +491,7 @@ VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &dof,
   
                                   // check whether boundary values at the
                                   // left boundary of the line are requested
-  if (dirichlet_bc.find(0) != dirichlet_bc.end())
+  if (boundary_component == 0)
     {
                                       // first find the leftmost active
                                       // cell by first traversing the coarse
@@ -512,12 +513,12 @@ VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &dof,
       for (unsigned int i=0; i<fe.dofs_per_vertex; ++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);
+           = boundary_function.value(leftmost_cell->vertex(0), i);
     };
 
                                   // same for the right boundary of
                                   // the line are requested
-  if (dirichlet_bc.find(1) != dirichlet_bc.end())
+  if (boundary_component == 1)
     {
                                       // first find the leftmost active
                                       // cell by first traversing the coarse
@@ -535,7 +536,7 @@ VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &dof,
       for (unsigned int i=0; i<fe.dofs_per_vertex; ++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);
+           = boundary_function.value(rightmost_cell->vertex(1), i);
     };
   
 };
@@ -548,18 +549,19 @@ VectorTools<1>::interpolate_boundary_values (const DoFHandler<1> &dof,
 template <int dim>
 void
 VectorTools<dim>::interpolate_boundary_values (const DoFHandler<dim> &dof,
-                                              const FunctionMap     &dirichlet_bc,
+                                              unsigned char          boundary_component,
+                                              const Function<dim>   &boundary_function,
                                               map<int,double>       &boundary_values,
                                               const vector<bool>    &component_mask_)
 {
-  Assert (dirichlet_bc.find(255) == dirichlet_bc.end(),
+  Assert (boundary_component != 255,
          ExcInvalidBoundaryIndicator());
 
   const FiniteElement<dim> &fe           = dof.get_fe();
   const unsigned int        n_components = fe.n_components;
   const bool                fe_is_system = (n_components != 1);
   
-  Assert (n_components == dirichlet_bc.begin()->second->n_components,
+  Assert (n_components == boundary_function.n_components,
          ExcInvalidFE());
 
                                   // set the component mask to either
@@ -571,8 +573,6 @@ VectorTools<dim>::interpolate_boundary_values (const DoFHandler<dim> &dof,
   Assert (count(component_mask.begin(), component_mask.end(), true) > 0,
          ExcComponentMismatch());
 
-  typename FunctionMap::const_iterator function_ptr;
-
                                   // field to store the indices of dofs
   vector<int>         face_dofs (fe.dofs_per_face, -1);
   vector<Point<dim> > dof_locations (face_dofs.size(), Point<dim>());
@@ -589,10 +589,8 @@ VectorTools<dim>::interpolate_boundary_values (const DoFHandler<dim> &dof,
   DoFHandler<dim>::active_face_iterator face = dof.begin_active_face(),
                                        endf = dof.end_face();
   for (; face!=endf; ++face)
-    if ((function_ptr = dirichlet_bc.find(face->boundary_indicator())) !=
-       dirichlet_bc.end()) 
-                                      // face is subject to one of the
-                                      // bc listed in #dirichlet_bc#
+    if (boundary_component == face->boundary_indicator()) 
+                                      // face is of the right component
       {
                                         // get indices, physical location and
                                         // boundary values of dofs on this
@@ -602,7 +600,7 @@ VectorTools<dim>::interpolate_boundary_values (const DoFHandler<dim> &dof,
 
        if (fe_is_system)
          {
-           function_ptr->second->vector_value_list (dof_locations, dof_values_system);
+           boundary_function.vector_value_list (dof_locations, dof_values_system);
            
                                             // enter into list
            
@@ -617,7 +615,7 @@ VectorTools<dim>::interpolate_boundary_values (const DoFHandler<dim> &dof,
          {
                                             // get only the one component that
                                             // this function has
-           function_ptr->second->value_list (dof_locations,
+           boundary_function.value_list (dof_locations,
                                              dof_values_scalar,
                                              0);
            
@@ -636,7 +634,8 @@ void
 VectorTools<dim>::project_boundary_values (const DoFHandler<dim>    &dof,
                                           const FunctionMap        &boundary_functions,
                                           const Quadrature<dim-1>  &q,
-                                          map<int,double>          &boundary_values) {
+                                          map<int,double>          &boundary_values)
+{
   Assert (dof.get_fe().n_components == boundary_functions.begin()->second->n_components,
          ExcComponentMismatch());
   
index 84d5a12436db7d8365c0e20e9ad037c289a5cf1d..0650686cceb547c1785be80c8f7e39c4b524317d 100644 (file)
@@ -5938,12 +5938,9 @@ void TimeStep_Dual<dim>::do_timestep ()
   map<int,double> boundary_value_list;
   if (dim != 1)
     {
-      VectorTools<dim>::FunctionMap dirichlet_bc;
       static const ZeroFunction<dim> boundary_values;
       
-      dirichlet_bc[0] = &boundary_values;
-      
-      VectorTools<dim>::interpolate_boundary_values (*dof_handler, dirichlet_bc,
+      VectorTools<dim>::interpolate_boundary_values (*dof_handler, 0, boundary_values,
                                                     boundary_value_list);
       MatrixTools<dim>::apply_boundary_values (boundary_value_list,
                                               system_matrix, v,
@@ -8271,12 +8268,10 @@ void TimeStep_Primal<dim>::do_timestep ()
                                       // zero already.
       parameters.boundary_values_u->set_time (time);
       parameters.boundary_values_v->set_time (time);
-      VectorTools<dim>::FunctionMap dirichlet_bc;
-      dirichlet_bc[0] = parameters.boundary_values_u;
       
       map<int,double> boundary_value_list;
-      VectorTools<dim>::interpolate_boundary_values (*dof_handler,
-                                                    dirichlet_bc,
+      VectorTools<dim>::interpolate_boundary_values (*dof_handler, 0,
+                                                    *(parameters.boundary_values_u),
                                                     boundary_value_list);
       MatrixTools<dim>::apply_boundary_values (boundary_value_list,
                                               system_matrix, u,
@@ -8300,11 +8295,9 @@ void TimeStep_Primal<dim>::do_timestep ()
                                   // at all
   if (dim != 1)
     {
-      VectorTools<dim>::FunctionMap dirichlet_bc;
-      dirichlet_bc[0] = parameters.boundary_values_v;
       map<int,double> boundary_value_list;
-      VectorTools<dim>::interpolate_boundary_values (*dof_handler,
-                                                    dirichlet_bc,
+      VectorTools<dim>::interpolate_boundary_values (*dof_handler, 0,
+                                                    *(parameters.boundary_values_v),
                                                     boundary_value_list);
       MatrixTools<dim>::apply_boundary_values (boundary_value_list,
                                               system_matrix, v,

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.