Reference documentation for deal.II version SVN Revision 32821
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Functions::FEFieldFunction< dim, DH, VECTOR > Class Template Reference

#include <fe_field_function.h>

Inheritance diagram for Functions::FEFieldFunction< dim, DH, VECTOR >:
[legend]

Public Member Functions

 FEFieldFunction (const DH &dh, const VECTOR &data_vector, const Mapping< dim > &mapping=StaticMappingQ1< dim >::mapping)
 
void set_active_cell (const typename DH::active_cell_iterator &newcell)
 
virtual void vector_value (const Point< dim > &p, Vector< double > &values) const
 
virtual double value (const Point< dim > &p, const unsigned int component=0) const
 
virtual void value_list (const std::vector< Point< dim > > &points, std::vector< double > &values, const unsigned int component=0) const
 
virtual void vector_value_list (const std::vector< Point< dim > > &points, std::vector< Vector< double > > &values) const
 
virtual void vector_gradient (const Point< dim > &p, std::vector< Tensor< 1, dim > > &gradients) const
 
virtual Tensor< 1, dim > gradient (const Point< dim > &p, const unsigned int component=0) const
 
virtual void vector_gradient_list (const std::vector< Point< dim > > &p, std::vector< std::vector< Tensor< 1, dim > > > &gradients) const
 
virtual void gradient_list (const std::vector< Point< dim > > &p, std::vector< Tensor< 1, dim > > &gradients, const unsigned int component=0) const
 
virtual double laplacian (const Point< dim > &p, const unsigned int component=0) const
 
virtual void vector_laplacian (const Point< dim > &p, Vector< double > &values) const
 
virtual void laplacian_list (const std::vector< Point< dim > > &points, std::vector< double > &values, const unsigned int component=0) const
 
virtual void vector_laplacian_list (const std::vector< Point< dim > > &points, std::vector< Vector< double > > &values) const
 
unsigned int compute_point_locations (const std::vector< Point< dim > > &points, std::vector< typename DH::active_cell_iterator > &cells, std::vector< std::vector< Point< dim > > > &qpoints, std::vector< std::vector< unsigned int > > &maps) const
 
 DeclException0 (ExcPointNotAvailableHere)
 
- Public Member Functions inherited from Function< dim >
 Function (const unsigned int n_components=1, const double initial_time=0.0)
 
virtual ~Function ()=0
 
Functionoperator= (const Function &f)
 
virtual void vector_values (const std::vector< Point< dim > > &points, std::vector< std::vector< double > > &values) const
 
virtual void vector_gradients (const std::vector< Point< dim > > &points, std::vector< std::vector< Tensor< 1, dim > > > &gradients) const
 
std::size_t memory_consumption () const
 
- Public Member Functions inherited from FunctionTime
 FunctionTime (const double initial_time=0.0)
 
virtual ~FunctionTime ()
 
double get_time () const
 
virtual void set_time (const double new_time)
 
virtual void advance_time (const double delta_t)
 
- Public Member Functions inherited from Subscriptor
 Subscriptor ()
 
 Subscriptor (const Subscriptor &)
 
virtual ~Subscriptor ()
 
Subscriptoroperator= (const Subscriptor &)
 
void subscribe (const char *identifier=0) const
 
void unsubscribe (const char *identifier=0) const
 
unsigned int n_subscriptions () const
 
void list_subscribers () const
 
 DeclException3 (ExcInUse, int, char *, std::string &,<< "Object of class "<< arg2<< " is still used by "<< arg1<< " other objects.\n"<< "(Additional information: "<< arg3<< ")\n"<< "Note the entry in the Frequently Asked Questions of "<< "deal.II (linked to from http://www.dealii.org/) for "<< "more information on what this error means.")
 
 DeclException2 (ExcNoSubscriber, char *, char *,<< "No subscriber with identifier \""<< arg2<< "\" did subscribe to this object of class "<< arg1)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Types

typedef
Threads::ThreadLocalStorage
< typename
DH::active_cell_iterator > 
cell_hint_t
 

Private Member Functions

boost::optional< Point< dim > > get_reference_coordinates (const typename DH::active_cell_iterator &cell, const Point< dim > &point) const
 

Private Attributes

SmartPointer< const DH,
FEFieldFunction< dim, DH,
VECTOR > > 
dh
 
const VECTOR & data_vector
 
const Mapping< dim > & mapping
 
cell_hint_t cell_hint
 
