MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
MAST::NastranIO Class Reference

Detailed Description

Nastran BDF mesh input.

The NastranIO class is a preliminary implementation for reading NASTRAN mesh information using pyNastran with BDF data as input. Note that this class is not designed to be a complete Nastran BDF reader with solution & case control, but rather a way to get basic mesh data defined in BDF format into libMesh/MAST. We define basic mesh data as:

  • nodes: Nastran grids (only supports grid definition in global coordinate system)
  • elements: Nastran elements with nodal connectivity (property IDs mapped to subdomains)
  • subdomains: libMesh mesh subdomains are similar to property card assignment in Nastran (used to connect properties to elements)
  • node boundary domains: similar to SPC ID sets in Nastran. We don't use actual BC values assigned on SPC cards, but rather track which nodes are used in each SPC ID. These become node boundary domains in libMesh/MAST, to which different boundary conditions can be assigned.

TODO: Unit tests for NastranIO class.

Definition at line 62 of file nastran_io.h.

#include <nastran_io.h>

Inheritance diagram for MAST::NastranIO:
Collaboration diagram for MAST::NastranIO:

Public Member Functions

 NastranIO (libMesh::MeshBase &mesh, const bool python_preinit=false)
 Constructor. More...
 
virtual ~NastranIO ()
 Destructor. More...
 
std::map< libMesh::Elem *, uint64_t > get_libmesh_to_nastran_elem_map ()
 Returns mapping between libMesh/MAST elements and Nastran BDF element ID's. More...
 
std::map< const libMesh::Node *, uint64_t > get_libmesh_to_nastran_node_map ()
 Returns mapping between libMesh/MAST nodes and Nastran BDF grid ID's. More...
 
std::map< std::pair< int, int >, int > get_nastran_pid_elemtype_to_libmesh_subdomain_map ()
 Provides mapping between Nastran property ID & element-type pairs and corresponding libMesh/MAST subdomain ID's. More...
 
std::map< int, std::set< int > > get_nastran_property_to_libmesh_subdomains_map ()
 Returns mapping between Nastran property ID's and sets of libMesh/MAST subdomains. More...
 
std::map< uint64_t, libMesh::Elem * > get_nastran_to_libmesh_elem_map ()
 Returns mapping between Nastran BDF element ID's and libMesh/MAST elements. More...
 
std::map< uint64_t, libMesh::Node * > get_nastran_to_libmesh_node_map ()
 Returns mapping between Nastran BDF grid ID's and libMesh/MAST nodes. More...
 
void print_pid_to_subdomain_id_map ()
 Print map between Nastran property ID's (PID) to libMesh subdomain ID's (SID) to libMesh::out. More...
 
virtual void read (const std::string &filename) override
 Read ASCII NASTRAN BDF given by filename. More...
 
virtual void read (BDFModel *model)
 Read data directly from BDFModel object. More...
 

Private Member Functions

void finalize_python ()
 
void initialize_python ()
 
void read_elements (BDFModel *model, libMesh::MeshBase &the_mesh)
 
void read_node_boundaries (BDFModel *model, libMesh::MeshBase &the_mesh)
 
void read_nodes (BDFModel *model, libMesh::MeshBase &the_mesh)
 

Private Attributes

std::map< libMesh::Elem *, uint64_t > libmesh_to_nastran_elem_map
 Mapping from libMesh/MAST element pointers to Nastran element IDs from BDF input. More...
 
std::map< const libMesh::Node *, uint64_t > libmesh_to_nastran_node_map
 Mapping from libMesh/MAST node pointers to Nastran grid IDs from BDF input. More...
 
std::map< std::pair< int, int >, int > nastran_pid_elemtype_to_libmesh_subdomain_map = {}
 Mapping from Nastran property ID/element-type pair to libMesh/MAST subdomain. More...
 
std::map< uint64_t, libMesh::Elem * > nastran_to_libmesh_elem_map
 Mapping from Nastran element IDs from BDF input to pointers to libMesh/MAST elements. More...
 
std::map< std::string, libMesh::ElemType > nastran_to_libmesh_elem_type_map
 Map from Nastran elements to equivalent libMesh/MAST element types. More...
 
std::map< uint64_t, libMesh::Node * > nastran_to_libmesh_node_map
 Mapping from Nastran grid IDs from BDF input to pointers to libMesh/MAST nodes. More...
 
bool python_initialized = false
 Indicates is Python has been initialized. More...
 
const bool python_preinitialized = false
 Indicates if Python was initialized outside of NastranIO class. More...
 

Constructor & Destructor Documentation

◆ NastranIO()

MAST::NastranIO::NastranIO ( libMesh::MeshBase &  mesh,
const bool  python_preinit = false 
)
explicit

Constructor.

Parameters
mesha libMesh mesh object.
python_preinitbool describing if Python has been already initialized somewhere in the current program (by another C++/Python interface).

Definition at line 41 of file nastran_io.cpp.

◆ ~NastranIO()

