libMesh
dyna_io.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_DYNA_IO_H
21 #define LIBMESH_DYNA_IO_H
22 
23 // Local includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/mesh_input.h"
26 #include "libmesh/mesh_output.h"
27 
28 // C++ includes
29 #include <algorithm>
30 #include <cstddef>
31 #include <map>
32 #include <vector>
33 
34 namespace libMesh
35 {
36 
37 // Forward declarations
38 class MeshBase;
39 
40 
41 
52 class DynaIO : public MeshInput<MeshBase>
53 {
54 public:
55 
60  explicit
61  DynaIO (MeshBase & mesh);
62 
84  virtual void read (const std::string & name) override;
85 
91  void add_spline_constraints(DofMap & dof_map,
92  unsigned int sys_num,
93  unsigned int var_num);
94 
95 private:
96  // Keep track of spline node indexing, so as to enable adding
97  // constraint rows easily later.
98  std::vector<Node *> spline_node_ptrs;
99 
100  // Keep track of the constraint equations associated with each FE
101  // node.
102  //
103  // constraint_rows[FE_node][i].first is the constraining spline
104  // node, and .second is the constraining coefficient.
105  std::map<dof_id_type, std::vector<std::pair<dof_id_type, Real>>>
107 
108  // Have we broadcast the constraint_rows to non-root procs yet?
110 
116  void read_mesh (std::istream & in);
117 
121  typedef int32_t dyna_int_type;
122 
126  static const int max_ints_per_line = 10;
127 
131  typedef double dyna_fp_type;
132 
136  static const int max_fps_per_line = 5;
137 
146  {
147  ElementDefinition(ElemType type_in,
148  dyna_int_type dyna_type_in,
149  dyna_int_type dim_in,
150  dyna_int_type p_in);
151 
152  ElementDefinition(ElemType type_in,
153  dyna_int_type dyna_type_in,
154  dyna_int_type dim_in,
155  dyna_int_type p_in,
156  std::vector<unsigned int> && nodes_in);
157 
162  std::vector<unsigned int> nodes;
163  };
164 
169  struct ElementMaps
170  {
171  // Helper function to add a (key, value) pair to both maps
172  void add_def(const ElementDefinition & eledef)
173  {
174  out.insert(std::make_pair(eledef.type, eledef));
175  in.insert(std::make_pair(std::make_tuple(eledef.dyna_type, eledef.dim, eledef.p), eledef));
176  }
177 
178  std::map<ElemType, ElementDefinition> out;
179 
180  typedef std::tuple<dyna_int_type, dyna_int_type, dyna_int_type> Key;
181 
182  std::map<Key, ElementDefinition> in;
183  };
184 
190 
196 };
197 
198 
199 } // namespace libMesh
200 
201 #endif // LIBMESH_DYNA_IO_H
libMesh::DynaIO::ElementMaps::in
std::map< Key, ElementDefinition > in
Definition: dyna_io.h:182
libMesh::DynaIO::ElementDefinition::dyna_type
dyna_int_type dyna_type
Definition: dyna_io.h:159
libMesh::DynaIO::ElementDefinition::type
ElemType type
Definition: dyna_io.h:158
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::DynaIO::spline_node_ptrs
std::vector< Node * > spline_node_ptrs
Definition: dyna_io.h:98
libMesh::DynaIO::ElementDefinition::dim
dyna_int_type dim
Definition: dyna_io.h:160
libMesh::DynaIO::ElementDefinition::nodes
std::vector< unsigned int > nodes
Definition: dyna_io.h:162
libMesh::DynaIO::ElementDefinition::ElementDefinition
ElementDefinition(ElemType type_in, dyna_int_type dyna_type_in, dyna_int_type dim_in, dyna_int_type p_in)
Definition: dyna_io.C:91
libMesh::DynaIO::add_spline_constraints
void add_spline_constraints(DofMap &dof_map, unsigned int sys_num, unsigned int var_num)
Constrains finite element degrees of freedom in terms of spline degrees of freedom by adding user-def...
Definition: dyna_io.C:685
libMesh::DynaIO::read_mesh
void read_mesh(std::istream &in)
Implementation of the read() function.
Definition: dyna_io.C:137
libMesh::DynaIO::dyna_fp_type
double dyna_fp_type
The floating-point type DYNA uses.
Definition: dyna_io.h:131
libMesh::MeshBase
This is the MeshBase class.
Definition: mesh_base.h:78
libMesh::DynaIO::build_element_maps
static ElementMaps build_element_maps()
A static function used to construct the _element_maps struct, statically.
Definition: dyna_io.C:46
libMesh::DynaIO::constraint_rows_broadcast
bool constraint_rows_broadcast
Definition: dyna_io.h:109
libMesh::DynaIO::ElementDefinition
Defines mapping from libMesh element types to LS-DYNA element types or vice-versa.
Definition: dyna_io.h:145
libMesh::DynaIO::_element_maps
static ElementMaps _element_maps
A static ElementMaps object that is built statically and used by all instances of this class.
Definition: dyna_io.h:189
libMesh::DynaIO::ElementMaps::out
std::map< ElemType, ElementDefinition > out
Definition: dyna_io.h:178
libMesh::DynaIO
Reading and writing meshes in (a subset of) LS-DYNA format.
Definition: dyna_io.h:52
libMesh::DynaIO::dyna_int_type
int32_t dyna_int_type
The integer type DYNA uses.
Definition: dyna_io.h:121
libMesh::DynaIO::ElementMaps::add_def
void add_def(const ElementDefinition &eledef)
Definition: dyna_io.h:172
libMesh::DynaIO::max_ints_per_line
static const int max_ints_per_line
How many can we find on a line?
Definition: dyna_io.h:126
libMesh::DofMap
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:176
libMesh::DynaIO::max_fps_per_line
static const int max_fps_per_line
How many can we find on a line?
Definition: dyna_io.h:136
libMesh::DynaIO::ElementMaps::Key
std::tuple< dyna_int_type, dyna_int_type, dyna_int_type > Key
Definition: dyna_io.h:180
libMesh::DynaIO::constraint_rows
std::map< dof_id_type, std::vector< std::pair< dof_id_type, Real > > > constraint_rows
Definition: dyna_io.h:106
libMesh::MeshInput< MeshBase >::mesh
MeshBase & mesh()
Definition: mesh_input.h:169
libMesh::DynaIO::ElementDefinition::p
dyna_int_type p
Definition: dyna_io.h:161
libMesh::DynaIO::read
virtual void read(const std::string &name) override
Reads in a mesh in the Dyna format from the ASCII file given by name.
Definition: dyna_io.C:129
libMesh::DynaIO::DynaIO
DynaIO(MeshBase &mesh)
Constructor.
Definition: dyna_io.C:121
libMesh::Quality::name
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
libMesh::MeshInput
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:60
libMesh::ElemType
ElemType
Defines an enum for geometric element types.
Definition: enum_elem_type.h:33
libMesh::DynaIO::ElementMaps
struct which holds a map from LS-DYNA to libMesh element numberings and vice-versa.
Definition: dyna_io.h:169