const unsigned int n_components
 

Additional Inherited Members

- Public Attributes inherited from Function< dim >
const unsigned int n_components
 
- Static Public Attributes inherited from Function< dim >
static const unsigned int dimension = dim
 

Detailed Description

template<int dim, typename DH = DoFHandler<dim>, typename VECTOR = Vector<double>>
class Functions::FEFieldFunction< dim, DH, VECTOR >

This is an interpolation function for the given dof handler and the given solution vector. The points at which this function can be evaluated MUST be inside the domain of the dof handler, but except from this, no other requirement is given. This function is rather slow, as it needs to construct a quadrature object for the point (or set of points) where you want to evaluate your finite element function. In order to do so, it needs to find out where the points lie.

If you know in advance in which cell your points lie, you can accelerate things a bit, by calling set_active_cell before asking for values or gradients of the function. If you don't do this, and your points don't lie in the cell that is currently stored, the function GridTools::find_cell_around_point is called to find out where the point is. You can specify an optional mapping to use when looking for points in the grid. If you don't do so, this function uses a Q1 mapping.

Once the FEFieldFunction knows where the points lie, it creates a quadrature formula for those points, and calls FEValues::get_function_values or FEValues::get_function_grads with the given quadrature points.

If you only need the quadrature points but not the values of the finite element function (you might want this for the adjoint interpolation), you can also use the function compute_point_locations alone.

An example of how to use this function is the following:

// Generate two triangulations
// Read the triangulations from files, or build them up, or get
// them from some place... Assume that tria_2 is *entirely*
// included in tria_1
...
// Associate a dofhandler and a solution to the first
// triangulation
DoFHandler<dim> dh1(tria_1);
Vector<double> solution_1;
// Do the same with the second
Vector<double> solution_2;
// Setup the system, assemble matrices, solve problems and get the
// nobel prize on the first domain...
...
// Now project it to the second domain
FEFieldFunction<dim> fe_function_1 (dh_1, solution_1);
VectorTools::project(dh_2, constraints_2, quad, fe_function_1, solution_2);
// Or interpolate it...
Vector<double> solution_3;
VectorTools::interpolate(dh_2, fe_function_1, solution_3);

The snippet of code above will work assuming that the second triangulation is entirely included in the first one.

FEFieldFunction is designed to be an easy way to get the results of your computations across different, possibly non matching, grids. No knowledge of the location of the points is assumed in this class, which makes it rely entirely on the GridTools::find_active_cell_around_point utility for its job. However the class can be fed an "educated guess" of where the points that will be computed actually are by using the FEFieldFunction::set_active_cell method, so if you have a smart way to tell where your points are, you will save a lot of computational time by letting this class know.

Using FEFieldFunction with parallel::distributed::Triangulation

When using this class with a parallel distributed triangulation object and evaluating the solution at a particular point, not every processor will own the cell at which the solution is evaluated. Rather, it may be that the cell in which this point is found is in fact a ghost or artificial cell (see GlossArtificialCell and GlossGhostCell). If the cell is artificial, we have no access to the solution there and functions that evaluate the solution at such a point will trigger an exception of type FEFieldFunction::ExcPointNotAvailableHere. The same kind of exception will also be produced if the cell is a ghost cell: On such cells, one could in principle evaluate the solution, but it becomes easier if we do not allow to do so because then there is exactly one processor in a parallel distributed computation that can indeed evaluate the solution. Consequently, it is clear which processor is responsible for producing output if the point evaluation is done as a postprocessing step.

To deal with this situation, you will want to use code as follows when, for example, evaluating the solution at the origin (here using a parallel TrilinosWrappers vector to hold the solution):

solution_function (dof_handler, solution);
double solution_at_origin;
bool point_found = true;
try
{
solution_at_origin = solution_function.value (origin);
}
catch (const typename Functions::FEFieldFunction<dim,DoFHandler<dim>,TrilinosWrappers::MPI::Vector>::ExcPointNotAvailableHere &)
{
point_found = false;
}
if (point_found == true)
...do something...;
Note
To C++, Functions::FEFieldFunction<dim>::ExcPointNotAvailableHere and Functions::FEFieldFunction<dim,DoFHandler<dim>,TrilinosWrappers::MPI::Vector>::ExcPointNotAvailableHere are distinct types. You need to make sure that the type of the exception you catch matches the type of the object that throws it, as shown in the example above.
Author
Luca Heltai, 2006, Markus Buerg, 2012, Wolfgang Bangerth, 2013

