v0.13.1
Loading...
Searching...
No Matches
build_large_problem.cpp

Atom test for building problems.

Atom test for building problems

Bug:
Not verifying what if partitioned mesh is loaded.
/** \file build_problems.cpp
\example build_problems.cpp
\brief atom test build problem
*/
#include <MoFEM.hpp>
using namespace MoFEM;
static char help[] = "...\n\n";
int main(int argc, char *argv[]) {
MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
try {
moab::Core mb_instance;
moab::Interface &moab = mb_instance;
int rank;
MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
PetscBool flg = PETSC_TRUE;
char mesh_file_name[255];
#if PETSC_VERSION_GE(3, 6, 4)
CHKERR PetscOptionsGetString(PETSC_NULL, "", "-my_file", mesh_file_name,
255, &flg);
#else
CHKERR PetscOptionsGetString(PETSC_NULL, PETSC_NULL, "-my_file",
mesh_file_name, 255, &flg);
#endif
if (flg != PETSC_TRUE)
SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_FOUND, "file not found -my_file %s",
CHKERR moab.load_file(mesh_file_name, 0, "");
// Create MoFEM database
MoFEM::Core core(moab);
MoFEM::Interface &m_field = core;
// set entities bit level
CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevelByDim(
0, 3, BitRefLevel().set(0));
// fields
MB_TAG_DENSE);
// meshset consisting all entities in mesh
EntityHandle root_set = moab.get_root_set();
// add entities to field
CHKERR m_field.add_ents_to_field_by_type(root_set, MBVERTEX, "F1");
CHKERR m_field.add_ents_to_field_by_type(root_set, MBEDGE, "F1");
CHKERR m_field.add_ents_to_field_by_type(root_set, MBTRI, "F1");
CHKERR m_field.add_ents_to_field_by_type(root_set, MBTET, "F1");
// set app. order
constexpr int order = 3;
CHKERR m_field.set_field_order(root_set, MBVERTEX, "F1", 1);
CHKERR m_field.set_field_order(root_set, MBEDGE, "F1", order);
CHKERR m_field.set_field_order(root_set, MBTRI, "F1", order);
CHKERR m_field.set_field_order(root_set, MBTET, "F1", order);
CHKERR m_field.build_fields();
// add elements
CHKERR m_field.add_finite_element("E1");
CHKERR m_field.add_ents_to_finite_element_by_type(root_set, MBTET, "E1");
// Problems
CHKERR m_field.add_problem("P1");
// build problems
auto prb_mng_ptr = m_field.getInterface<ProblemsManager>();
CHKERR m_field.getInterface(prb_mng_ptr);
CHKERR prb_mng_ptr->buildProblem("P1", true);
CHKERR prb_mng_ptr->partitionProblem("P1");
CHKERR prb_mng_ptr->partitionFiniteElements("P1");
CHKERR prb_mng_ptr->partitionGhostDofs("P1");
MOFEM_LOG("WORLD", Sev::inform) << "Create matrix";
->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>("P1", A);
MOFEM_LOG("WORLD", Sev::inform) << "Done";
auto fe_ptr = boost::make_shared<FEMethod>();
auto pre_proc_hook = [&]() {
};
auto post_proc_hook = [&]() {
};
auto op_hook = [&]() {
MOFEM_LOG("WORLD", Sev::verbose)
<< "Iterate finite element " << *(fe_ptr->numeredEntFiniteElementPtr);
auto row_dofs = fe_ptr->getRowDofsPtr();
for (auto &dof : *row_dofs)
MOFEM_LOG("WORLD", Sev::noisy) << *dof << endl;
};
fe_ptr->preProcessHook = pre_proc_hook;
fe_ptr->postProcessHook = post_proc_hook;
fe_ptr->operatorHook = op_hook;
MOFEM_LOG("WORLD", Sev::inform) << "Iterate finite elements";
CHKERR m_field.loop_finite_elements("P1", "E1", *fe_ptr);
MOFEM_LOG("WORLD", Sev::inform) << "Done";
auto vol_ptr = boost::make_shared<Vol>(m_field);
struct Op : public VolOp {
Op() : VolOp("F1", VolOp::OPROWCOL, true) {}
MoFEMErrorCode doWork(int row_side, int col_side, EntityType row_type,
EntityType col_type, EntData &row_data,
EntData &col_data) {
return 0;
};
};
vol_ptr->getOpPtrVector().push_back(new Op());
MOFEM_LOG("WORLD", Sev::inform) << "Iterate volume finite elements";
CHKERR m_field.loop_finite_elements("P1", "E1", *vol_ptr);
MOFEM_LOG("WORLD", Sev::inform) << "Done";
}
// finish work cleaning memory, getting statistics, etc.
return 0;
}
static char help[]
int main()
Definition: adol-c_atom.cpp:46
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
@ H1
continuous field
Definition: definitions.h:85
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ MOFEM_NOT_FOUND
Definition: definitions.h:33
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
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_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 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_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 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.
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:301
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:277
virtual MoFEMErrorCode loop_finite_elements(const std::string &problem_name, const std::string &fe_name, FEMethod &method, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)=0
Make a loop over finite elements.
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
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
char mesh_file_name[255]
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
constexpr AssemblyType A
Definition: plastic.cpp:46
Managing BitRefLevels.
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.
Core (interface) class.
Definition: Core.hpp:82
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:72
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
@ OPROWCOL
operator doWork is executed on FE rows &columns
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 refernce to pointer of interface.
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
VolEle::UserDataOperator VolOp