v0.9.0
Functions | Variables
field_to_vertices.cpp File Reference

Field to vertices. More...

#include <MoFEM.hpp>
#include <BasicFiniteElements.hpp>

Go to the source code of this file.

Functions

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

Variables

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

Detailed Description

Field to vertices.

Definition in file field_to_vertices.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)
Examples
field_to_vertices.cpp.

Definition at line 28 of file field_to_vertices.cpp.

28  {
29  MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
30 
31  try {
32 
33  // global variables
34  char mesh_file_name[255];
35  PetscBool flg_file = PETSC_FALSE;
36  char field_name_param[255] = "RHO";
37  CHKERR PetscOptionsBegin(PETSC_COMM_WORLD, "", "Field to vertices options", "none");
38  CHKERR PetscOptionsString("-my_file", "mesh file name", "", "mesh.h5m",
39  mesh_file_name, 255, &flg_file);
40  CHKERR PetscOptionsString("-my_field", "field name", "", "FIELD",
41  field_name_param, 255, PETSC_NULL);
42  ierr = PetscOptionsEnd(); CHKERRG(ierr);
43 
44  std::string field_name(field_name_param);
45 
46  moab::Core mb_instance;
47  moab::Interface &moab = mb_instance;
48  ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
49  if (pcomm == NULL)
50  pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
51  const char *option;
52  option = "";
53  CHKERR moab.load_file(mesh_file_name, 0, option);
54 
55  // Create MoFEM database
56  MoFEM::Core core(moab);
57  MoFEM::Interface &m_field = core;
58 
59  if (flg_file != PETSC_TRUE) {
60  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
61  "*** ERROR -my_file (MESH FILE NEEDED)");
62  }
63  BitRefLevel bit_level0;
64  bit_level0.set(0);
65  CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevelByDim(
66  0, 3, bit_level0);
67  CHKERR m_field.build_fields();
68 
69  bool field_flg = false;
70  const Field_multiIndex *fields_ptr;
71  CHKERR m_field.get_fields(&fields_ptr);
72  for(auto field : (*fields_ptr)) {
73  bool check_space = field->getSpace() == H1;
74  if(field->getName() == field_name && check_space) field_flg = true;
75  }
76  if (!field_flg) {
77  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
78  "*** ERROR -my_field (FIELD (in H1 space) is NOT FOUND)");
79  }
80 
81 
82  SaveVertexDofOnTag ent_method(m_field, field_name.c_str());
83 
84  CHKERR m_field.loop_dofs(field_name.c_str(),ent_method);
85  PetscPrintf(PETSC_COMM_WORLD, "\nDone. Saving files... \n");
86 
87  //TODO: Higher order field mapping
88  CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByType(
89  bit_level0, BitRefLevel().set(), MBTET, "out_mesh.vtk", "VTK", "");
90  CHKERR moab.write_file("out.h5m");
91  }
93 
95 
96  return 0;
97 }
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:548
multi_index_container< boost::shared_ptr< Field >, indexed_by< hashed_unique< tag< BitFieldId_mi_tag >, const_mem_fun< Field, const BitFieldId &, &Field::getId >, HashBit< BitFieldId >, EqBit< BitFieldId > >, ordered_unique< tag< Meshset_mi_tag >, member< Field, EntityHandle, &Field::meshSet > >, ordered_unique< tag< FieldName_mi_tag >, const_mem_fun< Field, boost::string_ref, &Field::getNameRef > >, ordered_non_unique< tag< BitFieldId_space_mi_tag >, const_mem_fun< Field, FieldSpace, &Field::getSpace > > > > Field_multiIndex
Field_multiIndex for Field.
Core (interface) class.
Definition: Core.hpp:50
Save field DOFS on vertices/tags.
static char help[]
char mesh_file_name[255]
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:51
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
Managing BitRefLevels.
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
#define CHKERR
Inline error check.
Definition: definitions.h:600
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:289
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:437
continuous field
Definition: definitions.h:175
virtual MoFEMErrorCode get_fields(const Field_multiIndex **fields_ptr) const =0
Get fields multi-index from database.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:61

Variable Documentation

◆ help

char help[] = "...\n\n"
static
Examples
field_to_vertices.cpp.

Definition at line 26 of file field_to_vertices.cpp.