Definition at line 173 of file fe_field_function.h.

Member Typedef Documentation

template<int dim, typename DH = DoFHandler<dim>, typename VECTOR = Vector<double>>
typedef Threads::ThreadLocalStorage<typename DH::active_cell_iterator > Functions::FEFieldFunction< dim, DH, VECTOR >::cell_hint_t
private

Typedef holding the local cell_hint.

Definition at line 500 of file fe_field_function.h.

Constructor & Destructor Documentation

template<int dim, typename DH , typename VECTOR >
Functions::FEFieldFunction< dim, DH, VECTOR >::FEFieldFunction ( const DH &  dh,
const VECTOR &  data_vector,
const Mapping< dim > &  mapping = StaticMappingQ1<dim>::mapping 
)

Construct a vector function. A smart pointers is stored to the dof handler, so you have to make sure that it make sense for the entire lifetime of this object. The number of components of this functions is equal to the number of components of the finite element object. If a mapping is specified, that is what is used to find out where the points lay. Otherwise the standard Q1 mapping is used.

Definition at line 35 of file fe_field_function.templates.h.

Member Function Documentation

template<int dim, typename DH , typename VECTOR >
void Functions::FEFieldFunction< dim, DH, VECTOR >::set_active_cell ( const typename DH::active_cell_iterator &  newcell)

Set the current cell. If you know in advance where your points lie, you can tell this object by calling this function. This will speed things up a little.

Definition at line 53 of file fe_field_function.templates.h.

template<int dim, typename DH , typename VECTOR >
void Functions::FEFieldFunction< dim, DH, VECTOR >::vector_value ( const Point< dim > &  p,
Vector< double > &  values 
) const
virtual

Get one vector value at the given point. It is inefficient to use single points. If you need more than one at a time, use the vector_value_list() function. For efficiency reasons, it is better if all the points lie on the same cell. This is not mandatory, however it does speed things up.

Note
When using this function on a parallel::distributed::Triangulation you may get an exception when trying to evaluate the solution at a point that does not lie in a locally owned cell (see GlossLocallyOwnedCell). See the section in the general documentation of this class for more information.

Reimplemented from Function< dim >.

Definition at line 61 of file fe_field_function.templates.h.

template<int dim, typename DH , typename VECTOR >
double Functions::FEFieldFunction< dim, DH, VECTOR >::value ( const Point< dim > &  p,
const unsigned int  component = 0 
) const
virtual

Return the value of the function at the given point. Unless there is only one component (i.e. the function is scalar), you should state the component you want to have evaluated; it defaults to zero, i.e. the first component. It is inefficient to use single points. If you need more than one at a time, use the vector_value_list function. For efficiency reasons, it is better if all the points lie on the same cell. This is not mandatory, however it does speed things up.

Note
When using this function on a parallel::distributed::Triangulation you may get an exception when trying to evaluate the solution at a point that does not lie in a locally owned cell (see GlossLocallyOwnedCell). See the section in the general documentation of this class for more information.

Reimplemented from Function< dim >.

Definition at line 99 of file fe_field_function.templates.h.

template<int dim, typename DH , typename VECTOR >
void Functions::FEFieldFunction< dim, DH, VECTOR >::value_list ( const std::vector< Point< dim > > &  points,
std::vector< double > &  values,
const unsigned int  component = 0 
) const
virtual

Set values to the point values of the specified component of the function at the points. It is assumed that values already has the right size, i.e. the same size as the points array. This is rather efficient if all the points lie on the same cell. If this is not the case, things may slow down a bit.

Note
When using this function on a parallel::distributed::Triangulation you may get an exception when trying to evaluate the solution at a point that does not lie in a locally owned cell (see GlossLocallyOwnedCell). See the section in the general documentation of this class for more information.

Reimplemented from Function< dim >.

Definition at line 261 of file fe_field_function.templates.h.

template<int dim, typename DH , typename VECTOR >
void Functions::FEFieldFunction< dim, DH, VECTOR >::vector_value_list ( const std::vector< Point< dim > > &  points,
std::vector< Vector< double > > &  values 
) const
virtual

Set values to the point values of the function at the points. It is assumed that values already has the right size, i.e. the same size as the points array. This is rather efficient if all the points lie on the same cell. If this is not the case, things may slow down a bit.

