Vector<double> &rhs_vector);
/**
+ * Prepare Dirichlet boundary conditions.
* Make up the list of nodes subject
* to Dirichlet boundary conditions
* and the values to be
* 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
* 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#.
*
* 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
* 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.
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(),
// 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);
template <int dim>
-void ProblemBase<dim>::solve () {
+void ProblemBase<dim>::solve ()
+{
Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected());
SolverControl control(4000, 1e-16);
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());
// 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
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
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);
};
};
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
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>());
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
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
{
// 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);
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());
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,
// 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,
// 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,