v0.14.0
remove_mofem_meshsets.cpp
Go to the documentation of this file.
1 /** \file field_to_vertices.cpp
2  \brief Field to vertices
3  \example field_to_vertices.cpp
4 
5 */
6 
7 
8 
9 #include <MoFEM.hpp>
10 #include <BasicFiniteElements.hpp>
11 
12 using namespace MoFEM;
13 
14 static char help[] = "...\n\n";
15 
16 int main(int argc, char *argv[]) {
17  MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
18 
19  try {
20 
21  // global variables
22  char mesh_file_name[255];
23  PetscBool flg_file = PETSC_FALSE;
24  char mesh_out_file[255] = "out.h5m";
25 
26  CHKERR PetscOptionsBegin(PETSC_COMM_WORLD, "", "Field to vertices options",
27  "none");
28  CHKERR PetscOptionsString("-file_name", "mesh file name", "", "mesh.h5m",
29  mesh_file_name, 255, &flg_file);
30  CHKERR PetscOptionsString("-output_file", "output mesh file name", "",
31  "out.h5m", mesh_out_file, 255, PETSC_NULL);
32 
33  ierr = PetscOptionsEnd(); CHKERRG(ierr);
34 
35  moab::Core mb_instance;
36  moab::Interface &moab = mb_instance;
37  ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
38  if (pcomm == NULL)
39  pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
40  const char *option;
41  option = "";
42  CHKERR moab.load_file(mesh_file_name, 0, option);
43 
44  // Create MoFEM database
45  MoFEM::Core core(moab);
46  MoFEM::Interface &m_field = core;
47 
48  // Add logging channel for example
49  auto core_log = logging::core::get();
50  core_log->add_sink(
52  LogManager::setLog("REMOVER");
53  MOFEM_LOG_TAG("REMOVER", "remover");
54 
55  auto prb_ptr = m_field.get_problems();
56  std::vector<std::string> prb_list;
57  for(auto &it : *prb_ptr)
58  prb_list.push_back(it.getName());
59 
60  for (auto &it : prb_list) {
61  MOFEM_LOG("REMOVER", Sev::inform) << "Delete problem " << it;
62  CHKERR m_field.delete_problem(it);
63  }
64 
65  auto fe_ptr = m_field.get_finite_elements();
66  std::vector<std::string> fe_list;
67  for (auto &it : *fe_ptr)
68  fe_list.push_back(it->getName());
69 
70  for (auto &it : fe_list) {
71  MOFEM_LOG("REMOVER", Sev::inform)
72  << "Delete finite element " << it;
73  CHKERR m_field.delete_finite_element(it);
74  }
75 
76  auto field_ptr = m_field.get_fields();
77  std::vector<std::string> field_list;
78  for (auto &it : *field_ptr)
79  field_list.push_back(it->getName());
80 
81  for (auto &it : field_list) {
82  MOFEM_LOG("REMOVER", Sev::inform) << "Delete field " << it;
83  CHKERR m_field.delete_field(it);
84  }
85 
86  CHKERR moab.write_file(mesh_out_file);
87 
88  }
90 
92 
93  return 0;
94 }
MYPCOMM_INDEX
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:215
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MoFEM.hpp
BasicFiniteElements.hpp
MoFEM::CoreInterface::get_finite_elements
virtual const FiniteElement_multiIndex * get_finite_elements() const =0
Get the finite elements object.
MoFEM::CoreTmp< 0 >::Finalize
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
MoFEM::LogManager::createSink
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
Definition: LogManager.cpp:298
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1975
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
help
static char help[]
Definition: remove_mofem_meshsets.cpp:14
MoFEM::CoreInterface::delete_field
virtual MoFEMErrorCode delete_field(const std::string name, int verb=DEFAULT_VERBOSITY)=0
Delete field.
MoFEM::LogManager::getStrmWorld
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Definition: LogManager.cpp:344
MoFEM::CoreInterface::delete_finite_element
virtual MoFEMErrorCode delete_finite_element(const std::string name, int verb=DEFAULT_VERBOSITY)=0
delete finite element from mofem database
MOFEM_LOG_TAG
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:339
MoFEM::CoreInterface::get_problems
virtual const Problem_multiIndex * get_problems() const =0
Get the problems object.
mesh_file_name
char mesh_file_name[255]
Definition: mesh_smoothing.cpp:23
MoFEM::CoreInterface::get_fields
virtual const Field_multiIndex * get_fields() const =0
Get the fields object.
MoFEM::CoreTmp< 0 >::Initialize
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
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1094
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
MoFEM::LogManager::setLog
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
Definition: LogManager.cpp:389
MoFEM::CoreInterface::delete_problem
virtual MoFEMErrorCode delete_problem(const std::string name)=0
Delete problem.
CHKERRG
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
main
int main(int argc, char *argv[])
Definition: remove_mofem_meshsets.cpp:16