v0.10.0
build_large_problem.cpp

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
*/
/* This file is part of MoFEM.
* MoFEM is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* MoFEM is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with MoFEM. If not, see <http://www.gnu.org/licenses/>. */
#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",
ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
if (pcomm == NULL)
pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
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;
}