14#include "arcane/utils/ITraceMng.h"
15#include "arcane/utils/SmallArray.h"
16#include "arcane/utils/FixedArray.h"
18#include "arcane/core/IMeshReader.h"
19#include "arcane/core/BasicService.h"
21#include "arcane/core/IPrimaryMesh.h"
22#include "arcane/core/IItemFamily.h"
23#include "arcane/core/ICaseMeshReader.h"
24#include "arcane/core/IMeshBuilder.h"
25#include "arcane/core/IParallelMng.h"
26#include "arcane/core/MeshPartInfo.h"
27#include "arcane/core/NodesOfItemReorderer.h"
29#include "arcane/core/ItemPrinter.h"
60 class MEDToArcaneItemInfo
64 MEDToArcaneItemInfo(
int dimension,
int nb_node, med_int med_type,
66 : m_dimension(dimension)
68 , m_med_type(med_type)
69 , m_arcane_type(arcane_type)
70 , m_indirection(indirection)
75 int dimension()
const {
return m_dimension; }
76 int nbNode()
const {
return m_nb_node; }
77 med_int medType()
const {
return m_med_type; }
78 Int16 arcaneType()
const {
return m_arcane_type; }
79 const Int32* indirection()
const {
return m_indirection; }
85 med_int m_med_type = {};
87 const Int32* m_indirection =
nullptr;
95 explicit MEDFamilyInfo(
Int32 family_id)
119 explicit MEDGroupInfo(
Int32 index)
140 _initMEDToArcaneTypes();
157 explicit AutoCloseMED(med_idt
id)
170 IPrimaryMesh* m_mesh =
nullptr;
172 UniqueArray<MEDToArcaneItemInfo> m_med_to_arcane_types;
174 std::unordered_map<med_int, Int32> m_med_geotype_to_arcane_type_index;
176 std::unordered_map<Int32, MEDFamilyInfo> m_med_families_map;
178 UniqueArray<MEDGroupInfo> m_med_groups;
180 UniqueArray<med_int> m_med_geotypes_in_mesh;
185 Array<med_int>& connectivity, Array<med_int>& family_values);
186 void _initMEDToArcaneTypes();
187 void _addTypeInfo(
int dimension,
int nb_node, med_int med_type, ItemTypeId arcane_type)
189 _addTypeInfo(dimension, nb_node, med_type, arcane_type,
nullptr);
191 void _addTypeInfo(
int dimension,
int nb_node, med_int med_type, ItemTypeId arcane_type,
192 const Int32* indirection)
195 Int32 index = m_med_to_arcane_types.size();
196 m_med_to_arcane_types.add(t);
197 m_med_geotype_to_arcane_type_index.insert(std::make_pair(med_type, index));
199 void _readAndCreateCells(IPrimaryMesh* mesh,
Int32 mesh_dimension, med_idt fid,
const char* meshname);
200 void _readFaces(IPrimaryMesh* mesh,
Int32 mesh_dimension, med_idt fid,
const char* meshname);
203 _readNodesCoordinates(IPrimaryMesh* mesh,
Int64 nb_node,
Int32 spacedim,
204 med_idt fid,
const char* meshname);
205 void _readFamilies(med_idt fid,
const char* meshname);
206 void _readAvailableTypes(med_idt fid,
const char* meshname);
207 void _clearItemsInGroups()
210 g.m_unique_ids.clear();
211 g.m_local_ids.clear();
214 void _broadcastGroups(ConstArrayView<String> names, IItemFamily* family);
224 const Int32 Hexaedron8_indirection[] = { 1, 0, 3, 2, 5, 4, 7, 6 };
225 const Int32 Hexaedron20_indirection[] = { 1, 8, 10, 3, 9, 2, 0, 11, 5, 14, 18, 7, 6, 4, 16, 15, 13, 12, 17, 19 };
226 const Int32 Pyramid5_indirection[] = { 1, 0, 3, 2, 4 };
227 const Int32 Quad4_indirection[] = { 1, 0, 3, 2 };
228 const Int32 Quad8_indirection[] = { 1, 0, 3, 2, 5, 4, 7, 6 };
229 const Int32 Triangle3_indirection[] = { 1, 0, 2 };
231 const Int32 Tetraedron4_indirection[] = { 1, 0, 2, 3 };
238_initMEDToArcaneTypes()
240 m_med_to_arcane_types.clear();
245 _addTypeInfo(1, 2, MED_SEG2, ITI_Line2);
246 _addTypeInfo(1, 3, MED_SEG3, ITI_Line3);
247 _addTypeInfo(1, 4, MED_SEG4, ITI_NullType);
250 _addTypeInfo(2, 3, MED_TRIA3, ITI_Triangle3, Triangle3_indirection);
251 _addTypeInfo(2, 4, MED_QUAD4, ITI_Quad4, Quad4_indirection);
252 _addTypeInfo(2, 6, MED_TRIA6, ITI_NullType);
253 _addTypeInfo(2, 7, MED_TRIA7, ITI_NullType);
254 _addTypeInfo(2, 8, MED_QUAD8, ITI_Quad8, Quad8_indirection);
255 _addTypeInfo(2, 9, MED_QUAD9, ITI_NullType);
258 _addTypeInfo(3, 4, MED_TETRA4, ITI_Tetraedron4);
259 _addTypeInfo(3, 5, MED_PYRA5, ITI_Pyramid5, Pyramid5_indirection);
260 _addTypeInfo(3, 6, MED_PENTA6, ITI_Pentaedron6);
261 _addTypeInfo(3, 8, MED_HEXA8, ITI_Hexaedron8, Hexaedron8_indirection);
262 _addTypeInfo(3, 10, MED_TETRA10, ITI_Tetraedron10);
263 _addTypeInfo(3, 12, MED_OCTA12, ITI_Octaedron12);
264 _addTypeInfo(3, 13, MED_PYRA13, ITI_NullType);
265 _addTypeInfo(3, 15, MED_PENTA15, ITI_NullType);
266 _addTypeInfo(3, 18, MED_PENTA18, ITI_NullType);
267 _addTypeInfo(3, 20, MED_HEXA20, ITI_Hexaedron20, Hexaedron20_indirection);
268 _addTypeInfo(3, 27, MED_HEXA27, ITI_NullType);
276 _addTypeInfo(2, 0, MED_POLYGON, ITI_NullType);
277 _addTypeInfo(2, 0, MED_POLYGON2, ITI_NullType);
278 _addTypeInfo(3, 0, MED_POLYHEDRON, ITI_NullType);
292 info() <<
"Trying to read MED File name=" << file_name;
294 return _readMesh(mesh, file_name);
303 const med_idt fid = MEDfileOpen(filename.localstr(), MED_ACC_RDONLY);
305 MESSAGE(
"ERROR: can not open MED file ");
306 error() <<
"ERROR: can not open MED file '" << filename <<
"'";
310 AutoCloseMED auto_close_med(fid);
312 int nb_mesh = MEDnMesh(fid);
314 error() <<
"Error reading number of meshes";
317 info() <<
"MED: nb_mesh=" << nb_mesh;
319 error() <<
"No mesh is present";
327 int nb_axis = MEDmeshnAxis(fid, mesh_index);
329 error() <<
"Can not read number of axis (MEDmeshnAxis)";
332 info() <<
"MED: nb_axis=" << nb_axis;
334 UniqueArray<char> axisname(MED_SNAME_SIZE * nb_axis + 1,
'\0');
335 UniqueArray<char> unitname(MED_SNAME_SIZE * nb_axis + 1,
'\0');
337 char meshname[MED_NAME_SIZE + 1];
339 char meshdescription[MED_COMMENT_SIZE + 1];
340 meshdescription[0] =
'\0';
341 char dtunit[MED_SNAME_SIZE + 1];
343 med_int spacedim = 0;
345 med_mesh_type meshtype = MED_UNDEF_MESH_TYPE;
346 med_sorting_type sortingtype = MED_SORT_UNDEF;
348 med_axis_type axistype = MED_UNDEF_AXIS_TYPE;
350 err = MEDmeshInfo(fid, mesh_index, meshname, &spacedim, &meshdim, &meshtype, meshdescription,
351 dtunit, &sortingtype, &nstep, &axistype, axisname.data(), unitname.data());
353 error() <<
"Can not read mesh info (MEDmeshInfo) r=" << err;
356 if (meshtype != MED_UNSTRUCTURED_MESH) {
357 error() <<
"Arcane handle only MED unstructured mesh (MED_UNSTRUCTURED_MESH) type=" << meshtype;
360 Integer mesh_dimension = meshdim;
361 if (mesh_dimension != 2 && mesh_dimension != 3)
362 ARCANE_FATAL(
"MED reader handles only 2D or 3D meshes");
364 info() <<
"MED: name=" << meshname;
365 info() <<
"MED: description=" << meshdescription;
366 info() <<
"MED: spacedim=" << spacedim;
367 info() <<
"MED: meshdim=" << meshdim;
368 info() <<
"MED: dtunit=" << dtunit;
369 info() <<
"MED: meshtype=" << meshtype;
370 info() <<
"MED: sortingtype=" << sortingtype;
371 info() <<
"MED: axistype=" << axistype;
372 info() <<
"MED: nstep=" << nstep;
377 med_bool coordinatechangement;
378 med_bool geotransformation;
381 med_int med_nb_node = MEDmeshnEntity(fid, meshname, MED_NO_DT, MED_NO_IT, MED_NODE, MED_NO_GEOTYPE,
382 MED_COORDINATE, MED_NO_CMODE, &coordinatechangement,
384 if (med_nb_node < 0) {
385 error() <<
"Can not read number of nodes (MEDmeshnEntity) err=" << med_nb_node;
388 nb_node = med_nb_node;
390 info() <<
"MED: nb_node=" << nb_node;
392 mesh->setDimension(mesh_dimension);
394 IParallelMng* pm = mesh->parallelMng();
395 bool is_parallel = pm->isParallel();
396 Int32 rank = mesh->meshPartInfo().partRank();
398 bool is_read_items = !(is_parallel && rank != 0);
400 _readAvailableTypes(fid, meshname);
401 _readFamilies(fid, meshname);
402 _readAndCreateCells(mesh, mesh_dimension, fid, meshname);
411 UniqueArray<String> cell_group_names;
412 IItemFamily* cell_family = mesh->cellFamily();
419 UniqueArray<Int32> cell_local_ids;
421 Int32 nb_cell_in_group = g.m_unique_ids.size();
422 cell_local_ids.resize(nb_cell_in_group);
423 cell_family->itemsUniqueIdToLocalId(cell_local_ids, g.m_unique_ids);
424 for (
const String& name : g.m_names) {
425 info() <<
"Group=" << name <<
" index=" << g.m_index <<
" nb_item=" << nb_cell_in_group;
426 CellGroup cell_group = cell_family->findGroup(name,
true);
427 cell_group.
addItems(cell_local_ids);
428 cell_group_names.add(name);
432 _broadcastGroups(cell_group_names, cell_family);
439 bool is_face_group_disabled =
false;
441 is_face_group_disabled = (v.value());
442 if (!is_face_group_disabled)
443 _readFaces(mesh, mesh_dimension, fid, meshname);
446 UniqueArray<String> face_group_names;
447 IItemFamily* face_family = mesh->faceFamily();
451 Int32 nb_face_in_group = g.m_local_ids.size();
452 info() <<
"Check Group index=" << g.m_index <<
" nb_item=" << nb_face_in_group;
453 if (nb_face_in_group == 0)
455 for (
const String& name : g.m_names) {
456 info() <<
"FaceGroup=" << name <<
" index=" << g.m_index <<
" nb_item=" << nb_face_in_group;
457 FaceGroup face_group = face_family->findGroup(name,
true);
459 face_group_names.add(name);
463 _broadcastGroups(face_group_names, face_family);
467 return _readNodesCoordinates(mesh, nb_node, spacedim, fid, meshname);
478_readAvailableTypes(med_idt fid,
const char* meshname)
481 med_bool coordinatechangement;
482 med_bool geotransformation;
483 med_int nb_geo = MEDmeshnEntity(fid, meshname, MED_NO_DT, MED_NO_IT, MED_CELL, MED_GEO_ALL,
484 MED_CONNECTIVITY, MED_NODAL, &coordinatechangement,
487 ARCANE_FATAL(
"Can not read number of geometric entities nb_geo={0}", nb_geo);
488 info() <<
"MED: nb_geotype = " << nb_geo;
491 for (med_int it = 1; it <= nb_geo; it++) {
493 med_geometry_type geotype = MED_GEO_ALL;
494 FixedArray<char, MED_NAME_SIZE + 1> geotype_name;
497 med_int type_ret = MEDmeshEntityInfo(fid, meshname, MED_NO_DT, MED_NO_IT, MED_CELL, it,
498 geotype_name.data(), &geotype);
500 ARCANE_FATAL(
"Can not read informations for geotype index={0} ret={1}", it, type_ret);
502 med_int nb_item = MEDmeshnEntity(fid, meshname, MED_NO_DT, MED_NO_IT, MED_CELL, geotype,
503 MED_CONNECTIVITY, MED_NODAL, &coordinatechangement,
506 ARCANE_FATAL(
"Can not read number of items for geotype={0} name={1} ret={2}",
507 geotype, geotype_name.data(), nb_item);
508 info() <<
"MED: type=" << geotype <<
" '" << geotype_name.data() <<
"' nb_item=" << nb_item;
509 m_med_geotypes_in_mesh.add(geotype);
517_readAndCreateCells(
IPrimaryMesh* mesh,
Int32 mesh_dimension, med_idt fid,
const char* meshname)
519 _clearItemsInGroups();
524 Int64 cell_unique_id = 0;
529 for (med_int geotype : m_med_geotypes_in_mesh) {
530 Int32 index_in_list = m_med_geotype_to_arcane_type_index[geotype];
533 Int32 item_dimension = iinfo.dimension();
535 if (item_dimension != mesh_dimension)
537 UniqueArray<med_int> med_connectivity;
538 UniqueArray<med_int> med_family_values;
539 Int32 nb_item = _readItems(fid, meshname, iinfo, med_connectivity, med_family_values);
542 Int16 arcane_type = iinfo.arcaneType();
543 Int32 nb_item_node = iinfo.nbNode();
544 Int32 nb_family_values = med_family_values.size();
545 if (arcane_type == IT_NullType) {
547 ARCANE_FATAL(
"MED type '{0}' is not supported by Arcane", iinfo.medType());
549 Int64 cells_infos_index = 0;
550 Int64 med_connectivity_index = 0;
551 UniqueArray<Int64> cells_infos((2 + nb_item_node) * nb_item);
552 info() <<
"CELL_INFOS size=" << cells_infos.size() <<
" nb_item=" << nb_item
553 <<
" type=" << arcane_type;
554 const Int32* indirection = iinfo.indirection();
555 for (
Int32 i = 0; i < nb_item; ++i) {
556 Int64 current_cell_unique_id = cell_unique_id;
558 cells_infos[cells_infos_index] = arcane_type;
560 cells_infos[cells_infos_index] = current_cell_unique_id;
564 Span<Int64> cinfo_span(cells_infos.span().subspan(cells_infos_index, nb_item_node));
565 Span<med_int> med_cinfo_span(med_connectivity.span().subspan(med_connectivity_index, nb_item_node));
567 for (
Integer k = 0; k < nb_item_node; ++k) {
568 cinfo_span[k] = med_cinfo_span[indirection[k]] - 1;
572 for (
Integer k = 0; k < nb_item_node; ++k)
573 cinfo_span[k] = med_cinfo_span[k] - 1;
575 if (i < nb_family_values) {
577 med_int f = med_family_values[i];
578 auto x = m_med_families_map.find(f);
579 if (x == m_med_families_map.end()) {
580 ARCANE_FATAL(
"Can not find family id '{0}' for cell '{1}' of geotype '{2}'",
581 f, i, iinfo.medType());
583 m_med_groups[x->second.m_index].m_unique_ids.add(current_cell_unique_id);
586 med_connectivity_index += nb_item_node;
587 cells_infos_index += nb_item_node;
589 mesh->allocateCells(nb_item, cells_infos,
false);
604_readFaces(
IPrimaryMesh* mesh,
Int32 mesh_dimension, med_idt fid,
const char* meshname)
606 _clearItemsInGroups();
607 ItemTypeMng* itm = mesh->itemTypeMng();
608 NodesOfItemReorderer nodes_reorderer(itm);
610 IItemFamily* node_family = mesh->nodeFamily();
611 NodeInfoListView mesh_nodes(node_family);
615 for (med_int geotype : m_med_geotypes_in_mesh) {
616 Int32 index_in_list = m_med_geotype_to_arcane_type_index[geotype];
619 Int32 item_dimension = iinfo.dimension();
621 if (item_dimension != (mesh_dimension - 1))
623 ItemTypeInfo* iti = itm->typeFromId(iinfo.arcaneType());
624 info() <<
"Reading faces geotype=" << geotype <<
" arcane_type=" << iinfo.arcaneType()
625 <<
" " << iti->typeName();
627 UniqueArray<med_int> med_connectivity;
628 UniqueArray<med_int> med_family_values;
629 Int32 nb_item = _readItems(fid, meshname, iinfo, med_connectivity, med_family_values);
632 ItemTypeId arcane_type(iinfo.arcaneType());
633 Int32 nb_item_node = iinfo.nbNode();
634 Int32 nb_family_values = med_family_values.size();
635 if (arcane_type == IT_NullType) {
637 ARCANE_FATAL(
"MED type '{0}' is not supported by Arcane", iinfo.medType());
640 SmallArray<Int64> orig_nodes_id(nb_item_node);
641 info() <<
"FACES_INFOS nb_item=" << nb_item <<
" type=" << arcane_type
642 <<
" nb_family_values=" << nb_family_values;
644 const Int32* indirection = iinfo.indirection();
645 Int64 med_connectivity_index = 0;
647 for (
Int32 i = 0; i < nb_item; ++i) {
650 ArrayView<Int64> cinfo_span(orig_nodes_id);
651 Span<med_int> med_cinfo_span(med_connectivity.span().subspan(med_connectivity_index, nb_item_node));
653 for (
Integer k = 0; k < nb_item_node; ++k) {
654 cinfo_span[k] = med_cinfo_span[indirection[k]] - 1;
658 for (
Integer k = 0; k < nb_item_node; ++k)
659 cinfo_span[k] = med_cinfo_span[k] - 1;
661 med_connectivity_index += nb_item_node;
663 nodes_reorderer.reorder(arcane_type, cinfo_span);
664 ConstArrayView<Int64> ordered_nodes = nodes_reorderer.sortedNodes();
668 Node first_node(MeshUtils::findOneItem(node_family, ordered_nodes[0]));
669 if (first_node.null())
670 ARCANE_FATAL(
"Can not find node uid={0} for face index '{1}'", ordered_nodes[0], i);
671 Face face = MeshUtils::getFaceFromNodesUniqueId(first_node, ordered_nodes);
673 info() <<
"ERROR: Can not find face in mesh i=" << i <<
" nodes=" << ordered_nodes;
674 info() <<
"List of faces for node=" << ItemPrinter(first_node);
675 for (Face subface : first_node.faces()) {
676 info() <<
"Face=" << ItemPrinter(subface);
677 for (Node subnode : subface.nodes()) {
678 info() <<
" Node=" << ItemPrinter(subnode);
681 ARCANE_FATAL(
"Can not find face with nodes=", ordered_nodes);
686 if (i < nb_family_values) {
688 med_int f = med_family_values[i];
689 auto x = m_med_families_map.find(f);
690 if (x == m_med_families_map.end()) {
691 ARCANE_FATAL(
"Can not find family id '{0}' for face '{1}' of geotype '{2}'",
692 f, i, iinfo.medType());
695 m_med_groups[x->second.m_index].m_local_ids.add(face.localId());
698 info() <<
"END_READING_ITEMS";
707 med_idt fid,
const char* meshname)
709 const bool do_verbose =
false;
711 UniqueArray<Real3> nodes_coordinates(nb_node);
713 UniqueArray<med_float> coordinates(nb_node * spacedim);
714 int err = MEDmeshNodeCoordinateRd(fid, meshname, MED_NO_DT, MED_NO_IT, MED_FULL_INTERLACE,
717 error() <<
"Can not read nodes coordinates err=" << err;
722 for (
Int64 i = 0; i < nb_node; ++i) {
723 Real3 xyz(coordinates[i * 3], coordinates[(i * 3) + 1], coordinates[(i * 3) + 2]);
725 info() <<
"I=" << i <<
" XYZ=" << xyz;
726 nodes_coordinates[i] = xyz;
729 else if (spacedim == 2) {
730 for (
Int64 i = 0; i < nb_node; ++i) {
731 Real3 xyz(coordinates[i * 2], coordinates[(i * 2) + 1], 0.0);
733 info() <<
"I=" << i <<
" XYZ=" << xyz;
734 nodes_coordinates[i] = xyz;
738 ARCANE_THROW(NotImplementedException,
"spacedim!=2 && spacedim!=3");
746 nodes_coord_var[inode] = nodes_coordinates[node.uniqueId()];
766_readItems(med_idt fid,
const char* meshname,
const MEDToArcaneItemInfo& iinfo,
769 constexpr bool is_verbose =
false;
771 connectivity.clear();
772 family_values.clear();
774 int med_item_type = iinfo.medType();
775 med_bool coordinatechangement;
776 med_bool geotransformation;
777 med_int nb_med_item = ::MEDmeshnEntity(fid, meshname, MED_NO_DT, MED_NO_IT, MED_CELL, med_item_type,
778 MED_CONNECTIVITY, MED_NODAL, &coordinatechangement,
781 ARCANE_FATAL(
"Can not read MED med_item_type '{0}' error={1}", med_item_type, nb_med_item);
783 info() <<
"MED: Reading items";
784 info() <<
"MED: type=" << med_item_type <<
" nb_item=" << nb_med_item;
785 if (nb_med_item == 0)
788 Int64 nb_node = iinfo.nbNode();
791 ARCANE_THROW(NotImplementedException,
"Reading items with MED type '{0}'", med_item_type);
793 connectivity.resize(nb_node * nb_med_item);
794 int err = MEDmeshElementConnectivityRd(fid, meshname, MED_NO_DT, MED_NO_IT, MED_CELL,
795 med_item_type, MED_NODAL, MED_FULL_INTERLACE,
796 connectivity.data());
798 ARCANE_FATAL(
"Can not read connectivity MED med_item_type '{0}' error={1}",
802 info() <<
"CON: " << connectivity;
804 med_int nb_med_family = MEDmeshnEntity(fid, meshname, MED_NO_DT, MED_NO_IT,
805 MED_CELL, med_item_type, MED_FAMILY_NUMBER, MED_NODAL,
806 &coordinatechangement, &geotransformation);
807 info() <<
"nb_family=" << nb_med_family;
808 if (nb_med_family < 0)
809 ARCANE_FATAL(
"Can not read family size for type med_item_type={0} error={1}", med_item_type, nb_med_family);
810 if (nb_med_family > 0) {
811 family_values.resize(nb_med_family);
812 int r = MEDmeshEntityFamilyNumberRd(fid, meshname, MED_NO_DT, MED_NO_IT,
813 MED_CELL, med_item_type, family_values.data());
815 ARCANE_FATAL(
"Can not read family values for type med_item_type={0} error={1}", med_item_type, nb_med_family);
817 info() <<
"FAM: " << family_values;
827_readFamilies(med_idt fid,
const char* meshname)
829 FixedArray<char, MED_NAME_SIZE + 1> familyname;
831 info() <<
"Read families";
834 med_int nb_family = MEDnFamily(fid, meshname);
836 ARCANE_FATAL(
"Can not read number of families (error={0})", nb_family);
838 info() <<
"MED: nb_family= " << nb_family;
839 for (med_int i = 0; i < nb_family; i++) {
840 info() <<
"MED: Read family i=" << i;
842 med_int nb_group = MEDnFamilyGroup(fid, meshname, i + 1);
844 ARCANE_FATAL(
"Can not read number of groups for family index={0}", i);
845 info() <<
"MED: family index=" << i <<
" nb_group=" << nb_group;
852 UniqueArray<char> all_group_names(MED_LNAME_SIZE * nb_group + 1);
853 med_int family_number = 0;
854 if (MEDfamilyInfo(fid, meshname, i + 1, familyname.data(), &family_number, all_group_names.data()) < 0)
855 ARCANE_FATAL(
"Can not read group names from family index={0}", i);
858 Int32 group_index = m_med_groups.size();
859 med_family.m_index = group_index;
863 for (
Int32 z = 0; z < nb_group; ++z) {
865 SmallSpan<char> med_group_name = all_group_names.smallSpan().subSpan(MED_LNAME_SIZE * z, MED_LNAME_SIZE);
868 SmallArray<Byte, MED_LNAME_SIZE + 1> valid_name;
870 for (; pos < MED_LNAME_SIZE; ++pos) {
871 char c = med_group_name[pos];
874 if (c ==
' ' || c ==
'_')
876 valid_name.add(
static_cast<Byte>(c));
878 String name(valid_name.view());
879 med_group.m_names.add(name);
880 info() <<
"Family id=" << family_number <<
" group='" << name <<
"'";
883 m_med_families_map.insert(std::make_pair(family_number, med_family));
884 m_med_groups.add(med_group);
898 IParallelMng* pm = m_mesh->parallelMng();
900 Int32 rank = pm->commRank();
903 Int32 nb_group = group_names.size();
904 pm->broadcast(ArrayView<Int32>(1, &nb_group), 0);
905 for (String name : group_names)
906 pm->broadcastString(name, 0);
910 pm->broadcast(ArrayView<Int32>(1, &nb_group), 0);
911 String current_group_name;
912 for (
Int32 i = 0; i < nb_group; ++i) {
913 pm->broadcastString(current_group_name, 0);
914 CellGroup cell_group = family->findGroup(current_group_name,
true);
927class MEDMeshReaderService
945 [[maybe_unused]]
const XmlNode& mesh_element,
948 [[maybe_unused]]
bool use_internal_partition)
override
950 ARCANE_UNUSED(dir_name);
952 return reader.readMesh(mesh, file_name);
971class MEDCaseMeshReader
984 , m_read_info(read_info)
991 ARCANE_UNUSED(build_info);
996 String fname = m_read_info.fileName();
997 m_trace_mng->info() <<
"MED Reader (ICaseMeshReader) file_name=" << fname;
1020 if (read_info.format() ==
"med")
#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.
Ce fichier contient les différentes fabriques de services et macro pour enregistrer les services.
#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.
Classe de base des vecteurs 1D de données.
Informations nécessaires pour la lecture d'un fichier de maillage.
Vue constante d'un tableau de type T.
static std::optional< Int32 > tryParseFromEnvironment(StringView s, bool throw_if_invalid)
Interface du service de lecture du maillage à partir du jeu de données.
Interface d'une famille d'entités.
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.
Interface du gestionnaire de traces.
void addItems(Int32ConstArrayView items_local_id, bool check_if_present=true)
Ajoute des entités.
Type d'une entité (Item).
void allocateMeshItems(IPrimaryMesh *pm) override
Alloue les entités du maillage géré par ce service.
void fillMeshBuildInfo(MeshBuildInfo &build_info) override
Remplit build_info avec les informations nécessaires pour créer le maillage.
Service de lecture d'un maillage au format MED depuis le jeu de données.
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_element, const String &file_name, const String &dir_name, bool use_internal_partition) override
Lit un maillage à partir d'un fichier.
Information sur une famille d'entité MED.
Int32 m_family_id
Id de la famille pour MED.
Int32 m_index
Index dans la liste des groupes Arcane.
Liste des groupes et des entités leur appartenant.
Int32 m_index
Index du groupe dans la liste des groupes.
UniqueArray< Int64 > m_unique_ids
Liste des uniqueId() des entités du groupe.
UniqueArray< String > m_names
Nom des groupes associés.
UniqueArray< Int32 > m_local_ids
Liste des localId() des entités du groupe.
Informations pour passer des types MED aux types Arcane pour les entités.
Lecteur de maillages au format MED.
Paramètres nécessaires à la construction d'un maillage.
Référence à une instance.
Structure contenant les informations pour créer un service.
Chaîne de caractères unicode.
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).
ItemGroupT< Cell > CellGroup
Groupe de mailles.
ItemGroupT< Face > FaceGroup
Groupe de faces.
#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.
std::int16_t Int16
Type entier signé sur 16 bits.
unsigned char Byte
Type d'un octet.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Créé une référence sur un pointeur.
std::int32_t Int32
Type entier signé sur 32 bits.