37 static const std::string tet_name_in_aster_mail_file =
"TETRA4";
38 static const std::string hex_name_in_aster_mail_file =
"HEXA10";
39 static const std::string prism_name_in_aster_mail_file =
"PENTA6";
40 static const std::string pyr_name_in_aster_mail_file =
"PYRAM5";
42 static const std::string* cell_name_in_aster_mail_file[4] = {
43 &tet_name_in_aster_mail_file, &hex_name_in_aster_mail_file,
44 &prism_name_in_aster_mail_file, &pyr_name_in_aster_mail_file };
46 static const std::string triangle_name_in_aster_mail_file =
"TRIA3";
47 static const std::string quad_name_in_aster_mail_file =
"QUAD4";
49 static const std::string* polygon_name_in_aster_mail_file[2] = {
50 &triangle_name_in_aster_mail_file, &quad_name_in_aster_mail_file };
67 class AsterIOHandler final:
public GeoModelIOHandler< 3 > {
69 void load(
const std::string& filename, GeoModel3D& geomodel )
final 73 throw RINGMeshException(
"I/O",
74 "Loading of a GeoModel from Code_Aster mesh not implemented yet" );
76 void save(
const GeoModel3D& geomodel,
const std::string& filename )
final 78 std::ofstream out( filename.c_str() );
80 const RINGMesh::GeoModelMesh3D& geomodel_mesh = geomodel.mesh;
82 write_title( out, geomodel );
83 write_vertices( out, geomodel_mesh );
84 write_cells( geomodel, out );
85 write_polygons( geomodel, out );
86 write_regions( geomodel, out );
87 write_interfaces( geomodel, out );
94 void write_title( std::ofstream& out,
const GeoModel3D& geomodel )
const 96 out <<
"TITRE" <<
EOL;
97 out << geomodel.name() <<
EOL;
98 out <<
"FINSF" <<
EOL;
102 const RINGMesh::GeoModelMesh3D& geomodel_mesh )
const 104 out <<
"COOR_3D" <<
EOL;
105 for(
auto v : range( geomodel_mesh.vertices.nb() ) ) {
106 out <<
"V" << v <<
" " << geomodel_mesh.vertices.vertex( v ) <<
EOL;
108 out <<
"FINSF" <<
EOL;
111 void write_cells(
const GeoModel3D& geomodel, std::ofstream& out )
const 113 const GeoModelMesh3D& geomodel_mesh = geomodel.mesh;
114 for(
auto r : range( geomodel.nb_regions() ) ) {
116 for(
auto ct : range( GEO::MESH_NB_CELL_TYPES - 1 ) ) {
117 if( geomodel_mesh.cells.nb_cells( r,
CellType( ct ) ) > 0 ) {
118 write_cells_in_region(
CellType( ct ), r, geomodel_mesh,
125 void write_polygons(
const GeoModel3D& geomodel, std::ofstream& out )
const 127 const GeoModelMesh3D& geomodel_mesh = geomodel.mesh;
128 for(
const auto& surface : surface_range < 3 > ( geomodel ) ) {
130 for(
auto pt : range(
132 if( geomodel_mesh.polygons.nb_polygons( surface.index(),
135 surface.index(), geomodel_mesh, out );
140 void write_cells_in_region(
143 const GeoModelMesh3D& geomodel_mesh,
144 std::ofstream& out )
const 149 geomodel_mesh.cells.nb_cells( region, cell_type ) ) ) {
150 index_t global_id = geomodel_mesh.cells.cell( region, c, cell_type );
151 out <<
"C" << global_id <<
" ";
152 for(
auto v : range( geomodel_mesh.cells.nb_vertices( c ) ) ) {
154 << geomodel_mesh.cells.vertex(
155 ElementLocalVertex( global_id, v ) ) <<
" ";
159 out <<
"FINSF" <<
EOL;
162 void write_polygons_in_interface(
165 const RINGMesh::GeoModelMesh3D& mesh,
166 std::ofstream& out )
const 170 polygon_type )] <<
EOL;
172 mesh.polygons.nb_polygons( surface, polygon_type ) ) ) {
173 index_t global_id = mesh.polygons.polygon( surface, p,
175 out <<
"F" << global_id <<
" ";
176 for(
auto v : range( mesh.polygons.nb_vertices( p ) ) ) {
178 << mesh.polygons.vertex( ElementLocalVertex( global_id, v ) )
183 out <<
"FINSF" <<
EOL;
186 void write_regions(
const GeoModel3D& geomodel, std::ofstream& out )
const 188 for(
const auto& region : region_range < 3 > ( geomodel ) ) {
189 if( region.is_meshed() ) {
190 out <<
"GROUP_MA" <<
EOL;
191 out << region.name() <<
EOL;
193 geomodel.mesh.cells.nb_cells( region.index() ) ) ) {
194 out <<
"C" << geomodel.mesh.cells.cell( region.index(), c )
197 out <<
"FINSF" <<
EOL;
202 void write_interfaces(
const GeoModel3D& geomodel, std::ofstream& out )
const 204 for(
auto& cur_interface : geomodel.geol_entities(
205 Interface3D::type_name_static() ) ) {
206 for(
auto s : range( cur_interface.nb_children() ) ) {
207 index_t surface_id = cur_interface.child( s ).index();
208 out <<
"GROUP_MA" <<
EOL;
209 out << cur_interface.name() <<
"_" << s <<
EOL;
211 geomodel.mesh.polygons.nb_polygons( surface_id ) ) ) {
212 out <<
"F" << geomodel.mesh.polygons.polygon( surface_id, p )
215 out <<
"FINSF" <<
EOL;
218 out <<
"GROUP_MA" <<
EOL;
219 out << cur_interface.name() <<
EOL;
220 for(
auto s : range( cur_interface.nb_children() ) ) {
221 index_t surface_id = cur_interface.child( s ).index();
223 geomodel.mesh.polygons.nb_polygons( surface_id ) ) ) {
224 out <<
"F" << geomodel.mesh.polygons.polygon( surface_id, p )
228 out <<
"FINSF" <<
EOL;
void ringmesh_unused(const T &)
auto to_underlying_type(Enum e) -> typename std::underlying_type< Enum >::type