Reference documentation for deal.II version GIT relicensing-1125-gadd8e16ae6 2024-07-19 10:00:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
NonMatching::FEValues< dim > Class Template Reference

#include <deal.II/non_matching/fe_values.h>

Public Types

using AdditionalData = typename QuadratureGenerator< dim >::AdditionalData
 

Public Member Functions

template<typename VectorType >
 FEValues (const hp::FECollection< dim > &fe_collection, const Quadrature< 1 > &quadrature, const RegionUpdateFlags region_update_flags, const MeshClassifier< dim > &mesh_classifier, const DoFHandler< dim > &dof_handler, const VectorType &level_set, const AdditionalData &additional_data=AdditionalData())
 
template<typename VectorType >
 FEValues (const hp::MappingCollection< dim > &mapping_collection, const hp::FECollection< dim > &fe_collection, const hp::QCollection< dim > &q_collection, const hp::QCollection< 1 > &q_collection_1d, const RegionUpdateFlags region_update_flags, const MeshClassifier< dim > &mesh_classifier, const DoFHandler< dim > &dof_handler, const VectorType &level_set, const AdditionalData &additional_data=AdditionalData())
 
template<bool level_dof_access>
void reinit (const TriaIterator< DoFCellAccessor< dim, dim, level_dof_access > > &cell, const unsigned int q_index=numbers::invalid_unsigned_int, const unsigned int mapping_index=numbers::invalid_unsigned_int)
 
void reinit (const TriaIterator< CellAccessor< dim, dim > > &cell, const unsigned int q_index=numbers::invalid_unsigned_int, const unsigned int mapping_index=numbers::invalid_unsigned_int, const unsigned int fe_index=numbers::invalid_unsigned_int)
 
const std::optional<::FEValues< dim > > & get_inside_fe_values () const
 
const std::optional<::FEValues< dim > > & get_outside_fe_values () const
 
const std::optional< FEImmersedSurfaceValues< dim > > & get_surface_fe_values () const
 

Private Member Functions

template<typename CellIteratorType >
void reinit_internal (const CellIteratorType &cell, const unsigned int q_index, const unsigned int mapping_index, const unsigned int fe_index)
 
void initialize (const hp::QCollection< dim > &q_collection)
 

Private Attributes

const SmartPointer< const hp::MappingCollection< dim > > mapping_collection
 
const SmartPointer< const hp::FECollection< dim > > fe_collection
 
const hp::QCollection< 1 > q_collection_1D
 
LocationToLevelSet current_cell_location
 
unsigned int active_fe_index
 
const RegionUpdateFlags region_update_flags
 
const SmartPointer< const MeshClassifier< dim > > mesh_classifier
 
std::deque< std::optional<::FEValues< dim > > > fe_values_inside_full_quadrature
 
std::deque< std::optional<::FEValues< dim > > > fe_values_outside_full_quadrature
 
std::optional<::FEValues< dim > > fe_values_inside
 
std::optional<::FEValues< dim > > fe_values_outside
 
std::optional< NonMatching::FEImmersedSurfaceValues< dim > > fe_values_surface
 
DiscreteQuadratureGenerator< dim > quadrature_generator
 

Detailed Description

template<int dim>
class NonMatching::FEValues< dim >

This class is intended to facilitate assembling in immersed (in the sense of cut) finite element methods when the domain is described by a level set function, \(\psi : \mathbb{R}^{dim} \to \mathbb{R}\). In this type of method, we typically need to integrate over 3 different regions of each cell, \(K\):

\[ N = \{x \in K : \psi(x) < 0 \}, \\ P = \{x \in K : \psi(x) > 0 \}, \\ S = \{x \in K : \psi(x) = 0 \}. \]

Thus we need quadrature rules for these 3 regions:

As in the QuadratureGenerator class, we refer to \(N\), \(P\), and \(S\) as the inside, outside, and surface regions. The constructor of this class takes a discrete level set function described by a DoFHandler and a Vector. When the reinit() function is called, the QuadratureGenerator will be called in the background to create these immersed quadrature rules. This class then creates FEValues objects for the inside/outside regions and an FEImmersedSurfaceValues object for the surface region. These objects can then be accessed through one of the functions: get_inside_fe_values(), get_outside_fe_values(), or get_surface_fe_values(). Since a cut between a cell and the domain can be arbitrarily small, the underlying algorithm may generate a quadrature rule with 0 points. This can, for example, happen if the relative size of the cut is similar to the floating-point accuracy. Since the FEValues-like objects are not allowed to contain 0 points, the object that get_inside/outside/surface_fe_values() returns is wrapped in a std::optional. This requires us to check if the returned FEValues-like object contains a value before we use it:

