v0.9.0
remove_entities_from_problem.cpp

Remove field entities from the problem

/** \file remove_entities_from_problem.cpp
\example remove_entities_from_problem.cpp
\brief Remove field entities from the 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)
SETERRQ(PETSC_COMM_WORLD, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
if (pcomm == NULL)
pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
const char *option;
option = "PARALLEL=BCAST_DELETE;PARALLEL_RESOLVE_SHARED_ENTS;PARTITION="
"PARALLEL_PARTITION;";
CHKERR moab.load_file(mesh_file_name, 0, option);
// Create MoFEM database
MoFEM::Core core(moab);
MoFEM::Interface &m_field = core;
// set entities bit level
const auto bit_level = BitRefLevel().set(0);
CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevelByDim(
0, 3, bit_level);
// Fields
// 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, MBTET, "F1");
CHKERR m_field.add_ents_to_field_by_type(root_set, MBTET, "F2");
// set app. order
// see Hierarchic Finite Element Bases on Unstructured Tetrahedral Meshes
// (Mark Ainsworth & Joe Coyle)
int order = 2;
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.set_field_order(root_set, MBTET, "F2", order);
CHKERR m_field.set_field_order(root_set, MBTRI, "F2", 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");
CHKERR m_field.build_adjacencies(bit_level);
// Problems
CHKERR m_field.add_problem("P1");
// set refinement level for problem
CHKERR m_field.modify_problem_ref_level_add_bit("P1", bit_level);
// build problems
ProblemsManager *prb_mng_ptr;
CHKERR m_field.getInterface(prb_mng_ptr);
CHKERR prb_mng_ptr->buildProblemOnDistributedMesh("P1", true);
CHKERR prb_mng_ptr->partitionFiniteElements("P1");
CHKERR prb_mng_ptr->partitionGhostDofs("P1");
auto get_triangles_on_skin = [&](Range &tets_skin) {
Range tets;
CHKERR m_field.get_moab().get_entities_by_type(root_set, MBTET, tets);
Range tets_skin_part;
Skinner skin(&m_field.get_moab());
CHKERR skin.find_skin(0, tets, false, tets_skin_part);
CHKERR pcomm->filter_pstatus(tets_skin_part,
PSTATUS_SHARED | PSTATUS_MULTISHARED,
PSTATUS_NOT, -1, &tets_skin);
};
Range tets_skin;
CHKERR get_triangles_on_skin(tets_skin);
CHKERR prb_mng_ptr->removeDofsOnEntities("P1", "F1", tets_skin, 0, 1, NOISY,
true);
->checkMPIAIJWithArraysMatrixFillIn<PetscGlobalIdx_mi_tag>("P1", -2, -2,
0);
}
// finish work cleaning memory, getting statistics, etc.
return 0;
}