Note
When using this function on a parallel::distributed::Triangulation you may get an exception when trying to evaluate the solution at a point that does not lie in a locally owned cell (see GlossLocallyOwnedCell). See the section in the general documentation of this class for more information.

Reimplemented from Function< dim >.

Definition at line 217 of file fe_field_function.templates.h.

template<int dim, typename DH , typename VECTOR >
void Functions::FEFieldFunction< dim, DH, VECTOR >::vector_gradient ( const Point< dim > &  p,
std::vector< Tensor< 1, dim > > &  gradients 
) const
virtual

Return the gradient of all components of the function at the given point. It is inefficient to use single points. If you need more than one at a time, use the vector_value_list function. For efficiency reasons, it is better if all the points lie on the same cell. This is not mandatory, however it does speed things up.

Note
When using this function on a parallel::distributed::Triangulation you may get an exception when trying to evaluate the solution at a point that does not lie in a locally owned cell (see GlossLocallyOwnedCell). See the section in the general documentation of this class for more information.

Reimplemented from Function< dim >.

Definition at line 112 of file fe_field_function.templates.h.

template<int dim, typename DH , typename VECTOR >
Tensor< 1, dim > Functions::FEFieldFunction< dim, DH, VECTOR >::gradient ( const Point< dim > &  p,
const unsigned int  component = 0 
) const
virtual

Return the gradient of the specified component of the function at the given point. It is inefficient to use single points. If you need more than one at a time, use the vector_value_list function. For efficiency reasons, it is better if all the points lie on the same cell. This is not mandatory, however it does speed things up.

Note
When using this function on a parallel::distributed::Triangulation you may get an exception when trying to evaluate the solution at a point that does not lie in a locally owned cell (see GlossLocallyOwnedCell). See the section in the general documentation of this class for more information.

Reimplemented from Function< dim >.

Definition at line 152 of file fe_field_function.templates.h.

template<int dim, typename DH , typename VECTOR >
void Functions::FEFieldFunction< dim, DH, VECTOR >::vector_gradient_list ( const std::vector< Point< dim > > &  p,
std::vector< std::vector< Tensor< 1, dim > > > &  gradients 
) const
virtual

Return the gradient of all components of the function at all the given points. This is rather efficient if all the points lie on the same cell. If this is not the case, things may slow down a bit.

Note
When using this function on a parallel::distributed::Triangulation you may get an exception when trying to evaluate the solution at a point that does not lie in a locally owned cell (see GlossLocallyOwnedCell). See the section in the general documentation of this class for more information.

Reimplemented from Function< dim >.

Definition at line 278 of file fe_field_function.templates.h.

template<int dim, typename DH , typename VECTOR >
void Functions::FEFieldFunction< dim, DH, VECTOR >::gradient_list ( const std::vector< Point< dim > > &  p,
std::vector< Tensor< 1, dim > > &  gradients,
const unsigned int  component = 0 
) const
virtual

Return the gradient of the specified component of the function at all the given points. This is rather efficient if all the points lie on the same cell. If this is not the case, things may slow down a bit.

Note
When using this function on a parallel::distributed::Triangulation you may get an exception when trying to evaluate the solution at a point that does not lie in a locally owned cell (see GlossLocallyOwnedCell). See the section in the general documentation of this class for more information.

Reimplemented from Function< dim >.

Definition at line 322 of file fe_field_function.templates.h.

template<int dim, typename DH , typename VECTOR >
double Functions::FEFieldFunction< dim, DH, VECTOR >::laplacian ( const Point< dim > &  p,
const unsigned int  component = 0 
) const
virtual

Compute the Laplacian of a given component at point p.

Note
When using this function on a parallel::distributed::Triangulation you may get an exception when trying to evaluate the solution at a point that does not lie in a locally owned cell (see GlossLocallyOwnedCell). See the section in the general documentation of this class for more information.

Reimplemented from Function< dim >.

Definition at line 203 of file fe_field_function.templates.h.

template<int dim, typename DH , typename VECTOR >
void Functions::FEFieldFunction< dim, DH, VECTOR >::vector_laplacian ( const Point< dim > &  p,
Vector< double > &  values 
) const
virtual

Compute the Laplacian of all components at point p and store them in values.

Note
When using this function on a parallel::distributed::Triangulation you may get an exception when trying to evaluate the solution at a point that does not lie in a locally owned cell (see GlossLocallyOwnedCell). See the section in the general documentation of this class for more information.

