v0.14.0
Functions | Variables
cubit_bc_test.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 []
 

Function Documentation

◆ main()

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

Definition at line 15 of file cubit_bc_test.cpp.

15  {
16 
17  MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
18 
19  try {
20 
21  moab::Core mb_instance;
22  moab::Interface &moab = mb_instance;
23  int rank;
24  MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
25 
26  // Read parameters from line command
27  PetscBool flg = PETSC_TRUE;
28  char mesh_file_name[255];
29 #if PETSC_VERSION_GE(3, 6, 4)
30  CHKERR PetscOptionsGetString(PETSC_NULL, "", "-my_file", mesh_file_name,
31  255, &flg);
32 #else
33  CHKERR PetscOptionsGetString(PETSC_NULL, PETSC_NULL, "-my_file",
34  mesh_file_name, 255, &flg);
35 #endif
36  if (flg != PETSC_TRUE) {
37  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
38  "*** ERROR -my_file (MESH FILE NEEDED)");
39  }
40 
41  // Read mesh to MOAB
42  const char *option;
43  option = ""; //"PARALLEL=BCAST;";//;DEBUG_IO";
44  CHKERR moab.load_file(mesh_file_name, 0, option);
45 
46  // Create MoFEM (Joseph) database
47  MoFEM::Core core(moab);
48  MoFEM::Interface &m_field = core;
49 
50  // Open mesh_file_name.txt for writing
51  std::ofstream myfile;
52  myfile.open((std::string(mesh_file_name) + ".txt").c_str());
53 
54  std::cout << "<<<< NODESETs >>>>>" << std::endl;
55  // NODESETs
57  std::cout << *it << std::endl;
58  CHKERR it->printBcData(std::cout);
59  std::vector<char> bc_data;
60  CHKERR it->getBcData(bc_data);
61  if (bc_data.empty())
62  continue;
63 
64  // Displacement
65  if (strcmp(&bc_data[0], "Displacement") == 0) {
67  CHKERR it->getBcDataStructure(mydata);
68  // Print data
69  std::cout << mydata;
70  myfile << mydata;
71  }
72 
73  // Force
74  else if (strcmp(&bc_data[0], "Force") == 0) {
75  ForceCubitBcData mydata;
76  CHKERR it->getBcDataStructure(mydata);
77  // Print data
78  std::cout << mydata;
79  myfile << mydata;
80  }
81 
82  // Velocity
83  else if (strcmp(&bc_data[0], "Velocity") == 0) {
84  VelocityCubitBcData mydata;
85  CHKERR it->getBcDataStructure(mydata);
86  // Print data
87  std::cout << mydata;
88  myfile << mydata;
89  }
90 
91  // Acceleration
92  else if (strcmp(&bc_data[0], "Acceleration") == 0) {
94  CHKERR it->getBcDataStructure(mydata);
95  // Print data
96  std::cout << mydata;
97  myfile << mydata;
98  }
99 
100  // Temperature
101  else if (strcmp(&bc_data[0], "Temperature") == 0) {
102  TemperatureCubitBcData mydata;
103  CHKERR it->getBcDataStructure(mydata);
104  // Print data
105  std::cout << mydata;
106  myfile << mydata;
107  }
108 
109  else
110  SETERRQ(PETSC_COMM_SELF, 1, "Error: Unrecognizable BC type");
111  }
112 
113  std::cout << "<<<< SIDESETs >>>>>" << std::endl;
114  // SIDESETs
116  std::cout << *it << std::endl;
117  CHKERR it->printBcData(std::cout);
118  std::vector<char> bc_data;
119  CHKERR it->getBcData(bc_data);
120  if (bc_data.empty())
121  continue;
122 
123  // Pressure
124  if (strcmp(&bc_data[0], "Pressure") == 0) {
125  PressureCubitBcData mydata;
126  CHKERR it->getBcDataStructure(mydata);
127  // Print data
128  std::cout << mydata;
129  myfile << mydata;
130  }
131 
132  // Heat Flux
133  else if (strcmp(&bc_data[0], "HeatFlux") == 0) {
134  HeatFluxCubitBcData mydata;
135  CHKERR it->getBcDataStructure(mydata);
136  // Print data
137  std::cout << mydata;
138  myfile << mydata;
139  }
140 
141  // cfd_bc
142  else if (strcmp(&bc_data[0], "cfd_bc") == 0) {
143  CfgCubitBcData mydata;
144  CHKERR it->getBcDataStructure(mydata);
145 
146  // Interface bc (Hex:6 Dec:6)
147  if (mydata.data.type == 6) { // 6 is the decimal value of the
148  // corresponding value (hex) in bc_data
149  // Print data
150  std::cout << std::endl << "Interface" << std::endl;
151  myfile << std::endl << "Interface" << std::endl;
152  std::cout << mydata;
153  myfile << mydata;
154  }
155  // Pressure inlet (Hex:f Dec:15)
156  else if (mydata.data.type == 15) { // 15 is the decimal value of the
157  // corresponding value (hex) in
158  // bc_data
159  // Print data
160  std::cout << std::endl << "Pressure Inlet" << std::endl;
161  myfile << std::endl << "Pressure Inlet" << std::endl;
162  std::cout << mydata;
163  myfile << mydata;
164  }
165  // Pressure outlet (Hex:10 Dec:16)
166  else if (mydata.data.type == 16) { // 16 is the decimal value of the
167  // corresponding value (hex) in
168  // bc_data
169  // Print data
170  std::cout << std::endl << "Pressure Outlet" << std::endl;
171  myfile << std::endl << "Pressure Outlet" << std::endl;
172  std::cout << mydata;
173  myfile << mydata;
174  }
175  }
176 
177  else
178  SETERRQ(PETSC_COMM_SELF, 1, "Error: Unrecognizable BC type");
179  }
180 
181  MeshsetsManager *meshsets_manager_ptr;
182  CHKERR m_field.getInterface(meshsets_manager_ptr);
183 
184  std::cout << "<<<< BLOCKSETs >>>>>" << std::endl;
185  // BLOCKSETs
187  std::cout << std::endl << *it << std::endl;
188 
189  // Get and print block name
190  CHKERR it->printName(std::cout);
191  CHKERR it->printName(myfile);
192 
193  // Get and print block attributes
194  std::vector<double> attributes;
195  CHKERR it->getAttributes(attributes);
196  CHKERR it->printAttributes(std::cout);
197  CHKERR it->printAttributes(myfile);
198  }
199 
200  // Get block attributes and assign them as material properties/solution
201  // parameters based on the name of each block
202 
203  // Conventions:
204  //----------------------------------------------------------------------------------------
205  // Materials are defined with block names starting with MAT_ e.g.
206  // MAT_ELASTIC_abcd,
207  // MAT_FRACTcdef etc.
208  // Solution procedures are defined with block names starting with SOL_ e.g.
209  // SOL_ELASTIC_xx, SOL_NLELASTICxx, SOL_FRACTabcd etc.
210  //----------------------------------------------------------------------------------------
211 
213 
214  std::cout << std::endl << *it << std::endl;
215 
216  // Get block name
217  std::string name = it->getName();
218 
219  // Elastic material
220  if (name.compare(0, 20, "MAT_ELASTIC_TRANSISO") == 0) {
221  Mat_Elastic_TransIso mydata;
222  CHKERR it->getAttributeDataStructure(mydata);
223  // Print data
224  std::cout << mydata;
225  myfile << mydata;
226  } else if (name.compare(0, 11, "MAT_ELASTIC") == 0) {
227  Mat_Elastic mydata;
228  CHKERR it->getAttributeDataStructure(mydata);
229  // Print data
230  std::cout << mydata;
231  myfile << mydata;
232  } else if (name.compare(0, 10, "MAT_INTERF") == 0) {
233  Mat_Interf mydata;
234  CHKERR it->getAttributeDataStructure(mydata);
235  // Print data
236  std::cout << mydata;
237  myfile << mydata;
238  } else
239  SETERRQ(PETSC_COMM_SELF, 1, "Error: Unrecognizable Material type");
240  }
241 
242  // Close mesh_file_name.txt
243  myfile.close();
244 
245  } CATCH_ERRORS;
246 
247  return MoFEM::Core::Finalize();
248 }

