v0.15.0
Loading...
Searching...
No Matches
mofem/tools/remove_mofem_meshsets.cpp
/** \file field_to_vertices.cpp
\brief Field to vertices
\example mofem/tools/remove_mofem_meshsets.cpp
*/
#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 {
// global variables
char mesh_file_name[255];
PetscBool flg_file = PETSC_FALSE;
char mesh_out_file[255] = "out.h5m";
PetscOptionsBegin(PETSC_COMM_WORLD, "", "Field to vertices options",
"none");
CHKERR PetscOptionsString("-file_name", "mesh file name", "", "mesh.h5m",
mesh_file_name, 255, &flg_file);
CHKERR PetscOptionsString("-output_file", "output mesh file name", "",
"out.h5m", mesh_out_file, 255, PETSC_NULLPTR);
PetscOptionsEnd();
moab::Core mb_instance;
moab::Interface &moab = mb_instance;
ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
if (pcomm == NULL)
pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
const char *option;
option = "";
CHKERR moab.load_file(mesh_file_name, 0, option);
// Create MoFEM database
MoFEM::Core core(moab);
MoFEM::Interface &m_field = core;
// Add logging channel for example
auto core_log = logging::core::get();
core_log->add_sink(
LogManager::createSink(LogManager::getStrmWorld(), "REMOVER"));
LogManager::setLog("REMOVER");
MOFEM_LOG_TAG("REMOVER", "remover");
auto prb_ptr = m_field.get_problems();
std::vector<std::string> prb_list;
for(auto &it : *prb_ptr)
prb_list.push_back(it.getName());
for (auto &it : prb_list) {
MOFEM_LOG("REMOVER", Sev::inform) << "Delete problem " << it;
CHKERR m_field.delete_problem(it);
}
auto fe_ptr = m_field.get_finite_elements();
std::vector<std::string> fe_list;
for (auto &it : *fe_ptr)
fe_list.push_back(it->getName());
for (auto &it : fe_list) {
MOFEM_LOG("REMOVER", Sev::inform)
<< "Delete finite element " << it;
}
auto field_ptr = m_field.get_fields();
std::vector<std::string> field_list;
for (auto &it : *field_ptr)
field_list.push_back(it->getName());
for (auto &it : field_list) {
MOFEM_LOG("REMOVER", Sev::inform) << "Delete field " << it;
CHKERR m_field.delete_field(it);
}
CHKERR moab.write_file(mesh_out_file);
}
return 0;
}
static char help[]
int main()
#define CATCH_ERRORS
Catch errors.
#define MYPCOMM_INDEX
default communicator number PCOMM
#define CHKERR
Inline error check.
virtual const FiniteElement_multiIndex * get_finite_elements() const =0
Get the finite elements object.
virtual const Problem_multiIndex * get_problems() const =0
Get the problems object.
virtual const Field_multiIndex * get_fields() const =0
Get the fields object.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
virtual MoFEMErrorCode delete_problem(const std::string name)=0
Delete problem.
char mesh_file_name[255]
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
virtual MoFEMErrorCode delete_finite_element(const std::string name, int verb=DEFAULT_VERBOSITY)=0
Delete finite element from MoFEM database.
virtual MoFEMErrorCode delete_field(const std::string name, int verb=DEFAULT_VERBOSITY)=0
Delete 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:118
Deprecated interface functions.