v0.15.0
Loading...
Searching...
No Matches
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 14 of file read_med.cpp.

14 {
15 MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
16
17 try {
18
19 moab::Core mb_instance;
20 moab::Interface &moab = mb_instance;
21 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
22 if (pcomm == NULL)
23 pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
24
25 // Create MoFEM database
26 MoFEM::Core core(moab);
27 MoFEM::Interface &m_field = core;
28
29 char mesh_out_file[255] = "out.h5m";
30
31 int time_step = 0;
32 PetscOptionsBegin(m_field.get_comm(), "", "Read MED tool", "none");
33 CHKERR PetscOptionsInt("-med_time_step", "time step", "", time_step,
34 &time_step, PETSC_NULLPTR);
35 CHKERR PetscOptionsString("-output_file", "output mesh file name", "",
36 "out.h5m", mesh_out_file, 255, PETSC_NULLPTR);
37 PetscOptionsEnd();
38
39 MedInterface *med_interface_ptr;
40 CHKERR m_field.getInterface(med_interface_ptr);
41 CHKERR med_interface_ptr->readMed();
42 CHKERR med_interface_ptr->medGetFieldNames();
43
44 for (std::map<std::string, MedInterface::FieldData>::iterator fit =
45 med_interface_ptr->fieldNames.begin();
46 fit != med_interface_ptr->fieldNames.end(); fit++) {
47 CHKERR med_interface_ptr->readFields(med_interface_ptr->medFileName,
48 fit->first, false, time_step);
49 }
50
51 // Add meshsets if config file provided
52 MeshsetsManager *meshsets_interface_ptr;
53 CHKERR m_field.getInterface(meshsets_interface_ptr);
54 CHKERR meshsets_interface_ptr->setMeshsetFromFile();
55
56 MOFEM_LOG_CHANNEL("WORLD");
57 MOFEM_LOG_TAG("WORLD", "read_med")
58 MOFEM_LOG("WORLD", Sev::inform)
59 << "Print all meshsets (old and added from meshsets "
60 "configurational file)";
61 for (auto cit = meshsets_interface_ptr->getBegin();
62 cit != meshsets_interface_ptr->getEnd(); cit++)
63 MOFEM_LOG("WORLD", Sev::inform) << *cit;
64
65 CHKERR moab.write_file(mesh_out_file);
66 }
68
69 MoFEM::Core::Finalize();
70
71 return 0;
72}
#define CATCH_ERRORS
Catch errors.
#define MYPCOMM_INDEX
default communicator number PCOMM
#define CHKERR
Inline error check.
#define MOFEM_LOG(channel, severity)
Log.
SeverityLevel
Severity levels.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
static char help[]
Definition read_med.cpp:12
virtual MPI_Comm & get_comm() const =0
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
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 reference to pointer of interface.

Variable Documentation

◆ help

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

Definition at line 12 of file read_med.cpp.