for (const auto &cell : dof_handler.active_cell_iterators())
{
fe_values.reinit(cell);
const std::optional<FEValues<dim>> &fe_values_inside =
fe_values.get_inside_fe_values();
{
// Assemble locally
for (const unsigned int q_index :
fe_values_inside->quadrature_point_indices())
{
// ...
}
}
}
std::optional<::FEValues< dim > > fe_values_inside
Definition fe_values.h:397

Of course, it is somewhat expensive to generate the immersed quadrature rules and create FEValues objects with the generated quadratures. To reduce the amount of work, the reinit() function of this class uses the MeshClassifier passed to the constructor to check how the incoming cell relates to the level set function. It only generates the immersed quadrature rules if the cell is intersected. If the cell is completely inside or outside, it returns a cached FEValues object created with a quadrature over the reference cell: \([0, 1]^{dim}\).

Definition at line 143 of file fe_values.h.

Member Typedef Documentation

◆ AdditionalData

template<int dim>
using NonMatching::FEValues< dim >::AdditionalData = typename QuadratureGenerator<dim>::AdditionalData

Definition at line 146 of file fe_values.h.

Constructor & Destructor Documentation

◆ FEValues() [1/2]

template<int dim>
template<typename VectorType >
FEValues< dim >::FEValues ( const hp::FECollection< dim > &  fe_collection,
const Quadrature< 1 > &  quadrature,
const RegionUpdateFlags  region_update_flags,
const MeshClassifier< dim > &  mesh_classifier,
const DoFHandler< dim > &  dof_handler,
const VectorType &  level_set,
const AdditionalData additional_data = AdditionalData() 
)

Constructor.

Parameters
fe_collectionCollection of FiniteElements to be used.
quadrature1-dimensional quadrature rule used to generate the immersed quadrature rules. See the QuadratureGenerator class. On the non intersected elements a tensor product of this quadrature will be used.
mesh_classifierObject used to determine when the immersed quadrature rules need to be generated.
region_update_flagsStruct storing UpdateFlags for the inside/outside/surface region of the cell.
dof_handlerThe DoFHandler associated with the discrete level set function.
level_setThe degrees of freedom of the discrete level set function.
additional_dataAdditional data passed to the QuadratureGenerator class.
Note
Pointers to fe_collection, mesh_classifier, dof_handler, and level_set are stored internally, so these need to have a longer life span than the instance of this class.

Definition at line 45 of file fe_values.cc.

◆ FEValues() [2/2]

template<int dim>
template<typename VectorType >
FEValues< dim >::FEValues ( const hp::MappingCollection< dim > &  mapping_collection,
const hp::FECollection< dim > &  fe_collection,
const hp::QCollection< dim > &  q_collection,
const hp::QCollection< 1 > &  q_collection_1d,
const RegionUpdateFlags  region_update_flags,
const MeshClassifier< dim > &  mesh_classifier,
const DoFHandler< dim > &  dof_handler,
const VectorType &  level_set,
const AdditionalData additional_data = AdditionalData() 
)

Constructor.

Parameters
mapping_collectionCollection of Mappings to be used.
fe_collectionCollection of FiniteElements to be used.
q_collectionCollection of Quadrature rules over \([0, 1]^{dim}\) that should be used when a cell is not intersected and we do not need to generate immersed quadrature rules.
q_collection_1dCollection of 1-dimensional quadrature rules used to generate the immersed quadrature rules. See the QuadratureGenerator class.
mesh_classifierObject used to determine when the immersed quadrature rules need to be generated.
region_update_flagsStruct storing UpdateFlags for the inside/outside/surface region of the cell.
dof_handlerThe DoFHandler associated with the discrete level set function.
level_setThe degrees of freedom of the discrete level set function.
additional_dataAdditional data passed to the QuadratureGenerator class.
Note
Pointers to mapping_collection, fe_collection, mesh_classifier, dof_handler, and level_set are stored internally, so these need to have a longer life span than the instance of this class.

Definition at line 75 of file fe_values.cc.

Member Function Documentation

◆ reinit() [1/2]

template<int dim>
template<bool level_dof_access>
void FEValues< dim >::reinit ( const TriaIterator< DoFCellAccessor< dim, dim, level_dof_access > > &  cell,
const unsigned int  q_index = numbers::invalid_unsigned_int,
const unsigned int  mapping_index = numbers::invalid_unsigned_int 
)

