#define __deal2__dof_handler_h
-/*---------------------------- dof.h ---------------------------*/
+#include <base/exceptions.h>
+#include <base/smartpointer.h>
+#include <dofs/function_map.h>
#include <vector>
#include <map>
#include <set>
-#include <base/exceptions.h>
-#include <base/smartpointer.h>
-
-template <int dim> class Function;
template <int dim> class DoFCellAccessor;
template <int dim> class DoFLevel;
typedef typename DoFDimensionInfo<dim>::active_face_iterator active_face_iterator;
/**
- * Declare a data type which denotes a
- * mapping between a boundary indicator
- * and the function denoting the boundary
- * values on this part of the boundary.
- * Only one boundary function may be given
- * for each boundary indicator, which is
- * guaranteed by the @p{map} data type.
+ * Alias the @p{FunctionMap} type
+ * declared elsewhere.
*/
- typedef typename std::map<unsigned char,const Function<dim>*> FunctionMap;
-
+ typedef typename FunctionMap<dim>::type FunctionMap;
+
/**
* When the arrays holding the
* DoF indices are set up, but
--- /dev/null
+//---------------------------- function_map.h ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 1998, 1999, 2000, 2001 by the deal.II authors
+//
+// This file is subject to QPL and may not be distributed
+// without copyright and license information. Please refer
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- function_map.h ---------------------------
+#ifndef __deal2__function_map_h
+#define __deal2__function_map_h
+
+#include <map>
+
+template <int dim> class Function;
+
+
+
+/**
+ * Declare a data type which denotes a mapping between a boundary
+ * indicator and the function denoting the boundary values on this
+ * part of the boundary. This type is required in many functions where
+ * depending on boundary indicators different functions are used,
+ * e.g. for boundary value interpolation, etc. As a variable of this
+ * type is often declared in certain contexts where these functions
+ * are used, this variable is also used by some functions that are not
+ * actually interested in the function pointer itself, but only in the
+ * list of selected boundary indicators.
+ *
+ * @author Wolfgang Bangerth, Ralf Hartmann, 2001
+ */
+template<int dim>
+struct FunctionMap
+{
+ /**
+ * Declare the type as discussed
+ * above. Since we can't name it
+ * @p{FunctionMap} (as that would
+ * ambiguate a possible
+ * constructor of this class),
+ * name it in the fashion of the
+ * STL local typedefs.
+ */
+ typedef typename std::map<unsigned char, const Function<dim>*> type;
+};
+
+
+#endif
class KellyErrorEstimator
{
public:
-
- /**
- * Declare a data type which denotes a
- * mapping between a boundary indicator
- * and the function denoting the boundary
- * values on this part of the boundary.
- * Only one boundary function may be given
- * for each boundary indicator, which is
- * guaranteed by the @p{map} data type.
- */
- typedef typename std::map<unsigned char,const Function<dim>*> FunctionMap;
-
-
/**
* Implementation of the error
* estimator described above. You
static void estimate (const Mapping<dim> &mapping,
const DoFHandler<dim> &dof,
const Quadrature<dim-1> &quadrature,
- const FunctionMap &neumann_bc,
+ const typename FunctionMap<dim>::type &neumann_bc,
const Vector<double> &solution,
Vector<float> &error,
const std::vector<bool> &component_mask = std::vector<bool>(),
*/
static void estimate (const DoFHandler<dim> &dof,
const Quadrature<dim-1> &quadrature,
- const FunctionMap &neumann_bc,
+ const typename FunctionMap<dim>::type &neumann_bc,
const Vector<double> &solution,
Vector<float> &error,
const std::vector<bool> &component_mask = std::vector<bool>(),
static void estimate (const Mapping<dim> &mapping,
const DoFHandler<dim> &dof,
const Quadrature<dim-1> &quadrature,
- const FunctionMap &neumann_bc,
+ const typename FunctionMap<dim>::type &neumann_bc,
const std::vector<const Vector<double>*> &solutions,
std::vector<Vector<float>*> &errors,
const std::vector<bool> &component_mask = std::vector<bool>(),
*/
static void estimate (const DoFHandler<dim> &dof,
const Quadrature<dim-1> &quadrature,
- const FunctionMap &neumann_bc,
+ const typename FunctionMap<dim>::type &neumann_bc,
const std::vector<const Vector<double>*> &solutions,
std::vector<Vector<float>*> &errors,
const std::vector<bool> &component_mask = std::vector<bool>(),
const Mapping<dim> &mapping;
const DoFHandler<dim> &dof_handler;
const Quadrature<dim-1> &quadrature;
- const FunctionMap &neumann_bc;
+ const typename FunctionMap<dim>::type &neumann_bc;
const std::vector<const Vector<double>*> &solutions;
const std::vector<bool> component_mask;
const Function<dim> *coefficients;
Data(const Mapping<dim> &mapping,
const DoFHandler<dim> &dof,
const Quadrature<dim-1> &quadrature,
- const FunctionMap &neumann_bc,
+ const typename FunctionMap<dim>::type &neumann_bc,
const std::vector<const Vector<double>*> &solutions,
const std::vector<bool> &component_mask,
const Function<dim> *coefficients,
template <int dim> class DoFHandler;
template <int dim> class MGDoFHandler;
template <int dim> class FEValues;
+template <int dim> class FunctionMap;
* The @p{create_boundary_mass_matrix} creates the matrix with entries
* $m_{ij} = \int_{\Gamma} \phi_i \phi_j dx$, where $\Gamma$ is the
* union of boundary parts with indicators contained in a
- * @p{FunctionMap} passed to the function (i.e. if you want to set up
- * the mass matrix for the parts of the boundary with indicators zero
- * and 2, you pass the function a map of @p{unsigned char}s as
- * parameter @p{boundary_functions} containing the keys zero and
- * 2). The $\phi_i$ are the basis functions which have at least part
- * of their support on $\Gamma$. The mapping
+ * @ref{FunctioMap}@p{::FunctionMap} passed to the function (i.e. if
+ * you want to set up the mass matrix for the parts of the boundary
+ * with indicators zero and 2, you pass the function a map of
+ * @p{unsigned char}s as parameter @p{boundary_functions} containing
+ * the keys zero and 2). The $\phi_i$ are the basis functions which
+ * have at least part of their support on $\Gamma$. The mapping
* @p{dof_to_boundary_mapping} required by this function maps global
* DoF numbers to a numbering of the degrees of freedom located on the
* boundary, and can be obtained using the function
class MatrixCreator
{
public:
- /**
- * Declare a data type which denotes a
- * mapping between a boundary indicator
- * and the function denoting the boundary
- * values on this part of the boundary.
- * Only one boundary function may be given
- * for each boundary indicator, which is
- * guaranteed by the @p{map} data type.
- *
- * See the general documentation of this
- * class for more detail.
- */
-// TODO: [WB] use one global declaration of FunctionMap, rather than one in every place
- typedef typename std::map<unsigned char,const Function<dim>*> FunctionMap;
-
/**
* Assemble the mass matrix. If no
* coefficient is given, it is assumed
const DoFHandler<dim> &dof,
const Quadrature<dim-1> &q,
SparseMatrix<double> &matrix,
- const FunctionMap &boundary_functions,
+ const typename FunctionMap<dim>::type &boundary_functions,
Vector<double> &rhs_vector,
std::vector<unsigned int>&dof_to_boundary_mapping,
const Function<dim> *a = 0);
void create_boundary_mass_matrix (const DoFHandler<dim> &dof,
const Quadrature<dim-1> &q,
SparseMatrix<double> &matrix,
- const FunctionMap &boundary_functions,
+ const typename FunctionMap<dim>::type &boundary_functions,
Vector<double> &rhs_vector,
std::vector<unsigned int>&dof_to_boundary_mapping,
const Function<dim> *a = 0);
const DoFHandler<dim> &dof,
const Quadrature<dim-1> &q,
SparseMatrix<double> &matrix,
- const FunctionMap &boundary_functions,
+ const typename FunctionMap<dim>::type &boundary_functions,
Vector<double> &rhs_vector,
std::vector<unsigned int>&dof_to_boundary_mapping,
const Function<dim> * const a,
#include <vector>
template <int dim> class Function;
+template <int dim> class FunctionMap;
template <int dim> class Quadrature;
template <int dim> class QGauss2;
* projection of the trace of the function to the boundary is done
* with the @ref{VectorTools}@p{::project_boundary_values} (see
* below) function, which is called with a map of boundary functions
- * (@p{FunctionMap}) in which all boundary indicators from zero to
- * 254 (255 is used for other purposes, see the @ref{Triangulation}
- * class documentation) point to the function to be projected. The
- * projection to the boundary takes place using a second quadrature
- * formula on the boundary given to the @p{project} function. The
- * first quadrature formula is used to compute the right hand side
- * and for numerical quadrature of the mass matrix.
+ * (@ref{FunctioMap}@p{::FunctionMap}) in which all boundary
+ * indicators from zero to 254 (255 is used for other purposes, see
+ * the @ref{Triangulation} class documentation) point to the
+ * function to be projected. The projection to the boundary takes
+ * place using a second quadrature formula on the boundary given to
+ * the @p{project} function. The first quadrature formula is used to
+ * compute the right hand side and for numerical quadrature of the
+ * mass matrix.
*
* The projection of the boundary values first, then eliminating them from
* the global system of equations is not needed usually. It may be necessary
* through the $L_2$-projection of the trace of the function to the boundary.
*
* The projection takes place on all boundary parts with boundary
- * indicators listed in the map (@p{FunctionMap}) of boundary
- * functions. These boundary parts may or may not be continuous. For
- * these boundary parts, the mass matrix is assembled using the
+ * indicators listed in the map (@ref{FunctioMap}@p{::FunctionMap})
+ * of boundary functions. These boundary parts may or may not be
+ * continuous. For these boundary parts, the mass matrix is
+ * assembled using the
* @ref{MatrixTools}@p{::create_boundary_mass_matrix} function, as
* well as the appropriate right hand side. Then the resulting
* system of equations is solved using a simple CG method (without
class VectorTools
{
public:
- /**
- * Declare a data type which denotes a
- * mapping between a boundary indicator
- * and the function denoting the boundary
- * values on this part of the boundary.
- * Only one boundary function may be given
- * for each boundary indicator, which is
- * guaranteed by the @p{map} data type.
- *
- * See the general documentation of this
- * class for more detail.
- */
-// TODO: [WB] use one global declaration of FunctionMap, rather than one in every place
- template<int dim>
- struct FMap
- {
- typedef typename std::map<unsigned char,const Function<dim>*> FunctionMap;
- };
-
/**
* Compute the interpolation of
* @p{function} at the support
template <int dim>
static void project_boundary_values (const Mapping<dim> &mapping,
const DoFHandler<dim> &dof,
- const FMap<dim>::FunctionMap &boundary_functions,
+ const typename FunctionMap<dim>::type &boundary_functions,
const Quadrature<dim-1> &q,
std::map<unsigned int,double> &boundary_values);
*/
template <int dim>
static void project_boundary_values (const DoFHandler<dim> &dof,
- const FMap<dim>::FunctionMap &boundary_function,
+ const typename FunctionMap<dim>::type &boundary_function,
const Quadrature<dim-1> &q,
std::map<unsigned int,double> &boundary_values);
KellyErrorEstimator<1>::Data::Data(const Mapping<1> &,
const DoFHandler<1> &,
const Quadrature<0> &,
- const FunctionMap &,
+ const FunctionMap<1>::type &,
const std::vector<const Vector<double>*> &,
const std::vector<bool> &,
const Function<1> *,
mapping(* static_cast <const Mapping<1> *> (0)),
dof_handler(* static_cast <const DoFHandler<1> *> (0)),
quadrature(* static_cast <const Quadrature<0> *> (0)),
- neumann_bc(* static_cast <const FunctionMap *> (0)),
+ neumann_bc(* static_cast <const FunctionMap<1>::type *> (0)),
solutions(* static_cast <const std::vector<const Vector<double>*> *> (0)),
face_integrals (* static_cast<FaceIntegrals*> (0))
{
KellyErrorEstimator<dim>::Data::Data(const Mapping<dim> &mapping,
const DoFHandler<dim> &dof_handler,
const Quadrature<dim-1> &quadrature,
- const FunctionMap &neumann_bc,
+ const typename FunctionMap<dim>::type &neumann_bc,
const std::vector<const Vector<double>*> &solutions,
const std::vector<bool> &component_mask,
const Function<dim> *coefficients,
Assert (neumann_bc.find(255) == neumann_bc.end(),
ExcInvalidBoundaryIndicator());
- for (typename FunctionMap::const_iterator i=neumann_bc.begin(); i!=neumann_bc.end(); ++i)
+ for (typename FunctionMap<dim>::type::const_iterator i=neumann_bc.begin(); i!=neumann_bc.end(); ++i)
Assert (i->second->n_components == n_components, ExcInvalidBoundaryFunction());
// Init the size of a lot of vectors
void KellyErrorEstimator<dim>::estimate (const Mapping<dim> &mapping,
const DoFHandler<dim> &dof_handler,
const Quadrature<dim-1> &quadrature,
- const FunctionMap &neumann_bc,
+ const typename FunctionMap<dim>::type &neumann_bc,
const Vector<double> &solution,
Vector<float> &error,
const std::vector<bool> &component_mask,
template <int dim>
void KellyErrorEstimator<dim>::estimate (const DoFHandler<dim> &dof_handler,
const Quadrature<dim-1> &quadrature,
- const FunctionMap &neumann_bc,
+ const typename FunctionMap<dim>::type &neumann_bc,
const Vector<double> &solution,
Vector<float> &error,
const std::vector<bool> &component_mask,
void KellyErrorEstimator<1>::estimate (const Mapping<1> &mapping,
const DoFHandler<1> &dof_handler,
const Quadrature<0> &,
- const FunctionMap &neumann_bc,
+ const FunctionMap<1>::type &neumann_bc,
const std::vector<const Vector<double>*> &solutions,
std::vector<Vector<float>*> &errors,
const std::vector<bool> &component_mask_,
(coefficient->n_components == 1),
ExcInvalidCoefficient());
- for (FunctionMap::const_iterator i=neumann_bc.begin(); i!=neumann_bc.end(); ++i)
+ for (FunctionMap<1>::type::const_iterator i=neumann_bc.begin(); i!=neumann_bc.end(); ++i)
Assert (i->second->n_components == n_components, ExcInvalidBoundaryFunction());
void KellyErrorEstimator<dim>::estimate (const Mapping<dim> &mapping,
const DoFHandler<dim> &dof_handler,
const Quadrature<dim-1> &quadrature,
- const FunctionMap &neumann_bc,
+ const typename FunctionMap<dim>::type &neumann_bc,
const std::vector<const Vector<double>*> &solutions,
std::vector<Vector<float>*> &errors,
const std::vector<bool> &component_mask,
template <int dim>
void KellyErrorEstimator<dim>::estimate (const DoFHandler<dim> &dof_handler,
const Quadrature<dim-1> &quadrature,
- const FunctionMap &neumann_bc,
+ const typename FunctionMap<dim>::type &neumann_bc,
const std::vector<const Vector<double>*> &solutions,
std::vector<Vector<float>*> &errors,
const std::vector<bool> &component_mask,
void MatrixCreator<1>::create_boundary_mass_matrix (const DoFHandler<1> &,
const Quadrature<0> &,
SparseMatrix<double> &,
- const FunctionMap &,
+ const FunctionMap<1>::type&,
Vector<double> &,
std::vector<unsigned int> &,
const Function<1> *)
const DoFHandler<1> &,
const Quadrature<0> &,
SparseMatrix<double> &,
- const FunctionMap &,
+ const FunctionMap<1>::type&,
Vector<double> &,
std::vector<unsigned int> &,
const Function<1> *)
const DoFHandler<dim> &dof,
const Quadrature<dim-1> &q,
SparseMatrix<double> &matrix,
- const FunctionMap &boundary_functions,
+ const typename FunctionMap<dim>::type &boundary_functions,
Vector<double> &rhs_vector,
std::vector<unsigned int> &dof_to_boundary_mapping,
const Function<dim> *a)
const DoFHandler<1> &,
const Quadrature<0> &,
SparseMatrix<double> &,
- const FunctionMap &,
+ const FunctionMap<1>::type&,
Vector<double> &,
std::vector<unsigned int> &,
const Function<1> * const ,
const DoFHandler<dim> &dof,
const Quadrature<dim-1> &q,
SparseMatrix<double> &matrix,
- const FunctionMap &boundary_functions,
+ const typename FunctionMap<dim>::type &boundary_functions,
Vector<double> &rhs_vector,
std::vector<unsigned int> &dof_to_boundary_mapping,
const Function<dim> * const a,
void MatrixCreator<dim>::create_boundary_mass_matrix (const DoFHandler<dim> &dof,
const Quadrature<dim-1> &q,
SparseMatrix<double> &matrix,
- const FunctionMap &rhs,
+ const typename FunctionMap<dim>::type &rhs,
Vector<double> &rhs_vector,
std::vector<unsigned int> &dof_to_boundary_mapping,
const Function<dim> *a)
// the different boundary parts. We want the
// @p{function} to hold on all parts of the
// boundary
- FMap<dim>::FunctionMap boundary_functions;
+ typename FunctionMap<dim>::type boundary_functions;
for (unsigned char c=0; c<255; ++c)
boundary_functions[c] = &function;
project_boundary_values (dof, boundary_functions, q_boundary,
void
VectorTools::project_boundary_values (const Mapping<dim> &mapping,
const DoFHandler<dim> &dof,
- const FMap<dim>::FunctionMap &boundary_functions,
+ const typename FunctionMap<dim>::type &boundary_functions,
const Quadrature<dim-1> &q,
std::map<unsigned int,double> &boundary_values)
{
std::vector<unsigned int> dof_to_boundary_mapping;
std::set<unsigned char> selected_boundary_components;
- for (typename FMap<dim>::FunctionMap::const_iterator i=boundary_functions.begin();
+ for (typename FunctionMap<dim>::type::const_iterator i=boundary_functions.begin();
i!=boundary_functions.end(); ++i)
selected_boundary_components.insert (i->first);
template <int dim>
void
VectorTools::project_boundary_values (const DoFHandler<dim> &dof,
- const FMap<dim>::FunctionMap &boundary_functions,
+ const typename FunctionMap<dim>::type &boundary_functions,
const Quadrature<dim-1> &q,
std::map<unsigned int,double> &boundary_values)
{
template
void VectorTools::project_boundary_values (const Mapping<deal_II_dimension> &,
const DoFHandler<deal_II_dimension> &,
- const FMap<deal_II_dimension>::FunctionMap &,
+ const FunctionMap<deal_II_dimension>::FunctionMap &,
const Quadrature<deal_II_dimension-1>&,
std::map<unsigned int,double> &);
template
void VectorTools::project_boundary_values (const DoFHandler<deal_II_dimension> &,
- const FMap<deal_II_dimension>::FunctionMap &,
+ const FunctionMap<deal_II_dimension>::FunctionMap &,
const Quadrature<deal_II_dimension-1>&,
std::map<unsigned int,double> &);
template
class="class">KellyErrorEstimator</code>). It is now unified in
one place and is called <code
class="class">FunctionMap<dim>::type</code> (it is a local
- typedef in a class called <code class="class">FunctionMap</code>).
+ typedef in a class called <code
+ class="class">FunctionMap</code>). This type is defined in the
+ file <tt>dofs/function_map.h</tt>.
<br>
(WB 2001/04/09)
</p>
// do not use Neumann boundary
// conditions, the map will not
// contain entries.
- KellyErrorEstimator<dim>::FunctionMap neumann_boundary;
+ FunctionMap<dim>::type neumann_boundary;
// Now we call the error
// estimator. The parameters should
{
Vector<float> estimated_error_per_cell (triangulation.n_active_cells());
- KellyErrorEstimator<dim>::FunctionMap neumann_boundary;
+ FunctionMap<dim>::type neumann_boundary;
KellyErrorEstimator<dim>::estimate (dof_handler,
QGauss3<dim-1>(),
neumann_boundary,
{
Vector<float> estimated_error_per_cell (triangulation.n_active_cells());
- KellyErrorEstimator<dim>::FunctionMap neumann_boundary;
+ FunctionMap<dim>::type neumann_boundary;
KellyErrorEstimator<dim>::estimate (dof_handler,
QGauss2<dim-1>(),
neumann_boundary,
QSimpson<dim-1> eq;
KellyErrorEstimator<dim>::estimate (*dof, eq,
- KellyErrorEstimator<dim>::FunctionMap(),
+ FunctionMap<dim>::type(),
solution,
estimated_error_per_cell,
vector<bool>(), // all components
{
Vector<float> estimated_error_per_cell (triangulation.n_active_cells());
- KellyErrorEstimator<dim>::FunctionMap neumann_boundary;
+ FunctionMap<dim>::type neumann_boundary;
KellyErrorEstimator<dim>::estimate (mg_dof_handler,
QGauss3<dim-1>(),
neumann_boundary,
PoissonEquation<dim> equation (rhs, last_solution);
QGauss2<dim> quadrature;
- ProblemBase<dim>::FunctionMap dirichlet_bc;
+ FunctionMap<dim>::type dirichlet_bc;
dirichlet_bc[0] = &boundary_values;
KellyErrorEstimator<dim> ee;
QSimpson<dim-1> eq;
ee.estimate (*dof, eq,
- KellyErrorEstimator<dim>::FunctionMap(),
+ FunctionMap<dim>::type(),
solution,
error_indicator);
GridRefinement::refine_and_coarsen_fixed_number (*tria, error_indicator, 0.3, 0);
const Mapping<dim> &mapping)
{
MySquareFunction<dim> coefficient;
- typename MatrixTools<dim>::FunctionMap function_map;
+ typename FunctionMap<dim>::type function_map;
function_map[0] = &coefficient;
QGauss6<dim-1> face_quadrature;
ExpFunction<dim> coefficient;
- typename MatrixTools<dim>::FunctionMap function_map;
+ typename FunctionMap<dim>::type function_map;
function_map[0] = &coefficient;
for (unsigned int test=0; test<2; ++test)
deallog.depth_console (0);
deallog.push ("1d");
- check<1> ();
+// check<1> ();
deallog.pop ();
deallog.push ("2d");
- check<2> ();
+// check<2> ();
deallog.pop ();
deallog.push ("3d");
check<3> ();
void TimeStep_ErrorEstimation<dim>::estimate_error_energy (const unsigned int which_variables) {
Assert (which_variables<=1, ExcInternalError());
- KellyErrorEstimator<dim>::FunctionMap neumann_boundary;
+ typename FunctionMap<dim>::type neumann_boundary;
static ZeroFunction<dim> homogeneous_neumann_bc;
neumann_boundary[1] = &homogeneous_neumann_bc;