v0.13.0
Functions | Variables
read_med.cpp File Reference
#include <MoFEM.hpp>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Variables

static char help [] = "...\n\n"
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 26 of file read_med.cpp.

26  {
27  MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
28 
29  try {
30 
31  moab::Core mb_instance;
32  moab::Interface &moab = mb_instance;
33  ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
34  if (pcomm == NULL)
35  pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
36 
37  // Create MoFEM database
38  MoFEM::Core core(moab);
39  MoFEM::Interface &m_field = core;
40 
41  char mesh_out_file[255] = "out.h5m";
42 
43  int time_step = 0;
44  CHKERR PetscOptionsBegin(m_field.get_comm(), "", "Read MED tool", "none");
45  CHKERR PetscOptionsInt("-med_time_step", "time step", "", time_step,
46  &time_step, PETSC_NULL);
47  CHKERR PetscOptionsString("-output_file", "output mesh file name", "",
48  "out.h5m", mesh_out_file, 255, PETSC_NULL);
49  ierr = PetscOptionsEnd();
50  CHKERRQ(ierr);
51 
52  MedInterface *med_interface_ptr;
53  CHKERR m_field.getInterface(med_interface_ptr);
54  CHKERR med_interface_ptr->readMed();
55  CHKERR med_interface_ptr->medGetFieldNames();
56 
57  for (std::map<std::string, MedInterface::FieldData>::iterator fit =
58  med_interface_ptr->fieldNames.begin();
59  fit != med_interface_ptr->fieldNames.end(); fit++) {
60  CHKERR med_interface_ptr->readFields(med_interface_ptr->medFileName,
61  fit->first, false, time_step);
62  }
63 
64  // Add meshsets if config file provided
65  MeshsetsManager *meshsets_interface_ptr;
66  CHKERR m_field.getInterface(meshsets_interface_ptr);
67  CHKERR meshsets_interface_ptr->setMeshsetFromFile();
68 
69  MOFEM_LOG_CHANNEL("WORLD");
70  MOFEM_LOG_TAG("WORLD", "read_med")
71  MOFEM_LOG("WORLD", Sev::inform)
72  << "Print all meshsets (old and added from meshsets "
73  "configurational file";
74  for (auto cit = meshsets_interface_ptr->getBegin();
75  cit != meshsets_interface_ptr->getEnd(); cit++)
76  MOFEM_LOG("WORLD", Sev::inform) << *cit;
77 
78  CHKERR moab.write_file(mesh_out_file);
79  }
81 
82  MoFEM::Core::Finalize();
83 
84  return 0;
85 }
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:385
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:228
#define CHKERR
Inline error check.
Definition: definitions.h:548
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:311
SeverityLevel
Severity levels.
Definition: LogManager.hpp:43
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:342
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:287
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:87
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
CoreTmp< 0 > Core
Definition: Core.hpp:1096
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1965
static char help[]
Definition: read_med.cpp:24
virtual MPI_Comm & get_comm() const =0
Core (interface) class.
Definition: Core.hpp:92
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:85
Deprecated interface functions.
Interface for load MED files.
MoFEMErrorCode readMed(const string &file, int verb=1)
read MED file
std::map< std::string, FieldData > fieldNames
std::string medFileName
MED file name.
MoFEMErrorCode readFields(const std::string &file_name, const std::string &field_name, const bool load_series=false, const int only_step=-1, int verb=1)
MoFEMErrorCode medGetFieldNames(const string &file, int verb=1)
Get field names in MED file.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode setMeshsetFromFile(const string file_name, const bool clean_file_options=true)
add blocksets reading config file
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.

Variable Documentation

◆ help

char help[] = "...\n\n"
static

Definition at line 24 of file read_med.cpp.