Reinitialize the various FEValues-like objects for the 3 different regions of the cell. After calling this function an FEValues-like object can be retrieved for each region using the functions get_inside_fe_values(), get_outside_fe_values(), or get_surface_fe_values().

If the q_index argument is left at its default value, then we use that quadrature formula within the hp::QCollection passed to the constructor of this class with index given by cell->active_fe_index(), i.e. the same index as that of the finite element. In this case, there should be a corresponding quadrature formula for each finite element in the hp::FECollection. As a special case, if the quadrature collection contains only a single element (a frequent case if one wants to use the same quadrature object for all finite elements in an hp-discretization, even if that may not be the most efficient), then this single quadrature is used unless a different value for this argument is specified. On the other hand, if a value is given for this argument, it overrides the choice of cell->active_fe_index() or the choice for the single quadrature.

If the mapping_index argument is left at its default value, then we use that mapping object within the hp::MappingCollection passed to the constructor of this class with index given by cell->active_fe_index(), i.e. the same index as that of the finite element. As above, if the mapping collection contains only a single element (a frequent case if one wants to use a \(Q_1\) mapping for all finite elements in an hp-discretization), then this single mapping is used unless a different value for this argument is specified.

Definition at line 150 of file fe_values.cc.

◆ reinit() [2/2]

template<int dim>
void FEValues< dim >::reinit ( const TriaIterator< CellAccessor< dim, dim > > &  cell,
const unsigned int  q_index = numbers::invalid_unsigned_int,
const unsigned int  mapping_index = numbers::invalid_unsigned_int,
const unsigned int  fe_index = numbers::invalid_unsigned_int 
)

Like the previous function, but for non-DoFHandler iterators. The reason this function exists is so that one can use NonMatching::FEValues for Triangulation objects too.

Since cell->active_fe_index() doesn't make sense for triangulation iterators, this function chooses the zero-th finite element, mapping, and quadrature object from the relevant constructions passed to the constructor of this object. The only exception is if you specify a value different from the default value for any of these last three arguments.

Definition at line 165 of file fe_values.cc.

◆ get_inside_fe_values()

template<int dim>
const std::optional<::FEValues< dim > > & FEValues< dim >::get_inside_fe_values ( ) const

Return an FEValues object reinitialized with a quadrature for the inside region of the cell: \(\{x \in K : \psi(x) < 0 \}\).

Note
If the quadrature rule over the region is empty, e.g. because the cell is completely located in the outside domain, the returned optional will not contain a value.

Definition at line 306 of file fe_values.cc.

◆ get_outside_fe_values()

template<int dim>
const std::optional<::FEValues< dim > > & FEValues< dim >::get_outside_fe_values ( ) const

Return an FEValues object reinitialized with a quadrature for the outside region of the cell: \(\{x \in K : \psi(x) > 0 \}\).

Note
If the quadrature rule over the region is empty, e.g. because the cell is completely located in the inside domain, the returned optional will not contain a value.

Definition at line 318 of file fe_values.cc.

◆ get_surface_fe_values()

template<int dim>
const std::optional< FEImmersedSurfaceValues< dim > > & FEValues< dim >::get_surface_fe_values ( ) const

Return an FEValues object reinitialized with a quadrature for the surface region of the cell: \(\{x \in K : \psi(x) = 0 \}\).

Note
If the quadrature rule over the region is empty, e.g. because the cell is not intersected, the returned optional will not contain a value.

Definition at line 330 of file fe_values.cc.

◆ reinit_internal()

template<int dim>
template<typename CellIteratorType >
void FEValues< dim >::reinit_internal ( const CellIteratorType &  cell,
const unsigned int  q_index,
const unsigned int  mapping_index,
const unsigned int  fe_index 
)
private

Internal function called by the reinit() functions.

Definition at line 178 of file fe_values.cc.

◆ initialize()

template<int dim>
void FEValues< dim >::initialize ( const hp::QCollection< dim > &  q_collection)
private

Do work common to the constructors. The incoming QCollection should be quadratures integrating over \([0, 1]^{dim}\). These will be used on the non-intersected cells.

Definition at line 101 of file fe_values.cc.

Member Data Documentation

◆ mapping_collection

template<int dim>
const SmartPointer<const hp::MappingCollection<dim> > NonMatching::FEValues< dim >::mapping_collection
private

A pointer to the collection of mappings to be used.

Definition at line 325 of file fe_values.h.

