Atom test for building composite problems.
static char help[] =
"...\n\n";
int main(
int argc,
char *argv[]) {
try {
PetscBool flg = PETSC_TRUE;
#if PETSC_VERSION_GE(3, 6, 4)
255, &flg);
#else
CHKERR PetscOptionsGetString(PETSC_NULLPTR, PETSC_NULLPTR,
"-my_file",
#endif
if (flg != PETSC_TRUE) {
SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
}
moab::Core mb_instance;
moab::Interface &moab = mb_instance;
const char *option;
option = "";
CHKERR moab.get_entities_by_type(root_set, MBTET, tets,
false);
CHKERR moab.create_meshset(MESHSET_SET, part_set);
ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
if (pcomm == NULL)
"Communicator should be allocated");
Tag part_tag = pcomm->part_tag();
0, MBENTITYSET, &part_tag, NULL, 1, tagged_sets,
moab::Interface::UNION);
for (Range::iterator mit = tagged_sets.begin(); mit != tagged_sets.end();
mit++) {
int part;
CHKERR moab.tag_get_data(part_tag, &*mit, 1, &part);
CHKERR moab.get_entities_by_type(*mit, MBTET, proc_ents,
true);
CHKERR moab.add_entities(part_set, proc_ents);
}
}
CHKERR skin.find_skin(0, tets,
false, tets_skin);
proc_ents_skin[3] = proc_ents;
CHKERR skin.find_skin(0, proc_ents,
false, proc_ents_skin[2]);
proc_ents_skin[2] = subtract(proc_ents_skin[2], tets_skin);
CHKERR moab.get_adjacencies(proc_ents_skin[2], 1,
false, proc_ents_skin[1],
moab::Interface::UNION);
CHKERR moab.get_connectivity(proc_ents_skin[1], proc_ents_skin[0],
true);
for (int dd = 0; dd != 3; dd++) {
CHKERR moab.add_entities(part_set, proc_ents_skin[dd]);
}
if (0) {
std::ostringstream file_skin;
CHKERR moab.create_meshset(MESHSET_SET, meshset_skin);
CHKERR moab.add_entities(meshset_skin, proc_ents_skin[2]);
CHKERR moab.add_entities(meshset_skin, proc_ents_skin[1]);
CHKERR moab.add_entities(meshset_skin, proc_ents_skin[0]);
CHKERR moab.write_file(file_skin.str().c_str(),
"VTK",
"", &meshset_skin,
1);
}
CHKERR pcomm->resolve_shared_ents(0, proc_ents, 3, -1, proc_ents_skin);
Range owned_tets = proc_ents;
if (0) {
std::ostringstream file_owned;
CHKERR moab.create_meshset(MESHSET_SET, meshset_owned);
CHKERR moab.add_entities(meshset_owned, owned_tets);
CHKERR moab.write_file(file_owned.str().c_str(),
"VTK",
"",
&meshset_owned, 1);
}
CHKERR pcomm->get_shared_entities(-1, shared_ents);
if (0) {
std::ostringstream file_shared_owned;
file_shared_owned <<
"out_shared_owned_" << m_field.
get_comm_rank()
<< ".vtk";
CHKERR moab.create_meshset(MESHSET_SET, meshset_shared_owned);
CHKERR moab.add_entities(meshset_shared_owned, shared_ents);
CHKERR moab.write_file(file_shared_owned.str().c_str(),
"VTK",
"",
&meshset_shared_owned, 1);
}
bit_level0.set(0);
part_set, 3, bit_level0);
if (0) {
->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(
"P1",
m);
MatView(
m, PETSC_VIEWER_DRAW_WORLD);
std::string wait;
std::cin >> wait;
}
->checkMPIAIJWithArraysMatrixFillIn<PetscGlobalIdx_mi_tag>("P1", -1, -1,
1);
->checkMPIAIJWithArraysMatrixFillIn<PetscGlobalIdx_mi_tag>("P2", -1, -1,
1);
DMType dm_name = "MOFEM";
CHKERR DMRegister_MoFEM(dm_name);
auto dm = createDM(m_field.
get_comm(), dm_name);
CHKERR DMMoFEMCreateMoFEM(dm, &m_field,
"COMP", bit_level0);
CHKERR DMMoFEMSetIsPartitioned(dm, PETSC_TRUE);
CHKERR DMMoFEMAddElement(dm,
"E1");
CHKERR DMMoFEMAddElement(dm,
"E2");
CHKERR DMMoFEMAddRowCompositeProblem(dm,
"P1");
CHKERR DMMoFEMAddRowCompositeProblem(dm,
"P2");
if (0) {
->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(
"COMP",
m);
MatView(
m, PETSC_VIEWER_DRAW_WORLD);
std::string wait;
std::cin >> wait;
}
->checkMPIAIJWithArraysMatrixFillIn<PetscGlobalIdx_mi_tag>("COMP", -1,
-1, 1);
}
return 0;
}
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MYPCOMM_INDEX
default communicator number PCOMM
@ MOFEM_DATA_INCONSISTENCY
#define CHKERR
Inline error check.
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_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string name, const bool recursive=true)=0
add entities to finite element
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 build_fields(int verb=DEFAULT_VERBOSITY)=0
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 add_ents_to_field_by_type(const Range &ents, const EntityType type, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
MoFEMErrorCode buildProblemOnDistributedMesh(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures, assuming that mesh is distributed (collective)
MoFEMErrorCode partitionGhostDofs(const std::string name, int verb=VERBOSE)
determine ghost nodes
MoFEMErrorCode partitionMesh(const Range &ents, const int dim, const int adj_dim, const int n_parts, Tag *th_vertex_weights=nullptr, Tag *th_edge_weights=nullptr, Tag *th_part_weights=nullptr, int verb=VERBOSE, const bool debug=false)
Set partition tag to each finite element in the problem.
MoFEMErrorCode partitionFiniteElements(const std::string name, bool part_from_moab=false, int low_proc=-1, int hi_proc=-1, int verb=VERBOSE)
partition finite elements
virtual MoFEMErrorCode add_problem(const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add problem.
virtual MoFEMErrorCode modify_problem_ref_level_add_bit(const std::string &name_problem, const BitRefLevel &bit)=0
add ref level to problem
virtual MoFEMErrorCode modify_problem_add_finite_element(const std::string name_problem, const std::string &fe_name)=0
add finite element to problem, this add entities assigned to finite element to a particular problem
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
FTensor::Index< 'm', 3 > m
virtual int get_comm_size() const =0
virtual moab::Interface & get_moab()=0
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
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 MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
Matrix manager is used to build and partition problems.
Problem manager is used to build and partition problems.
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.