Reimplemented from Function< dim >.

Definition at line 165 of file fe_field_function.templates.h.

template<int dim, typename DH , typename VECTOR >
void Functions::FEFieldFunction< dim, DH, VECTOR >::laplacian_list ( const std::vector< Point< dim > > &  points,
std::vector< double > &  values,
const unsigned int  component = 0 
) const
virtual

Compute the Laplacian of one component at a set of points.

Note
When using this function on a parallel::distributed::Triangulation you may get an exception when trying to evaluate the solution at a point that does not lie in a locally owned cell (see GlossLocallyOwnedCell). See the section in the general documentation of this class for more information.

Reimplemented from Function< dim >.

Definition at line 381 of file fe_field_function.templates.h.

template<int dim, typename DH , typename VECTOR >
void Functions::FEFieldFunction< dim, DH, VECTOR >::vector_laplacian_list ( const std::vector< Point< dim > > &  points,
std::vector< Vector< double > > &  values 
) const
virtual

Compute the Laplacians of all components at a set of points.

Note
When using this function on a parallel::distributed::Triangulation you may get an exception when trying to evaluate the solution at a point that does not lie in a locally owned cell (see GlossLocallyOwnedCell). See the section in the general documentation of this class for more information.

Reimplemented from Function< dim >.

Definition at line 339 of file fe_field_function.templates.h.

template<int dim, typename DH , typename VECTOR >
unsigned int Functions::FEFieldFunction< dim, DH, VECTOR >::compute_point_locations ( const std::vector< Point< dim > > &  points,
std::vector< typename DH::active_cell_iterator > &  cells,
std::vector< std::vector< Point< dim > > > &  qpoints,
std::vector< std::vector< unsigned int > > &  maps 
) const

Create quadrature rules. This function groups the points into blocks that live in the same cell, and fills up three vectors: cells, qpoints and maps. The first is a list of the cells that contain the points, the second is a list of quadrature points matching each cell of the first list, and the third contains the index of the given quadrature points, i.e., points[maps[3][4]] ends up as the 5th quadrature point in the 4th cell. This is where optimization would help. This function returns the number of cells that contain the given set of points.

Definition at line 397 of file fe_field_function.templates.h.

template<int dim, typename DH = DoFHandler<dim>, typename VECTOR = Vector<double>>
Functions::FEFieldFunction< dim, DH, VECTOR >::DeclException0 ( ExcPointNotAvailableHere  )

Exception

template<int dim, typename DH , typename VECTOR >
boost::optional< Point< dim > > Functions::FEFieldFunction< dim, DH, VECTOR >::get_reference_coordinates ( const typename DH::active_cell_iterator &  cell,
const Point< dim > &  point 
) const
private

Given a cell, return the reference coordinates of the given point within this cell if it indeed lies within the cell. Otherwise return an uninitialized boost::optional object.

Definition at line 560 of file fe_field_function.templates.h.

Member Data Documentation

template<int dim, typename DH = DoFHandler<dim>, typename VECTOR = Vector<double>>
SmartPointer<const DH,FEFieldFunction<dim, DH, VECTOR> > Functions::FEFieldFunction< dim, DH, VECTOR >::dh
private

Pointer to the dof handler.

Definition at line 505 of file fe_field_function.h.

template<int dim, typename DH = DoFHandler<dim>, typename VECTOR = Vector<double>>
const VECTOR& Functions::FEFieldFunction< dim, DH, VECTOR >::data_vector
private

A reference to the actual data vector.

Definition at line 511 of file fe_field_function.h.

template<int dim, typename DH = DoFHandler<dim>, typename VECTOR = Vector<double>>
const Mapping<dim>& Functions::FEFieldFunction< dim, DH, VECTOR >::mapping
private

A reference to the mapping being used.

Definition at line 517 of file fe_field_function.h.

template<int dim, typename DH = DoFHandler<dim>, typename VECTOR = Vector<double>>
cell_hint_t Functions::FEFieldFunction< dim, DH, VECTOR >::cell_hint
mutableprivate

The latest cell hint.

Definition at line 522 of file fe_field_function.h.

template<int dim, typename DH = DoFHandler<dim>, typename VECTOR = Vector<double>>
const unsigned int Functions::FEFieldFunction< dim, DH, VECTOR >::n_components
private

Store the number of components of this function.

Definition at line 528 of file fe_field_function.h.


The documentation for this class was generated from the following files: