v0.14.0
cubit_bc_test.cpp

Atom test for getting boundary conditions from blocksets, sidesets and nodesets.

/** \file cubit_bc_test.cpp
* \example cubit_bc_test.cpp
* \brief Atom test for getting boundary conditions from blocksets, sidesets and
* nodesets.
*
*/
#include <MoFEM.hpp>
using namespace MoFEM;
static char help[] = "Read file and print boundary conditions (ex. "
"./cubit_bc_test -my_file disp01.h5m) \n\n";
int main(int argc, char *argv[]) {
MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
try {
moab::Core mb_instance;
moab::Interface &moab = mb_instance;
int rank;
MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
// Read parameters from line command
PetscBool flg = PETSC_TRUE;
char mesh_file_name[255];
#if PETSC_VERSION_GE(3, 6, 4)
CHKERR PetscOptionsGetString(PETSC_NULL, "", "-my_file", mesh_file_name,
255, &flg);
#else
CHKERR PetscOptionsGetString(PETSC_NULL, PETSC_NULL, "-my_file",
mesh_file_name, 255, &flg);
#endif
if (flg != PETSC_TRUE) {
SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
"*** ERROR -my_file (MESH FILE NEEDED)");
}
// Read mesh to MOAB
const char *option;
option = ""; //"PARALLEL=BCAST;";//;DEBUG_IO";
CHKERR moab.load_file(mesh_file_name, 0, option);
// Create MoFEM (Joseph) database
MoFEM::Core core(moab);
MoFEM::Interface &m_field = core;
// Open mesh_file_name.txt for writing
std::ofstream myfile;
myfile.open((std::string(mesh_file_name) + ".txt").c_str());
std::cout << "<<<< NODESETs >>>>>" << std::endl;
// NODESETs
std::cout << *it << std::endl;
CHKERR it->printBcData(std::cout);
std::vector<char> bc_data;
CHKERR it->getBcData(bc_data);
if (bc_data.empty())
continue;
// Displacement
if (strcmp(&bc_data[0], "Displacement") == 0) {
CHKERR it->getBcDataStructure(mydata);
// Print data
std::cout << mydata;
myfile << mydata;
}
// Force
else if (strcmp(&bc_data[0], "Force") == 0) {
CHKERR it->getBcDataStructure(mydata);
// Print data
std::cout << mydata;
myfile << mydata;
}
// Velocity
else if (strcmp(&bc_data[0], "Velocity") == 0) {
CHKERR it->getBcDataStructure(mydata);
// Print data
std::cout << mydata;
myfile << mydata;
}
// Acceleration
else if (strcmp(&bc_data[0], "Acceleration") == 0) {
CHKERR it->getBcDataStructure(mydata);
// Print data
std::cout << mydata;
myfile << mydata;
}
// Temperature
else if (strcmp(&bc_data[0], "Temperature") == 0) {
CHKERR it->getBcDataStructure(mydata);
// Print data
std::cout << mydata;
myfile << mydata;
}
else
SETERRQ(PETSC_COMM_SELF, 1, "Error: Unrecognizable BC type");
}
std::cout << "<<<< SIDESETs >>>>>" << std::endl;
// SIDESETs
std::cout << *it << std::endl;
CHKERR it->printBcData(std::cout);
std::vector<char> bc_data;
CHKERR it->getBcData(bc_data);
if (bc_data.empty())
continue;
// Pressure
if (strcmp(&bc_data[0], "Pressure") == 0) {
CHKERR it->getBcDataStructure(mydata);
// Print data
std::cout << mydata;
myfile << mydata;
}
// Heat Flux
else if (strcmp(&bc_data[0], "HeatFlux") == 0) {
CHKERR it->getBcDataStructure(mydata);
// Print data
std::cout << mydata;
myfile << mydata;
}
// cfd_bc
else if (strcmp(&bc_data[0], "cfd_bc") == 0) {
CHKERR it->getBcDataStructure(mydata);
// Interface bc (Hex:6 Dec:6)
if (mydata.data.type == 6) { // 6 is the decimal value of the
// corresponding value (hex) in bc_data
// Print data
std::cout << std::endl << "Interface" << std::endl;
myfile << std::endl << "Interface" << std::endl;
std::cout << mydata;
myfile << mydata;
}
// Pressure inlet (Hex:f Dec:15)
else if (mydata.data.type == 15) { // 15 is the decimal value of the
// corresponding value (hex) in
// bc_data
// Print data
std::cout << std::endl << "Pressure Inlet" << std::endl;
myfile << std::endl << "Pressure Inlet" << std::endl;
std::cout << mydata;
myfile << mydata;
}
// Pressure outlet (Hex:10 Dec:16)
else if (mydata.data.type == 16) { // 16 is the decimal value of the
// corresponding value (hex) in
// bc_data
// Print data
std::cout << std::endl << "Pressure Outlet" << std::endl;
myfile << std::endl << "Pressure Outlet" << std::endl;
std::cout << mydata;
myfile << mydata;
}
}
else
SETERRQ(PETSC_COMM_SELF, 1, "Error: Unrecognizable BC type");
}
MeshsetsManager *meshsets_manager_ptr;
CHKERR m_field.getInterface(meshsets_manager_ptr);
std::cout << "<<<< BLOCKSETs >>>>>" << std::endl;
// BLOCKSETs
std::cout << std::endl << *it << std::endl;
// Get and print block name
CHKERR it->printName(std::cout);
CHKERR it->printName(myfile);
// Get and print block attributes
std::vector<double> attributes;
CHKERR it->getAttributes(attributes);
CHKERR it->printAttributes(std::cout);
CHKERR it->printAttributes(myfile);
}
// Get block attributes and assign them as material properties/solution
// parameters based on the name of each block
// Conventions:
//----------------------------------------------------------------------------------------
// Materials are defined with block names starting with MAT_ e.g.
// MAT_ELASTIC_abcd,
// MAT_FRACTcdef etc.
// Solution procedures are defined with block names starting with SOL_ e.g.
// SOL_ELASTIC_xx, SOL_NLELASTICxx, SOL_FRACTabcd etc.
//----------------------------------------------------------------------------------------
std::cout << std::endl << *it << std::endl;
// Get block name
std::string name = it->getName();
// Elastic material
if (name.compare(0, 20, "MAT_ELASTIC_TRANSISO") == 0) {
CHKERR it->getAttributeDataStructure(mydata);
// Print data
std::cout << mydata;
myfile << mydata;
} else if (name.compare(0, 11, "MAT_ELASTIC") == 0) {
Mat_Elastic mydata;
CHKERR it->getAttributeDataStructure(mydata);
// Print data
std::cout << mydata;
myfile << mydata;
} else if (name.compare(0, 10, "MAT_INTERF") == 0) {
Mat_Interf mydata;
CHKERR it->getAttributeDataStructure(mydata);
// Print data
std::cout << mydata;
myfile << mydata;
} else
SETERRQ(PETSC_COMM_SELF, 1, "Error: Unrecognizable Material type");
}
// Close mesh_file_name.txt
myfile.close();
}
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.hpp
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
main
int main(int argc, char *argv[])
Definition: cubit_bc_test.cpp:15
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
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
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