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"
110 Int32 entity_tag = -1;
119 struct MeshPhysicalName
122 : dimension(_dimension)
126 MeshPhysicalName() =
default;
127 bool isNull()
const {
return dimension == (-1); }
128 Int32 dimension = -1;
136 struct MeshPhysicalNameList
138 MeshPhysicalNameList()
139 : m_physical_names(4)
147 for (
auto& x : m_physical_names[dimension])
159 struct MeshV4EntitiesNodes
161 MeshV4EntitiesNodes(
Int32 _tag,
Int32 _physical_tag)
163 , physical_tag(_physical_tag)
170 struct MeshV4EntitiesWithNodes
175 , physical_tag(_physical_tag)
187 : node_coords_map(5000,
true)
194 for (
auto& x : entities_with_nodes_list[dimension - 1])
202 for (
auto& x : entities_nodes_list)
239 Integer _readElementsFromAsciiMshV2File(
IosFile&, MeshInfo& mesh_info);
242 void _allocateCells(
IMesh*
mesh, MeshInfo& mesh_info,
bool is_read_items);
243 void _allocateGroups(
IMesh*
mesh, MeshInfo& mesh_info,
bool is_read_items);
244 void _addFaceGroup(
IMesh*
mesh, MeshV4ElementsBlock& block,
const String& group_name);
245 void _addCellGroup(
IMesh*
mesh, MeshV4ElementsBlock& block,
const String& group_name);
246 void _addNodeGroup(
IMesh*
mesh, MeshV4ElementsBlock& block,
const String& group_name);
248 void _readPhysicalNames(
IosFile& ios_file, MeshInfo& mesh_info);
255extern "C++" Ref<IMshMeshReader>
256createMshMeshReader(ITraceMng* tm)
267 switch (mshElemType) {
273 info() <<
"Could not decode IT_NullType with nNodes=" << nNodes;
274 throw IOException(
"_convertToMshType",
"Could not decode IT_NullType with nNodes");
291 return IT_Tetraedron4;
294 return IT_Hexaedron8;
297 return IT_Pentaedron6;
303 return IT_Heptaedron10;
306 return IT_Octaedron12;
322 ARCANE_THROW(NotSupportedException,
"Unknown GMSH element type '{0}'", mshElemType);
334 info() <<
"[_readNodesFromAsciiMshV2File] Looking for number-of-nodes";
335 Integer nb_node = ios_file.getInteger();
337 throw IOException(A_FUNCINFO, String(
"Invalid number of nodes: n=") + nb_node);
338 info() <<
"[_readNodesFromAsciiMshV2File] nb_node=" << nb_node;
339 for (
Integer i = 0; i < nb_node; ++i) {
341 [[maybe_unused]]
Int32 id = ios_file.getInteger();
342 Real nx = ios_file.getReal();
343 Real ny = ios_file.getReal();
344 Real nz = ios_file.getReal();
345 node_coords.add(Real3(nx, ny, nz));
348 ios_file.getNextLine();
377 Integer nb_entity = ios_file.getInteger();
378 Integer total_nb_node = ios_file.getInteger();
379 Integer min_node_tag = ios_file.getInteger();
380 Integer max_node_tag = ios_file.getInteger();
381 ios_file.getNextLine();
382 if (total_nb_node < 0)
384 info() <<
"[Nodes] nb_entity=" << nb_entity
385 <<
" total_nb_node=" << total_nb_node
386 <<
" min_tag=" << min_node_tag
387 <<
" max_tag=" << max_node_tag;
390 for (
Integer i_entity = 0; i_entity < nb_entity; ++i_entity) {
392 [[maybe_unused]]
Integer entity_dim = ios_file.getInteger();
394 [[maybe_unused]]
Integer entity_tag = ios_file.getInteger();
395 Integer parametric_coordinates = ios_file.getInteger();
396 Integer nb_node2 = ios_file.getInteger();
397 ios_file.getNextLine();
399 info(4) <<
"[Nodes] index=" << i_entity <<
" entity_dim=" << entity_dim <<
" entity_tag=" << entity_tag
400 <<
" parametric=" << parametric_coordinates
401 <<
" nb_node2=" << nb_node2;
402 if (parametric_coordinates != 0)
408 nodes_uids.
resize(nb_node2);
409 for (
Integer i = 0; i < nb_node2; ++i) {
411 nodes_uids[i] = ios_file.getInteger();
414 for (
Integer i = 0; i < nb_node2; ++i) {
415 Real nx = ios_file.getReal();
416 Real ny = ios_file.getReal();
417 Real nz = ios_file.getReal();
418 Real3 xyz(nx, ny, nz);
419 mesh_info.node_coords_map.add(nodes_uids[i], xyz);
422 ios_file.getNextLine();
431_readElementsFromAsciiMshV2File(
IosFile& ios_file, MeshInfo& mesh_info)
433 Integer number_of_elements = ios_file.getInteger();
434 if (number_of_elements < 0)
437 info() <<
"nb_elements=" << number_of_elements;
442 bool it_starts_at_zero =
false;
443 for (
Integer i = 0; i < number_of_elements; ++i) {
444 [[maybe_unused]]
Integer elm_number = ios_file.getInteger();
445 Integer elm_type = ios_file.getInteger();
448 Integer number_of_tags = ios_file.getInteger();
450 for (
Integer j = 0; j < number_of_tags; ++j)
451 lastTag = ios_file.getInteger();
453 if (elm_type == IT_NullType) {
454 number_of_nodes = lastTag;
455 info() <<
"We hit the case the number of nodes is encoded (number_of_nodes=" << number_of_nodes <<
")";
457 Integer cell_type = _switchMshType(elm_type, number_of_nodes);
460 if (number_of_nodes < 3) {
461 for (
Integer j = 0; j < number_of_nodes; ++j)
462 ios_file.getInteger();
466 mesh_info.cells_type.add(cell_type);
467 mesh_info.cells_nb_node.add(number_of_nodes);
468 mesh_info.cells_uid.add(i);
469 info() << elm_number <<
" " << elm_type <<
" " << number_of_tags <<
" number_of_nodes=" << number_of_nodes;
471 for (
Integer j = 0; j < number_of_nodes; ++j) {
473 Integer id = ios_file.getInteger();
475 it_starts_at_zero =
true;
476 mesh_info.cells_connectivity.add(
id);
480 if (!it_starts_at_zero)
481 for (
Integer j = 0, max = mesh_info.cells_connectivity.size(); j < max; ++j)
482 mesh_info.cells_connectivity[j] = mesh_info.cells_connectivity[j] - 1;
484 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() <<
"'";
870 if (nb_entity < 10) {
871 info(4) <<
"Nodes UIDS=" << block.uids;
872 info(4) <<
"Nodes LIDS=" << nodes_id;
874 node_group.addItems(nodes_id);
876 if (nb_entity < 10) {
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);
908 if (s.startsWith(quote_mark))
910 if (s.endsWith(quote_mark))
911 s = s.substring(0, s.length() - 1);
912 mesh_info.physical_name_list.add(dim, tag, s);
913 info(4) <<
"[PhysicalName] index=" << i <<
" dim=" << dim <<
" tag=" << tag <<
" name='" << s <<
"'";
915 StringView s = ios_file.getNextLine();
916 if (s !=
"$EndPhysicalNames")
917 ARCANE_FATAL(
"found '{0}' and expected '$EndPhysicalNames'", s);
956 Int32 nb_dim_item[4];
957 nb_dim_item[0] = ios_file.getInteger();
958 nb_dim_item[1] = ios_file.getInteger();
959 nb_dim_item[2] = ios_file.getInteger();
960 nb_dim_item[3] = ios_file.getInteger();
961 info(4) <<
"[Entities] nb_0d=" << nb_dim_item[0] <<
" nb_1d=" << nb_dim_item[1]
962 <<
" nb_2d=" << nb_dim_item[2] <<
" nb_3d=" << nb_dim_item[3];
965 StringView next_line = ios_file.getNextLine();
966 for (
Int32 i = 0; i < nb_dim_item[0]; ++i) {
967 Int32 tag = ios_file.getInteger();
968 Real x = ios_file.getReal();
969 Real y = ios_file.getReal();
970 Real z = ios_file.getReal();
971 Int32 num_physical_tag = ios_file.getInteger();
972 if (num_physical_tag > 1)
973 ARCANE_FATAL(
"NotImplemented numPhysicalTag>1 (n={0})", num_physical_tag);
974 Int32 physical_tag = -1;
975 if (num_physical_tag == 1)
976 physical_tag = ios_file.getInteger();
977 info(4) <<
"[Entities] point tag=" << tag <<
" x=" << x <<
" y=" << y <<
" z=" << z <<
" phys_tag=" << physical_tag;
979 next_line = ios_file.getNextLine();
982 for (
Int32 dim = 1; dim <= 3; ++dim) {
983 for (
Int32 i = 0; i < nb_dim_item[dim]; ++i) {
984 Int32 tag = ios_file.getInteger();
985 Real min_x = ios_file.getReal();
986 Real min_y = ios_file.getReal();
987 Real min_z = ios_file.getReal();
988 Real max_x = ios_file.getReal();
989 Real max_y = ios_file.getReal();
990 Real max_z = ios_file.getReal();
991 Int32 num_physical_tag = ios_file.getInteger();
992 if (num_physical_tag > 1)
993 ARCANE_FATAL(
"NotImplemented numPhysicalTag>1 (n={0})", num_physical_tag);
994 Int32 physical_tag = -1;
995 if (num_physical_tag == 1)
996 physical_tag = ios_file.getInteger();
997 Int32 num_bounding_group = ios_file.getInteger();
998 for (
Int32 k = 0; k < num_bounding_group; ++k) {
999 [[maybe_unused]]
Int32 group_tag = ios_file.getInteger();
1002 info(4) <<
"[Entities] dim=" << dim <<
" tag=" << tag
1003 <<
" min_x=" << min_x <<
" min_y=" << min_y <<
" min_z=" << min_z
1004 <<
" max_x=" << max_x <<
" max_y=" << max_y <<
" max_z=" << max_z
1005 <<
" phys_tag=" << physical_tag;
1006 next_line = ios_file.getNextLine();
1010 if (s !=
"$EndEntities")
1011 ARCANE_FATAL(
"found '{0}' and expected '$EndEntities'", s);
1050 const char* func_name =
"MshMeshReader::_readMeshFromNewMshFile()";
1051 info() <<
"[_readMeshFromNewMshFile] New native mesh file format detected";
1053#define MSH_BINARY_TYPE 1
1055 Real version = ios_file.getReal();
1058 else if (version == 4.1)
1061 ARCANE_THROW(
IOException,
"Wrong msh file version '{0}'. Only versions '2.0' or '4.1' are supported", version);
1062 info() <<
"Msh mesh_major_version=" << m_version;
1063 Integer file_type = ios_file.getInteger();
1064 if (file_type == MSH_BINARY_TYPE)
1067 Integer data_size = ios_file.getInteger();
1068 ARCANE_UNUSED(data_size);
1070 if (file_type == MSH_BINARY_TYPE) {
1071 (void)ios_file.getInteger();
1073 ios_file.getNextLine();
1076 if (!ios_file.lookForString(
"$EndMeshFormat"))
1083 StringView next_line = ios_file.getNextLine();
1085 if (next_line ==
"$PhysicalNames") {
1086 _readPhysicalNames(ios_file, mesh_info);
1087 next_line = ios_file.getNextLine();
1091 if (next_line ==
"$Entities") {
1093 next_line = ios_file.getNextLine();
1096 if (next_line !=
"$Nodes")
1100 if (file_type != MSH_BINARY_TYPE) {
1101 if (m_version == 2) {
1102 if (_readNodesFromAsciiMshV2File(ios_file, mesh_info.node_coords) !=
IMeshReader::RTOk)
1105 else if (m_version == 4) {
1111 if (_readNodesFromBinaryMshFile(ios_file, mesh_info.node_coords) !=
IMeshReader::RTOk)
1115 if (!ios_file.lookForString(
"$EndNodes"))
1121 if (!ios_file.lookForString(
"$Elements"))
1125 mesh_dimension = _readElementsFromAsciiMshV2File(ios_file, mesh_info);
1126 else if (m_version == 4)
1130 if (!ios_file.lookForString(
"$EndElements"))
1131 throw IOException(func_name,
"$EndElements not found");
1134 info() <<
"Computed mesh dimension = " << mesh_dimension;
1141 Int32 rank =
mesh->meshPartInfo().partRank();
1143 bool is_read_items = !(is_parallel && rank != 0);
1144 _allocateCells(
mesh, mesh_info, is_read_items);
1145 _allocateGroups(
mesh, mesh_info, is_read_items);
1158 info() <<
"Trying to read 'msh' file '" << filename <<
"'"
1159 <<
" use_internal_partition=" << use_internal_partition;
1161 std::ifstream ifile(filename.
localstr());
1163 error() <<
"Unable to read file '" << filename <<
"'";
1167 String mesh_format_str = ios_file.getNextLine();
1168 if (IosFile::isEqualString(mesh_format_str,
"$MeshFormat"))
1170 info() <<
"The file does not begin with '$MeshFormat' returning RTError";
1181createMshParallelMeshReader(
ITraceMng* tm);
1189 bool use_new_reader =
true;
1191 use_new_reader = (v.value() != 0);
1194 reader = createMshParallelMeshReader(tm);
1196 reader = createMshMeshReader(tm);
1205class MshMeshReaderService
1224 bool use_internal_partition)
override
1226 ARCANE_UNUSED(dir_name);
1227 ARCANE_UNUSED(mesh_node);
1230 return reader->readMeshFromMshFile(
mesh, file_name, use_internal_partition);
1249class MshCaseMeshReader
1262 , m_read_info(read_info)
1263 , m_use_internal_partition(read_info.isParallelRead())
1270 ARCANE_UNUSED(build_info);
1275 String fname = m_read_info.fileName();
1276 m_trace_mng->info() <<
"Msh Reader (ICaseMeshReader) file_name=" << fname;
1286 bool m_use_internal_partition =
false;
1300 if (read_info.format() ==
"msh")
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Utility functions for the mesh.
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro to declare an interface when registering a service.
AbstractService(const ServiceBuildInfo &)
Constructor from a ServiceBuildInfo.
Base class for 1D data vectors.
void addRange(ConstReferenceType val, Int64 n)
Adds n elements of value val to the end of the array.
void resize(Int64 s)
Changes the number of elements in the array to s.
void add(ConstReferenceType val)
Adds element val to the end of the array.
Necessary information for reading a mesh file.
Template class for converting a type.
Hash table for associative arrays.
Interface for the mesh reading service from the dataset.
Interface of a mesh creation/reading service.
Interface of the service managing the reading of a mesh.
eReturnType
Types of return codes for a read or write operation.
@ RTError
Error during the operation.
@ RTOk
Operation successfully performed.
Exception when an input/output error is detected.
Interface of the parallelism manager for a subdomain.
virtual bool isParallel() const =0
Returns true if the execution is parallel.
virtual void setDimension(Integer dim)=0
Positions the mesh dimension (1D, 2D, or 3D).
File Read/Write Routines.
Parameters necessary for building a mesh.
void fillMeshBuildInfo(MeshBuildInfo &build_info) override
Fills build_info with the necessary information to create the mesh.
void allocateMeshItems(IPrimaryMesh *pm) override
Allocates the mesh entities managed by this service.
Ref< IMeshBuilder > createBuilder(const CaseMeshReaderReadInfo &read_info) const override
Returns a builder to create and read the mesh whose information is specified in read_info.
bool allowExtension(const String &str) override
Checks if the service supports files with the extension str.
void build() override
Build-level construction of the service.
eReturnType readMeshFromFile(IPrimaryMesh *mesh, const XmlNode &mesh_node, const String &file_name, const String &dir_name, bool use_internal_partition) override
Reads a mesh from a file.
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)
Reading of entities.
eReturnType _readMeshFromNewMshFile(IMesh *, IosFile &)
Integer _readElementsFromAsciiMshV4File(IosFile &, MeshInfo &mesh_info)
Reading elements (cells, faces, ...).
Exception when an operation is not supported.
Class managing a 3-dimensional real vector.
Reference to an instance.
Structure containing the information to create a service.
View of a UTF-8 character string.
Unicode character string.
const char * localstr() const
Returns the conversion of the instance into UTF-8 encoding.
static String collapseWhiteSpace(const String &rhs)
Performs whitespace character normalization.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessage info() const
Flow for an information message.
TraceMessage error() const
Flow for an error message.
ITraceMng * traceMng() const
Trace manager.
1D data vector with value semantics (STL style).
T max(const T &a, const T &b, const T &c)
Returns the maximum of three elements.
ItemGroupT< Cell > CellGroup
Group of cells.
ItemGroupT< Face > FaceGroup
Group of faces.
ItemGroupT< Node > NodeGroup
Group of nodes.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro for registering a service.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Coordinate type quantity at node.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
@ ST_SubDomain
The service is used at the subdomain level.
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
double Real
Type representing a real number.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.
std::int32_t Int32
Signed integer type of 32 bits.
Information about the '$PhysicalNames' block.
Information about a physical name.
Information about a block for $Elements for version 4.
Int32 nb_entity
Number of entities in the block.
Int32 dimension
Dimension of the entity.
Int32 item_nb_node
Number of nodes in the entity.
Int32 index
Block index in the list.
Integer item_type
Arcane type of the entity.
Info for 1D, 2D, and 3D entities.