v0.14.0
Loading...
Searching...
No Matches
Functions | Variables
reading_med_file.cpp File Reference

Testing interface for reading and writing med files. More...

#include <MoFEM.hpp>

Go to the source code of this file.

Functions

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

Variables

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

Detailed Description

Testing interface for reading and writing med files.

Definition in file reading_med_file.cpp.

Function Documentation

◆ main()

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

Definition at line 14 of file reading_med_file.cpp.

14 {
15
16 MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
17
18 try {
19
20 moab::Core mb_instance;
21 moab::Interface &moab = mb_instance;
22
23 // Create MoFEM (Joseph) database
24 MoFEM::Core core(moab);
25 MoFEM::Interface &m_field = core;
26
27 MedInterface *med_interface_ptr;
28 CHKERR m_field.getInterface(med_interface_ptr);
29
30 CHKERR med_interface_ptr->readMed();
31 CHKERR med_interface_ptr->medGetFieldNames();
32
33 // read field tags
34 for (std::map<std::string, MedInterface::FieldData>::iterator fit =
35 med_interface_ptr->fieldNames.begin();
36 fit != med_interface_ptr->fieldNames.end(); fit++) {
37 CHKERR med_interface_ptr->readFields(med_interface_ptr->medFileName,
38 fit->first, false, 1);
39 }
40
41 PetscBool check = PETSC_TRUE;
42 CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-check", &check, PETSC_NULL);
43
44 int ii = 0;
45 const int check_list[] = {2163, 624, 65, 104};
47 EntityHandle meshset = cit->getMeshset();
48 int nb_ents;
49 CHKERR moab.get_number_entities_by_handle(meshset, nb_ents, true);
50 CHKERR PetscPrintf(PETSC_COMM_WORLD, "Nb of ents in %s %d\n",
51 cit->getName().c_str(), nb_ents);
53 if (check && nb_ents != check_list[ii]) {
54 SETERRQ2(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
55 "Wrong numbers of entities in meshset %d != %d", nb_ents,
56 check_list[ii]);
57 }
58 ii++;
59 }
60
61 MeshsetsManager *meshset_manager_ptr;
62 CHKERR m_field.getInterface(meshset_manager_ptr);
63 for (_IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_((*meshset_manager_ptr),
64 BLOCKSET, mit)) {
65 EntityHandle meshset = mit->getMeshset();
66 std::string name = mit->getName();
67 PetscPrintf(m_field.get_comm(), "Write mesh %s\n", name.c_str());
68 CHKERR moab.write_file(("out_" + mit->getName() + ".vtk").c_str(), NULL,
69 NULL, &meshset, 1);
70 }
71 }
73
75
76 return 0;
77}
#define CATCH_ERRORS
Catch errors.
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
@ BLOCKSET
@ MOFEM_ATOM_TEST_INVALID
Definition definitions.h:40
#define CHKERR
Inline error check.
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
static char help[]
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
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:112
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 getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.

Variable Documentation

◆ help

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

Definition at line 12 of file reading_med_file.cpp.