HyTeG
Matrix-Free Finite Elements
|
#include <DGFunction.hpp>
Public Types | |
template<typename VType > | |
using | FunctionType = DGFunction< VType > |
typedef FunctionTrait< DGFunction< ValueType > >::Tag | Tag |
typedef ValueType | valueType |
Public Member Functions | |
DGFunction (const std::string &name, const std::shared_ptr< PrimitiveStorage > &storage, uint_t minLevel, uint_t maxLevel, const std::shared_ptr< DGBasisInfo > &basis, uint_t initialPolyDegree, BoundaryCondition boundaryCondition=BoundaryCondition::create0123BC()) | |
Instantiates a DGFunction. | |
void | add (const std::vector< ValueType > scalars, const std::vector< std::reference_wrapper< const DGFunction< ValueType > > > &functions, uint_t level, DoFType flag=All) const |
void | add (const ValueType scalar, uint_t level, DoFType flag=All) const |
void | applyDirichletBoundaryConditions (const std::shared_ptr< DGForm > &form, uint_t level) |
Applies the Dirichlet boundary conditions to this function, treating it as the right-hand side of the linear system that corresponds to the form object. | |
void | assign (const std::vector< ValueType > &scalars, const std::vector< std::reference_wrapper< const DGFunction< ValueType > > > &functions, uint_t level, DoFType flag=All) |
Assigns a linear combination of multiple VolumeDoFFunctions to this. | |
std::shared_ptr< DGBasisInfo > | basis () const |
Returns the associated DGBasisInfo object. | |
void | communicate (uint_t level) const |
Updates ghost-layers. | |
template<typename OtherValueType > | |
void | copyBoundaryConditionFromFunction (const DGFunction< OtherValueType > &other) |
void | copyFrom (const DGFunction< ValueType > &other, const uint_t &level, const std::map< PrimitiveID, uint_t > &localPrimitiveIDsToRank, const std::map< PrimitiveID, uint_t > &otherPrimitiveIDsToRank) const |
ValueType | dotGlobal (const DGFunction< ValueType > &rhs, uint_t level, DoFType flag=All) const |
Evaluates the (global) dot product. Involves communication and has to be called collectively. | |
ValueType | dotLocal (const DGFunction< ValueType > &rhs, uint_t level, DoFType flag=All) const |
Evaluates the dot product on all local DoFs. | |
void | enableTiming (const std::shared_ptr< walberla::WcTimingTree > &timingTree) |
void | enumerate (uint_t level) const |
Assigns unique values to all data points. | |
void | enumerate (uint_t level, ValueType &offset) const |
Like enumerate() but starting with a value given by the offset parameter. | |
bool | evaluate (const Point3D &physicalCoords, uint_t level, ValueType &value, real_t searchToleranceRadius=1e-05) const |
Evaluate finite element function at a specific coordinates. | |
void | evaluateLinearFunctional (const std::function< real_t(const Point3D &) > &f, uint_t level) |
Evaluates the linear functional. | |
void | evaluateOnMicroElement (const Point3D &coordinates, uint_t level, const PrimitiveID &cellID, hyteg::indexing::Index elementIndex, celldof::CellType cellType, ValueType &value) const |
Evaluate finite element function on a specific micro-cell. | |
void | evaluateOnMicroElement (const Point3D &coordinates, uint_t level, const PrimitiveID &faceID, hyteg::indexing::Index elementIndex, facedof::FaceType faceType, ValueType &value) const |
Evaluate finite element function on a specific micro-face. | |
BoundaryCondition | getBoundaryCondition () const |
Returns the boundary conditions of this function. | |
uint_t | getDimension () const |
Query function object for the dimension of the field it represents. | |
const std::string & | getFunctionName () const |
ValueType | getMax (uint_t level, bool mpiReduce=true) const |
Returns the max DoF value. | |
uint_t | getMaxLevel () |
Query function object for maximal level on which it defined. | |
ValueType | getMaxMagnitude (uint_t level, bool mpiReduce=true) const |
Returns the max absolute DoF value. | |
ValueType | getMin (uint_t level, bool mpiReduce=true) const |
Returns the min DoF value. | |
uint_t | getMinLevel () |
Query function object for minimal level on which it defined. | |
uint_t | getNumberOfGlobalDoFs (uint_t level, const MPI_Comm &communicator=walberla::mpi::MPIManager::instance() ->comm(), const bool &onRootOnly=false) const |
Returns the number of DoFs. | |
uint_t | getNumberOfLocalDoFs (uint_t level) const |
Returns the number of DoFs that are allocated on this process. | |
std::shared_ptr< PrimitiveStorage > | getStorage () const |
void | interpolate (const std::function< ValueType(const hyteg::Point3D &) > &expr, uint_t level, DoFType flag=All) const |
void | interpolate (const std::vector< std::function< ValueType(const hyteg::Point3D &) > > &expressions, uint_t level, DoFType flag=All) const |
void | interpolate (ValueType constant, uint_t level, DoFType flag=All) const |
void | multElementwise (const std::vector< std::reference_wrapper< const DGFunction< ValueType > > > &functions, uint_t level, DoFType flag=All) const |
int | polynomialDegree (const PrimitiveID &primitiveID) const |
Returns the polynomial degree of the function on the passed primitive. | |
void | setBoundaryCondition (BoundaryCondition bc) |
Sets the boundary conditions of this function. | |
ValueType | sumGlobal (uint_t level, DoFType flag=All) const |
Evaluates the sum on all DoFs. | |
void | swap (const DGFunction< ValueType > &other, const uint_t &level, const DoFType &flag=All) const |
std::shared_ptr< volumedofspace::VolumeDoFFunction< ValueType > > | volumeDoFFunction () const |
Returns the internally stored VolumeDoFFunction. | |
void | toVector (const DGFunction< idx_t > &numerator, const std::shared_ptr< VectorProxy > &vec, uint_t level, DoFType flag) const |
conversion to/from linear algebra representation | |
void | fromVector (const DGFunction< idx_t > &numerator, const std::shared_ptr< VectorProxy > &vec, uint_t level, DoFType flag) const |
conversion to/from linear algebra representation | |
Static Public Member Functions | |
static std::vector< std::string > | getFunctionNames () |
static std::map< uint_t, uint_t > | getLevelWiseFunctionCounter () |
static uint_t | getNumFunctions () |
Protected Member Functions | |
void | startTiming (const std::string &timerString) const |
void | stopTiming (const std::string &timerString) const |
Protected Attributes | |
std::map< uint_t, std::shared_ptr< communication::BufferedCommunicator > > | additiveCommunicators_ |
std::map< uint_t, std::shared_ptr< communication::BufferedCommunicator > > | communicators_ |
std::string | functionName_ |
std::shared_ptr< walberla::WcTimingTree > | timingTree_ |
Private Attributes | |
std::shared_ptr< DGBasisInfo > | basis_ |
BoundaryCondition | boundaryCondition_ |
uint_t | maxLevel_ |
uint_t | minLevel_ |
std::string | name_ |
std::map< PrimitiveID, uint_t > | polyDegreesPerPrimitive_ |
std::shared_ptr< PrimitiveStorage > | storage_ |
std::shared_ptr< volumedofspace::VolumeDoFFunction< ValueType > > | volumeDoFFunction_ |
Static Private Attributes | |
static std::vector< std::string > | functionNames_ |
static std::map< uint_t, uint_t > | levelWiseFunctionCounter_ |
using hyteg::dg::DGFunction< ValueType >::FunctionType = DGFunction< VType > |
|
inherited |
typedef ValueType hyteg::dg::DGFunction< ValueType >::valueType |
hyteg::dg::DGFunction< ValueType >::DGFunction | ( | const std::string & | name, |
const std::shared_ptr< PrimitiveStorage > & | storage, | ||
uint_t | minLevel, | ||
uint_t | maxLevel, | ||
const std::shared_ptr< DGBasisInfo > & | basis, | ||
uint_t | initialPolyDegree, | ||
BoundaryCondition | boundaryCondition = BoundaryCondition::create0123BC() ) |
Instantiates a DGFunction.
name | name of the function for output / debugging purposes |
storage | PrimitiveStorage that this lives on |
minLevel | min refinement level to allocate |
maxLevel | max refinement level to allocate |
basis | polynomial basis information through corresponding DGBasisInfo object |
initialPolyDegree | polynomial degree to initialize with globally |
|
inline |
|
inline |
void hyteg::dg::DGFunction< ValueType >::applyDirichletBoundaryConditions | ( | const std::shared_ptr< DGForm > & | form, |
uint_t | level ) |
Applies the Dirichlet boundary conditions to this function, treating it as the right-hand side of the linear system that corresponds to the form object.
|
inline |
Assigns a linear combination of multiple VolumeDoFFunctions to this.
|
inline |
Returns the associated DGBasisInfo object.
|
inline |
Updates ghost-layers.
|
inline |
|
inline |
|
inline |
Evaluates the (global) dot product. Involves communication and has to be called collectively.
|
inline |
Evaluates the dot product on all local DoFs.
No communication is involved and the results may be different on each process.
|
inlineinherited |
void hyteg::dg::DGFunction< ValueType >::enumerate | ( | uint_t | level | ) | const |
Assigns unique values to all data points.
Increments by 1 per DoF.
Mainly used for sparse matrix assembly to get global integer identifiers for all DoFs.
level | refinement level to enumerate |
void hyteg::dg::DGFunction< ValueType >::enumerate | ( | uint_t | level, |
ValueType & | offset ) const |
Like enumerate() but starting with a value given by the offset parameter.
level | refinement level to enumerate |
offset | value to start from, the next "free" value is returned |
bool hyteg::dg::DGFunction< ValueType >::evaluate | ( | const Point3D & | physicalCoords, |
uint_t | level, | ||
ValueType & | value, | ||
real_t | searchToleranceRadius = 1e-05 ) const |
Evaluate finite element function at a specific coordinates.
In a parallel setting, the specified coordinate might not lie in the local subdomain.
Evaluation is performed in two steps:
If both tests fail, this function returns false, and no evaluation is performed (i.e. the returned, evaluated value is not set to anything meaningful).
Note that two parallel processes that return true, may return different values.
No communication is performed in this function. -> Does not need to be called collectively. -> Different values are returned on each process.
physicalCoords | coordinates in physical domain where the function is to be evaluated |
level | refinement level |
value | function value at the coordinate if search was successful |
searchToleranceRadius | radius of the sphere (circle) for the second search phase, skipped if negative |
void hyteg::dg::DGFunction< ValueType >::evaluateLinearFunctional | ( | const std::function< real_t(const Point3D &) > & | f, |
uint_t | level ) |
Evaluates the linear functional.
\[ l( v ) = \int_\Omega f \cdot v \]
by integration over the local basis functions and writes the result into the vector, i.e.
\[ u_i \leftarrow \int_T f \cdot \phi_i \]
where \(\phi_i\) is the basis function associated with the DoF \(u_i\) and \(f\) a given analytical function.
void hyteg::dg::DGFunction< ValueType >::evaluateOnMicroElement | ( | const Point3D & | coordinates, |
uint_t | level, | ||
const PrimitiveID & | cellID, | ||
hyteg::indexing::Index | elementIndex, | ||
celldof::CellType | cellType, | ||
ValueType & | value ) const |
Evaluate finite element function on a specific micro-cell.
The standard evaluate() function does not take the discontinuity of the function into account. If the function is evaluated at a discontinuity with evaluate(), it is kind of "random" which of the neighboring elements is used to evaluate the polynom.
This is for example an issue for accurate visualization of discontinuities.
The present method solves this issue by taking a specific (micro-)element as input argument. This way the function can be evaluated on different elements at the same coordinate. Note that regardless of whether the specified coordinate is located on the element or not - the local polynomial is extrapolated.
coordinates | where the function shall be evaluated |
level | refinement level |
cellID | the macro-cell where the (micro-)element is located on |
elementIndex | the logical index of the micro-element |
cellType | the type of the local micro-element |
value | the evaluation |
void hyteg::dg::DGFunction< ValueType >::evaluateOnMicroElement | ( | const Point3D & | coordinates, |
uint_t | level, | ||
const PrimitiveID & | faceID, | ||
hyteg::indexing::Index | elementIndex, | ||
facedof::FaceType | faceType, | ||
ValueType & | value ) const |
Evaluate finite element function on a specific micro-face.
The standard evaluate() function does not take the discontinuity of the function into account. If the function is evaluated at a discontinuity with evaluate(), it is kind of "random" which of the neighboring elements is used to evaluate the polynom.
This is for example an issue for accurate visualization of discontinuities.
The present method solves this issue by taking a specific (micro-)element as input argument. This way the function can be evaluated on different elements at the same coordinate. Note that regardless of whether the specified coordinate is located on the element or not - the local polynomial is extrapolated.
coordinates | where the function shall be evaluated |
level | refinement level |
faceID | the macro-face where the (micro-)element is located on |
elementIndex | the logical index of the micro-element |
faceType | the type of the local micro-element |
value | the evaluation |
void hyteg::dg::DGFunction< ValueType >::fromVector | ( | const DGFunction< idx_t > & | numerator, |
const std::shared_ptr< VectorProxy > & | vec, | ||
uint_t | level, | ||
DoFType | flag ) const |
conversion to/from linear algebra representation
|
inline |
Returns the boundary conditions of this function.
|
inlinevirtual |
Query function object for the dimension of the field it represents.
Implements hyteg::Function< DGFunction< ValueType > >.
|
inlineinherited |
|
inlinestaticinherited |
|
inlinestaticinherited |
ValueType hyteg::dg::DGFunction< ValueType >::getMax | ( | uint_t | level, |
bool | mpiReduce = true ) const |
Returns the max DoF value.
level | refinement level |
mpiReduce | if true, reduces over all processes (global max), if false returns the process local value |
|
inlineinherited |
Query function object for maximal level on which it defined.
ValueType hyteg::dg::DGFunction< ValueType >::getMaxMagnitude | ( | uint_t | level, |
bool | mpiReduce = true ) const |
Returns the max absolute DoF value.
level | refinement level |
mpiReduce | if true, reduces over all processes (global max magnitude), if false returns the process local value |
ValueType hyteg::dg::DGFunction< ValueType >::getMin | ( | uint_t | level, |
bool | mpiReduce = true ) const |
Returns the min DoF value.
level | refinement level |
mpiReduce | if true, reduces over all processes (global min), if false returns the process local value |
|
inlineinherited |
Query function object for minimal level on which it defined.
uint_t hyteg::dg::DGFunction< ValueType >::getNumberOfGlobalDoFs | ( | uint_t | level, |
const MPI_Comm & | communicator = walberla::mpi::MPIManager::instance()->comm(), | ||
const bool & | onRootOnly = false ) const |
Returns the number of DoFs.
Performs global reduction, must be called collectively.
level | refinement level |
communicator | if required, a custom communicator can be passed |
onRootOnly | if true, the result is only returned on the root process |
uint_t hyteg::dg::DGFunction< ValueType >::getNumberOfLocalDoFs | ( | uint_t | level | ) | const |
Returns the number of DoFs that are allocated on this process.
|
inlinestaticinherited |
|
inlineinherited |
|
inline |
|
inline |
void hyteg::dg::DGFunction< ValueType >::interpolate | ( | ValueType | constant, |
uint_t | level, | ||
DoFType | flag = All ) const |
|
inline |
|
inline |
Returns the polynomial degree of the function on the passed primitive.
|
inline |
Sets the boundary conditions of this function.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inline |
Evaluates the sum on all DoFs.
|
inline |
void hyteg::dg::DGFunction< ValueType >::toVector | ( | const DGFunction< idx_t > & | numerator, |
const std::shared_ptr< VectorProxy > & | vec, | ||
uint_t | level, | ||
DoFType | flag ) const |
conversion to/from linear algebra representation
|
inline |
Returns the internally stored VolumeDoFFunction.
|
protectedinherited |
|
private |
|
private |
|
protectedinherited |
|
protectedinherited |
|
staticprivateinherited |
|
staticprivateinherited |
|
private |
|
private |
|
private |
|
private |
|
private |
|
protectedinherited |
|
private |