const Function<dim> &rhs,
Vector<double> &rhs_vector);
-//TODO:[WB] Update interpolate_boundary_values for use of FunctionMap.
-// keep both, the functions using and the functions not using a FunctionMap.
/**
- * Prepare Dirichlet boundary conditions.
- * Make up the list of nodes subject
- * to Dirichlet boundary conditions
- * and the values to be
- * assigned to them, by interpolation around
- * the boundary. If the
- * @p{boundary_values} contained values
- * before, the new ones are added, or
- * the old one overwritten if a node
- * of the boundary part to be projected
- * on already was in the variable.
+ * Prepare Dirichlet boundary
+ * conditions. Make up the list
+ * of degrees of freedom subject
+ * to Dirichlet boundary
+ * conditions and the values to
+ * be assigned to them, by
+ * interpolation around the
+ * boundary. If the
+ * @p{boundary_values} contained
+ * values before, the new ones
+ * are added, or the old one
+ * overwritten if a node of the
+ * boundary part to be projected
+ * on already was in the
+ * variable.
*
- * The parameter @p{boundary_component} corresponds
- * to the number @p{boundary_indicator} of the face.
- * 255 is an illegal value, since it is reserved
+ * The parameter
+ * @p{boundary_component}
+ * corresponds to the number
+ * @p{boundary_indicator} of the
+ * face. 255 is an illegal
+ * value, since it is reserved
* for interior faces.
*
* The flags in the last
* 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.
+ * interpolated. If it 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 function
* information.
*/
template <int dim>
+ static void interpolate_boundary_values (const Mapping<dim> &mapping,
+ const DoFHandler<dim> &dof,
+ const typename FunctionMap<dim>::type &function_map,
+ std::map<unsigned int,double> &boundary_values,
+ const std::vector<bool> &component_mask = std::vector<bool>());
+
+ /**
+ * Same function as above, but
+ * taking only one pair of
+ * boundary indicator and
+ * corresponding boundary
+ * function. Calls the other
+ * function with remapped
+ * arguments.
+ *
+ * This function is there mainly
+ * for backward compatibility.
+ */
+ template <int dim>
static void interpolate_boundary_values (const Mapping<dim> &mapping,
const DoFHandler<dim> &dof,
const unsigned char boundary_component,
const Function<dim> &boundary_function,
std::map<unsigned int,double> &boundary_values,
const std::vector<bool> &component_mask = std::vector<bool>());
-
+
/**
- * Calls the @p{interpolate_boundary_values}
+ * Calls the other
+ * @p{interpolate_boundary_values}
* function, see above, with
* @p{mapping=MappingQ1<dim>()}.
*/
std::map<unsigned int,double> &boundary_values,
const std::vector<bool> &component_mask = std::vector<bool>());
+ /**
+ * Calls the other
+ * @p{interpolate_boundary_values}
+ * function, see above, with
+ * @p{mapping=MappingQ1<dim>()}.
+ */
+ template <int dim>
+ static void interpolate_boundary_values (const DoFHandler<dim> &dof,
+ const typename FunctionMap<dim>::type &function_map,
+ std::map<unsigned int,double> &boundary_values,
+ const std::vector<bool> &component_mask = std::vector<bool>());
+
+
//TODO:[WB] Update project_boundary_values for more components
/**
* Project @p{function} to the boundary
const std::vector<bool> component_mask ((component_mask_.size() == 0) ?
std::vector<bool> (fe.n_components(), true) :
component_mask_);
- Assert (count(component_mask.begin(), component_mask.end(), true) > 0,
+ Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0,
ExcComponentMismatch());
// check whether boundary values at
};
+
+template <>
+void
+VectorTools::interpolate_boundary_values (const Mapping<1> &mapping,
+ const DoFHandler<1> &dof,
+ const FunctionMap<1>::type &function_map,
+ std::map<unsigned int,double> &boundary_values,
+ const std::vector<bool> &component_mask)
+{
+ for (FunctionMap<1>::type::const_iterator i=function_map.begin();
+ i!=function_map.end(); ++i)
+ interpolate_boundary_values (mapping, dof, i->first, *i->second,
+ boundary_values, component_mask);
+};
+
+
#endif
void
VectorTools::interpolate_boundary_values (const Mapping<dim> &mapping,
const DoFHandler<dim> &dof,
- const unsigned char boundary_component,
- const Function<dim> &boundary_function,
+ const typename FunctionMap<dim>::type &function_map,
std::map<unsigned int,double> &boundary_values,
const std::vector<bool> &component_mask_)
{
- Assert (boundary_component != 255,
+ // if for whatever we were passed
+ // an empty map, return immediately
+ if (function_map.size() == 0)
+ return;
+
+ Assert (function_map.find(255) == function_map.end(),
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 == boundary_function.n_components,
+ Assert ((function_map.size() == 0) ||
+ (n_components == function_map.begin()->second->n_components),
ExcInvalidFE());
// set the component mask to either
const std::vector<bool> component_mask ((component_mask_.size() == 0) ?
std::vector<bool> (fe.n_components(), true) :
component_mask_);
- Assert (count(component_mask.begin(), component_mask.end(), true) > 0,
+ Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0,
ExcComponentMismatch());
// field to store the indices
Quadrature<dim-1> aux_quad (unit_support_points, dummy_weights);
FEFaceValues<dim> fe_values (mapping, fe, aux_quad, update_q_points);
- DoFHandler<dim>::active_cell_iterator cell = dof.begin_active(),
- endc = dof.end();
+ typename DoFHandler<dim>::active_cell_iterator cell = dof.begin_active(),
+ endc = dof.end();
for (; cell!=endc; ++cell)
for (unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
++face_no)
{
- DoFHandler<dim>::face_iterator face = cell->face(face_no);
- if (boundary_component == face->boundary_indicator())
+ typename DoFHandler<dim>::face_iterator face = cell->face(face_no);
+ const unsigned char boundary_component = face->boundary_indicator();
+ if (function_map.find(boundary_component) != function_map.end())
// face is of the right component
{
// get indices, physical location and
if (fe_is_system)
{
- boundary_function.vector_value_list (dof_locations, dof_values_system);
+ function_map.find(boundary_component)->second->vector_value_list (dof_locations,
+ dof_values_system);
// enter into list
-
for (unsigned int i=0; i<face_dofs.size(); ++i)
if (component_mask[fe.face_system_to_component_index(i).first])
boundary_values[face_dofs[i]]
{
// get only the one component that
// this function has
- boundary_function.value_list (dof_locations,
- dof_values_scalar,
- 0);
+ function_map.find(boundary_component)->second->value_list (dof_locations,
+ dof_values_scalar,
+ 0);
// enter into list
}
}
+
+
+template <int dim>
+void
+VectorTools::interpolate_boundary_values (const Mapping<dim> &mapping,
+ const DoFHandler<dim> &dof,
+ const unsigned char boundary_component,
+ const Function<dim> &boundary_function,
+ std::map<unsigned int,double> &boundary_values,
+ const std::vector<bool> &component_mask)
+{
+ typename FunctionMap<dim>::type function_map;
+ function_map[boundary_component] = &boundary_function;
+ interpolate_boundary_values (mapping, dof, function_map, boundary_values,
+ component_mask);
+};
+
+
template <int dim>
void
+template <int dim>
+void
+VectorTools::interpolate_boundary_values (const DoFHandler<dim> &dof,
+ const typename FunctionMap<dim>::type &function_map,
+ std::map<unsigned int,double> &boundary_values,
+ const std::vector<bool> &component_mask)
+{
+ Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping"));
+ static const MappingQ1<dim> mapping;
+ interpolate_boundary_values(mapping, dof, function_map,
+ boundary_values, component_mask);
+}
+
+
+
template <int dim>
void
VectorTools::project_boundary_values (const Mapping<dim> &mapping,