MAST::NastranIO::~NastranIO ( )
virtual

Destructor.

Definition at line 53 of file nastran_io.cpp.

Member Function Documentation

◆ finalize_python()

void MAST::NastranIO::finalize_python ( )
private

Definition at line 285 of file nastran_io.cpp.

◆ get_libmesh_to_nastran_elem_map()

std::map< libMesh::Elem *, uint64_t > MAST::NastranIO::get_libmesh_to_nastran_elem_map ( )

Returns mapping between libMesh/MAST elements and Nastran BDF element ID's.

Returns
map between pointer to libMesh/MAST elements and corresponding Nastran element ID's.

Definition at line 80 of file nastran_io.cpp.

◆ get_libmesh_to_nastran_node_map()

std::map< const libMesh::Node *, uint64_t > MAST::NastranIO::get_libmesh_to_nastran_node_map ( )

Returns mapping between libMesh/MAST nodes and Nastran BDF grid ID's.

Returns
map between pointers to libMesh/MAST nodes and corresponding Nastran grid ID's.

Definition at line 68 of file nastran_io.cpp.

◆ get_nastran_pid_elemtype_to_libmesh_subdomain_map()

std::map< std::pair< int, int >, int > MAST::NastranIO::get_nastran_pid_elemtype_to_libmesh_subdomain_map ( )

Provides mapping between Nastran property ID & element-type pairs and corresponding libMesh/MAST subdomain ID's.

Note we must use a pair combining a Nastran property ID along with a specific element type to get a unique map key to libMesh/MAST subdomains. This is because Nastran allows one property ID to be assigned to elements of different type (ie. PSHELL to both CQUAD4 & CTRIA3), but libMesh does not allow elements of different type to belong to the same subdomain.

Returns
map between Nastran property ID + element type pairs and corresponding libMesh/MAST subdomain ID's.

Definition at line 100 of file nastran_io.cpp.

◆ get_nastran_property_to_libmesh_subdomains_map()

std::map< int, std::set< int > > MAST::NastranIO::get_nastran_property_to_libmesh_subdomains_map ( )

Returns mapping between Nastran property ID's and sets of libMesh/MAST subdomains.

Note that one Nastran property ID can map to multiple libMesh/MAST subdomains because Nastran allows one property ID to be assigned to elements of different type (ie. PSHELL to both CQUAD4 & CTRIA3), but libMesh does not allow elements of different type to belong to the same subdomain. In this case, we use multiple subdomains to contain the different element types.

Returns
map between Nastran property ID's and sets of corresponding libMesh/MAST subdomain ID's.

Definition at line 86 of file nastran_io.cpp.

◆ get_nastran_to_libmesh_elem_map()

std::map< uint64_t, libMesh::Elem * > MAST::NastranIO::get_nastran_to_libmesh_elem_map ( )

Returns mapping between Nastran BDF element ID's and libMesh/MAST elements.

Returns
map between Nastran element ID's and pointers to corresponding libMesh/MAST elements.

Definition at line 74 of file nastran_io.cpp.

◆ get_nastran_to_libmesh_node_map()

std::map< uint64_t, libMesh::Node * > MAST::NastranIO::get_nastran_to_libmesh_node_map ( )

Returns mapping between Nastran BDF grid ID's and libMesh/MAST nodes.

Returns
map between Nastran grid ID's and pointers to corresponding libMesh/MAST nodes.

Definition at line 62 of file nastran_io.cpp.

◆ initialize_python()

void MAST::NastranIO::initialize_python ( )
private

Definition at line 264 of file nastran_io.cpp.

◆ print_pid_to_subdomain_id_map()

void MAST::NastranIO::print_pid_to_subdomain_id_map ( )

Print map between Nastran property ID's (PID) to libMesh subdomain ID's (SID) to libMesh::out.

Note that some PID will correspond to multiple SID since libMesh requires all elements in a subdomain to be the same type, but Nastran allows property assignment to multiple element types from the same property card (ie. PSHELL to both CQUAD4 and CTRIA3).

Definition at line 292 of file nastran_io.cpp.

◆ read() [1/2]

void MAST::NastranIO::read ( const std::string &  filename)
overridevirtual

Read ASCII NASTRAN BDF given by filename.

Parameters
filenamestring path to Nastran BDF formatted file.

Definition at line 217 of file nastran_io.cpp.

◆ read() [2/2]

void MAST::NastranIO::read ( BDFModel model)
virtual

Read data directly from BDFModel object.

Parameters
modelpointer to BDFModel object.

Definition at line 245 of file nastran_io.cpp.

◆ read_elements()

void MAST::NastranIO::read_elements ( BDFModel model,
libMesh::MeshBase &  the_mesh 
)
private

Definition at line 128 of file nastran_io.cpp.

◆ read_node_boundaries()

void MAST::NastranIO::read_node_boundaries ( BDFModel model,
libMesh::MeshBase &  the_mesh 
)
private

Definition at line 199 of file nastran_io.cpp.

◆ read_nodes()

