62#ifndef __FORCES_AND_SOURCES_CORE__HPP__
63#define __FORCES_AND_SOURCES_CORE__HPP__
65using namespace boost::numeric;
78 typedef boost::function<int(
int order_row,
int order_col,
int order_data)>
82 int order_row,
int order_col,
228 const EntityType type,
229 boost::ptr_vector<EntitiesFieldData::EntData> &data)
const;
240 const EntityType type,
const FieldSpace space,
241 boost::ptr_vector<EntitiesFieldData::EntData> &data)
const;
250 template <EntityType type>
263 template <EntityType type>
274 template <
typename EXTRACTOR>
278 VectorInt &local_nodes_indices, EXTRACTOR &&extractor)
const;
282 const int bit_number)
const;
286 const int bit_number)
const;
288 template <
typename EXTRACTOR>
291 const EntityType type_lo,
292 const EntityType type_hi,
293 EXTRACTOR &&extractor)
const;
297 const EntityType type_lo = MBVERTEX,
298 const EntityType type_hi = MBPOLYHEDRON)
const;
302 const EntityType type_lo = MBVERTEX,
303 const EntityType type_hi = MBPOLYHEDRON)
const;
308 const int bit_number)
const;
312 const int bit_number)
const;
331 const int bit_number)
const;
335 const EntityType type_lo = MBVERTEX,
336 const EntityType type_hi = MBPOLYHEDRON)
const;
346 template <
typename EXTRACTOR>
348 const int bit_number,
349 EXTRACTOR &&extractor)
const;
374 EntityType type,
int side_number,
380 EntityType type,
int side_number,
385 EntityType type,
int side_number,
427 virtual int getRule(
int order_row,
int order_col,
int order_data);
508 const std::array<boost::shared_ptr<EntitiesFieldData>,
LASTSPACE>
515 const std::array<boost::shared_ptr<EntitiesFieldData>,
LASTSPACE>
644 const bool symm =
true);
664 const bool symm =
true);
683 const std::string col_field_name,
const char type,
684 const bool symm =
true);
688 inline boost::shared_ptr<const NumeredEntFiniteElement>
723 const EntityType type);
758 const EntityType type);
782 const EntityType type,
const int side,
800 const EntityType type,
const int side,
882 inline Vec
getTSu()
const;
888 inline Vec
getTSf()
const;
890 inline Mat
getTSA()
const;
892 inline Mat
getTSB()
const;
900 inline double getTSa()
const;
996 std::vector<boost::weak_ptr<NumeredEntFiniteElement>>>;
1015 boost::shared_ptr<Range> fe_range =
nullptr,
1016 const int verb =
QUIET,
1035 const int verb =
QUIET,
1050 const int verb =
QUIET,
1065 const int verb =
QUIET,
1080 boost::shared_ptr<Range> fe_range,
1081 const int verb =
QUIET,
1117boost::shared_ptr<const NumeredEntFiniteElement>
1123 return getNumeredEntFiniteElementPtr()->getEnt();
1134boost::weak_ptr<SideNumber>
1136 const int side_number,
const EntityType type) {
1137 auto &side_table_by_side_and_type =
1138 ptrFE->numeredEntFiniteElementPtr->getSideNumberTable().get<1>();
1140 side_table_by_side_and_type.find(boost::make_tuple(type, side_number));
1141 if (side_it != side_table_by_side_and_type.end())
1144 return boost::weak_ptr<SideNumber>();
1149 const EntityType type) {
1150 if (
auto side_ptr = getSideNumberPtr(side_number, type).lock())
1151 return side_ptr->ent;
1157 return ptrFE->getNumberOfNodes();
1175 return getFEMethod()->getNinTheLoop();
1179 return getFEMethod()->getLoopSize();
1183 return getFEMethod()->getFEName();
1188 return getFEMethod()->data_ctx;
1193 return getFEMethod()->ksp_ctx;
1198 return getFEMethod()->snes_ctx;
1203 return getFEMethod()->ts_ctx;
1208 if (getFEMethod()->
ksp_f == PETSC_NULLPTR)
1211 return getFEMethod()->ksp_f;
1216 if (getFEMethod()->
ksp_A == PETSC_NULLPTR)
1219 return getFEMethod()->ksp_A;
1224 if (getFEMethod()->
ksp_B == PETSC_NULLPTR)
1227 return getFEMethod()->ksp_B;
1232 if (getFEMethod()->
snes_f == PETSC_NULLPTR)
1235 return getFEMethod()->snes_f;
1240 if (getFEMethod()->
snes_x == PETSC_NULLPTR)
1243 return getFEMethod()->snes_x;
1248 if (getFEMethod()->
snes_A == PETSC_NULLPTR)
1251 return getFEMethod()->snes_A;
1256 if (getFEMethod()->
snes_B == PETSC_NULLPTR)
1259 return getFEMethod()->snes_B;
1264 if (getFEMethod()->
ts_u == PETSC_NULLPTR)
1267 return getFEMethod()->ts_u;
1272 if (getFEMethod()->
ts_u_t == PETSC_NULLPTR)
1275 return getFEMethod()->ts_u_t;
1280 if (getFEMethod()->
ts_u_tt == PETSC_NULLPTR)
1283 return getFEMethod()->ts_u_tt;
1288 if (getFEMethod()->
ts_F == PETSC_NULLPTR)
1291 return getFEMethod()->ts_F;
1296 if (getFEMethod()->
ts_A == PETSC_NULLPTR)
1299 return getFEMethod()->ts_A;
1304 if (getFEMethod()->
ts_B == PETSC_NULLPTR)
1307 return getFEMethod()->ts_B;
1312 if ((getFEMethod()->
data_ctx & PetscData::PetscData::CtxSetTime).none())
1315 return getFEMethod()->ts_step;
1320 if ((getFEMethod()->
data_ctx & PetscData::PetscData::CtxSetTime).none())
1323 return getFEMethod()->ts_t;
1328 if ((getFEMethod()->
data_ctx & PetscData::PetscData::CtxSetTime).none())
1331 return getFEMethod()->ts_dt;
1341 return getFEMethod()->ts_a;
1351 return getFEMethod()->ts_aa;
1360 &(getGaussPts()(getGaussPts().size1() - 1, 0)));
1389 &getCoordsAtGaussPts()(0, 0), &getCoordsAtGaussPts()(0, 1),
1390 &getCoordsAtGaussPts()(0, 2));
1407template <
typename E>
1413 const int side_dim, boost::shared_ptr<Range> fe_range,
1415 boost::shared_ptr<AdjCache> adj_cache =
nullptr)
1417 sideFEName(fe_name), sideDim(side_dim), sevLevel(sev),
1418 adjCache(adj_cache), feRange(fe_range) {}
1432 boost::shared_ptr<AdjCache> adj_cache =
nullptr)
1433 :
OpLoopSide(m_field, fe_name, side_dim, nullptr, sev, adj_cache) {}
1437 return loopSide(sideFEName, sideFEPtr.get(), sideDim, 0, feRange,
VERBOSE,
1438 sevLevel, adjCache.get());
1442 return sideFEPtr->getOpPtrVector();
1461template <
typename E>
1467 boost::shared_ptr<Range> fe_range,
1470 rangeFEName(fe_name), sevLevel(sev), feRange(fe_range) {}
1474 return loopRange(rangeFEName, rangeFEPtr.get(), feRange,
VERBOSE, sevLevel);
1478 return rangeFEPtr->getOpPtrVector();
FieldApproximationBase
approximation base
FieldSpace
approximation spaces
@ LASTSPACE
FieldSpace in [ 0, LASTSPACE )
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
constexpr int order
Order displacement.
multi_index_container< boost::shared_ptr< NumeredDofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< NumeredDofEntity::interface_type_DofEntity, UId, &NumeredDofEntity::getLocalUniqueId > >, ordered_non_unique< tag< Part_mi_tag >, member< NumeredDofEntity, unsigned int, &NumeredDofEntity::pArt > >, ordered_non_unique< tag< Idx_mi_tag >, member< NumeredDofEntity, DofIdx, &NumeredDofEntity::dofIdx > >, ordered_non_unique< tag< PetscGlobalIdx_mi_tag >, member< NumeredDofEntity, DofIdx, &NumeredDofEntity::petscGloablDofIdx > >, ordered_non_unique< tag< PetscLocalIdx_mi_tag >, member< NumeredDofEntity, DofIdx, &NumeredDofEntity::petscLocalDofIdx > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< NumeredDofEntity::interface_type_DofEntity, EntityHandle, &NumeredDofEntity::getEnt > > > > NumeredDofEntity_multiIndex
MultiIndex container keeps NumeredDofEntity.
SeverityLevel
Severity levels.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
UBlasVector< int > VectorInt
implementation of Data Operators for Forces and Sources
auto type_from_handle(const EntityHandle h)
get type from entity handle
DEPRECATED typedef ForcesAndSourcesCore ForcesAndSurcesCore
auto dimension_from_handle(const EntityHandle h)
get entity dimension form handle
std::vector< boost::weak_ptr< FieldEntity > > FieldEntity_vector_view
constexpr auto field_name
virtual moab::Interface & get_moab()=0
base operator to do operations at Gauss Pt. level
Deprecated interface functions.
Base face element used to integrate on skeleton.
Data on single entity (This is passed as argument to DataOperator::doWork)
data structure for finite element entity
std::array< boost::ptr_vector< EntData >, MBMAXTYPE > dataOnEntities
Structure for user loop methods on finite elements.
EntityHandle getFEEntityHandle() const
Get the entity handle of the current finite element.
boost::shared_ptr< const NumeredEntFiniteElement > numeredEntFiniteElementPtr
Shared pointer to finite element database structure.
Base face element used to integrate on skeleton.
Base face element used to integrate on skeleton.
void setOpType(const OpType type)
Set operator type.
EntityHandle getFEEntityHandle() const
Return finite element entity handle.
MoFEM::Interface & getMField()
MoFEMErrorCode getProblemColIndices(const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
Get col indices.
int getLoopSize() const
get size of elements in the loop
EntityType getFEType() const
Get dimension of finite element.
const KspMethod::KSPContext getKSPCtx() const
static const char *const OpTypeNames[]
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 elemen...
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.
int getNinTheLoop() const
get number of finite element in the loop
auto getFTensor1CoordsAtGaussPts()
Get coordinates at integration points assuming linear geometry.
int getNumberOfNodesOnElement() const
Get the number of nodes on finite element.
boost::weak_ptr< SideNumber > getSideNumberPtr(const int side_number, const EntityType type)
Get the side number pointer.
const SnesMethod::SNESContext getSNESCtx() const
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 op...
const PetscData::Switches & getDataCtx() const
moab::Interface & getMoab()
ForcesAndSourcesCore * ptrFE
EntityHandle getSideEntity(const int side_number, const EntityType type)
Get the side entity.
MatrixDouble & getCoordsAtGaussPts()
Gauss points and weight, matrix (nb. of points x 3)
auto getFTensor0IntegrationWeight()
Get integration weights.
const TSMethod::TSContext getTSCtx() const
double getMeasure() const
get measure of element
std::string getFEName() const
Get name of the element.
ForcesAndSourcesCore * getRefinePtrFE() const
MoFEMErrorCode getProblemRowIndices(const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
Get row indices.
boost::shared_ptr< const NumeredEntFiniteElement > getNumeredEntFiniteElementPtr() const
Return raw pointer to NumeredEntFiniteElement.
std::map< EntityHandle, std::vector< boost::weak_ptr< NumeredEntFiniteElement > > > AdjCache
double getTStimeStep() const
void addOpType(const OpType type)
Add operator type.
ForcesAndSourcesCore * getPtrFE() const
int getOpType() const
Get operator types.
OpType
Controls loop over entities on element.
@ 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
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 op...
virtual MoFEMErrorCode setPtrFE(ForcesAndSourcesCore *ptr)
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
ForcesAndSourcesCore * getSidePtrFE() const
int getFEDim() const
Get dimension of finite element.
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
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....
structure to get information from mofem into EntitiesFieldData
int getMaxRowOrder() const
Get max order of approximation for field in rows.
EntitiesFieldData & dataNoField
MoFEMErrorCode calHierarchicalBaseFunctionsOnElement()
Calculate base functions.
auto & getDataOnElementBySpaceArray()
Get data on entities and space.
MoFEMErrorCode getEntityFieldData(EntitiesFieldData &data, const int bit_number, const EntityType type_lo=MBVERTEX, const EntityType type_hi=MBPOLYHEDRON) const
MoFEMErrorCode loopOverOperators()
Iterate user data operators.
auto & getUserPolynomialBase()
Get the User Polynomial Base object.
MoFEMErrorCode getEntitySense(EntitiesFieldData &data) const
Get the entity sense (orientation)
EntitiesFieldData & dataHdiv
MoFEMErrorCode getEntityDataOrder(const EntityType type, const FieldSpace space, boost::ptr_vector< EntitiesFieldData::EntData > &data) const
Get the entity data order.
MoFEMErrorCode getProblemNodesColIndices(const std::string &field_name, VectorInt &nodes_indices) const
MoFEMErrorCode getRowNodesIndices(EntitiesFieldData &data, const int bit_number) const
get row node indices from FENumeredDofEntity_multiIndex
const std::array< boost::shared_ptr< EntitiesFieldData >, LASTSPACE > derivedDataOnElement
Entity data on element entity columns fields.
MoFEMErrorCode getNoFieldRowIndices(EntitiesFieldData &data, const int bit_number) const
get col NoField indices
virtual MoFEMErrorCode setGaussPts(int order_row, int order_col, int order_data)
set user specific integration rule
MoFEMErrorCode getNoFieldEntityFieldData(EntitiesFieldData &data, const int bit_number, EXTRACTOR &&extractor) const
Get field data on entities where no field is defined.
MoFEMErrorCode getEntityIndices(EntitiesFieldData &data, const int bit_number, FieldEntity_vector_view &ents_field, const EntityType type_lo, const EntityType type_hi, EXTRACTOR &&extractor) const
EntitiesFieldData & dataHcurl
int getMaxDataOrder() const
Get max order of approximation for data fields.
auto & getElementPolynomialBase()
Get the Entity Polynomial Base object.
ForcesAndSourcesCore * sidePtrFE
Element to integrate on the sides.
MoFEMErrorCode getProblemTypeRowIndices(const std::string &field_name, EntityType type, int side_number, VectorInt &indices) const
EntitiesFieldData & dataH1
MoFEMErrorCode getColNodesIndices(EntitiesFieldData &data, const int bit_number) const
get col node indices from FENumeredDofEntity_multiIndex
MoFEMErrorCode getSpacesAndBaseOnEntities(EntitiesFieldData &data) const
Get field approximation space and base on entities.
MoFEMErrorCode getNodesIndices(const int bit_number, FieldEntity_vector_view &ents_field, VectorInt &nodes_indices, VectorInt &local_nodes_indices, EXTRACTOR &&extractor) const
get node indices
MatrixDouble coordsAtGaussPts
coordinated at gauss points
virtual MoFEMErrorCode operator()()
Main operator function executed for each loop iteration.
boost::function< MoFEMErrorCode(ForcesAndSourcesCore *fe_raw_ptr, int order_row, int order_col, int order_data)> GaussHookFun
MoFEMErrorCode setSideFEPtr(const ForcesAndSourcesCore *side_fe_ptr)
Set the pointer to face element on the side.
virtual MoFEMErrorCode preProcess()
Pre-processing function executed at loop initialization.
boost::ptr_deque< UserDataOperator > opPtrVector
Vector of finite element users data operators.
MoFEMErrorCode getNodesFieldData(EntitiesFieldData &data, const int bit_number) const
Get data on nodes.
int getMaxColOrder() const
Get max order of approximation for field in columns.
const std::array< boost::shared_ptr< EntitiesFieldData >, LASTSPACE > dataOnElement
Entity data on element entity rows fields.
auto & getDerivedDataOnElementBySpaceArray()
Get derived data on entities and space.
MoFEMErrorCode getEntityRowIndices(EntitiesFieldData &data, const int bit_number, const EntityType type_lo=MBVERTEX, const EntityType type_hi=MBPOLYHEDRON) const
MoFEMErrorCode getProblemTypeIndices(const std::string &field_name, const NumeredDofEntity_multiIndex &dofs, EntityType type, int side_number, VectorInt &indices) const
get indices by type (generic function) which are declared for problem but not this particular element
MatrixDouble gaussPts
Matrix of integration points.
auto & getEntData(const FieldSpace space, const EntityType type, const int side)
Get the entity data.
MoFEMErrorCode getEntityDataOrder(EntitiesFieldData &data, const FieldSpace space) const
Get the entity data order for given space.
MoFEMErrorCode getProblemNodesRowIndices(const std::string &field_name, VectorInt &nodes_indices) const
MoFEMErrorCode getEntityColIndices(EntitiesFieldData &data, const int bit_number, const EntityType type_lo=MBVERTEX, const EntityType type_hi=MBPOLYHEDRON) const
MoFEMErrorCode getFaceNodes(EntitiesFieldData &data) const
Get nodes on faces.
EntityType lastEvaluatedElementEntityType
Last evaluated type of element entity.
boost::function< int(int order_row, int order_col, int order_data)> RuleHookFun
virtual MoFEMErrorCode postProcess()
Post-processing function executed at loop completion.
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
Use to push back operator for row operator.
GaussHookFun setRuleHook
Set function to calculate integration rule.
boost::shared_ptr< BaseFunction > elementPolynomialBasePtr
Pointer to entity polynomial base.
MoFEMErrorCode getBitRefLevelOnData()
MoFEMErrorCode getProblemTypeColIndices(const std::string &field_name, EntityType type, int side_number, VectorInt &indices) const
ForcesAndSourcesCore * refinePtrFE
Element to integrate parent or child.
MoFEMErrorCode getNoFieldColIndices(EntitiesFieldData &data, const int bit_number) const
get col NoField indices
MoFEMErrorCode getProblemNodesIndices(const std::string &field_name, const NumeredDofEntity_multiIndex &dofs, VectorInt &nodes_indices) const
get indices of nodal indices which are declared for problem but not this particular element
virtual int getRule(int order_row, int order_col, int order_data)
another variant of getRule
MoFEMErrorCode createDataOnElement(EntityType type)
Create a entity data on element object.
MoFEMErrorCode getEntitySense(const EntityType type, boost::ptr_vector< EntitiesFieldData::EntData > &data) const
get sense (orientation) of entity
MoFEMErrorCode calBernsteinBezierBaseFunctionsOnElement()
Calculate Bernstein-Bezier base.
boost::shared_ptr< BaseFunction > userPolynomialBasePtr
Pointer to user polynomial base.
RuleHookFun getRuleHook
Hook to get rule.
MoFEMErrorCode setRefineFEPtr(const ForcesAndSourcesCore *refine_fe_ptr)
Set the pointer to face element refined.
EntitiesFieldData & dataL2
Mat & ksp_B
Reference to preconditioner matrix in KSP context.
KSPContext
Context enumeration for KSP solver phases.
Mat & ksp_A
Reference to system matrix in KSP context.
Vec & ksp_f
Reference to residual vector in KSP context.
Operator for broken loop side.
Copy geometry-related data from one element to other.
Iterate over range of (sub)elements.
OpLoopRange(MoFEM::Interface &m_field, const std::string fe_name, boost::shared_ptr< Range > fe_range, const LogManager::SeverityLevel sev=Sev::noisy)
boost::shared_ptr< E > & getRangeFEPtr()
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
const std::string rangeFEName
const LogManager::SeverityLevel sevLevel
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.
boost::shared_ptr< Range > feRange
boost::shared_ptr< E > rangeFEPtr
Element used to execute operators on side of the element.
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.
boost::shared_ptr< Range > feRange
boost::shared_ptr< E > & getSideFEPtr()
const std::string sideFEName
boost::shared_ptr< AdjCache > adjCache
boost::shared_ptr< E > sideFEPtr
OpLoopSide(MoFEM::Interface &m_field, const std::string fe_name, const int side_dim, boost::shared_ptr< Range > fe_range, const LogManager::SeverityLevel sev=Sev::noisy, boost::shared_ptr< AdjCache > adj_cache=nullptr)
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
const LogManager::SeverityLevel sevLevel
OpLoopSide(MoFEM::Interface &m_field, const std::string fe_name, const int side_dim, const LogManager::SeverityLevel sev=Sev::noisy, boost::shared_ptr< AdjCache > adj_cache=nullptr)
Construct a new Op Loop Side object.
static constexpr Switches CtxSetA
Jacobian matrix switch.
static constexpr Switches CtxSetX_TT
Second time derivative switch.
std::bitset< 8 > Switches
Bitset type for context switches.
Switches data_ctx
Current data context switches.
static constexpr Switches CtxSetX_T
First time derivative switch.
static constexpr Switches CtxSetB
Preconditioner matrix switch.
SNESContext
Context enumeration for SNES solver phases.
Vec & snes_f
Reference to residual vector.
Vec & snes_x
Reference to current solution state vector.
Mat & snes_B
Reference to preconditioner of Jacobian matrix.
Mat & snes_A
Reference to Jacobian matrix.
TSContext
Context enumeration for TS solver phases.
Mat & ts_A
Reference to Jacobian matrix: dF/dU + a*dF/dU_t + aa*dF/dU_tt.
Vec & ts_F
Reference to residual vector F(t,U,U_t,U_tt)
Vec & ts_u_tt
Reference to second time derivative of state vector d²U/dt²
Vec & ts_u_t
Reference to first time derivative of state vector dU/dt.
Vec & ts_u
Reference to current state vector U(t)
Mat & ts_B
Reference to preconditioner matrix for ts_A.
Base volume element used to integrate on skeleton.