◆ fe_collection

template<int dim>
const SmartPointer<const hp::FECollection<dim> > NonMatching::FEValues< dim >::fe_collection
private

A pointer to the collection of finite elements to be used.

Definition at line 330 of file fe_values.h.

◆ q_collection_1D

template<int dim>
const hp::QCollection<1> NonMatching::FEValues< dim >::q_collection_1D
private

Collection of 1-dimensional quadrature rules that are used by QuadratureGenerator as base for generating the immersed quadrature rules.

Definition at line 336 of file fe_values.h.

◆ current_cell_location

template<int dim>
LocationToLevelSet NonMatching::FEValues< dim >::current_cell_location
private

Location of the last cell that reinit was called with.

Definition at line 341 of file fe_values.h.

◆ active_fe_index

template<int dim>
unsigned int NonMatching::FEValues< dim >::active_fe_index
private

Active fe index of the last cell that reinit was called with.

Definition at line 346 of file fe_values.h.

◆ region_update_flags

template<int dim>
const RegionUpdateFlags NonMatching::FEValues< dim >::region_update_flags
private

The update flags passed to the constructor.

Definition at line 351 of file fe_values.h.

◆ mesh_classifier

template<int dim>
const SmartPointer<const MeshClassifier<dim> > NonMatching::FEValues< dim >::mesh_classifier
private

Pointer to the MeshClassifier passed to the constructor.

Definition at line 356 of file fe_values.h.

◆ fe_values_inside_full_quadrature

template<int dim>
std::deque<std::optional<::FEValues<dim> > > NonMatching::FEValues< dim >::fe_values_inside_full_quadrature
private

For each element in the FECollection passed to the constructor, this object contains an FEValues object created with a quadrature rule over the full reference cell: \([0, 1]^{dim}\) and UpdateFlags for the inside region. Thus, these optionals should always contain a value.

When LocationToLevelSet of the cell is INSIDE (and we do not need to generate an immersed quadrature), we return the FEValues object in this container corresponding to the cell's active_fe_index.

This container is a std::deque, which is compatible with the FEValues class that does not have a copy-constructor.

Definition at line 372 of file fe_values.h.

◆ fe_values_outside_full_quadrature

template<int dim>
std::deque<std::optional<::FEValues<dim> > > NonMatching::FEValues< dim >::fe_values_outside_full_quadrature
private

For each element in the FECollection passed to the constructor, this object contains an FEValues object created with a quadrature rule over the full reference cell: \([0, 1]^{dim}\) and UpdateFlags for the outside region. Thus, these optionals should always contain a value.

When LocationToLevelSet of the cell is OUTSIDE (and we do not need to generate an immersed quadrature), we return the FEValues object in this container corresponding to the cell's active_fe_index.

This container is a std::deque, which is compatible with the FEValues class that does not have a copy-constructor.

Definition at line 388 of file fe_values.h.

◆ fe_values_inside

template<int dim>
std::optional<::FEValues<dim> > NonMatching::FEValues< dim >::fe_values_inside
private

FEValues object created with a quadrature rule integrating over the inside region, \(\{x \in B : \psi(x) < 0 \}\), that was generated in the last call to reinit(..). If the cell in the last call was not intersected or if 0 quadrature points were generated, this optional will not contain a value.

Definition at line 397 of file fe_values.h.

◆ fe_values_outside

template<int dim>
std::optional<::FEValues<dim> > NonMatching::FEValues< dim >::fe_values_outside
private

FEValues object created with a quadrature rule integrating over the outside region, \(\{x \in B : \psi(x) > 0 \}\), that was generated in the last call to reinit(..). If the cell in the last call was not intersected or if 0 quadrature points were generated, this optional will not contain a value.

Definition at line 406 of file fe_values.h.

◆ fe_values_surface

template<int dim>
std::optional<NonMatching::FEImmersedSurfaceValues<dim> > NonMatching::FEValues< dim >::fe_values_surface
private

FEImmersedSurfaceValues object created with a quadrature rule integrating over the surface region, \(\{x \in B : \psi(x) = 0 \}\), that was generated in the last call to reinit(..). If the cell in the last call was not intersected or if 0 quadrature points were generated, this optional will not contain a value.

Definition at line 415 of file fe_values.h.

◆ quadrature_generator

template<int dim>
DiscreteQuadratureGenerator<dim> NonMatching::FEValues< dim >::quadrature_generator
private

Object that generates the immersed quadrature rules.

Definition at line 420 of file fe_values.h.


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