Variable Documentation

◆ help

char help[]
static
Initial value:
= "Read file and print boundary conditions (ex. "
"./cubit_bc_test -my_file disp01.h5m) \n\n"
Examples
cubit_bc_test.cpp.

Definition at line 12 of file cubit_bc_test.cpp.

MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Definition: UnknownInterface.hpp:93
SIDESET
@ SIDESET
Definition: definitions.h:147
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MoFEM::AccelerationCubitBcData
Definition of the acceleration bc data structure.
Definition: BCData.hpp:247
MoFEM::TemperatureCubitBcData
Definition of the temperature bc data structure.
Definition: BCData.hpp:306
MoFEM::Mat_Elastic
Elastic material data structure.
Definition: MaterialBlocks.hpp:139
MoFEM::ForceCubitBcData
Definition of the force bc data structure.
Definition: BCData.hpp:139
MoFEM::DisplacementCubitBcData
Definition of the displacement bc data structure.
Definition: BCData.hpp:76
MoFEM::CoreTmp< 0 >::Finalize
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
MoFEM::PressureCubitBcData
Definition of the pressure bc data structure.
Definition: BCData.hpp:379
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1975
MoFEM::Mat_Interf
Linear interface data structure.
Definition: MaterialBlocks.hpp:430
NODESET
@ NODESET
Definition: definitions.h:146
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM::Mat_Elastic_TransIso
Transverse Isotropic material data structure.
Definition: MaterialBlocks.hpp:371
MoFEM::CfgCubitBcData::data
_data_ data
Definition: BCData.hpp:485
mesh_file_name
char mesh_file_name[255]
Definition: mesh_smoothing.cpp:23
MoFEM::VelocityCubitBcData
Definition of the velocity bc data structure.
Definition: BCData.hpp:189
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
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
_IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_
#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.
Definition: MeshsetsManager.hpp:71
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1094
BLOCKSET
@ BLOCKSET
Definition: definitions.h:148
MoFEM::PetscOptionsGetString
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
Definition: DeprecatedPetsc.hpp:172
MoFEM::MeshsetsManager
Interface for managing meshsets containing materials and boundary conditions.
Definition: MeshsetsManager.hpp:104
MoFEM::HeatFluxCubitBcData
Definition of the heat flux bc data structure.
Definition: BCData.hpp:427
help
static char help[]
Definition: cubit_bc_test.cpp:12
MoFEM::CfgCubitBcData
Definition of the cfd_bc data structure.
Definition: BCData.hpp:480
MOFEM_INVALID_DATA
@ MOFEM_INVALID_DATA
Definition: definitions.h:36