24 *iface =
const_cast<Simple *
>(
this);
29 static_assert(DIM == 2 || DIM == 3,
"not implemented");
37 auto defaultSkeletonEdge =
48 std::vector<EntityHandle> bride_adjacency_edge;
49 CHKERR moab.get_adjacencies(&fe_ent, 1, 2,
false, bride_adjacency_edge);
51 switch (field.getSpace()) {
53 CHKERR moab.get_connectivity(&*bride_adjacency_edge.begin(),
54 bride_adjacency_edge.size(), adjacency,
58 CHKERR moab.get_adjacencies(&*bride_adjacency_edge.begin(),
59 bride_adjacency_edge.size(), 1,
false,
60 adjacency, moab::Interface::UNION);
62 adjacency.insert(adjacency.end(), bride_adjacency_edge.begin(),
63 bride_adjacency_edge.end());
69 "this field is not implemented for TRI finite element");
72 std::sort(adjacency.begin(), adjacency.end());
73 auto it = std::unique(adjacency.begin(), adjacency.end());
75 std::vector<EntityHandle> new_adjacency(
76 std::distance(adjacency.begin(), it));
77 std::copy(adjacency.begin(), it, new_adjacency.begin());
79 for (
auto e : new_adjacency) {
80 auto side_table = fe.getSideNumberTable();
81 if (side_table.find(e) == side_table.end())
84 boost::shared_ptr<SideNumber>(
new SideNumber(e, -1, 0, 0)));
87 adjacency.swap(new_adjacency);
103 auto defaultSkeletonEdge =
114 std::vector<EntityHandle> bride_adjacency_edge;
115 CHKERR moab.get_adjacencies(&fe_ent, 1, 2,
false, bride_adjacency_edge);
117 switch (field.getSpace()) {
119 CHKERR moab.get_connectivity(&*bride_adjacency_edge.begin(),
120 bride_adjacency_edge.size(), adjacency,
123 CHKERR moab.get_adjacencies(&*bride_adjacency_edge.begin(),
124 bride_adjacency_edge.size(), 1,
false,
125 adjacency, moab::Interface::UNION);
127 CHKERR moab.get_adjacencies(&*bride_adjacency_edge.begin(),
128 bride_adjacency_edge.size(), 2,
false,
129 adjacency, moab::Interface::UNION);
131 adjacency.insert(adjacency.end(), bride_adjacency_edge.begin(),
132 bride_adjacency_edge.end());
138 "this field is not implemented for TRI finite element");
141 std::sort(adjacency.begin(), adjacency.end());
142 auto it = std::unique(adjacency.begin(), adjacency.end());
144 std::vector<EntityHandle> new_adjacency(
145 std::distance(adjacency.begin(), it));
146 std::copy(adjacency.begin(), it, new_adjacency.begin());
148 for (
auto e : new_adjacency) {
149 auto side_table = fe.getSideNumberTable();
150 if (side_table.find(e) == side_table.end())
153 boost::shared_ptr<SideNumber>(
new SideNumber(e, -1, 0, 0)));
156 adjacency.swap(new_adjacency);
163 defaultSkeletonEdge);
165 defaultSkeletonEdge);
176 return setSkeletonAdjacency<2>();
178 return setSkeletonAdjacency<3>();
191 return setSkeletonAdjacency<2>();
193 return setSkeletonAdjacency<3>();
202 bitLevelMask(
BitRefLevel().set()), meshSet(0), boundaryMeshset(0),
203 skeletonMeshset(0), nameOfProblem(
"SimpleProblem"), domainFE(
"dFE"),
204 boundaryFE(
"bFE"), skeletonFE(
"sFE"), dIm(-1), addSkeletonFE(false),
205 addBoundaryFE(false) {
209 PetscLogEventRegister(
"SimpleBuildFiniteElements", 0,
217 PetscBool flg = PETSC_TRUE;
219 ierr = PetscOptionsBegin(PETSC_COMM_WORLD,
"",
"Simple interface options",
222 ierr = PetscOptionsString(
"-file_name",
"file name",
"",
"mesh.h5m",
225 ierr = PetscOptionsEnd();
249 if (nb_ents_3d > 0) {
255 if (nb_ents_2d > 0) {
286 "PARALLEL_RESOLVE_SHARED_ENTS;"
287 "PARTITION=PARALLEL_PARTITION;",
296 const TagType tag_type,
const enum MoFEMTypes bh,
301 CHKERR m_field.
add_field(name, space, base, nb_of_cooficients, tag_type, bh,
314 const TagType tag_type,
const enum MoFEMTypes bh,
318 CHKERR m_field.
add_field(name, space, base, nb_of_cooficients, tag_type, bh,
324 "NOFIELD space for boundary filed not implemented in Simple interface");
332 const TagType tag_type,
const enum MoFEMTypes bh,
337 CHKERR m_field.
add_field(name, space, base, nb_of_cooficients, tag_type, bh,
343 "NOFIELD space for boundary filed not implemented in Simple interface");
352 const TagType tag_type,
const enum MoFEMTypes bh,
357 CHKERR m_field.
add_field(name, space, base, nb_of_cooficients, tag_type, bh,
370 auto remove_field_from_list = [&](
auto &vec) {
371 auto it = std::find(vec.begin(), vec.end(), name);
386 auto remove_field_from_list = [&](
auto &vec) {
387 auto it = std::find(vec.begin(), vec.end(), name);
401 auto remove_field_from_list = [&](
auto &vec) {
402 auto it = std::find(vec.begin(), vec.end(), name);
416 auto clear_rows_and_cols = [&](
auto &fe_name) {
420 ->get<FiniteElement_name_mi_tag>();
421 auto it_fe = fe_by_name.find(fe_name);
422 if (it_fe != fe_by_name.end()) {
426 "modification unsuccessful");
430 "modification unsuccessful");
441 auto add_fields = [&](
auto &fe_name,
auto &fields) {
443 for (
auto &field : fields) {
451 auto add_data_fields = [&](
auto &fe_name,
auto &fields) {
453 for (
auto &field : fields)
500 for (std::vector<std::string>::iterator fit =
otherFEs.begin();
509 const int order,
const Range *ents) {
512 {field_name, {
order, ents == NULL ? Range() : Range(*ents)}});
525 auto add_ents_to_field = [&](
auto meshset,
auto dim,
auto &fields) {
527 for (
auto &field : fields) {
529 CHKERR comm_interface_ptr->synchroniseFieldEntities(field, 0);
534 auto make_no_field_ents = [&](
auto &fields) {
536 for (
auto &field : fields) {
537 std::array<double, 6> coords = {0, 0, 0, 0, 0, 0};
539 CHKERR comm_interface_ptr->makeFieldEntitiesMultishared(field, 0);
550 std::set<std::string> nofield_fields;
552 nofield_fields.insert(
f);
554 nofield_fields.insert(
f);
556 CHKERR make_no_field_ents(nofield_fields);
559 auto set_order = [&](
auto meshset,
auto dim,
auto &fields) {
561 for (
auto &field : fields) {
564 "Order for field not set %s", field.c_str());
583 "Glasgow we have a problem");
586 auto set_order = [&](
auto field,
auto &ents) {
590 for (
auto o = range.first;
o != range.second; ++
o) {
591 if (!
o->second.second.empty())
592 ents = intersect(ents,
o->second.second);
603 CHKERR set_order(field, ents);
611 CHKERR set_order(field, ents);
646 for (std::vector<std::string>::iterator fit =
otherFEs.begin();
692 const auto problem_name = problem_ptr->
getName();
751 const std::string col_field)
const {
762 ParallelComm *pcomm =
765 auto get_skin = [&](
auto meshset) {
771 CHKERR pcomm->filter_pstatus(domain_ents,
772 PSTATUS_SHARED | PSTATUS_MULTISHARED,
773 PSTATUS_NOT, -1,
nullptr);
777 CHKERR skin.find_skin(0, domain_ents,
false, domain_skin);
778 CHKERR pcomm->filter_pstatus(domain_skin,
779 PSTATUS_SHARED | PSTATUS_MULTISHARED,
780 PSTATUS_NOT, -1,
nullptr);
784 auto create_boundary_meshset = [&](
auto &&domain_skin) {
795 moab::Interface::UNION);
810 ParallelComm *pcomm =
813 auto create_skeleton_meshset = [&](
auto meshset) {
819 Range boundary_ents, skeleton_ents;
821 dIm - 1, boundary_ents);
826 domain_ents,
dIm - 1,
false, skeleton_ents, moab::Interface::UNION);
827 skeleton_ents = subtract(skeleton_ents, boundary_ents);
828 CHKERR pcomm->filter_pstatus(skeleton_ents, PSTATUS_NOT_OWNED, PSTATUS_NOT,
843 MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Exchange ghost cells";
845 ParallelComm *pcomm =
851 CHKERR m_field.
get_moab().get_entities_by_type(0, MBVERTEX, verts);
858 for (
auto d =
dIm - 1;
d >= 1; --
d) {
860 moab::Interface::UNION);
862 CHKERR pcomm->filter_pstatus(shared, PSTATUS_SHARED | PSTATUS_MULTISHARED,
863 PSTATUS_OR, -1, &shared);
864 Tag part_tag = pcomm->part_tag();
865 CHKERR pcomm->exchange_tags(part_tag, shared);
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
FieldApproximationBase
approximation base
@ AINSWORTH_BERNSTEIN_BEZIER_BASE
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
FieldSpace
approximation spaces
@ L2
field with C-1 continuity
@ NOFIELD
scalar or vector of scalars describe (no true field)
@ HCURL
field with continuous tangents
@ HDIV
field with continuous normal traction
#define MYPCOMM_INDEX
default communicator number PCOMM
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
@ MOFEM_OPERATION_UNSUCCESSFUL
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
PetscErrorCode DMMoFEMCreateMoFEM(DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[], const MoFEM::BitRefLevel bit_level, const MoFEM::BitRefLevel bit_mask=MoFEM::BitRefLevel().set())
Must be called by user to set MoFEM data structures.
PetscErrorCode DMMoFEMAddElement(DM dm, const char fe_name[])
add element to dm
PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr)
Get pointer to problem data structure.
PetscErrorCode DMSetUp_MoFEM(DM dm)
multi_index_container< boost::shared_ptr< SideNumber >, indexed_by< ordered_unique< member< SideNumber, EntityHandle, &SideNumber::ent > >, ordered_non_unique< composite_key< SideNumber, const_mem_fun< SideNumber, EntityType, &SideNumber::getEntType >, member< SideNumber, char, &SideNumber::side_number > > > > > SideNumber_multiIndex
SideNumber_multiIndex for SideNumber.
multi_index_container< boost::shared_ptr< FiniteElement >, indexed_by< hashed_unique< tag< FiniteElement_Meshset_mi_tag >, member< FiniteElement, EntityHandle, &FiniteElement::meshset > >, hashed_unique< tag< BitFEId_mi_tag >, const_mem_fun< FiniteElement, BitFEId, &FiniteElement::getId >, HashBit< BitFEId >, EqBit< BitFEId > >, ordered_unique< tag< FiniteElement_name_mi_tag >, const_mem_fun< FiniteElement, boost::string_ref, &FiniteElement::getNameRef > > > > FiniteElement_multiIndex
MultiIndex for entities for FiniteElement.
virtual const FiniteElement_multiIndex * get_finite_elements() const =0
Get the finite elements object.
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string &name_row)=0
set field row which finite element use
virtual MoFEMErrorCode add_ents_to_finite_element_by_dim(const EntityHandle entities, const int dim, const std::string &name, const bool recursive=true)=0
add entities to finite element
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
virtual MoFEMErrorCode modify_finite_element_adjacency_table(const std::string &fe_name, const EntityType type, ElementAdjacencyFunct function)=0
modify finite element table, only for advanced user
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string &name_filed)=0
set finite element field data
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string &name_row)=0
set field col which finite element use
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
virtual MoFEMErrorCode add_ents_to_field_by_dim(const Range &ents, const int dim, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
virtual MoFEMErrorCode set_field_order(const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)=0
Set order approximation of the entities in the field.
virtual MoFEMErrorCode get_field_entities_by_dimension(const std::string name, int dim, Range &ents) const =0
get entities in the field by dimension
virtual Field * get_field_structure(const std::string &name)=0
get field structure
#define MOFEM_LOG(channel, severity)
Log.
virtual MoFEMErrorCode modify_problem_mask_ref_level_set_bit(const std::string &name_problem, const BitRefLevel &bit)=0
set dof mask ref level for problem
virtual MoFEMErrorCode modify_problem_ref_level_set_bit(const std::string &name_problem, const BitRefLevel &bit)=0
set ref level for problem
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
const Tensor1_Expr< const dTensor0< T, Dim, i >, typename promote< T, double >::V, Dim, i > d(const Tensor0< T * > &a, const Index< i, Dim > index, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
int FieldCoefficientsNumber
Number of field coefficients.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
implementation of Data Operators for Forces and Sources
auto createSmartDM
Creates smart DM object.
PetscObject getPetscObject(T obj)
DeprecatedCoreInterface Interface
virtual int get_comm_size() const =0
virtual bool check_finite_element(const std::string &name) const =0
Check if finite element is in database.
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
virtual MoFEMErrorCode delete_finite_element(const std::string name, int verb=DEFAULT_VERBOSITY)=0
delete finite element from mofem database
virtual MoFEMErrorCode add_field(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add field.
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual MoFEMErrorCode rebuild_database(int verb=DEFAULT_VERBOSITY)=0
Clear database and initialize it once again.
virtual MoFEMErrorCode create_vertices_and_add_to_field(const std::string name, const double coords[], int size, int verb=DEFAULT_VERBOSITY)=0
Create a vertices and add to field object.
static MoFEMErrorCode defaultEdge(Interface &moab, const Field &field, const EntFiniteElement &fe, std::vector< EntityHandle > &adjacency)
static MoFEMErrorCode defaultFace(Interface &moab, const Field &field, const EntFiniteElement &fe, std::vector< EntityHandle > &adjacency)
Deprecated interface functions.
Finite element data for entity.
Provide data structure for (tensor) field approximation.
FieldApproximationBase getApproxBase() const
Get approximation base.
FieldSpace getSpace() const
Get field approximation space.
keeps basic data about problem
Problem manager is used to build and partition problems.
keeps information about side number for the finite element
Simple interface for fast problem set-up.
EntityHandle boundaryMeshset
meshset with boundary
MoFEMErrorCode buildProblem()
Build problem.
std::vector< std::string > dataFields
Data fields.
std::vector< std::string > domainFields
domain fields
MoFEMErrorCode removeDomainField(const std::string &name)
Remove field form domain.
MoFEMErrorCode defineFiniteElements()
Define finite elements.
char meshFileName[255]
mesh file name
EntityHandle meshSet
domain meshset
int getDim() const
Get the problem dimension.
std::vector< std::string > otherFEs
Other finite elements.
MoFEMErrorCode setSkeletonAdjacency()
MoFEMErrorCode buildFiniteElements()
Build finite elements.
MoFEMErrorCode addDataField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on domain.
MoFEMErrorCode exchangeGhostCells()
std::multimap< std::string, std::pair< int, Range > > fieldsOrder
fields order
PetscLogEvent MOFEM_EVENT_SimpleBuildFields
PetscLogEvent MOFEM_EVENT_SimpleLoadMesh
MoFEMErrorCode addDomainField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on domain.
std::vector< std::string > noFieldFields
NOFIELD field name.
bool addSkeletonFE
Add skeleton FE.
bool addBoundaryFE
Add boundary FE.
MoFEMErrorCode addFieldToEmptyFieldBlocks(const std::string row_field, const std::string col_field) const
add empty block to problem
std::string skeletonFE
skeleton finite element
std::vector< std::string > noFieldDataFields
NOFIELD field name.
std::string boundaryFE
boundary finite element
std::string nameOfProblem
problem name
SmartPetscObj< DM > getDM()
Return smart DM object.
MoFEMErrorCode getOptions()
get options
std::string domainFE
domain finite element
std::vector< std::string > boundaryFields
boundary fields
MoFEMErrorCode reSetUp()
Rebuild internal MoFEM data structures.
SmartPetscObj< DM > dM
Discrete manager (interface to PETSc/MoFEM functions)
MoFEMErrorCode buildFields()
Build fields.
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name)
Load mesh file.
BitRefLevel bitLevel
BitRefLevel of the probelm.
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
MoFEMErrorCode addBoundaryField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on boundary.
MoFEMErrorCode defineProblem(const PetscBool is_partitioned=PETSC_TRUE)
define problem
std::vector< std::string > skeletonFields
fields on the skeleton
MoFEMErrorCode addSkeletonField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on skeleton.
MoFEMErrorCode removeSkeletonField(const std::string &name)
Remove field form skeleton.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
MoFEMErrorCode removeBoundaryField(const std::string &name)
Remove field form boundary.
const std::string getProblemName() const
Get the Problem Name.
int dIm
dimension of problem
MoFEMErrorCode deleteDM()
Delete dm.
PetscLogEvent MOFEM_EVENT_SimpleSetUP
PetscLogEvent MOFEM_EVENT_SimpleKSPSolve
MoFEMErrorCode createBoundaryMeshset()
PetscLogEvent MOFEM_EVENT_SimpleBuildFiniteElements
BitRefLevel bitLevelMask
BitRefLevel of the probelm.
PetscLogEvent MOFEM_EVENT_SimpleBuildProblem
MoFEMErrorCode deleteFiniteElements()
Delete finite elements.
Simple(const MoFEM::Core &core)
EntityHandle skeletonMeshset
skeleton meshset with boundary
MoFEMErrorCode createSkeletonMeshset()
base class for all interface classes
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.