49#ifndef __FORCES_AND_SOURCES_CORE__HPP__
50#define __FORCES_AND_SOURCES_CORE__HPP__
52using namespace boost::numeric;
65 typedef boost::function<int(
int order_row,
int order_col,
int order_data)>
69 int order_row,
int order_col,
215 const EntityType type,
216 boost::ptr_vector<EntitiesFieldData::EntData> &data)
const;
227 const EntityType type,
const FieldSpace space,
228 boost::ptr_vector<EntitiesFieldData::EntData> &data)
const;
237 template <EntityType type>
250 template <EntityType type>
261 template <
typename EXTRACTOR>
265 VectorInt &local_nodes_indices, EXTRACTOR &&extractor)
const;
269 const int bit_number)
const;
273 const int bit_number)
const;
275 template <
typename EXTRACTOR>
278 const EntityType type_lo,
279 const EntityType type_hi,
280 EXTRACTOR &&extractor)
const;
284 const EntityType type_lo = MBVERTEX,
285 const EntityType type_hi = MBPOLYHEDRON)
const;
289 const EntityType type_lo = MBVERTEX,
290 const EntityType type_hi = MBPOLYHEDRON)
const;
295 const int bit_number)
const;
299 const int bit_number)
const;
318 const int bit_number)
const;
322 const EntityType type_lo = MBVERTEX,
323 const EntityType type_hi = MBPOLYHEDRON)
const;
333 template <
typename EXTRACTOR>
335 const int bit_number,
336 EXTRACTOR &&extractor)
const;
361 EntityType type,
int side_number,
367 EntityType type,
int side_number,
372 EntityType type,
int side_number,
414 virtual int getRule(
int order_row,
int order_col,
int order_data);
495 const std::array<boost::shared_ptr<EntitiesFieldData>,
LASTSPACE>
502 const std::array<boost::shared_ptr<EntitiesFieldData>,
LASTSPACE>
631 const bool symm =
true);
651 const bool symm =
true);
670 const std::string col_field_name,
const char type,
671 const bool symm =
true);
675 inline boost::shared_ptr<const NumeredEntFiniteElement>
710 const EntityType type);
745 const EntityType type);
769 const EntityType type,
const int side,
787 const EntityType type,
const int side,
869 inline Vec
getTSu()
const;
875 inline Vec
getTSf()
const;
877 inline Mat
getTSA()
const;
879 inline Mat
getTSB()
const;
887 inline double getTSa()
const;
983 std::vector<boost::weak_ptr<NumeredEntFiniteElement>>>;
1002 boost::shared_ptr<Range> fe_range =
nullptr,
1003 const int verb =
QUIET,
1022 const int verb =
QUIET,
1037 const int verb =
QUIET,
1052 const int verb =
QUIET,
1067 boost::shared_ptr<Range> fe_range,
1068 const int verb =
QUIET,
1093 return boost::weak_ptr<ForcesAndSourcesCore>();
1113boost::shared_ptr<const NumeredEntFiniteElement>
1119 return getNumeredEntFiniteElementPtr()->getEnt();
1130boost::weak_ptr<SideNumber>
1132 const int side_number,
const EntityType type) {
1133 auto &side_table_by_side_and_type =
1134 ptrFE->numeredEntFiniteElementPtr->getSideNumberTable().get<1>();
1136 side_table_by_side_and_type.find(boost::make_tuple(type, side_number));
1137 if (side_it != side_table_by_side_and_type.end())
1140 return boost::weak_ptr<SideNumber>();
1145 const EntityType type) {
1146 if (
auto side_ptr = getSideNumberPtr(side_number, type).lock())
1147 return side_ptr->ent;
1153 return ptrFE->getNumberOfNodes();
1171 return getFEMethod()->getNinTheLoop();
1175 return getFEMethod()->getLoopSize();
1179 return getFEMethod()->getFEName();
1184 return getFEMethod()->data_ctx;
1189 return getFEMethod()->ksp_ctx;
1194 return getFEMethod()->snes_ctx;
1199 return getFEMethod()->ts_ctx;
1204 if (getFEMethod()->
ksp_f == PETSC_NULLPTR)
1207 return getFEMethod()->ksp_f;
1212 if (getFEMethod()->
ksp_A == PETSC_NULLPTR)
1215 return getFEMethod()->ksp_A;
1220 if (getFEMethod()->
ksp_B == PETSC_NULLPTR)
1223 return getFEMethod()->ksp_B;
1228 if (getFEMethod()->
snes_f == PETSC_NULLPTR)
1231 return getFEMethod()->snes_f;
1236 if (getFEMethod()->
snes_x == PETSC_NULLPTR)
1239 return getFEMethod()->snes_x;
1244 if (getFEMethod()->
snes_A == PETSC_NULLPTR)
1247 return getFEMethod()->snes_A;
1252 if (getFEMethod()->
snes_B == PETSC_NULLPTR)
1255 return getFEMethod()->snes_B;
1260 if (getFEMethod()->
ts_u == PETSC_NULLPTR)
1263 return getFEMethod()->ts_u;
1268 if (getFEMethod()->
ts_u_t == PETSC_NULLPTR)
1271 return getFEMethod()->ts_u_t;
1276 if (getFEMethod()->
ts_u_tt == PETSC_NULLPTR)
1279 return getFEMethod()->ts_u_tt;
1284 if (getFEMethod()->
ts_F == PETSC_NULLPTR)
1287 return getFEMethod()->ts_F;
1292 if (getFEMethod()->
ts_A == PETSC_NULLPTR)
1295 return getFEMethod()->ts_A;
1300 if (getFEMethod()->
ts_B == PETSC_NULLPTR)
1303 return getFEMethod()->ts_B;
1308 if ((getFEMethod()->
data_ctx & PetscData::PetscData::CtxSetTime).none())
1311 return getFEMethod()->ts_step;
1316 if ((getFEMethod()->
data_ctx & PetscData::PetscData::CtxSetTime).none())
1319 return getFEMethod()->ts_t;
1324 if ((getFEMethod()->
data_ctx & PetscData::PetscData::CtxSetTime).none())
1327 return getFEMethod()->ts_dt;
1337 return getFEMethod()->ts_a;
1347 return getFEMethod()->ts_aa;
1356 &(getGaussPts()(getGaussPts().size1() - 1, 0)));
1379 &getCoordsAtGaussPts()(0, 0), &getCoordsAtGaussPts()(0, 1),
1380 &getCoordsAtGaussPts()(0, 2));
1397template <
typename E>
1403 const int side_dim, boost::shared_ptr<Range> fe_range,
1405 boost::shared_ptr<AdjCache> adj_cache =
nullptr)
1407 sideFEName(fe_name), sideDim(side_dim), sevLevel(sev),
1408 adjCache(adj_cache), feRange(fe_range) {}
1422 boost::shared_ptr<AdjCache> adj_cache =
nullptr)
1423 :
OpLoopSide(m_field, fe_name, side_dim, nullptr, sev, adj_cache) {}
1427 return loopSide(sideFEName, sideFEPtr.get(), sideDim, 0, feRange,
VERBOSE,
1428 sevLevel, adjCache.get());
1432 return sideFEPtr->getOpPtrVector();
1455template <
typename E>
1461 boost::shared_ptr<Range> fe_range,
1464 rangeFEName(fe_name), sevLevel(sev), feRange(fe_range) {}
1468 return loopRange(rangeFEName, rangeFEPtr.get(), feRange,
VERBOSE, sevLevel);
1472 return rangeFEPtr->getOpPtrVector();
FieldApproximationBase
approximation base
FieldSpace
approximation spaces
@ LASTSPACE
FieldSpace in [ 0, LASTSPACE )
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
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.
virtual boost::weak_ptr< ForcesAndSourcesCore > getSubPipelinePtr() const
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::weak_ptr< ForcesAndSourcesCore > getSubPipelinePtr() const override
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()
boost::weak_ptr< ForcesAndSourcesCore > getSubPipelinePtr() const override
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.