v0.15.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
MoFEM::ForcesAndSourcesCore::UserDataOperator Struct Reference

#include "src/finite_elements/ForcesAndSourcesCore.hpp"

Inheritance diagram for MoFEM::ForcesAndSourcesCore::UserDataOperator:
[legend]
Collaboration diagram for MoFEM::ForcesAndSourcesCore::UserDataOperator:
[legend]

Public Types

enum  OpType {
  OPROW = 1 << 0 , OPCOL = 1 << 1 , OPROWCOL = 1 << 2 , OPSPACE = 1 << 3 ,
  OPLAST = 1 << 3
}
 Controls loop over entities on element. More...
 
- Public Types inherited from MoFEM::DataOperator
using DoWorkLhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)>
 
using DoWorkRhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int side, EntityType type, EntitiesFieldData::EntData &data)>
 

Public Member Functions

 UserDataOperator (const FieldSpace space, const char type=OPSPACE, const bool symm=true)
 Constructor for operators working on finite element spaces.
 
 UserDataOperator (const std::string field_name, const char type, const bool symm=true)
 Constructor for operators working on a single field.
 
 UserDataOperator (const std::string row_field_name, const std::string col_field_name, const char type, const bool symm=true)
 Constructor for operators working on two fields (bilinear forms)
 
boost::shared_ptr< const NumeredEntFiniteElementgetNumeredEntFiniteElementPtr () const
 Return raw pointer to NumeredEntFiniteElement.
 
EntityHandle getFEEntityHandle () const
 Return finite element entity handle.
 
int getFEDim () const
 Get dimension of finite element.
 
EntityType getFEType () const
 Get dimension of finite element.
 
boost::weak_ptr< SideNumbergetSideNumberPtr (const int side_number, const EntityType type)
 Get the side number pointer.
 
EntityHandle getSideEntity (const int side_number, const EntityType type)
 Get the side entity.
 
int getNumberOfNodesOnElement () const
 Get the number of nodes on finite element.
 
MoFEMErrorCode getProblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get row indices.
 
MoFEMErrorCode getProblemColIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get col indices.
 
const FEMethodgetFEMethod () const
 Return raw pointer to Finite Element Method object.
 
int getOpType () const
 Get operator types.
 
void setOpType (const OpType type)
 Set operator type.
 
void addOpType (const OpType type)
 Add operator type.
 
int getNinTheLoop () const
 get number of finite element in the loop
 
int getLoopSize () const
 get size of elements in the loop
 
std::string getFEName () const
 Get name of the element.
 
ForcesAndSourcesCoregetPtrFE () const
 
ForcesAndSourcesCoregetSidePtrFE () const
 
ForcesAndSourcesCoregetRefinePtrFE () const
 
Accessing KSP
const PetscData::SwitchesgetDataCtx () const
 
const KspMethod::KSPContext getKSPCtx () const
 
const SnesMethod::SNESContext getSNESCtx () const
 
const TSMethod::TSContext getTSCtx () const
 
Vec getKSPf () const
 
Mat getKSPA () const
 
Mat getKSPB () const
 
Accessing SNES
Vec getSNESf () const
 
Vec getSNESx () const
 
Mat getSNESA () const
 
Mat getSNESB () const
 
Accessing TS
Vec getTSu () const
 
Vec getTSu_t () const
 
Vec getTSu_tt () const
 
Vec getTSf () const
 
Mat getTSA () const
 
Mat getTSB () const
 
int getTSstep () const
 
double getTStime () const
 
double getTStimeStep () const
 
double getTSa () const
 
double getTSaa () const
 
Base functions and integration points
MatrixDoublegetGaussPts ()
 matrix of integration (Gauss) points for Volume Element
 
auto getFTensor0IntegrationWeight ()
 Get integration weights.
 
Coordinates and access to internal data
MatrixDoublegetCoordsAtGaussPts ()
 Gauss points and weight, matrix (nb. of points x 3)
 
auto getFTensor1CoordsAtGaussPts ()
 Get coordinates at integration points assuming linear geometry.
 
Measures (area, volume, length, etc.)
double getMeasure () const
 get measure of element
 
doublegetMeasure ()
 get measure of element
 
- Public Member Functions inherited from MoFEM::DataOperator
 DataOperator (const bool symm=true)
 
virtual ~DataOperator ()=default
 
virtual MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Operator for bi-linear form, usually to calculate values on left hand side.
 
virtual MoFEMErrorCode opLhs (EntitiesFieldData &row_data, EntitiesFieldData &col_data)
 
virtual MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 Operator for linear form, usually to calculate values on right hand side.
 
virtual MoFEMErrorCode opRhs (EntitiesFieldData &data, const bool error_if_no_base=false)
 
bool getSymm () const
 Get if operator uses symmetry of DOFs or not.
 
void setSymm ()
 set if operator is executed taking in account symmetry
 
void unSetSymm ()
 unset if operator is executed for non symmetric problem
 

Public Attributes

char opType
 
std::string rowFieldName
 
std::string colFieldName
 
FieldSpace sPace
 
- Public Attributes inherited from MoFEM::DataOperator
DoWorkLhsHookFunType doWorkLhsHook
 
DoWorkRhsHookFunType doWorkRhsHook
 
bool sYmm
 If true assume that matrix is symmetric structure.
 
std::array< bool, MBMAXTYPE > doEntities
 If true operator is executed for entity.
 
booldoVertices
 \deprectaed If false skip vertices
 
booldoEdges
 \deprectaed If false skip edges
 
booldoQuads
 \deprectaed
 
booldoTris
 \deprectaed
 
booldoTets
 \deprectaed
 
booldoPrisms
 \deprectaed
 

Static Public Attributes

static const char *const OpTypeNames []
 

Protected Member Functions

virtual MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 

Protected Attributes

ForcesAndSourcesCoreptrFE
 

Friends

class ForcesAndSourcesCore
 
class EdgeElementForcesAndSourcesCore
 
class FaceElementForcesAndSourcesCore
 
class ContactPrismElementForcesAndSourcesCore
 

Loops

}

using AdjCache = std::map< EntityHandle, std::vector< boost::weak_ptr< NumeredEntFiniteElement > > >
 
MoFEMErrorCode loopSide (const string &fe_name, ForcesAndSourcesCore *side_fe, const size_t dim, const EntityHandle ent_for_side=0, boost::shared_ptr< Range > fe_range=nullptr, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy, AdjCache *adj_cache=nullptr)
 User calls this function to loop over elements on the side of face. This function calls finite element with its operator to do calculations.
 