void MAST::NastranIO::read_nodes ( BDFModel model,
libMesh::MeshBase &  the_mesh 
)
private

Definition at line 105 of file nastran_io.cpp.

Member Data Documentation

◆ libmesh_to_nastran_elem_map

std::map<libMesh::Elem*, uint64_t> MAST::NastranIO::libmesh_to_nastran_elem_map
private

Mapping from libMesh/MAST element pointers to Nastran element IDs from BDF input.

Definition at line 163 of file nastran_io.h.

◆ libmesh_to_nastran_node_map

std::map<const libMesh::Node*, uint64_t> MAST::NastranIO::libmesh_to_nastran_node_map
private

Mapping from libMesh/MAST node pointers to Nastran grid IDs from BDF input.

Definition at line 159 of file nastran_io.h.

◆ nastran_pid_elemtype_to_libmesh_subdomain_map

std::map<std::pair<int, int>, int> MAST::NastranIO::nastran_pid_elemtype_to_libmesh_subdomain_map = {}
private

Mapping from Nastran property ID/element-type pair to libMesh/MAST subdomain.

Note we must use a pair combining a Nastran property ID along with a specific element type to get a unique map key to libMesh/MAST subdomains. This is because Nastran allows one property ID to be assigned to elements of different type (ie. PSHELL to both CQUAD4 and CTRIA3), but libMesh does not allow elements of different type to belong to the same subdomain. In this case, we use multiple subdomains to contain the different element types and store this mapping for reference.

Definition at line 175 of file nastran_io.h.

◆ nastran_to_libmesh_elem_map

std::map<uint64_t, libMesh::Elem*> MAST::NastranIO::nastran_to_libmesh_elem_map
private

Mapping from Nastran element IDs from BDF input to pointers to libMesh/MAST elements.

Definition at line 161 of file nastran_io.h.

◆ nastran_to_libmesh_elem_type_map

std::map<std::string, libMesh::ElemType> MAST::NastranIO::nastran_to_libmesh_elem_type_map
private
Initial value:
= {
{"CELAS1_1", libMesh::NODEELEM}, {"CELAS2_1", libMesh::NODEELEM},
{"CELAS3_1", libMesh::NODEELEM}, {"CELAS4_1", libMesh::NODEELEM},
{"CBUSH_1", libMesh::NODEELEM}, {"CBUSH1D_1", libMesh::NODEELEM},
{"CELAS1_2", libMesh::EDGE2}, {"CELAS2_2", libMesh::EDGE2},
{"CELAS3_2", libMesh::EDGE2}, {"CELAS4_2", libMesh::EDGE2},
{"CBUSH_2", libMesh::EDGE2}, {"CBUSH1D_2", libMesh::EDGE2},
{"CBUSH2D_2",libMesh::EDGE2},
{"CROD_2", libMesh::EDGE2}, {"CBAR_2", libMesh::EDGE2},
{"CBEAM_2", libMesh::EDGE2}, {"CBEAM3_3", libMesh::EDGE3},
{"CTRIA3_3", libMesh::TRI3}, {"CTRIA6_6", libMesh::TRI6},
{"CTRIAR_3", libMesh::TRI3},
{"CQUAD4_4", libMesh::QUAD4}, {"CQUAD8_8", libMesh::QUAD8},
{"CQUADR_4", libMesh::QUADSHELL4}, {"CQUAD_4", libMesh::QUAD4},
{"CQUAD_8", libMesh::QUAD8}, {"CQUAD_9", libMesh::QUAD9},
{"CQUADX_4", libMesh::QUAD4}, {"CQUADX_8", libMesh::QUAD8},
{"CQUADX_9", libMesh::QUAD9},
{"CTETRA_4", libMesh::TET4}, {"CTETRA_10", libMesh::TET10},
{"CPENTA_6", libMesh::PRISM6}, {"CPENTA_15", libMesh::PRISM15},
{"CPYRAM_5", libMesh::PYRAMID5}, {"CPYRAM_13", libMesh::PYRAMID13},
{"CHEXA_8", libMesh::HEX8}, {"CHEXA_20", libMesh::HEX20}
}

Map from Nastran elements to equivalent libMesh/MAST element types.

TODO: Not yet complete, need to add all Nastran elements we need support for.

Definition at line 185 of file nastran_io.h.

◆ nastran_to_libmesh_node_map

std::map<uint64_t, libMesh::Node*> MAST::NastranIO::nastran_to_libmesh_node_map
private

Mapping from Nastran grid IDs from BDF input to pointers to libMesh/MAST nodes.

Definition at line 157 of file nastran_io.h.

◆ python_initialized

bool MAST::NastranIO::python_initialized = false
private

Indicates is Python has been initialized.

Definition at line 154 of file nastran_io.h.

◆ python_preinitialized

const bool MAST::NastranIO::python_preinitialized = false
private

Indicates if Python was initialized outside of NastranIO class.

Definition at line 152 of file nastran_io.h.


The documentation for this class was generated from the following files: