14#include "arcane/utils/Iostream.h"
15#include "arcane/utils/StdHeader.h"
16#include "arcane/utils/HashTableMap.h"
17#include "arcane/utils/ValueConvert.h"
18#include "arcane/utils/ITraceMng.h"
19#include "arcane/utils/String.h"
20#include "arcane/utils/IOException.h"
21#include "arcane/utils/Collection.h"
22#include "arcane/utils/Real3.h"
23#include "arcane/utils/OStringStream.h"
25#include "arcane/core/AbstractService.h"
26#include "arcane/core/FactoryService.h"
27#include "arcane/core/IMeshReader.h"
28#include "arcane/core/IMesh.h"
29#include "arcane/core/IMeshSubMeshTransition.h"
30#include "arcane/core/IItemFamily.h"
31#include "arcane/core/Item.h"
33#include "arcane/core/VariableTypes.h"
34#include "arcane/core/IVariableAccessor.h"
35#include "arcane/core/IParallelMng.h"
36#include "arcane/core/MeshPartInfo.h"
38#include "arcane/core/ICaseMeshReader.h"
39#include "arcane/core/IMeshBuilder.h"
40#include "arcane/core/ItemPrinter.h"
43#include "arcane/std/internal/IosFile.h"
44#include "arcane/std/internal/IosGmsh.h"
111 Int32 entity_tag = -1;
120 struct MeshPhysicalName
123 : dimension(_dimension)
127 MeshPhysicalName() =
default;
128 bool isNull()
const {
return dimension == (-1); }
129 Int32 dimension = -1;
120 struct MeshPhysicalName {
…};
137 struct MeshPhysicalNameList
139 MeshPhysicalNameList()
140 : m_physical_names(4)
148 for (
auto& x : m_physical_names[dimension])
137 struct MeshPhysicalNameList {
…};
160 struct MeshV4EntitiesNodes
162 MeshV4EntitiesNodes(
Int32 _tag,
Int32 _physical_tag)
164 , physical_tag(_physical_tag)
160 struct MeshV4EntitiesNodes {
…};
171 struct MeshV4EntitiesWithNodes
176 , physical_tag(_physical_tag)
171 struct MeshV4EntitiesWithNodes {
…};
188 : node_coords_map(5000,
true)
195 for (
auto& x : entities_with_nodes_list[dimension - 1])
203 for (
auto& x : entities_nodes_list)
240 Integer _readElementsFromAsciiMshV2File(
IosFile&, MeshInfo& mesh_info);
243 void _allocateCells(
IMesh*
mesh, MeshInfo& mesh_info,
bool is_read_items);
244 void _allocateGroups(
IMesh*
mesh, MeshInfo& mesh_info,
bool is_read_items);
245 void _addFaceGroup(
IMesh*
mesh, MeshV4ElementsBlock& block,
const String& group_name);
246 void _addCellGroup(
IMesh*
mesh, MeshV4ElementsBlock& block,
const String& group_name);
247 void _addNodeGroup(
IMesh*
mesh, MeshV4ElementsBlock& block,
const String& group_name);
249 void _readPhysicalNames(
IosFile& ios_file, MeshInfo& mesh_info);
90class MshMeshReader {
…};
256extern "C++" Ref<IMshMeshReader>
257createMshMeshReader(ITraceMng* tm)
268 switch (mshElemType) {
274 info() <<
"Could not decode IT_NullType with nNodes=" << nNodes;
275 throw IOException(
"_switchMshType",
"Could not decode IT_NullType with nNodes");
292 return IT_Tetraedron4;
295 return IT_Hexaedron8;
298 return IT_Pentaedron6;
304 return IT_Heptaedron10;
307 return IT_Octaedron12;
323 ARCANE_THROW(NotSupportedException,
"Unknown GMSH element type '{0}'", mshElemType);
335 info() <<
"[_readNodesFromAsciiMshV2File] Looking for number-of-nodes";
336 Integer nb_node = ios_file.getInteger();
338 throw IOException(A_FUNCINFO, String(
"Invalid number of nodes: n=") + nb_node);
339 info() <<
"[_readNodesFromAsciiMshV2File] nb_node=" << nb_node;
340 for (
Integer i = 0; i < nb_node; ++i) {
342 [[maybe_unused]]
Int32 id = ios_file.getInteger();
343 Real nx = ios_file.getReal();
344 Real ny = ios_file.getReal();
345 Real nz = ios_file.getReal();
346 node_coords.add(Real3(nx, ny, nz));
349 ios_file.getNextLine();
378 Integer nb_entity = ios_file.getInteger();
379 Integer total_nb_node = ios_file.getInteger();
380 Integer min_node_tag = ios_file.getInteger();
381 Integer max_node_tag = ios_file.getInteger();
382 ios_file.getNextLine();
383 if (total_nb_node < 0)
385 info() <<
"[Nodes] nb_entity=" << nb_entity
386 <<
" total_nb_node=" << total_nb_node
387 <<
" min_tag=" << min_node_tag
388 <<
" max_tag=" << max_node_tag;
391 for (
Integer i_entity = 0; i_entity < nb_entity; ++i_entity) {
393 [[maybe_unused]]
Integer entity_dim = ios_file.getInteger();
395 [[maybe_unused]]
Integer entity_tag = ios_file.getInteger();
396 Integer parametric_coordinates = ios_file.getInteger();
397 Integer nb_node2 = ios_file.getInteger();
398 ios_file.getNextLine();
400 info(4) <<
"[Nodes] index=" << i_entity <<
" entity_dim=" << entity_dim <<
" entity_tag=" << entity_tag
401 <<
" parametric=" << parametric_coordinates
402 <<
" nb_node2=" << nb_node2;
403 if (parametric_coordinates != 0)
409 nodes_uids.
resize(nb_node2);
410 for (
Integer i = 0; i < nb_node2; ++i) {
412 nodes_uids[i] = ios_file.getInteger();
415 for (
Integer i = 0; i < nb_node2; ++i) {
416 Real nx = ios_file.getReal();
417 Real ny = ios_file.getReal();
418 Real nz = ios_file.getReal();
419 Real3 xyz(nx, ny, nz);
420 mesh_info.node_coords_map.add(nodes_uids[i], xyz);
423 ios_file.getNextLine();
432_readElementsFromAsciiMshV2File(
IosFile& ios_file, MeshInfo& mesh_info)
434 Integer number_of_elements = ios_file.getInteger();
435 if (number_of_elements < 0)
438 info() <<
"nb_elements=" << number_of_elements;
443 bool it_starts_at_zero =
false;
444 for (
Integer i = 0; i < number_of_elements; ++i) {
445 [[maybe_unused]]
Integer elm_number = ios_file.getInteger();
446 Integer elm_type = ios_file.getInteger();
449 Integer number_of_tags = ios_file.getInteger();
451 for (
Integer j = 0; j < number_of_tags; ++j)
452 lastTag = ios_file.getInteger();
454 if (elm_type == IT_NullType) {
455 number_of_nodes = lastTag;
456 info() <<
"We hit the case the number of nodes is encoded (number_of_nodes=" << number_of_nodes <<
")";
458 Integer cell_type = _switchMshType(elm_type, number_of_nodes);
461 if (number_of_nodes < 3) {
462 for (
Integer j = 0; j < number_of_nodes; ++j)
463 ios_file.getInteger();
467 mesh_info.cells_type.add(cell_type);
468 mesh_info.cells_nb_node.add(number_of_nodes);
469 mesh_info.cells_uid.add(i);
470 info() << elm_number <<
" " << elm_type <<
" " << number_of_tags <<
" number_of_nodes=" << number_of_nodes;
472 for (
Integer j = 0; j < number_of_nodes; ++j) {
474 Integer id = ios_file.getInteger();
476 it_starts_at_zero =
true;
477 mesh_info.cells_connectivity.add(
id);
481 if (!it_starts_at_zero)
482 for (
Integer j = 0, max = mesh_info.cells_connectivity.size(); j < max; ++j)
483 mesh_info.cells_connectivity[j] = mesh_info.cells_connectivity[j] - 1;
485 ios_file.getNextLine();
513 Integer nb_block = ios_file.getInteger();
515 Integer number_of_elements = ios_file.getInteger();
516 Integer min_element_tag = ios_file.getInteger();
517 Integer max_element_tag = ios_file.getInteger();
518 ios_file.getNextLine();
519 info() <<
"[Elements] nb_block=" << nb_block
520 <<
" nb_elements=" << number_of_elements
521 <<
" min_element_tag=" << min_element_tag
522 <<
" max_element_tag=" << max_element_tag;
524 if (number_of_elements < 0)
539 Integer entity_dim = ios_file.getInteger();
540 Integer entity_tag = ios_file.getInteger();
541 Integer entity_type = ios_file.getInteger();
542 Integer nb_entity_in_block = ios_file.getInteger();
545 Integer item_type = _switchMshType(entity_type, item_nb_node);
547 info(4) <<
"[Elements] index=" << block.index <<
" entity_dim=" << entity_dim
548 <<
" entity_tag=" << entity_tag
549 <<
" entity_type=" << entity_type <<
" nb_in_block=" << nb_entity_in_block
550 <<
" item_type=" << item_type <<
" item_nb_node=" << item_nb_node;
552 block.nb_entity = nb_entity_in_block;
553 block.item_type = item_type;
554 block.item_nb_node = item_nb_node;
555 block.dimension = entity_dim;
556 block.entity_tag = entity_tag;
558 if (entity_type==MSH_PNT){
564 [[maybe_unused]]
Int64 unused_id = ios_file.getInt64();
565 Int64 item_unique_id = ios_file.getInt64();
566 info(4) <<
"Adding unique node uid=" << item_unique_id;
567 block.uids.add(item_unique_id);
570 for (
Integer i = 0; i < nb_entity_in_block; ++i) {
571 Int64 item_unique_id = ios_file.getInt64();
572 block.uids.add(item_unique_id);
573 for (
Integer j = 0; j < item_nb_node; ++j)
574 block.connectivity.add(ios_file.getInt64());
577 ios_file.getNextLine();
583 mesh_dimension =
math::max(mesh_dimension, block.dimension);
584 if (mesh_dimension < 0)
585 ARCANE_FATAL(
"Invalid computed mesh dimension '{0}'", mesh_dimension);
586 if (mesh_dimension != 2 && mesh_dimension != 3)
588 info() <<
"Computed mesh dimension = " << mesh_dimension;
593 if (block.dimension != mesh_dimension)
596 info(4) <<
"Keeping block index=" << block.index;
598 Integer item_type = block.item_type;
599 Integer item_nb_node = block.item_nb_node;
601 for (
Integer i = 0; i < block.nb_entity; ++i) {
602 mesh_info.cells_type.
add(item_type);
603 mesh_info.cells_nb_node.
add(item_nb_node);
604 mesh_info.cells_uid.
add(block.uids[i]);
605 auto v = block.connectivity.subView(i * item_nb_node, item_nb_node);
606 mesh_info.cells_connectivity.
addRange(v);
610 return mesh_dimension;
624 ARCANE_UNUSED(ios_file);
625 ARCANE_UNUSED(node_coords);
633_allocateCells(IMesh* mesh, MeshInfo& mesh_info,
bool is_read_items)
635 Integer nb_elements = mesh_info.cells_type.size();
636 info() <<
"nb_of_elements=cells_type.size()=" << nb_elements;
637 Integer nb_cell_node = mesh_info.cells_connectivity.size();
638 info() <<
"nb_cell_node=cells_connectivity.size()=" << nb_cell_node;
641 info() <<
"Building cells, nb_cell=" << nb_elements <<
" nb_cell_node=" << nb_cell_node;
646 UniqueArray<Int64> cells_infos;
647 Integer connectivity_index = 0;
648 UniqueArray<Real3> local_coords;
649 for (
Integer i = 0; i < nb_elements; ++i) {
650 Integer current_cell_nb_node = mesh_info.cells_nb_node[i];
651 Integer cell_type = mesh_info.cells_type[i];
652 Int64 cell_uid = mesh_info.cells_uid[i];
653 cells_infos.add(cell_type);
654 cells_infos.add(cell_uid);
656 ArrayView<Int64> local_info(current_cell_nb_node, &mesh_info.cells_connectivity[connectivity_index]);
657 cells_infos.addRange(local_info);
658 connectivity_index += current_cell_nb_node;
661 IPrimaryMesh* pmesh = mesh->toPrimaryMesh();
662 info() <<
"## Allocating ##";
665 pmesh->allocateCells(nb_elements, cells_infos,
false);
667 pmesh->allocateCells(0, UniqueArray<Int64>(0),
false);
669 info() <<
"## Ending ##";
670 pmesh->endAllocate();
671 info() <<
"## Done ##";
676 bool has_map = mesh_info.node_coords.empty();
680 nodes_coord_var[node] = mesh_info.node_coords_map.lookupValue(node.uniqueId().asInt64());
682 nodes_coord_var.synchronize();
686 nodes_coord_var[node] = mesh_info.node_coords.item(node->uniqueId().asInt32());
696_allocateGroups(
IMesh*
mesh, MeshInfo& mesh_info,
bool is_read_items)
698 Int32 mesh_dim = mesh->dimension();
699 Int32 face_dim = mesh_dim - 1;
701 Int32 block_index = block.index;
702 Int32 block_dim = block.dimension;
705 Int32 block_entity_tag = block.entity_tag;
706 if (block_entity_tag < 0) {
707 info(5) <<
"[Groups] Skipping block index=" << block_index <<
" because it has no entity";
712 if (block_dim == 0) {
715 info(5) <<
"[Groups] Skipping block index=" << block_index
716 <<
" because entity tag is invalid";
719 Int32 entity_physical_tag = entity->physical_tag;
720 physical_name = mesh_info.physical_name_list.find(block_dim, entity_physical_tag);
725 info(5) <<
"[Groups] Skipping block index=" << block_index
726 <<
" because entity tag is invalid";
729 Int32 entity_physical_tag = entity->physical_tag;
730 physical_name = mesh_info.physical_name_list.find(block_dim, entity_physical_tag);
732 if (physical_name.isNull()) {
733 info(5) <<
"[Groups] Skipping block index=" << block_index
734 <<
" because entity physical tag is invalid";
737 info(4) <<
"[Groups] Block index=" << block_index <<
" dim=" << block_dim
738 <<
" name='" << physical_name.name <<
"'";
739 if (block_dim == mesh_dim) {
741 _addCellGroup(mesh, block, physical_name.name);
743 mesh->cellFamily()->findGroup(physical_name.name,
true);
745 else if (block_dim == face_dim) {
747 _addFaceGroup(mesh, block, physical_name.name);
749 mesh->faceFamily()->findGroup(physical_name.name,
true);
753 _addNodeGroup(mesh, block, physical_name.name);
755 mesh->nodeFamily()->findGroup(physical_name.name,
true);
764_addFaceGroup(
IMesh*
mesh, MeshV4ElementsBlock& block,
const String& group_name)
766 const Int32 nb_entity = block.nb_entity;
770 FaceGroup face_group = mesh->faceFamily()->findGroup(group_name,
true);
772 UniqueArray<Int32> faces_id(nb_entity);
774 const Int32 item_nb_node = block.item_nb_node;
775 const Int32 face_nb_node = nb_entity * item_nb_node;
777 UniqueArray<Int64> faces_first_node_unique_id(nb_entity);
778 UniqueArray<Int32> faces_first_node_local_id(nb_entity);
779 UniqueArray<Int64> faces_nodes_unique_id(face_nb_node);
780 Integer faces_nodes_unique_id_index = 0;
782 UniqueArray<Int64> orig_nodes_id(item_nb_node);
783 UniqueArray<Integer> face_nodes_index(item_nb_node);
785 IItemFamily* node_family = mesh->nodeFamily();
786 NodeInfoListView mesh_nodes(node_family);
790 for (
Integer i_face = 0; i_face < nb_entity; ++i_face) {
791 for (
Integer z = 0; z < item_nb_node; ++z)
792 orig_nodes_id[z] = block.connectivity[faces_nodes_unique_id_index + z];
794 mesh_utils::reorderNodesOfFace2(orig_nodes_id, face_nodes_index);
795 for (
Integer z = 0; z < item_nb_node; ++z)
796 faces_nodes_unique_id[faces_nodes_unique_id_index + z] = orig_nodes_id[face_nodes_index[z]];
797 faces_first_node_unique_id[i_face] = orig_nodes_id[face_nodes_index[0]];
798 faces_nodes_unique_id_index += item_nb_node;
801 node_family->itemsUniqueIdToLocalId(faces_first_node_local_id, faces_first_node_unique_id);
803 faces_nodes_unique_id_index = 0;
804 for (
Integer i_face = 0; i_face < nb_entity; ++i_face) {
805 const Integer n = item_nb_node;
806 Int64ConstArrayView face_nodes_id(item_nb_node, &faces_nodes_unique_id[faces_nodes_unique_id_index]);
807 Node current_node(mesh_nodes[faces_first_node_local_id[i_face]]);
808 Face face = mesh_utils::getFaceFromNodesUnique(current_node, face_nodes_id);
813 for (
Integer z = 0; z < n; ++z)
814 ostr() <<
' ' << face_nodes_id[z];
815 ostr() <<
" - " << current_node.localId() <<
")";
816 ARCANE_FATAL(
"INTERNAL: MeshMeshReader face index={0} with nodes '{1}' is not in node/face connectivity",
819 faces_id[i_face] = face.localId();
821 faces_nodes_unique_id_index += n;
823 info(4) <<
"Adding " << faces_id.size() <<
" faces from block index=" << block.index
824 <<
" to group '" << face_group.name() <<
"'";
825 face_group.addItems(faces_id);
832_addCellGroup(
IMesh*
mesh, MeshV4ElementsBlock& block,
const String& group_name)
834 const Int32 nb_entity = block.nb_entity;
838 IItemFamily* cell_family = mesh->cellFamily();
839 CellGroup cell_group = cell_family->findGroup(group_name,
true);
841 UniqueArray<Int32> cells_id(nb_entity);
843 cell_family->itemsUniqueIdToLocalId(cells_id, block.uids);
845 info(4) <<
"Adding " << cells_id.size() <<
" cells from block index=" << block.index
846 <<
" to group '" << cell_group.name() <<
"'";
847 cell_group.addItems(cells_id);
854_addNodeGroup(
IMesh*
mesh, MeshV4ElementsBlock& block,
const String& group_name)
856 const Int32 nb_entity = block.nb_entity;
860 IItemFamily* node_family = mesh->nodeFamily();
861 NodeGroup node_group = node_family->findGroup(group_name,
true);
863 UniqueArray<Int32> nodes_id(nb_entity);
865 node_family->itemsUniqueIdToLocalId(nodes_id, block.uids);
867 info(4) <<
"Adding " << nodes_id.size() <<
" nodes from block index=" << block.index
868 <<
" to group '" << node_group.name() <<
"'";
871 info(4) <<
"Nodes UIDS=" << block.uids;
872 info(4) <<
"Nodes LIDS=" << nodes_id;
874 node_group.addItems(nodes_id);
879 info(4) <<
"Node id=" << ItemPrinter(*inode) <<
" coord=" << coords[inode];
894_readPhysicalNames(
IosFile& ios_file, MeshInfo& mesh_info)
896 String quote_mark =
"\"";
897 Int32 nb_name = ios_file.getInteger();
898 info() <<
"nb_physical_name=" << nb_name;
899 ios_file.getNextLine();
900 for (
Int32 i = 0; i < nb_name; ++i) {
901 Int32 dim = ios_file.getInteger();
902 Int32 tag = ios_file.getInteger();
903 String s = ios_file.getNextLine();
904 if (dim < 0 || dim > 3)
905 ARCANE_FATAL(
"Invalid value for physical name dimension dim={0}", dim);
909 if (s.startsWith(quote_mark))
911 if (s.endsWith(quote_mark))
912 s = s.substring(0, s.length() - 1);
913 mesh_info.physical_name_list.add(dim, tag, s);
914 info(4) <<
"[PhysicalName] index=" << i <<
" dim=" << dim <<
" tag=" << tag <<
" name='" << s <<
"'";
916 StringView s = ios_file.getNextLine();
917 if (s !=
"$EndPhysicalNames")
918 ARCANE_FATAL(
"found '{0}' and expected '$EndPhysicalNames'", s);
957 Int32 nb_dim_item[4];
958 nb_dim_item[0] = ios_file.getInteger();
959 nb_dim_item[1] = ios_file.getInteger();
960 nb_dim_item[2] = ios_file.getInteger();
961 nb_dim_item[3] = ios_file.getInteger();
962 info(4) <<
"[Entities] nb_0d=" << nb_dim_item[0] <<
" nb_1d=" << nb_dim_item[1]
963 <<
" nb_2d=" << nb_dim_item[2] <<
" nb_3d=" << nb_dim_item[3];
966 StringView next_line = ios_file.getNextLine();
967 for (
Int32 i = 0; i < nb_dim_item[0]; ++i) {
968 Int32 tag = ios_file.getInteger();
969 Real x = ios_file.getReal();
970 Real y = ios_file.getReal();
971 Real z = ios_file.getReal();
972 Int32 num_physical_tag = ios_file.getInteger();
973 if (num_physical_tag > 1)
974 ARCANE_FATAL(
"NotImplemented numPhysicalTag>1 (n={0})", num_physical_tag);
975 Int32 physical_tag = -1;
976 if (num_physical_tag == 1)
977 physical_tag = ios_file.getInteger();
978 info(4) <<
"[Entities] point tag=" << tag <<
" x=" << x <<
" y=" << y <<
" z=" << z <<
" phys_tag=" << physical_tag;
980 next_line = ios_file.getNextLine();
983 for (
Int32 dim = 1; dim <= 3; ++dim) {
984 for (
Int32 i = 0; i < nb_dim_item[dim]; ++i) {
985 Int32 tag = ios_file.getInteger();
986 Real min_x = ios_file.getReal();
987 Real min_y = ios_file.getReal();
988 Real min_z = ios_file.getReal();
989 Real max_x = ios_file.getReal();
990 Real max_y = ios_file.getReal();
991 Real max_z = ios_file.getReal();
992 Int32 num_physical_tag = ios_file.getInteger();
993 if (num_physical_tag > 1)
994 ARCANE_FATAL(
"NotImplemented numPhysicalTag>1 (n={0})", num_physical_tag);
995 Int32 physical_tag = -1;
996 if (num_physical_tag == 1)
997 physical_tag = ios_file.getInteger();
998 Int32 num_bounding_group = ios_file.getInteger();
999 for (
Int32 k = 0; k < num_bounding_group; ++k) {
1000 [[maybe_unused]]
Int32 group_tag = ios_file.getInteger();
1003 info(4) <<
"[Entities] dim=" << dim <<
" tag=" << tag
1004 <<
" min_x=" << min_x <<
" min_y=" << min_y <<
" min_z=" << min_z
1005 <<
" max_x=" << max_x <<
" max_y=" << max_y <<
" max_z=" << max_z
1006 <<
" phys_tag=" << physical_tag;
1007 next_line = ios_file.getNextLine();
1011 if (s !=
"$EndEntities")
1012 ARCANE_FATAL(
"found '{0}' and expected '$EndEntities'", s);
1051 const char* func_name =
"MshMeshReader::_readMeshFromNewMshFile()";
1052 info() <<
"[_readMeshFromNewMshFile] New native mesh file format detected";
1054#define MSH_BINARY_TYPE 1
1056 Real version = ios_file.getReal();
1059 else if (version == 4.1)
1062 ARCANE_THROW(
IOException,
"Wrong msh file version '{0}'. Only versions '2.0' or '4.1' are supported", version);
1063 info() <<
"Msh mesh_major_version=" << m_version;
1064 Integer file_type = ios_file.getInteger();
1065 if (file_type == MSH_BINARY_TYPE)
1068 Integer data_size = ios_file.getInteger();
1069 ARCANE_UNUSED(data_size);
1071 if (file_type == MSH_BINARY_TYPE) {
1072 (void)ios_file.getInteger();
1074 ios_file.getNextLine();
1077 if (!ios_file.lookForString(
"$EndMeshFormat"))
1084 StringView next_line = ios_file.getNextLine();
1086 if (next_line ==
"$PhysicalNames") {
1087 _readPhysicalNames(ios_file, mesh_info);
1088 next_line = ios_file.getNextLine();
1092 if (next_line ==
"$Entities") {
1094 next_line = ios_file.getNextLine();
1097 if (next_line !=
"$Nodes")
1101 if (file_type != MSH_BINARY_TYPE) {
1102 if (m_version == 2) {
1103 if (_readNodesFromAsciiMshV2File(ios_file, mesh_info.node_coords) !=
IMeshReader::RTOk)
1106 else if (m_version == 4) {
1112 if (_readNodesFromBinaryMshFile(ios_file, mesh_info.node_coords) !=
IMeshReader::RTOk)
1116 if (!ios_file.lookForString(
"$EndNodes"))
1122 if (!ios_file.lookForString(
"$Elements"))
1126 mesh_dimension = _readElementsFromAsciiMshV2File(ios_file, mesh_info);
1127 else if (m_version == 4)
1131 if (!ios_file.lookForString(
"$EndElements"))
1132 throw IOException(func_name,
"$EndElements not found");
1135 info() <<
"Computed mesh dimension = " << mesh_dimension;
1142 Int32 rank =
mesh->meshPartInfo().partRank();
1144 bool is_read_items = !(is_parallel && rank != 0);
1145 _allocateCells(
mesh, mesh_info, is_read_items);
1146 _allocateGroups(
mesh, mesh_info, is_read_items);
1159 info() <<
"Trying to read 'msh' file '" << filename <<
"'"
1160 <<
" use_internal_partition=" << use_internal_partition;
1162 std::ifstream ifile(filename.
localstr());
1164 error() <<
"Unable to read file '" << filename <<
"'";
1168 String mesh_format_str = ios_file.getNextLine();
1169 if (IosFile::isEqualString(mesh_format_str,
"$MeshFormat"))
1171 info() <<
"The file does not begin with '$MeshFormat' returning RTError";
1182createMshParallelMeshReader(
ITraceMng* tm);
1190 bool use_new_reader =
true;
1192 use_new_reader = (v.value()!=0);
1195 reader = createMshParallelMeshReader(tm);
1197 reader = createMshMeshReader(tm);
1206class MshMeshReaderService
1225 bool use_internal_partition)
override
1227 ARCANE_UNUSED(dir_name);
1228 ARCANE_UNUSED(mesh_node);
1231 return reader->readMeshFromMshFile(
mesh, file_name, use_internal_partition);
1206class MshMeshReaderService {
…};
1250class MshCaseMeshReader
1263 , m_read_info(read_info)
1264 , m_use_internal_partition(read_info.isParallelRead())
1271 ARCANE_UNUSED(build_info);
1276 String fname = m_read_info.fileName();
1277 m_trace_mng->info() <<
"Msh Reader (ICaseMeshReader) file_name=" << fname;
1287 bool m_use_internal_partition =
false;
1301 if (read_info.format() ==
"msh")
1250class MshCaseMeshReader {
…};
#define ARCANE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Fonctions utilitaires sur le maillage.
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro pour déclarer une interface lors de l'enregistrement d'un service.
Classe de base d'un service.
AbstractService(const ServiceBuildInfo &)
Constructeur à partir d'un ServiceBuildInfo.
Tableau d'items de types quelconques.
void resize(Int64 s)
Change le nombre d'éléments du tableau à s.
void addRange(ConstReferenceType val, Int64 n)
Ajoute n élément de valeur val à la fin du tableau.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Informations nécessaires pour la lecture d'un fichier de maillage.
Table de hachage pour tableaux associatifs.
Interface du service de lecture du maillage à partir du jeu de données.
Interface d'un service de création/lecture du maillage.
Interface du service gérant la lecture d'un maillage.
eReturnType
Types des codes de retour d'une lecture ou écriture.
@ RTError
Erreur lors de l'opération.
@ RTOk
Opération effectuée avec succès.
Exception lorsqu'une erreur d'entrée/sortie est détectée.
Interface du gestionnaire de parallélisme pour un sous-domaine.
virtual bool isParallel() const =0
Retourne true si l'exécution est parallèle.
virtual void setDimension(Integer dim)=0
Positionne la dimension du maillage (1D, 2D ou 3D).
Interface du gestionnaire de traces.
Routines des Lecture/Ecriture d'un fichier.
Paramètres nécessaires à la construction d'un maillage.
void fillMeshBuildInfo(MeshBuildInfo &build_info) override
Remplit build_info avec les informations nécessaires pour créer le maillage.
void allocateMeshItems(IPrimaryMesh *pm) override
Alloue les entités du maillage géré par ce service.
Ref< IMeshBuilder > createBuilder(const CaseMeshReaderReadInfo &read_info) const override
Retourne un builder pour créer et lire le maillage dont les informations sont spécifiées dans read_in...
bool allowExtension(const String &str) override
Vérifie si le service supporte les fichiers avec l'extension str.
void build() override
Construction de niveau build du service.
eReturnType readMeshFromFile(IPrimaryMesh *mesh, const XmlNode &mesh_node, const String &file_name, const String &dir_name, bool use_internal_partition) override
Lit un maillage à partir d'un fichier.
eReturnType _readNodesFromAsciiMshV4File(IosFile &, MeshInfo &mesh_info)
eReturnType readMeshFromMshFile(IMesh *mesh, const String &file_name, bool use_internal_partition) override
void _readEntitiesV4(IosFile &ios_file, MeshInfo &mesh_info)
Lecture des entités.
eReturnType _readMeshFromNewMshFile(IMesh *, IosFile &)
Integer _readElementsFromAsciiMshV4File(IosFile &, MeshInfo &mesh_info)
Lecture des éléments (mailles,faces,...)
Exception lorsqu'une opération n'est pas supportée.
Classe gérant un vecteur de réel de dimension 3.
Référence à une instance.
Structure contenant les informations pour créer un service.
Vue sur une chaîne de caractères UTF-8.
Chaîne de caractères unicode.
const char * localstr() const
Retourne la conversion de l'instance dans l'encodage UTF-8.
static String collapseWhiteSpace(const String &rhs)
Effectue une normalisation des caractères espaces.
TraceAccessor(ITraceMng *m)
Construit un accesseur via le gestionnaire de trace m.
TraceMessage info() const
Flot pour un message d'information.
TraceMessage error() const
Flot pour un message d'erreur.
ITraceMng * traceMng() const
Gestionnaire de trace.
Vecteur 1D de données avec sémantique par valeur (style STL).
T max(const T &a, const T &b, const T &c)
Retourne le maximum de trois éléments.
ItemGroupT< Cell > CellGroup
Groupe de mailles.
ItemGroupT< Face > FaceGroup
Groupe de faces.
ItemGroupT< Node > NodeGroup
Groupe de noeuds.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro pour enregistrer un service.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
@ ST_SubDomain
Le service s'utilise au niveau du sous-domaine.
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
double Real
Type représentant un réel.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Créé une référence sur un pointeur.
std::int32_t Int32
Type entier signé sur 32 bits.
Infos du bloc '$PhysicalNames'.
Infos sur un nom physique.
Infos d'un bloc pour $Elements pour la version 4.
Int32 nb_entity
Nombre d'entités du bloc.
Int32 dimension
Dimension de l'entité
Int32 item_nb_node
Nombre de noeuds de l'entité.
Int32 index
Index du bloc dans la liste.
Integer item_type
Type Arcane de l'entité
Infos pour les entités 0D.
Infos pour les entités 1D, 2D et 3D.