MoFEMErrorCode loopThis (const string &fe_name, ForcesAndSourcesCore *this_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over the same element using a different set of integration points. This function calls finite element with its operator to do calculations.
 
MoFEMErrorCode loopParent (const string &fe_name, ForcesAndSourcesCore *parent_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations.
 
MoFEMErrorCode loopChildren (const string &fe_name, ForcesAndSourcesCore *child_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations.
 
MoFEMErrorCode loopRange (const string &fe_name, ForcesAndSourcesCore *range_fe, boost::shared_ptr< Range > fe_range, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 Iterate over range of elements.
 

Detailed Description

Examples
mofem/atom_tests/hanging_node_approx.cpp, mofem/atom_tests/schur_test_diag_mat.cpp, mofem/atom_tests/simple_interface.cpp, mofem/atom_tests/simple_l2_only.cpp, mofem/tools/mesh_smoothing.cpp, mofem/tutorials/adv-0/plastic.cpp, mofem/tutorials/adv-3/level_set.cpp, mofem/tutorials/adv-4/dynamic_first_order_con_law.cpp, mofem/tutorials/fun-0/hello_world.cpp, mofem/tutorials/vec-5/free_surface.cpp, mofem/tutorials/vec-7/adjoint.cpp, and mofem/users_modules/adolc-plasticity/src/ADOLCPlasticityLargeStrain.hpp.

Definition at line 597 of file ForcesAndSourcesCore.hpp.

Member Typedef Documentation

◆ AdjCache

using MoFEM::ForcesAndSourcesCore::UserDataOperator::AdjCache = std::map<EntityHandle, std::vector<boost::weak_ptr<NumeredEntFiniteElement> >>

Definition at line 994 of file ForcesAndSourcesCore.hpp.

Member Enumeration Documentation

◆ OpType

enum MoFEM::ForcesAndSourcesCore::UserDataOperator::OpType

Controls loop over entities on element.

  • OPROW is used if row vector is assembled
  • OPCOL is usually used if column vector is assembled
  • OPROWCOL is usually used for assemble matrices.
  • OPSPACE no field is defined for such operator. Is usually used to modify base

For typical problem like Bubnov-Galerkin OPROW and OPCOL are the same. In more general case for example for non-square matrices columns and rows could have different numeration and/or different set of fields.

Enumerator
OPROW 

operator doWork function is executed on FE rows

OPCOL 

operator doWork function is executed on FE columns

OPROWCOL 

operator doWork is executed on FE rows &columns

OPSPACE 

operator do Work is execute on space data

OPLAST 
Deprecated:
would be removed

Definition at line 614 of file ForcesAndSourcesCore.hpp.

614 {
615 OPROW = 1 << 0, ///< operator doWork function is executed on FE rows
616 OPCOL = 1 << 1, ///< operator doWork function is executed on FE columns
617 OPROWCOL = 1 << 2, ///< operator doWork is executed on FE rows &columns
618 OPSPACE = 1 << 3, ///< operator do Work is execute on space data
619 OPLAST = 1 << 3 ///< @deprecated would be removed
620 };
@ OPCOL
operator doWork function is executed on FE columns
@ OPROW
operator doWork function is executed on FE rows
@ OPROWCOL
operator doWork is executed on FE rows &columns
@ OPSPACE
operator do Work is execute on space data

Constructor & Destructor Documentation

◆ UserDataOperator() [1/3]

ForcesAndSourcesCore::UserDataOperator::UserDataOperator ( const FieldSpace  space,
const char  type = OPSPACE,
const bool  symm = true 
)

Constructor for operators working on finite element spaces.

This constructor is used when operators modify basis functions on approximation spaces. The operator runs for all data on the specified space without access to specific field data. Commonly used for:

  • Coordinate transformations (Piola transforms)
  • Integration weight modifications
  • Basis function scaling or rotation
Parameters
spaceField space to operate on (H1, HDIV, HCURL, L2, etc.)
typeOperator type (OPSPACE, OPROW, OPCOL, OPROWCOL)
symmWhether the operator maintains matrix symmetry (default: true)

Definition at line 2125 of file ForcesAndSourcesCore.cpp.

◆ UserDataOperator() [2/3]

ForcesAndSourcesCore::UserDataOperator::UserDataOperator ( const std::string  field_name,
const char  type,
const bool  symm = true 
)

Constructor for operators working on a single field.

This constructor creates operators that work with data from a specific field. Used for operations like:

  • Calculating field values at integration points
  • Computing field gradients or derivatives
  • Applying boundary conditions to specific fields
  • Post-processing field data
Parameters
field_nameName of the field to operate on
typeOperator type:
  • OPROW: Works with test functions (RHS assembly)
  • OPCOL: Works with trial functions (geometry setup)
  • OPROWCOL: Works with both (matrix assembly)
symmWhether the operator maintains matrix symmetry (default: true)

Definition at line 2130 of file ForcesAndSourcesCore.cpp.

2132 : DataOperator(symm), opType(type), rowFieldName(field_name),
@ LASTSPACE
FieldSpace in [ 0, LASTSPACE )
Definition definitions.h:89
constexpr auto field_name

◆ UserDataOperator() [3/3]

ForcesAndSourcesCore::UserDataOperator::UserDataOperator ( const std::string  row_field_name,
const std::string  col_field_name,
const char  type,
const bool  symm = true 
)

Constructor for operators working on two fields (bilinear forms)

This constructor creates operators that couple two different fields, essential for:

  • Mixed formulations (pressure-velocity coupling)
  • Multi-physics problems (thermal-mechanical coupling)
  • Contact mechanics (displacement-Lagrange multiplier)
  • Interface problems between different field types
Parameters
row_field_nameName of the field for test functions (rows)
col_field_nameName of the field for trial functions (columns)
typeOperator type (typically OPROWCOL for coupling)
symmWhether the operator maintains matrix symmetry (default: true) Note: Coupling between different fields is often non-symmetric

Definition at line 2135 of file ForcesAndSourcesCore.cpp.

2138 : DataOperator(symm), opType(type), rowFieldName(row_field_name),
2139 colFieldName(col_field_name), sPace(LASTSPACE), ptrFE(nullptr) {}

Member Function Documentation

◆ addOpType()

void ForcesAndSourcesCore::UserDataOperator::addOpType ( const OpType  type)
inline

Add operator type.

Definition at line 1161 of file ForcesAndSourcesCore.hpp.

1161 {
1162 opType |= type;
1163}

◆ getCoordsAtGaussPts()

MatrixDouble & ForcesAndSourcesCore::UserDataOperator::getCoordsAtGaussPts ( )
inline

◆ getDataCtx()

const PetscData::Switches & ForcesAndSourcesCore::UserDataOperator::getDataCtx ( ) const
inline

Definition at line 1178 of file ForcesAndSourcesCore.hpp.

1178 {
1179 return getFEMethod()->data_ctx;
1180}
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
Switches data_ctx
Current data context switches.

◆ getFEDim()

int ForcesAndSourcesCore::UserDataOperator::getFEDim ( ) const
inline

Get dimension of finite element.

Returns
int

Definition at line 1117 of file ForcesAndSourcesCore.hpp.

1117 {
1119};
auto dimension_from_handle(const EntityHandle h)
get entity dimension form handle
EntityHandle getFEEntityHandle() const
Return finite element entity handle.

◆ getFEEntityHandle()

EntityHandle ForcesAndSourcesCore::UserDataOperator::getFEEntityHandle ( ) const
inline

Return finite element entity handle.

Returns
Finite element entity handle
Examples
mofem/tutorials/cor-0to1/src/UnsaturatedFlow.hpp.

Definition at line 1113 of file ForcesAndSourcesCore.hpp.

1113 {
1114 return getNumeredEntFiniteElementPtr()->getEnt();
1115}
boost::shared_ptr< const NumeredEntFiniteElement > getNumeredEntFiniteElementPtr() const
Return raw pointer to NumeredEntFiniteElement.

◆ getFEMethod()

const FEMethod * ForcesAndSourcesCore::UserDataOperator::getFEMethod ( ) const
inline

◆ getFEName()

std::string ForcesAndSourcesCore::UserDataOperator::getFEName ( ) const
inline

Get name of the element.

Definition at line 1173 of file ForcesAndSourcesCore.hpp.

1173 {
1174 return getFEMethod()->getFEName();
1175}
auto getFEName() const
Get the name of the current finite element.

◆ getFEType()

EntityType ForcesAndSourcesCore::UserDataOperator::getFEType ( ) const
inline

Get dimension of finite element.

Returns
int

Definition at line 1121 of file ForcesAndSourcesCore.hpp.

1121 {
1123};
auto type_from_handle(const EntityHandle h)
get type from entity handle

◆ getFTensor0IntegrationWeight()

auto ForcesAndSourcesCore::UserDataOperator::getFTensor0IntegrationWeight ( )
inline

◆ getFTensor1CoordsAtGaussPts()

auto ForcesAndSourcesCore::UserDataOperator::getFTensor1CoordsAtGaussPts ( )
inline

Get coordinates at integration points assuming linear geometry.

auto t_coords = getFTensor1CoordsAtGaussPts();
for(int gg = 0;gg!=nb_int_ptrs;gg++) {
// do something
++t_coords;
}
auto getFTensor1CoordsAtGaussPts()
Get coordinates at integration points assuming linear geometry.
Examples
mofem/atom_tests/prism_polynomial_approximation.cpp, mofem/atom_tests/quad_polynomial_approximation.cpp, mofem/atom_tests/simple_interface.cpp, and mofem/tutorials/cor-0to1/src/UnsaturatedFlow.hpp.

Definition at line 1378 of file ForcesAndSourcesCore.hpp.

1378 {
1380 &getCoordsAtGaussPts()(0, 0), &getCoordsAtGaussPts()(0, 1),
1381 &getCoordsAtGaussPts()(0, 2));
1382}
MatrixDouble & getCoordsAtGaussPts()
Gauss points and weight, matrix (nb. of points x 3)

◆ getGaussPts()

MatrixDouble & ForcesAndSourcesCore::UserDataOperator::getGaussPts ( )
inline

matrix of integration (Gauss) points for Volume Element

For triangle: columns 0,1 are x,y coordinates respectively and column 2 is a weight value for example getGaussPts()(1,13) returns y coordinate of 13th Gauss point on particular volume element

For tetrahedron: columns 0,1,2 are x,y,z coordinates respectively and column 3 is a weight value for example getGaussPts()(1,13) returns y coordinate of 13th Gauss point on particular volume element

Examples
mofem/atom_tests/continuity_check_on_skeleton_3d.cpp, mofem/atom_tests/hdiv_check_approx_in_3d.cpp, mofem/atom_tests/simple_interface.cpp, mofem/tutorials/cor-0to1/src/UnsaturatedFlow.hpp, mofem/tutorials/cor-9/reaction_diffusion.cpp, mofem/tutorials/fun-1/integration.cpp, mofem/tutorials/max-0/src/MagneticElement.hpp, and mofem/tutorials/mix-1/phase.cpp.

Definition at line 1345 of file ForcesAndSourcesCore.hpp.

1345 {
1346 return static_cast<ForcesAndSourcesCore *>(ptrFE)->gaussPts;
1347}
MatrixDouble gaussPts
Matrix of integration points.

◆ getKSPA()

Mat ForcesAndSourcesCore::UserDataOperator::getKSPA ( ) const
inline

Definition at line 1205 of file ForcesAndSourcesCore.hpp.

1205 {
1206#ifndef NDEBUG
1207 if (getFEMethod()->ksp_A == PETSC_NULLPTR)
1208 THROW_MESSAGE("KSP not set A vector");
1209#endif
1210 return getFEMethod()->ksp_A;
1211}
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
Mat & ksp_A
Reference to system matrix in KSP context.

◆ getKSPB()

Mat ForcesAndSourcesCore::UserDataOperator::getKSPB ( ) const
inline

Definition at line 1213 of file ForcesAndSourcesCore.hpp.

1213 {
1214#ifndef NDEBUG
1215 if (getFEMethod()->ksp_B == PETSC_NULLPTR)
1216 THROW_MESSAGE("KSP not set B vector");
1217#endif
1218 return getFEMethod()->ksp_B;
1219}
Mat & ksp_B
Reference to preconditioner matrix in KSP context.

◆ getKSPCtx()

const KspMethod::KSPContext ForcesAndSourcesCore::UserDataOperator::getKSPCtx ( ) const
inline

Definition at line 1183 of file ForcesAndSourcesCore.hpp.

1183 {
1184 return getFEMethod()->ksp_ctx;
1185}
KSPContext ksp_ctx
Current KSP computation context.

◆ getKSPf()

Vec ForcesAndSourcesCore::UserDataOperator::getKSPf ( ) const
inline

Definition at line 1197 of file ForcesAndSourcesCore.hpp.

1197 {
1198#ifndef NDEBUG
1199 if (getFEMethod()->ksp_f == PETSC_NULLPTR)
1200 THROW_MESSAGE("KSP not set F vector");
1201#endif
1202 return getFEMethod()->ksp_f;
1203}
Vec & ksp_f
Reference to residual vector in KSP context.

◆ getLoopSize()

int ForcesAndSourcesCore::UserDataOperator::getLoopSize ( ) const
inline

get size of elements in the loop

Returns
loop size

Definition at line 1169 of file ForcesAndSourcesCore.hpp.

1169 {
1170 return getFEMethod()->getLoopSize();
1171}
int getLoopSize() const
Get total loop size.

◆ getMeasure() [1/2]

double & ForcesAndSourcesCore::UserDataOperator::getMeasure ( )
inline

get measure of element

Returns
volume

Definition at line 1388 of file ForcesAndSourcesCore.hpp.

1388 {
1389 return static_cast<ForcesAndSourcesCore *>(ptrFE)->elementMeasure;
1390}

◆ getMeasure() [2/2]

double ForcesAndSourcesCore::UserDataOperator::getMeasure ( ) const
inline

◆ getNinTheLoop()

int ForcesAndSourcesCore::UserDataOperator::getNinTheLoop ( ) const
inline

get number of finite element in the loop

Returns
number of finite element

Definition at line 1165 of file ForcesAndSourcesCore.hpp.

1165 {
1166 return getFEMethod()->getNinTheLoop();
1167}
int getNinTheLoop() const
Get current loop iteration index.

◆ getNumberOfNodesOnElement()

int ForcesAndSourcesCore::UserDataOperator::getNumberOfNodesOnElement ( ) const
inline

Get the number of nodes on finite element.

Returns
int
Examples
mofem/atom_tests/boundary_marker.cpp.

Definition at line 1147 of file ForcesAndSourcesCore.hpp.

1147 {
1148 return ptrFE->getNumberOfNodes();
1149}
auto getNumberOfNodes() const
Get the number of nodes in the current finite element.

◆ getNumeredEntFiniteElementPtr()

boost::shared_ptr< const NumeredEntFiniteElement > ForcesAndSourcesCore::UserDataOperator::getNumeredEntFiniteElementPtr ( ) const
inline

Return raw pointer to NumeredEntFiniteElement.

Examples
mofem/tutorials/cor-0to1/src/UnsaturatedFlow.hpp, mofem/tutorials/cor-7/src/ElasticityMixedFormulation.hpp, and mofem/users_modules/basic_finite_elements/src/impl/NavierStokesElement.cpp.

Definition at line 1109 of file ForcesAndSourcesCore.hpp.

1109 {
1111};
boost::shared_ptr< const NumeredEntFiniteElement > numeredEntFiniteElementPtr
Shared pointer to finite element database structure.

◆ getOpType()

int ForcesAndSourcesCore::UserDataOperator::getOpType ( ) const
inline

Get operator types.

Returns
Return operator type

Definition at line 1155 of file ForcesAndSourcesCore.hpp.

1155{ return opType; }

◆ getProblemColIndices()

MoFEMErrorCode ForcesAndSourcesCore::UserDataOperator::getProblemColIndices ( const std::string  filed_name,
const EntityType  type,
const int  side,
VectorInt indices 
) const

Get col indices.

Field could be or not declared for this element but is declared for problem

Parameters
field_name
typeentity type
sideside number, any number if type is MBVERTEX
Returns
indices

NOTE: Using those indices to assemble matrix will result in error if new non-zero values need to be created.

Definition at line 1701 of file ForcesAndSourcesCore.cpp.

1703 {
1705 if (ptrFE == NULL)
1706 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
1707
1708 switch (type) {
1709 case MBVERTEX:
1711 break;
1712 default:
1713 CHKERR ptrFE->getProblemTypeColIndices(field_name, type, side, indices);
1714 }
1716}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
MoFEMErrorCode getProblemTypeColIndices(const std::string &field_name, EntityType type, int side_number, VectorInt &indices) const
MoFEMErrorCode getProblemNodesColIndices(const std::string &field_name, VectorInt &nodes_indices) const

◆ getProblemRowIndices()

MoFEMErrorCode ForcesAndSourcesCore::UserDataOperator::getProblemRowIndices ( const std::string  filed_name,
const EntityType  type,
const int  side,
VectorInt indices 
) const

Get row indices.

Field could be or not declared for this element but is declared for problem

Parameters
field_name
typeentity type
sideside number, any number if type is MBVERTEX
Returns
indices

NOTE: Using those indices to assemble matrix will result in error if new non-zero values need to be created.

Definition at line 1684 of file ForcesAndSourcesCore.cpp.

1686 {
1688 if (ptrFE == NULL)
1689 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
1690
1691 switch (type) {
1692 case MBVERTEX:
1694 break;
1695 default:
1696 CHKERR ptrFE->getProblemTypeRowIndices(field_name, type, side, indices);
1697 }
1699}
MoFEMErrorCode getProblemNodesRowIndices(const std::string &field_name, VectorInt &nodes_indices) const
MoFEMErrorCode getProblemTypeRowIndices(const std::string &field_name, EntityType type, int side_number, VectorInt &indices) const

◆ getPtrFE()

ForcesAndSourcesCore * ForcesAndSourcesCore::UserDataOperator::getPtrFE ( ) const
inline

Definition at line 1360 of file ForcesAndSourcesCore.hpp.

1360 {
1361 return ptrFE;
1362}

◆ getRefinePtrFE()

ForcesAndSourcesCore * ForcesAndSourcesCore::UserDataOperator::getRefinePtrFE ( ) const
inline

Definition at line 1370 of file ForcesAndSourcesCore.hpp.

1370 {
1371 return ptrFE->refinePtrFE;
1372}
ForcesAndSourcesCore * refinePtrFE
Element to integrate parent or child.

◆ getSideEntity()

EntityHandle ForcesAndSourcesCore::UserDataOperator::getSideEntity ( const int  side_number,
const EntityType  type 
)
inline

Get the side entity.

Note
For vertex is expectation. Side basses in argument of function doWork is zero. For other entity types side can be used as argument of this function.
MoFEMErrorCode doWork(int side, EntityType type,
if (type == MBVERTEX) {
for (int n = 0; n != number_of_nodes; ++n)
// Do somthing
} else {
EntityHandle ent = getSideEntity(side, type);
// Do somthing
}
}
const double n
refractive index of diffusive medium
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
virtual MoFEMErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
Operator for bi-linear form, usually to calculate values on left hand side.
Data on single entity (This is passed as argument to DataOperator::doWork)
EntityHandle getSideEntity(const int side_number, const EntityType type)
Get the side entity.
Parameters
side_number
type
Examples
mofem/atom_tests/boundary_marker.cpp.

Definition at line 1139 of file ForcesAndSourcesCore.hpp.

1140 {
1141 if (auto side_ptr = getSideNumberPtr(side_number, type).lock())
1142 return side_ptr->ent;
1143 else
1144 return 0;
1145}
boost::weak_ptr< SideNumber > getSideNumberPtr(const int side_number, const EntityType type)
Get the side number pointer.

◆ getSideNumberPtr()

boost::weak_ptr< SideNumber > ForcesAndSourcesCore::UserDataOperator::getSideNumberPtr ( const int  side_number,
const EntityType  type 
)
inline

Get the side number pointer.

Note
For vertex is expectation. Side basses in argument of function doWork is zero. For other entity types side can be used as argument of this function.
Parameters
side_number
type
Returns
boost::weak_ptr<SideNumber>

Definition at line 1126 of file ForcesAndSourcesCore.hpp.

1127 {
1128 auto &side_table_by_side_and_type =
1129 ptrFE->numeredEntFiniteElementPtr->getSideNumberTable().get<1>();
1130 auto side_it =
1131 side_table_by_side_and_type.find(boost::make_tuple(type, side_number));
1132 if (side_it != side_table_by_side_and_type.end())
1133 return *side_it;
1134 else
1135 return boost::weak_ptr<SideNumber>();
1136}

◆ getSidePtrFE()

ForcesAndSourcesCore * ForcesAndSourcesCore::UserDataOperator::getSidePtrFE ( ) const
inline

Definition at line 1365 of file ForcesAndSourcesCore.hpp.

1365 {
1366 return ptrFE->sidePtrFE;
1367}
ForcesAndSourcesCore * sidePtrFE
Element to integrate on the sides.

◆ getSNESA()

Mat ForcesAndSourcesCore::UserDataOperator::getSNESA ( ) const
inline

Definition at line 1237 of file ForcesAndSourcesCore.hpp.

1237 {
1238#ifndef NDEBUG
1239 if (getFEMethod()->snes_A == PETSC_NULLPTR)
1240 THROW_MESSAGE("SNES not set A vector");
1241#endif
1242 return getFEMethod()->snes_A;
1243}
Mat & snes_A
Reference to Jacobian matrix.

◆ getSNESB()

Mat ForcesAndSourcesCore::UserDataOperator::getSNESB ( ) const
inline

Definition at line 1245 of file ForcesAndSourcesCore.hpp.

1245 {
1246#ifndef NDEBUG
1247 if (getFEMethod()->snes_B == PETSC_NULLPTR)
1248 THROW_MESSAGE("SNES not set A matrix");
1249#endif
1250 return getFEMethod()->snes_B;
1251}
Mat & snes_B
Reference to preconditioner of Jacobian matrix.

◆ getSNESCtx()

const SnesMethod::SNESContext ForcesAndSourcesCore::UserDataOperator::getSNESCtx ( ) const
inline

Definition at line 1188 of file ForcesAndSourcesCore.hpp.

1188 {
1189 return getFEMethod()->snes_ctx;
1190}
SNESContext snes_ctx
Current SNES computation context.

◆ getSNESf()

Vec ForcesAndSourcesCore::UserDataOperator::getSNESf ( ) const
inline

Definition at line 1221 of file ForcesAndSourcesCore.hpp.

1221 {
1222#ifndef NDEBUG
1223 if (getFEMethod()->snes_f == PETSC_NULLPTR)
1224 THROW_MESSAGE("SNES not set F vector");
1225#endif
1226 return getFEMethod()->snes_f;
1227}
Vec & snes_f
Reference to residual vector.

◆ getSNESx()

Vec ForcesAndSourcesCore::UserDataOperator::getSNESx ( ) const
inline

Definition at line 1229 of file ForcesAndSourcesCore.hpp.

1229 {
1230#ifndef NDEBUG
1231 if (getFEMethod()->snes_x == PETSC_NULLPTR)
1232 THROW_MESSAGE("SNESnot set X vector");
1233#endif
1234 return getFEMethod()->snes_x;
1235}
Vec & snes_x
Reference to current solution state vector.

◆ getTSA()

Mat ForcesAndSourcesCore::UserDataOperator::getTSA ( ) const
inline

Definition at line 1285 of file ForcesAndSourcesCore.hpp.

1285 {
1286#ifndef NDEBUG
1287 if (getFEMethod()->ts_A == PETSC_NULLPTR)
1288 THROW_MESSAGE("TS not set A matrix");
1289#endif
1290 return getFEMethod()->ts_A;
1291}
Mat & ts_A
Reference to Jacobian matrix: dF/dU + a*dF/dU_t + aa*dF/dU_tt.

◆ getTSa()

double ForcesAndSourcesCore::UserDataOperator::getTSa ( ) const
inline

Definition at line 1325 of file ForcesAndSourcesCore.hpp.

1325 {
1326#ifndef NDEBUG
1328 .none() ||
1330 THROW_MESSAGE("TS not set B matrix");
1331#endif
1332 return getFEMethod()->ts_a;
1333}
static constexpr Switches CtxSetA
Jacobian matrix switch.
static constexpr Switches CtxSetX_T
First time derivative switch.
static constexpr Switches CtxSetB
Preconditioner matrix switch.
PetscReal ts_a
Shift parameter for U_t (see PETSc Time Solver documentation)

◆ getTSaa()

double ForcesAndSourcesCore::UserDataOperator::getTSaa ( ) const
inline

Definition at line 1335 of file ForcesAndSourcesCore.hpp.

1335 {
1336#ifndef NDEBUG
1338 .none() ||
1340 THROW_MESSAGE("TS not set B matrix");
1341#endif
1342 return getFEMethod()->ts_aa;
1343}
static constexpr Switches CtxSetX_TT
Second time derivative switch.
PetscReal ts_aa
Shift parameter for U_tt (second time derivative)

◆ getTSB()

Mat ForcesAndSourcesCore::UserDataOperator::getTSB ( ) const
inline

Definition at line 1293 of file ForcesAndSourcesCore.hpp.

1293 {
1294#ifndef NDEBUG
1295 if (getFEMethod()->ts_B == PETSC_NULLPTR)
1296 THROW_MESSAGE("TS not set B matrix");
1297#endif
1298 return getFEMethod()->ts_B;
1299}
Mat & ts_B
Reference to preconditioner matrix for ts_A.

◆ getTSCtx()

const TSMethod::TSContext ForcesAndSourcesCore::UserDataOperator::getTSCtx ( ) const
inline

Definition at line 1193 of file ForcesAndSourcesCore.hpp.

1193 {
1194 return getFEMethod()->ts_ctx;
1195}
TSContext ts_ctx
Current TS computation context.

◆ getTSf()

Vec ForcesAndSourcesCore::UserDataOperator::getTSf ( ) const
inline

Definition at line 1277 of file ForcesAndSourcesCore.hpp.

1277 {
1278#ifndef NDEBUG
1279 if (getFEMethod()->ts_F == PETSC_NULLPTR)
1280 THROW_MESSAGE("TS not set F vector");
1281#endif
1282 return getFEMethod()->ts_F;
1283}
Vec & ts_F
Reference to residual vector F(t,U,U_t,U_tt)

◆ getTSstep()

int ForcesAndSourcesCore::UserDataOperator::getTSstep ( ) const
inline

Definition at line 1301 of file ForcesAndSourcesCore.hpp.

1301 {
1302#ifndef NDEBUG
1303 if ((getFEMethod()->data_ctx & PetscData::PetscData::CtxSetTime).none())
1304 THROW_MESSAGE("TS not set time");
1305#endif
1306 return getFEMethod()->ts_step;
1307}
PetscInt ts_step
Current time step number.

◆ getTStime()

double ForcesAndSourcesCore::UserDataOperator::getTStime ( ) const
inline

Definition at line 1309 of file ForcesAndSourcesCore.hpp.

1309 {
1310#ifndef NDEBUG
1311 if ((getFEMethod()->data_ctx & PetscData::PetscData::CtxSetTime).none())
1312 THROW_MESSAGE("TS not set time");
1313#endif
1314 return getFEMethod()->ts_t;
1315}
PetscReal ts_t
Current time value.

◆ getTStimeStep()

double ForcesAndSourcesCore::UserDataOperator::getTStimeStep ( ) const
inline

Definition at line 1317 of file ForcesAndSourcesCore.hpp.

1317 {
1318#ifndef NDEBUG
1319 if ((getFEMethod()->data_ctx & PetscData::PetscData::CtxSetTime).none())
1320 THROW_MESSAGE("TS not set time");
1321#endif
1322 return getFEMethod()->ts_dt;
1323}
PetscReal ts_dt
Current time step size.

◆ getTSu()

Vec ForcesAndSourcesCore::UserDataOperator::getTSu ( ) const
inline

Definition at line 1253 of file ForcesAndSourcesCore.hpp.

1253 {
1254#ifndef NDEBUG
1255 if (getFEMethod()->ts_u == PETSC_NULLPTR)
1256 THROW_MESSAGE("TS not set U vector");
1257#endif
1258 return getFEMethod()->ts_u;
1259}
Vec & ts_u
Reference to current state vector U(t)

◆ getTSu_t()

Vec ForcesAndSourcesCore::UserDataOperator::getTSu_t ( ) const
inline

Definition at line 1261 of file ForcesAndSourcesCore.hpp.

1261 {
1262#ifndef NDEBUG
1263 if (getFEMethod()->ts_u_t == PETSC_NULLPTR)
1264 THROW_MESSAGE("TS not set U_t vector");
1265#endif
1266 return getFEMethod()->ts_u_t;
1267}
Vec & ts_u_t
Reference to first time derivative of state vector dU/dt.

◆ getTSu_tt()

Vec ForcesAndSourcesCore::UserDataOperator::getTSu_tt ( ) const
inline

Definition at line 1269 of file ForcesAndSourcesCore.hpp.

1269 {
1270#ifndef NDEBUG
1271 if (getFEMethod()->ts_u_tt == PETSC_NULLPTR)
1272 THROW_MESSAGE("TS not set U_tt vector");
1273#endif
1274 return getFEMethod()->ts_u_tt;
1275}
Vec & ts_u_tt
Reference to second time derivative of state vector d²U/dt²

◆ loopChildren()

MoFEMErrorCode ForcesAndSourcesCore::UserDataOperator::loopChildren ( const string &  fe_name,
ForcesAndSourcesCore child_fe,
const int  verb = QUIET,
const LogManager::SeverityLevel  sev = Sev::noisy 
)

User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations.

Parameters
fe_name
child_fe
verb
sev
Returns
MoFEMErrorCode

Definition at line 1960 of file ForcesAndSourcesCore.cpp.

1962 {
1964
1965 auto fe_miit = ptrFE->mField.get_finite_elements()
1966 ->get<FiniteElement_name_mi_tag>()
1967 .find(fe_name);
1968 if (fe_miit != ptrFE->mField.get_finite_elements()
1969 ->get<FiniteElement_name_mi_tag>()
1970 .end()) {
1971
1972 const auto *problem_ptr = getFEMethod()->problemPtr;
1973 auto &ref_ents = *getPtrFE()->mField.get_ref_ents();
1974 auto &numered_fe =
1975 problem_ptr->numeredFiniteElementsPtr->get<Unique_mi_tag>();
1976
1977 const auto parent_ent = getNumeredEntFiniteElementPtr()->getEnt();
1978 const auto parent_type = getNumeredEntFiniteElementPtr()->getEntType();
1979 auto range =
1980 ref_ents.get<Composite_ParentEnt_And_EntType_mi_tag>().equal_range(
1981 boost::make_tuple(parent_type, parent_ent));
1982
1983 if (auto size = std::distance(range.first, range.second)) {
1984
1985 std::vector<EntityHandle> childs_vec;
1986 childs_vec.reserve(size);
1987 for (; range.first != range.second; ++range.first)
1988 childs_vec.emplace_back((*range.first)->getEnt());
1989
1990 Range childs;
1991
1992 if ((childs_vec.back() - childs_vec.front() + 1) == size)
1993 childs = Range(childs_vec.front(), childs_vec.back());
1994 else
1995 childs.insert_list(childs_vec.begin(), childs_vec.end());
1996
1997 child_fe->feName = fe_name;
1998
1999 CHKERR child_fe->setRefineFEPtr(ptrFE);
2000 CHKERR child_fe->copyBasicMethod(*getFEMethod());
2001 CHKERR child_fe->copyPetscData(*getFEMethod());
2002 CHKERR child_fe->copyKsp(*getFEMethod());
2003 CHKERR child_fe->copySnes(*getFEMethod());
2004 CHKERR child_fe->copyTs(*getFEMethod());
2005
2006 child_fe->cacheWeakPtr = getFEMethod()->cacheWeakPtr;
2007
2008 CHKERR child_fe->preProcess();
2009
2010 int nn = 0;
2011 child_fe->loopSize = size;
2012
2013 for (auto p = childs.pair_begin(); p != childs.pair_end(); ++p) {
2014
2015 auto miit =
2016 numered_fe.lower_bound(EntFiniteElement::getLocalUniqueIdCalculate(
2017 p->first, (*fe_miit)->getFEUId()));
2018 auto hi_miit =
2019 numered_fe.upper_bound(EntFiniteElement::getLocalUniqueIdCalculate(
2020 p->second, (*fe_miit)->getFEUId()));
2021
2022 for (; miit != hi_miit; ++miit) {
2023
2024 if (verb >= VERBOSE)
2025 MOFEM_LOG("SELF", sev)
2026 << "Child finite element " << "(" << nn << "): " << **miit;
2027
2028 child_fe->nInTheLoop = nn++;
2029 child_fe->numeredEntFiniteElementPtr = *miit;
2030 CHKERR (*child_fe)();
2031 }
2032 }
2033 }
2034
2035 CHKERR child_fe->postProcess();
2036 }
2037
2039}
@ VERBOSE
virtual const FiniteElement_multiIndex * get_finite_elements() const =0
Get the finite elements object.
virtual const RefEntity_multiIndex * get_ref_ents() const =0
Get the ref ents object.
#define MOFEM_LOG(channel, severity)
Log.
const Problem * problemPtr
Raw pointer to current MoFEM problem instance.
boost::weak_ptr< CacheTuple > cacheWeakPtr
Weak pointer to cached entity data.
UId getLocalUniqueIdCalculate() const
Generate UId for finite element entity.

◆ loopParent()

MoFEMErrorCode ForcesAndSourcesCore::UserDataOperator::loopParent ( const string &  fe_name,
ForcesAndSourcesCore parent_fe,
const int  verb = QUIET,
const LogManager::SeverityLevel  sev = Sev::noisy 
)

User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations.

Parameters
fe_name
parent_fe
verb
sev
Returns
MoFEMErrorCode

Definition at line 1911 of file ForcesAndSourcesCore.cpp.

1913 {
1915
1916 auto &fes =
1917 ptrFE->mField.get_finite_elements()->get<FiniteElement_name_mi_tag>();
1918 auto fe_miit = fes.find(fe_name);
1919 if (fe_miit != fes.end()) {
1920
1921 const auto *problem_ptr = getFEMethod()->problemPtr;
1922 auto &numered_fe =
1923 problem_ptr->numeredFiniteElementsPtr->get<Unique_mi_tag>();
1924
1925 parent_fe->feName = fe_name;
1926 CHKERR parent_fe->setRefineFEPtr(ptrFE);
1927 CHKERR parent_fe->copyBasicMethod(*getFEMethod());
1928 CHKERR parent_fe->copyPetscData(*getFEMethod());
1929 CHKERR parent_fe->copyKsp(*getFEMethod());
1930 CHKERR parent_fe->copySnes(*getFEMethod());
1931 CHKERR parent_fe->copyTs(*getFEMethod());
1932
1933 parent_fe->cacheWeakPtr = getFEMethod()->cacheWeakPtr;
1934
1935 const auto parent_ent = getNumeredEntFiniteElementPtr()->getParentEnt();
1936 auto miit = numered_fe.find(EntFiniteElement::getLocalUniqueIdCalculate(
1937 parent_ent, (*fe_miit)->getFEUId()));
1938 if (miit != numered_fe.end()) {
1939 if (verb >= VERBOSE)
1940 MOFEM_LOG("SELF", sev) << "Parent finite element: " << **miit;
1941 parent_fe->loopSize = 1;
1942 parent_fe->nInTheLoop = 0;
1943 parent_fe->numeredEntFiniteElementPtr = *miit;
1944 CHKERR parent_fe->preProcess();
1945 CHKERR (*parent_fe)();
1946 CHKERR parent_fe->postProcess();
1947 } else {
1948 if (verb >= VERBOSE)
1949 MOFEM_LOG("SELF", sev) << "Parent finite element: no parent";
1950 parent_fe->loopSize = 0;
1951 parent_fe->nInTheLoop = 0;
1952 CHKERR parent_fe->preProcess();
1953 CHKERR parent_fe->postProcess();
1954 }
1955 }
1956
1958}
boost::shared_ptr< NumeredEntFiniteElement_multiIndex > numeredFiniteElementsPtr
store finite elements

◆ loopRange()

MoFEMErrorCode ForcesAndSourcesCore::UserDataOperator::loopRange ( const string &  fe_name,
ForcesAndSourcesCore range_fe,
boost::shared_ptr< Range fe_range,
const int  verb = QUIET,
const LogManager::SeverityLevel  sev = Sev::noisy 
)

Iterate over range of elements.

Parameters
fe_name
range_fe
fe_range
verb
sev
Returns
* MoFEMErrorCode

Definition at line 2041 of file ForcesAndSourcesCore.cpp.

2044 {
2046
2047 auto &fes =
2048 ptrFE->mField.get_finite_elements()->get<FiniteElement_name_mi_tag>();
2049 auto fe_miit = fes.find(fe_name);
2050 if (fe_miit != fes.end()) {
2051
2052 const auto *problem_ptr = getFEMethod()->problemPtr;
2053 auto &numered_fe =
2054 problem_ptr->numeredFiniteElementsPtr->get<Unique_mi_tag>();
2055
2056 range_fe->feName = fe_name;
2057 CHKERR range_fe->setRefineFEPtr(ptrFE);
2058 CHKERR range_fe->copyBasicMethod(*getFEMethod());
2059 CHKERR range_fe->copyPetscData(*getFEMethod());
2060 CHKERR range_fe->copyKsp(*getFEMethod());
2061 CHKERR range_fe->copySnes(*getFEMethod());
2062 CHKERR range_fe->copyTs(*getFEMethod());
2063
2064 range_fe->cacheWeakPtr = getFEMethod()->cacheWeakPtr;
2065
2066 auto get_numered_fe_ptr = [&](auto &fe_uid, auto fe_range, auto execute) {
2068 if (fe_range) {
2069 int nn = 0;
2070 for (auto p = fe_range->pair_begin(); p != fe_range->pair_end(); ++p) {
2071 auto first = p->first;
2072 auto second = p->second;
2073 auto lo = numered_fe.lower_bound(
2075 auto hi = numered_fe.upper_bound(
2077 for (; lo != hi; ++lo) {
2078 CHKERR execute(lo, nn++);
2079 }
2080 }
2081 }
2083 };
2084
2085 auto execute = [&](auto lo, auto nn) {
2087 if (verb >= VERBOSE)
2088 MOFEM_LOG("SELF", sev) << "Range finite element: " << **lo;
2089 range_fe->nInTheLoop = nn;
2090 range_fe->numeredEntFiniteElementPtr = *lo;
2091 CHKERR range_fe->preProcess();
2092 CHKERR (*range_fe)();
2093 CHKERR range_fe->postProcess();
2095 };
2096
2097 CHKERR get_numered_fe_ptr((*fe_miit)->getFEUId(), fe_range, execute);
2098 }
2099
2101}

◆ loopSide()

MoFEMErrorCode ForcesAndSourcesCore::UserDataOperator::loopSide ( const string &  fe_name,
ForcesAndSourcesCore side_fe,
const size_t  dim,
const EntityHandle  ent_for_side = 0,
boost::shared_ptr< Range fe_range = nullptr,
const int  verb = QUIET,
const LogManager::SeverityLevel  sev = Sev::noisy,
AdjCache adj_cache = nullptr 
)

User calls this function to loop over elements on the side of face. This function calls finite element with its operator to do calculations.

Parameters
fe_namename of the side element
side_fepointer to the side element instance
dimdimension the of side element
ent_for_sideentity handle for which adjacent volume or face will be accessed
verb
sev
adj_cache
Returns
MoFEMErrorCode

Definition at line 1732 of file ForcesAndSourcesCore.cpp.

1735 {
1737
1738 const auto *problem_ptr = getFEMethod()->problemPtr;
1739 auto &numered_fe =
1740 problem_ptr->numeredFiniteElementsPtr->get<Unique_mi_tag>();
1741
1742 auto fe_miit = ptrFE->mField.get_finite_elements()
1743 ->get<FiniteElement_name_mi_tag>()
1744 .find(fe_name);
1745 if (fe_miit != ptrFE->mField.get_finite_elements()
1746 ->get<FiniteElement_name_mi_tag>()
1747 .end()) {
1748
1749 const auto ent = ent_for_side ? ent_for_side : getFEEntityHandle();
1750
1751 side_fe->feName = fe_name;
1752
1753 CHKERR side_fe->setSideFEPtr(ptrFE);
1754 CHKERR side_fe->copyBasicMethod(*getFEMethod());
1755 CHKERR side_fe->copyPetscData(*getFEMethod());
1756 CHKERR side_fe->copyKsp(*getFEMethod());
1757 CHKERR side_fe->copySnes(*getFEMethod());
1758 CHKERR side_fe->copyTs(*getFEMethod());
1759
1760 side_fe->cacheWeakPtr = getFEMethod()->cacheWeakPtr;
1761
1762 CHKERR side_fe->preProcess();
1763
1764 std::vector<boost::weak_ptr<NumeredEntFiniteElement>> fe_vec;
1765 auto get_numered_fe_ptr = [&](auto &fe_uid, Range &&adjacent_ents)
1766 -> std::vector<boost::weak_ptr<NumeredEntFiniteElement>> & {
1767 fe_vec.reserve(adjacent_ents.size());
1768 for (auto fe_ent : adjacent_ents) {
1769 auto miit = numered_fe.find(
1771 if (miit != numered_fe.end()) {
1772 fe_vec.emplace_back(*miit);
1773 }
1774 }
1775 return fe_vec;
1776 };
1777
1778 auto get_bit_entity_adjacency = [&]() {
1779 Range adjacent_ents;
1781 ptrFE->mField.getInterface<BitRefManager>()->getAdjacenciesAny(
1782 ent, side_dim, adjacent_ents),
1783 "getAdjacenciesAny failed");
1784 return adjacent_ents;
1785 };
1786
1787 auto get_bit_meshset_entities = [&]() {
1788 auto &bit = getFEMethod()->numeredEntFiniteElementPtr->getBitRefLevel();
1789 Range ents = *fe_range;
1791 ptrFE->mField.getInterface<BitRefManager>()->filterEntitiesByRefLevel(
1792 bit, BitRefLevel().set(), ents),
1793 "filterEntitiesByRefLevel failed");
1794 return ents;
1795 };
1796
1797 auto get_adj = [&](auto &fe_uid, auto get_adj_fun)
1798 -> std::vector<boost::weak_ptr<NumeredEntFiniteElement>> & {
1799 if (adj_cache) {
1800 try {
1801 return (*adj_cache).at(ent);
1802 } catch (const std::out_of_range &) {
1803 return (*adj_cache)[ent] = get_numered_fe_ptr(fe_uid, get_adj_fun());
1804 }
1805 } else {
1806 return get_numered_fe_ptr(fe_uid, get_adj_fun());
1807 }
1808 };
1809
1810 if (type_from_handle(ent) == MBENTITYSET) {
1811 if (!fe_range)
1812 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
1813 "No range of finite elements");
1814 }
1815 auto adj = (!fe_range)
1816 ? get_adj((*fe_miit)->getFEUId(), get_bit_entity_adjacency)
1817 : get_adj((*fe_miit)->getFEUId(), get_bit_meshset_entities);
1818
1819 if (verb >= VERBOSE && !adj.empty())
1820 MOFEM_LOG("SELF", sev) << "Number of side finite elements " << adj.size();
1821
1822 int nn = 0;
1823 side_fe->loopSize = adj.size();
1824 for (auto fe_weak_ptr : adj) {
1825 if (auto fe_ptr = fe_weak_ptr.lock()) {
1826 if (verb >= VERBOSE)
1827 MOFEM_LOG("SELF", sev)
1828 << "Side finite element " << "(" << nn << "): " << *fe_ptr;
1829 side_fe->nInTheLoop = nn;
1830 side_fe->numeredEntFiniteElementPtr = fe_ptr;
1831 CHKERR (*side_fe)();
1832 }
1833 ++nn;
1834 }
1835
1836 CHKERR side_fe->postProcess();
1837 }
1838
1840}
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
auto bit
set bit
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

◆ loopThis()

MoFEMErrorCode ForcesAndSourcesCore::UserDataOperator::loopThis ( const string &  fe_name,
ForcesAndSourcesCore this_fe,
const int  verb = QUIET,
const LogManager::SeverityLevel  sev = Sev::noisy 
)

User calls this function to loop over the same element using a different set of integration points. This function calls finite element with its operator to do calculations.

Parameters
fe_name
this_fe
verb
sev
Returns
MoFEMErrorCode

Definition at line 1842 of file ForcesAndSourcesCore.cpp.

1844 {
1846
1847
1848
1849 auto &fes =
1850 ptrFE->mField.get_finite_elements()->get<FiniteElement_name_mi_tag>();
1851 auto fe_miit = fes.find(fe_name);
1852 if (fe_miit != fes.end()) {
1853
1854 this_fe->feName = fe_name;
1855
1856 CHKERR this_fe->setRefineFEPtr(ptrFE);
1857 CHKERR this_fe->copyBasicMethod(*getFEMethod());
1858 CHKERR this_fe->copyPetscData(*getFEMethod());
1859 CHKERR this_fe->copyKsp(*getFEMethod());
1860 CHKERR this_fe->copySnes(*getFEMethod());
1861 CHKERR this_fe->copyTs(*getFEMethod());
1862
1863 this_fe->cacheWeakPtr = getFEMethod()->cacheWeakPtr;
1864
1865 this_fe->nInTheLoop = getNinTheLoop();
1866 this_fe->loopSize = getLoopSize();
1867
1868 CHKERR this_fe->preProcess();
1869
1870 if (fe_name == getFEName()) {
1871
1872 if (verb >= VERBOSE)
1873 MOFEM_LOG("SELF", sev)
1874 << "This finite element: " << *getNumeredEntFiniteElementPtr();
1875
1876 this_fe->numeredEntFiniteElementPtr = getNumeredEntFiniteElementPtr();
1877 CHKERR (*this_fe)();
1878 } else {
1879
1880 auto get_numered_fe_ptr = [&](auto &fe_uid, auto fe_ent) {
1881 auto &numered_fe =
1882 getFEMethod()
1883 ->problemPtr->numeredFiniteElementsPtr->get<Unique_mi_tag>();
1884 auto it = numered_fe.find(
1886 boost::shared_ptr<const NumeredEntFiniteElement> this_numered_fe_ptr;
1887 if (it != numered_fe.end()) {
1888 this_numered_fe_ptr = *it;
1889 }
1890 return this_numered_fe_ptr;
1891 };
1892
1893 auto this_numered_fe_ptr = get_numered_fe_ptr(
1894 (*fe_miit)->getFEUId(), getNumeredEntFiniteElementPtr()->getEnt());
1895 if (this_numered_fe_ptr) {
1896
1897 if (verb >= VERBOSE)
1898 MOFEM_LOG("SELF", sev)
1899 << "This finite element: " << *this_numered_fe_ptr;
1900
1901 this_fe->numeredEntFiniteElementPtr = this_numered_fe_ptr;
1902 CHKERR (*this_fe)();
1903 }
1904 }
1905 CHKERR this_fe->postProcess();
1906 }
1907
1909}
int getLoopSize() const
get size of elements in the loop
int getNinTheLoop() const
get number of finite element in the loop
std::string getFEName() const
Get name of the element.

◆ setOpType()

void ForcesAndSourcesCore::UserDataOperator::setOpType ( const OpType  type)
inline

Set operator type.

Parameters
Operatortype

Definition at line 1157 of file ForcesAndSourcesCore.hpp.

1157 {
1158 opType = type;
1159}

◆ setPtrFE()

MoFEMErrorCode ForcesAndSourcesCore::UserDataOperator::setPtrFE ( ForcesAndSourcesCore ptr)
protectedvirtual

Reimplemented in MoFEM::EdgeElementForcesAndSourcesCore::UserDataOperator, MoFEM::FaceElementForcesAndSourcesCore::UserDataOperator, MoFEM::FaceElementForcesAndSourcesCoreOnSide::UserDataOperator, MoFEM::FatPrismElementForcesAndSourcesCore::UserDataOperator, MoFEM::FlatPrismElementForcesAndSourcesCore::UserDataOperator, MoFEM::VertexElementForcesAndSourcesCore::UserDataOperator, MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator, and MoFEM::VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator.

Definition at line 2174 of file ForcesAndSourcesCore.cpp.

2174 {
2176 if (!(ptrFE = dynamic_cast<ForcesAndSourcesCore *>(ptr)))
2177 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
2178 "User operator and finite element do not work together");
2180}
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...

Friends And Related Symbol Documentation

◆ ContactPrismElementForcesAndSourcesCore

Definition at line 1102 of file ForcesAndSourcesCore.hpp.

◆ EdgeElementForcesAndSourcesCore

friend class EdgeElementForcesAndSourcesCore
friend

Definition at line 1100 of file ForcesAndSourcesCore.hpp.

◆ FaceElementForcesAndSourcesCore

friend class FaceElementForcesAndSourcesCore
friend

Definition at line 1101 of file ForcesAndSourcesCore.hpp.

◆ ForcesAndSourcesCore

friend class ForcesAndSourcesCore
friend

Definition at line 1099 of file ForcesAndSourcesCore.hpp.

Member Data Documentation

◆ colFieldName

std::string MoFEM::ForcesAndSourcesCore::UserDataOperator::colFieldName

Definition at line 626 of file ForcesAndSourcesCore.hpp.

◆ opType

char MoFEM::ForcesAndSourcesCore::UserDataOperator::opType

Definition at line 624 of file ForcesAndSourcesCore.hpp.

◆ OpTypeNames

const char *const ForcesAndSourcesCore::UserDataOperator::OpTypeNames
static
Initial value:
= {
"OPROW", " OPCOL", "OPROWCOL", "OPSPACE", "OPLAST"}

Definition at line 622 of file ForcesAndSourcesCore.hpp.

◆ ptrFE

ForcesAndSourcesCore* MoFEM::ForcesAndSourcesCore::UserDataOperator::ptrFE
protected

Definition at line 1094 of file ForcesAndSourcesCore.hpp.

◆ rowFieldName

std::string MoFEM::ForcesAndSourcesCore::UserDataOperator::rowFieldName

Definition at line 625 of file ForcesAndSourcesCore.hpp.

◆ sPace

FieldSpace MoFEM::ForcesAndSourcesCore::UserDataOperator::sPace

Definition at line 627 of file ForcesAndSourcesCore.hpp.


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