14#include "arcane/utils/CheckedConvert.h"
15#include "arcane/utils/List.h"
16#include "arcane/utils/ScopedPtr.h"
17#include "arcane/utils/OStringStream.h"
18#include "arcane/utils/StringBuilder.h"
19#include "arcane/utils/ITraceMng.h"
20#include "arcane/utils/JSONWriter.h"
21#include "arcane/utils/IHashAlgorithm.h"
24#include "arcane/core/IVariableMng.h"
25#include "arcane/core/VariableTypes.h"
26#include "arcane/core/ISubDomain.h"
27#include "arcane/core/StdNum.h"
28#include "arcane/core/MeshVariableInfo.h"
29#include "arcane/core/Variable.h"
30#include "arcane/core/IMesh.h"
31#include "arcane/core/IMeshSubMeshTransition.h"
33#include "arcane/core/ItemGroup.h"
34#include "arcane/core/Item.h"
35#include "arcane/core/ItemCompare.h"
36#include "arcane/core/ItemPrinter.h"
38#include "arcane/core/XmlNode.h"
39#include "arcane/core/XmlNodeList.h"
40#include "arcane/core/IParallelMng.h"
41#include "arcane/core/IIOMng.h"
42#include "arcane/core/IXmlDocumentHolder.h"
43#include "arcane/core/IItemFamily.h"
44#include "arcane/core/VariableCollection.h"
45#include "arcane/core/ITiedInterface.h"
46#include "arcane/core/SharedVariable.h"
47#include "arcane/core/MeshVisitor.h"
48#include "arcane/core/IVariableSynchronizer.h"
49#include "arcane/core/UnstructuredMeshConnectivity.h"
50#include "arcane/core/datatype/DataAllocationInfo.h"
72template <
class ValueType>
inline void
73_writeValue(ITraceMng* trace,
const String& name, ValueType v)
79template <>
inline void
80_writeValue(ITraceMng* trace,
const String& name, Real3 v)
83 trace->pinfo() << name <<
".x" <<
Trace::Width(wl) << v.x;
84 trace->pinfo() << name <<
".y" <<
Trace::Width(wl) << v.y;
85 trace->pinfo() << name <<
".z" <<
Trace::Width(wl) << v.z;
88template <>
inline void
89_writeValue(ITraceMng* trace,
const String& name, Real3x3 v)
92 trace->pinfo() << name <<
".xx" <<
Trace::Width(wl) << v.x.x;
93 trace->pinfo() << name <<
".xy" <<
Trace::Width(wl) << v.x.y;
94 trace->pinfo() << name <<
".xz" <<
Trace::Width(wl) << v.x.z;
96 trace->pinfo() << name <<
".yx" <<
Trace::Width(wl) << v.y.x;
97 trace->pinfo() << name <<
".yy" <<
Trace::Width(wl) << v.y.y;
98 trace->pinfo() << name <<
".yz" <<
Trace::Width(wl) << v.y.z;
100 trace->pinfo() << name <<
".zx" <<
Trace::Width(wl) << v.z.x;
101 trace->pinfo() << name <<
".zy" <<
Trace::Width(wl) << v.z.y;
102 trace->pinfo() << name <<
".zz" <<
Trace::Width(wl) << v.z.z;
105template <
class ItemType,
class ValueType>
inline void
106_writeInfo(ISubDomain* mng,
const VariableCollection& variables,
const ItemType& item)
108 typedef typename MeshVariableInfoT<ItemType, ValueType, 0>::PrivateType VariableScalarTrueType;
109 typedef typename MeshVariableInfoT<ItemType, ValueType, 1>::PrivateType VariableArrayTrueType;
111 ITraceMng* trace = mng->traceMng();
114 for (VariableCollection::Enumerator i(variables); ++i;) {
120 ItemGroup group = vp->itemGroup();
121 if (group.itemKind() != item_kind)
124 const String& name = vp->name();
125 auto* v =
dynamic_cast<VariableScalarTrueType*
>(vp);
127 ConstArrayView<ValueType> values = v->valueView();
128 if (values.size() < item.localId()) {
129 trace->error() <<
"Invalid dimensions for variable '" << name <<
"' "
130 <<
"(size=" << values.size() <<
" index=" << item.localId();
133 _writeValue(trace, name, values[item.localId()]);
136 auto* v2 =
dynamic_cast<VariableArrayTrueType*
>(vp);
138 Array2View<ValueType> values = v2->valueView();
140 if (values.dim1Size() < lid) {
141 trace->error() <<
"Invalid dimensions for variable '" << name <<
"' "
142 <<
"(size=" << values.dim1Size() <<
" index=" << lid;
145 Integer n = values[lid].size();
146 for (Integer z = 0; z < n; ++z) {
147 _writeValue(trace, name +
"[" + z +
"]", values[lid][z]);
157writeMeshItemInfo(ISubDomain* sd, Cell cell,
bool depend_info)
159 ITraceMng* trace = sd->traceMng();
160 Integer sid = sd->subDomainId();
161 StringBuilder buf(
"Info-");
165 VariableCollection variables(sd->variableMng()->usedVariables());
167 Integer nb_node = cell.nbNode();
168 Integer nb_edge = cell.nbEdge();
169 Integer nb_face = cell.nbFace();
171 trace->pinfo() <<
"** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- **";
172 trace->pinfo() <<
"** -- Dumping information for cell " << cell.uniqueId();
173 trace->pinfo() <<
"** -- Structure:";
174 trace->pinfo() <<
"unique id: " <<
Trace::Width(5) << cell.uniqueId();
175 trace->pinfo() <<
"local id: " <<
Trace::Width(5) << cell.localId();
176 trace->pinfo() <<
"owner: " <<
Trace::Width(5) << cell.owner();
177 trace->pinfo() <<
"type: " <<
Trace::Width(5) << cell.typeInfo()->typeName();
179 trace->pinfo() <<
"number of nodes: " <<
Trace::Width(5) << nb_node;
180 for (Integer i = 0; i < nb_node; ++i)
181 trace->pinfo() <<
"unique id of node " <<
Trace::Width(2)
182 << i <<
" : " <<
Trace::Width(5) << cell.node(i).uniqueId();
184 trace->pinfo() <<
"number of edges: " <<
Trace::Width(5) << nb_edge;
185 for (Integer i = 0; i < nb_edge; ++i)
186 trace->pinfo() <<
"unique id of edge " <<
Trace::Width(2)
187 << i <<
" : " <<
Trace::Width(5) << cell.edge(i).uniqueId();
189 trace->pinfo() <<
"number of faces: " <<
Trace::Width(5) << nb_face;
190 for (Integer i = 0; i < nb_face; ++i)
191 trace->pinfo() <<
"local id of face " <<
Trace::Width(2)
192 << i <<
" : " <<
Trace::Width(5) << cell.face(i).localId();
194 trace->pinfo() <<
"** -- Variables:";
195 _writeInfo<Cell, Real>(sd, variables, cell);
196 _writeInfo<Cell, Real2>(sd, variables, cell);
197 _writeInfo<Cell, Real3>(sd, variables, cell);
198 _writeInfo<Cell, Real2x2>(sd, variables, cell);
199 _writeInfo<Cell, Real3x3>(sd, variables, cell);
200 _writeInfo<Cell, Int32>(sd, variables, cell);
201 _writeInfo<Cell, Int64>(sd, variables, cell);
203 trace->pinfo() <<
"** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- **";
206 for (Integer i = 0; i < nb_node; ++i)
207 writeMeshItemInfo(sd, cell.node(i),
false);
208 for (Integer i = 0; i < nb_edge; ++i)
209 writeMeshItemInfo(sd, cell.edge(i),
false);
210 for (Integer i = 0; i < nb_face; ++i)
211 writeMeshItemInfo(sd, cell.face(i),
false);
219writeMeshItemInfo(ISubDomain* sd, Node node,
bool depend_info)
221 ITraceMng* trace = sd->traceMng();
222 Integer sid = sd->subDomainId();
223 StringBuilder buf(
"Info-");
227 VariableCollection variables(sd->variableMng()->usedVariables());
229 Integer nb_cell = node.nbCell();
230 Integer nb_edge = node.nbEdge();
231 Integer nb_face = node.nbFace();
233 trace->pinfo() <<
"** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- **";
234 trace->pinfo() <<
"** -- Dumping information for node " << node.uniqueId();
235 trace->pinfo() <<
"** -- Structure:";
236 trace->pinfo() <<
"unique id: " <<
Trace::Width(5) << node.uniqueId();
237 trace->pinfo() <<
"local id: " <<
Trace::Width(5) << node.localId();
238 trace->pinfo() <<
"owner: " <<
Trace::Width(5) << node.owner();
240 trace->pinfo() <<
"number of cells: " <<
Trace::Width(5) << nb_cell;
241 for (Integer i = 0; i < nb_cell; ++i)
242 trace->pinfo() <<
"unique id of cell " <<
Trace::Width(2)
243 << i <<
" : " <<
Trace::Width(5) << node.cell(i).uniqueId();
245 trace->pinfo() <<
"number of faces: " <<
Trace::Width(5) << nb_face;
246 for (Integer i = 0; i < nb_face; ++i)
247 trace->pinfo() <<
"local id of face " <<
Trace::Width(2)
248 << i <<
" : " <<
Trace::Width(5) << node.face(i).localId();
250 trace->pinfo() <<
"** -- Variables:";
251 _writeInfo<Node, Real>(sd, variables, node);
252 _writeInfo<Node, Real2>(sd, variables, node);
253 _writeInfo<Node, Real3>(sd, variables, node);
254 _writeInfo<Node, Real2x2>(sd, variables, node);
255 _writeInfo<Node, Real3x3>(sd, variables, node);
256 _writeInfo<Node, Int32>(sd, variables, node);
257 _writeInfo<Node, Int64>(sd, variables, node);
260 for (Integer i = 0; i < nb_cell; ++i)
261 writeMeshItemInfo(sd, node.cell(i),
false);
262 for (Integer i = 0; i < nb_edge; ++i)
263 writeMeshItemInfo(sd, node.edge(i),
false);
264 for (Integer i = 0; i < nb_face; ++i)
265 writeMeshItemInfo(sd, node.face(i),
false);
273writeMeshItemInfo(ISubDomain* sd, Edge edge,
bool depend_info)
275 ITraceMng* trace = sd->traceMng();
276 Integer sid = sd->subDomainId();
277 StringBuilder buf(
"Info-");
281 VariableCollection variables(sd->variableMng()->usedVariables());
283 Integer nb_cell = edge.nbCell();
284 Integer nb_face = edge.nbFace();
285 Integer nb_node = edge.nbNode();
287 trace->pinfo() <<
"** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- **";
288 trace->pinfo() <<
"** -- Dumping information for face " << edge.localId() <<
" (localid)";
289 trace->pinfo() <<
"** -- Structure:";
290 trace->pinfo() <<
"unique id: " <<
Trace::Width(5) <<
"None";
291 trace->pinfo() <<
"local id: " <<
Trace::Width(5) << edge.localId();
292 trace->pinfo() <<
"owner: " <<
Trace::Width(5) << edge.owner();
294 trace->pinfo() <<
"number of nodes: " <<
Trace::Width(5) << nb_node;
295 for (Integer i = 0; i < nb_node; ++i)
296 trace->pinfo() <<
"unique id of node " <<
Trace::Width(2)
297 << i <<
" : " <<
Trace::Width(5) << edge.node(i).uniqueId();
299 trace->pinfo() <<
"number of cells: " <<
Trace::Width(5) << nb_cell;
300 for (Integer i = 0; i < nb_cell; ++i)
301 trace->pinfo() <<
"unique id of cell " <<
Trace::Width(2)
302 << i <<
" : " <<
Trace::Width(5) << edge.cell(i).uniqueId();
304 trace->pinfo() <<
"** -- Variables:";
305 _writeInfo<Edge, Real>(sd, variables, edge);
306 _writeInfo<Edge, Real2>(sd, variables, edge);
307 _writeInfo<Edge, Real3>(sd, variables, edge);
308 _writeInfo<Edge, Real2x2>(sd, variables, edge);
309 _writeInfo<Edge, Real3x3>(sd, variables, edge);
310 _writeInfo<Edge, Int32>(sd, variables, edge);
311 _writeInfo<Edge, Int64>(sd, variables, edge);
314 for (Integer i = 0; i < nb_node; ++i)
315 writeMeshItemInfo(sd, edge.node(i),
false);
316 for (Integer i = 0; i < nb_face; ++i)
317 writeMeshItemInfo(sd, edge.face(i),
false);
318 for (Integer i = 0; i < nb_cell; ++i)
319 writeMeshItemInfo(sd, edge.cell(i),
false);
327writeMeshItemInfo(ISubDomain* sd, Face face,
bool depend_info)
329 ITraceMng* trace = sd->traceMng();
330 Integer sid = sd->subDomainId();
331 StringBuilder buf(
"Info-");
335 VariableCollection variables(sd->variableMng()->usedVariables());
337 Integer nb_cell = face.nbCell();
338 Integer nb_edge = face.nbEdge();
339 Integer nb_node = face.nbNode();
341 trace->pinfo() <<
"** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- ** -- **";
342 trace->pinfo() <<
"** -- Dumping information for face " << face.localId() <<
" (localid)";
343 trace->pinfo() <<
"** -- Structure:";
344 trace->pinfo() <<
"unique id: " <<
Trace::Width(5) <<
"None";
345 trace->pinfo() <<
"local id: " <<
Trace::Width(5) << face.localId();
346 trace->pinfo() <<
"owner: " <<
Trace::Width(5) << face.owner();
348 trace->pinfo() <<
"number of nodes: " <<
Trace::Width(5) << nb_node;
349 for (Integer i = 0; i < nb_node; ++i)
350 trace->pinfo() <<
"unique id of node " <<
Trace::Width(2)
351 << i <<
" : " <<
Trace::Width(5) << face.node(i).uniqueId();
353 trace->pinfo() <<
"number of cells: " <<
Trace::Width(5) << nb_cell;
354 for (Integer i = 0; i < nb_cell; ++i)
355 trace->pinfo() <<
"unique id of cell " <<
Trace::Width(2)
356 << i <<
" : " <<
Trace::Width(5) << face.cell(i).uniqueId();
358 trace->pinfo() <<
"** -- Variables:";
359 _writeInfo<Face, Real>(sd, variables, face);
360 _writeInfo<Face, Real2>(sd, variables, face);
361 _writeInfo<Face, Real3>(sd, variables, face);
362 _writeInfo<Face, Real2x2>(sd, variables, face);
363 _writeInfo<Face, Real3x3>(sd, variables, face);
364 _writeInfo<Face, Int32>(sd, variables, face);
365 _writeInfo<Face, Int64>(sd, variables, face);
368 for (Integer i = 0; i < nb_node; ++i)
369 writeMeshItemInfo(sd, face.node(i),
false);
370 for (Integer i = 0; i < nb_edge; ++i)
371 writeMeshItemInfo(sd, face.edge(i),
false);
372 for (Integer i = 0; i < nb_cell; ++i)
373 writeMeshItemInfo(sd, face.cell(i),
false);
384 bool operator()(
const Node& node1,
const Node& node2)
386 const Real3& r1 = m_coords[node1];
387 const Real3& r2 = m_coords[node2];
408 Integer nb1 = cell1.
nbNode();
409 Integer nb2 = cell2.
nbNode();
415 for (Integer i = 0; i < n; ++i) {
416 Integer n1 = m_nodes_sorted_id[cell1.
node(i).
localId()];
417 Integer n2 = m_nodes_sorted_id[cell2.
node(i).
localId()];
429 , m_nodes_sorted_id(nodes_sorted_id)
441 Integer nb_sub_item = ids.size();
442 ofile <<
" " << name <<
" " << nb_sub_item <<
" (";
443 for (Integer i = 0; i < nb_sub_item; ++i)
444 ofile <<
' ' << ids[i];
456 virtual Integer nbItem(
ItemBase item)
const = 0;
463 Integer nbItem(
ItemBase item)
const override {
return item.
nbEdge(); }
466 Integer nb_edge = ids.size();
467 for (Integer i = 0; i < nb_edge; ++i)
468 ids[i] = item.edgeId(i);
475 Int32 nbItem(
ItemBase item)
const override {
return item.
nbCell(); }
478 Integer nb_cell = ids.size();
479 for (Integer i = 0; i < nb_cell; ++i)
480 ids[i] = item.cellId(i);
487 Int32 nbItem(
ItemBase item)
const override {
return item.
nbFace(); }
490 Integer nb_face = ids.size();
491 for (Integer i = 0; i < nb_face; ++i)
492 ids[i] = item.faceId(i);
499 virtual Int32 nbItem(
ItemBase item)
const {
return item.
nbNode(); }
502 Integer nb_node = ids.size();
503 for (Integer i = 0; i < nb_node; ++i)
504 ids[i] = item.nodeId(i);
511 Integer n = filler.nbItem(item);
513 filler.fillLocalIds(item, local_ids);
514 for (Integer i = 0; i < n; ++i)
515 local_ids[i] = sorted_ids[local_ids[i]];
522writeMeshInfosSorted(
IMesh* mesh,
const String& file_name)
526 std::ofstream ofile(file_name.
localstr());
528 Integer nb_node = mesh->
nbNode();
529 Integer nb_edge = mesh->
nbEdge();
530 Integer nb_face = mesh->
nbFace();
531 Integer nb_cell = mesh->
nbCell();
532 ofile <<
"** Mesh Sorted --> "
533 <<
" Nodes " << nb_node
534 <<
" Edges " << nb_edge
535 <<
" Faces " << nb_face
536 <<
" Cells " << nb_cell
550 for (Integer i = 0; i < nb_node; ++i)
551 sorted_nodes[i] = nodes[i];
555 std::sort(std::begin(sorted_nodes), std::end(sorted_nodes), compare_nodes);
557 for (Integer i = 0; i < nb_node; ++i)
558 nodes_sorted_id[sorted_nodes[i].localId()] = i;
562 for (Integer i = 0; i < nb_edge; ++i)
563 sorted_edges[i] = edges[i];
566 std::sort(std::begin(sorted_edges), std::end(sorted_edges), compare_edges);
568 for (Integer i = 0; i < nb_edge; ++i)
569 edges_sorted_id[sorted_edges[i].localId()] = i;
573 for (Integer i = 0; i < nb_face; ++i)
574 sorted_faces[i] = faces[i];
577 std::sort(std::begin(sorted_faces), std::end(sorted_faces), compare_faces);
579 for (Integer i = 0; i < nb_face; ++i)
580 faces_sorted_id[sorted_faces[i].localId()] = i;
584 for (Integer i = 0; i < nb_cell; ++i)
585 sorted_cells[i] = cells[i];
588 std::sort(std::begin(sorted_cells), std::end(sorted_cells), compare_cells);
590 for (Integer i = 0; i < nb_cell; ++i)
591 cells_sorted_id[sorted_cells[i].localId()] = i;
595 ofile <<
"** Nodes\n";
597 for (Integer i = 0; i < nb_node; ++i) {
598 const Node& node = sorted_nodes[i];
599 ofile <<
"Node: " << i <<
" Coord: " << coords[node];
601 _fillSorted(node, lids, edges_sorted_id,
EdgeFiller());
602 std::sort(std::begin(lids), std::end(lids));
603 _writeItems(ofile,
"Edges", lids);
605 _fillSorted(node, lids, faces_sorted_id,
FaceFiller());
606 std::sort(std::begin(lids), std::end(lids));
607 _writeItems(ofile,
"Faces", lids);
609 _fillSorted(node, lids, cells_sorted_id,
CellFiller());
610 std::sort(std::begin(lids), std::end(lids));
611 _writeItems(ofile,
"Cells", lids);
616 ofile <<
"** Edges\n";
617 for (Integer i = 0; i < nb_edge; ++i) {
618 Edge edge = sorted_edges[i];
619 Integer edge_nb_node = edge.
nbNode();
620 Integer edge_nb_face = edge.
nbFace();
621 Integer edge_nb_cell = edge.
nbCell();
622 ofile <<
"Edge: " << i
623 <<
" Nodes " << edge_nb_node <<
" (";
624 for (Integer i_node = 0; i_node < edge_nb_node; ++i_node)
625 ofile <<
' ' << nodes_sorted_id[edge.
node(i_node).
localId()];
627 ofile <<
" Faces " << edge_nb_face <<
" (";
628 for (Integer i_face = 0; i_face < edge_nb_face; ++i_face)
629 ofile <<
' ' << faces_sorted_id[edge.
face(i_face).
localId()];
631 ofile <<
" Cells " << edge_nb_cell <<
" (";
632 for (Integer i_cell = 0; i_cell < edge_nb_cell; ++i_cell)
633 ofile <<
' ' << cells_sorted_id[edge.
cell(i_cell).
localId()];
638 ofile <<
"** Faces\n";
639 for (Integer i = 0; i < nb_face; ++i) {
640 Face face = sorted_faces[i];
641 Integer face_nb_node = face.
nbNode();
642 Integer face_nb_edge = face.
nbEdge();
643 Integer face_nb_cell = face.
nbCell();
644 ofile <<
"Face: " << i;
645 ofile <<
" Nodes " << face.
nbNode() <<
" (";
646 for (Integer i_node = 0; i_node < face_nb_node; ++i_node)
647 ofile <<
' ' << nodes_sorted_id[face.
node(i_node).
localId()];
650 ofile <<
" Edges " << face_nb_edge <<
" (";
651 for (Integer i_edge = 0; i_edge < face_nb_edge; ++i_edge)
652 ofile <<
' ' << edges_sorted_id[face.
edge(i_edge).
localId()];
655 ofile <<
" Cells " << face_nb_cell <<
" (";
656 for (Integer i_cell = 0; i_cell < face_nb_cell; ++i_cell)
657 ofile <<
' ' << cells_sorted_id[face.
cell(i_cell).
localId()];
660 if (!back_cell.
null())
661 ofile <<
" Back " << cells_sorted_id[back_cell.
localId()];
664 if (!front_cell.
null())
665 ofile <<
" Front " << cells_sorted_id[front_cell.
localId()];
671 ofile <<
"** Cells\n";
672 for (Integer i = 0; i < nb_cell; ++i) {
673 Cell cell = sorted_cells[i];
675 ofile <<
"Cell: " << i;
677 _fillSorted(cell, lids, nodes_sorted_id,
NodeFiller());
678 _writeItems(ofile,
"Nodes", lids);
679 _fillSorted(cell, lids, edges_sorted_id,
EdgeFiller());
680 _writeItems(ofile,
"Edges", lids);
681 _fillSorted(cell, lids, faces_sorted_id,
FaceFiller());
682 _writeItems(ofile,
"Faces", lids);
692writeMeshInfos(
IMesh* mesh,
const String& file_name)
696 std::ofstream ofile(file_name.
localstr());
698 Integer nb_node = mesh->
nbNode();
699 Integer nb_edge = mesh->
nbEdge();
700 Integer nb_face = mesh->
nbFace();
701 Integer nb_cell = mesh->
nbCell();
702 ofile <<
"** Mesh --> "
703 <<
" Nodes " << nb_node
704 <<
" Edges " << nb_edge
705 <<
" Faces " << nb_face
706 <<
" Cells " << nb_cell
715 ofile <<
"** Nodes\n";
716 for (Integer i = 0; i < nb_node; ++i) {
717 Node node = nodes[i];
718 Integer node_nb_face = node.
nbFace();
719 Integer node_nb_cell = node.
nbCell();
720 ofile <<
"Node: " << i <<
" Coord: " << coords[node];
721 ofile <<
" Faces " << node_nb_face <<
" (";
722 for (Integer i_face = 0; i_face < node_nb_face; ++i_face)
725 ofile <<
" Cells " << node_nb_cell <<
" (";
726 for (Integer i_cell = 0; i_cell < node_nb_cell; ++i_cell)
732 ofile <<
"** Faces\n";
733 for (Integer i = 0; i < nb_face; ++i) {
734 Face face = faces[i];
735 Integer face_nb_node = face.nbNode();
736 Integer face_nb_cell = face.nbCell();
737 ofile <<
"Face: " << i
738 <<
" Nodes " << face_nb_node <<
" (";
739 for (Integer i_node = 0; i_node < face_nb_node; ++i_node)
740 ofile <<
' ' << face.node(i_node).localId();
742 ofile <<
" Cells " << face_nb_cell <<
" (";
744 for (Integer i_cell = 0; i_cell < face_nb_cell; ++i_cell)
745 ofile <<
' ' << face.cell(i_cell).localId();
747 const Cell& back_cell = face.backCell();
748 if (!back_cell.null())
749 ofile <<
" Back " << back_cell.localId();
751 const Cell& front_cell = face.frontCell();
752 if (!front_cell.null())
753 ofile <<
" Front " << front_cell.localId();
759 ofile <<
"** Cells\n";
760 for (Integer i = 0; i < nb_cell; ++i) {
761 Cell cell = cells[i];
762 Integer cell_nb_node = cell.nbNode();
763 Integer cell_nb_face = cell.nbFace();
764 ofile <<
"Cell: " << i
765 <<
" Nodes " << cell_nb_node <<
" (";
766 for (Integer i_node = 0; i_node < cell_nb_node; ++i_node)
767 ofile <<
' ' << cell.node(i_node).localId();
769 ofile <<
" Faces " << cell_nb_face <<
" (";
770 for (Integer i_face = 0; i_face < cell_nb_face; ++i_face)
771 ofile <<
' ' << cell.face(i_face).localId();
782 template <
typename ItemType>
void
783 _sortByUniqueIds(IMesh* mesh,
eItemKind ik, Array<ItemType>& items)
785 ItemGroup all_items(mesh->itemFamily(ik)->allItems());
786 items.resize(all_items.size());
794 std::sort(std::begin(items), std::end(items), ItemCompare());
798 _stringToIds(
const String& str,
Int64Array& ids)
801 std::istringstream istr(str.localstr());
803 while (istr.good()) {
811 template <
typename SubItemType>
void
812 _writeSubItems(std::ostream& ofile,
const char* item_name, ItemConnectedListViewT<SubItemType> sub_list)
814 Int32 n = sub_list.size();
817 ofile <<
"<" << item_name <<
" count='" << n <<
"'>";
818 for (SubItemType sub_item : sub_list)
819 ofile <<
' ' << sub_item.uniqueId();
820 ofile <<
"</" << item_name <<
">";
828writeMeshConnectivity(
IMesh* mesh,
const String& file_name)
830 std::ofstream ofile(file_name.
localstr());
837 trace->
info() <<
"Writing mesh connectivity in '" << file_name <<
"'";
839 ofile <<
"<?xml version='1.0' ?>\n";
840 ofile <<
"<mesh-connectivity>\n";
846 _sortByUniqueIds(mesh,
IK_Node, nodes);
847 _sortByUniqueIds(mesh,
IK_Edge, edges);
848 _sortByUniqueIds(mesh,
IK_Face, faces);
849 _sortByUniqueIds(mesh,
IK_Cell, cells);
853 ofile <<
"<nodes count='" << nodes.
size() <<
"'>\n";
854 for (
Node item : nodes) {
855 ofile <<
" <node uid='" << item.
uniqueId() <<
"' owner='" << item.
owner() <<
"'>";
856 _writeSubItems(ofile,
"cells", item.cells());
857 _writeSubItems(ofile,
"faces", item.faces());
858 _writeSubItems(ofile,
"edges", item.edges());
859 ofile <<
"</node>\n";
861 ofile <<
"</nodes>\n";
866 ofile <<
"<edges count='" << edges.
size() <<
"'>\n";
867 for (
Edge edge : edges) {
868 ofile <<
" <edge uid='" << edge.uniqueId() <<
"' owner='" << edge.owner() <<
"'>";
869 _writeSubItems(ofile,
"nodes", edge.nodes());
870 _writeSubItems(ofile,
"cells", edge.cells());
871 _writeSubItems(ofile,
"faces", edge.faces());
872 ofile <<
"</edge>\n";
874 ofile <<
"</edges>\n";
879 ofile <<
"<faces count='" << faces.
size() <<
"'>\n";
880 for (
Face face : faces) {
882 ofile <<
" <face uid='" << face.uniqueId()
883 <<
"' typeid='" << face.type()
884 <<
"' owner='" << face.owner() <<
"'>";
885 _writeSubItems(ofile,
"nodes", face.nodes());
886 _writeSubItems(ofile,
"edges", face.edges());
890 Cell back_cell = face.backCell();
891 if (!back_cell.
null())
892 ofile <<
" back='" << back_cell.
uniqueId() <<
"'";
893 Cell front_cell = face.frontCell();
894 if (!front_cell.
null())
895 ofile <<
" front='" << front_cell.
uniqueId() <<
"'";
900 if (face.isSlaveFace())
901 _writeSubItems(ofile,
"slave-faces", face.slaveFaces());
902 if (face.isMasterFace()) {
903 ofile <<
"<faces count='1'>";
904 ofile <<
' ' << face.masterFace().uniqueId();
908 ofile <<
"</face>\n";
910 ofile <<
"</faces>\n";
915 ofile <<
"<cells count='" << cells.
size() <<
"'>\n";
920 ghost_cells_layer1.
reserve(100);
921 for (
Cell cell : cells) {
922 ofile <<
" <cell uid='" << cell.uniqueId()
923 <<
"' typeid='" << cell.type()
924 <<
"' owner='" << cell.owner() <<
"'>";
925 _writeSubItems(ofile,
"nodes", cell.nodes());
926 _writeSubItems(ofile,
"edges", cell.edges());
927 _writeSubItems(ofile,
"faces", cell.faces());
928 if (mesh->isAmrActivated()) {
929 ofile <<
"<amr level='" << cell.level() <<
"'>";
939 ofile <<
"<child count='" << cell.nbHChildren() <<
"'>";
940 for (Integer j = 0; j < cell.nbHChildren(); ++j) {
941 ofile <<
' ' << cell.hChild(j)->uniqueId();
948 ghost_cells_layer1.
clear();
949 for (
Node node : cell.nodes()) {
951 ghost_cells_layer1.
add(sub_cell.uniqueId().asInt64());
957 std::sort(std::begin(ghost_cells_layer1), std::end(ghost_cells_layer1));
958 auto new_end = std::unique(std::begin(ghost_cells_layer1), std::end(ghost_cells_layer1));
960 ofile <<
"<ghost1 count='" << ghost_cells_layer1.
size() <<
"'>";
961 for (
auto j : ghost_cells_layer1)
963 ofile <<
"</ghost1>\n";
966 ofile <<
"</cell>\n";
968 ofile <<
"</cells>\n";
974 ofile <<
"<groups>\n";
977 std::map<String,ItemGroup> sorted_groups;
982 sorted_groups.insert(std::make_pair(group.
name(),group));
984 for (
const auto& [name,group] : sorted_groups ){
985 ofile <<
"<group name='" << group.
name()
987 <<
"' count='" << group.size() <<
"'>\n";
989 ofile <<
' ' << i_item->uniqueId();
991 ofile <<
"\n</group>\n";
993 ofile <<
"</groups>\n";
998 ofile <<
"<tied-interfaces>\n";
1000 for (TiedInterfaceCollection::Enumerator itied(tied_interfaces); ++itied;) {
1002 FaceGroup slave_group = interface->slaveInterface();
1003 FaceGroup master_group = interface->masterInterface();
1004 ofile <<
"<tied-interface master_name='" << master_group.
name()
1005 <<
"' slave_name='" << slave_group.
name() <<
"'>\n";
1006 TiedInterfaceNodeList tied_nodes(interface->tiedNodes());
1007 TiedInterfaceFaceList tied_faces(interface->tiedFaces());
1011 ofile <<
"<master-face uid='" << face.
uniqueId() <<
"'>\n";
1012 for (Integer zz = 0, zs = tied_nodes[iface.index()].size(); zz < zs; ++zz) {
1013 TiedNode tn = tied_nodes[iface.index()][zz];
1016 for (Integer zz = 0, zs = tied_faces[iface.index()].size(); zz < zs; ++zz) {
1017 TiedFace tf = tied_faces[iface.index()][zz];
1018 ofile <<
"<face uid='" << tf.
face().
uniqueId() <<
"'/>\n";
1020 ofile <<
"</master-face>\n";
1022 ofile <<
"</tied-interface>\n";
1024 ofile <<
"</tied-interfaces>\n";
1026 ofile <<
"</mesh-connectivity>\n";
1054 bool operator<(Int64 uid)
const
1064 typedef std::map<Int64, ItemInternalXml> ItemInternalXmlMap;
1070 , m_doc_node(doc_node)
1071 , m_has_error(false)
1072 , m_check_sub_domain(check_sub_domain)
1085 bool m_check_sub_domain;
1086 ItemInternalXmlMap m_nodes_internal;
1087 ItemInternalXmlMap m_edges_internal;
1088 ItemInternalXmlMap m_faces_internal;
1089 ItemInternalXmlMap m_cells_internal;
1107 void _read(
eItemKind ik, ItemInternalXmlMap& items_internal,
1128checkMeshConnectivity(IMesh* mesh,
const XmlNode& doc_node,
bool check_sub_domain)
1132 MeshUtilsCheckConnectivity v(mesh, doc_node, check_sub_domain);
1137checkMeshConnectivity(IMesh* mesh,
const String& file_name,
bool check_sub_domain)
1139 ITraceMng* tm = mesh->traceMng();
1142 XmlNode root = doc->documentNode();
1143 checkMeshConnectivity(mesh, root, check_sub_domain);
1146void MeshUtilsCheckConnectivity::
1147_read(
eItemKind ik, ItemInternalXmlMap& items_internal, XmlNode root_node,
1148 const String& lower_case_kind_name)
1150 ITraceMng* trace = m_mesh->
traceMng();
1154 String ustr_uid(
"uid");
1155 String ustr_cells(
"cells");
1156 String ustr_count(
"count");
1157 String ustr_nodes(
"nodes");
1158 String ustr_ghost1(
"ghost1");
1164 ItemInternalXml ixml(item);
1165 items_internal.insert(ItemInternalXmlMap::value_type(item.uniqueId().asInt64(), ixml));
1168#ifdef ARCANE_DEBUG_MESH
1169 for (Integer i = 0; i < items_internal.size(); ++i) {
1170 const ItemInternalXml& item_xml = items_internal[i];
1171 trace->info() <<
"Item " << kind_name <<
":" << item_xml.m_item->uniqueId()
1172 <<
' ' << i <<
' ' << item_xml.m_item;
1176 XmlNodeList xml_items(root_node.children(lower_case_kind_name));
1177 for (
const auto& xml_node : xml_items) {
1178 Integer uid = xml_node.attr(ustr_uid).valueAsInteger();
1179 ItemInternalXmlMap::iterator iixml = items_internal.find(uid);
1180 if (iixml != items_internal.end()) {
1181 iixml->second.m_element = xml_node;
1184 ItemInternalXml* ixml = _find(items_internal,uid);
1186 ixml->m_element = xml_node;
1187#ifdef ARCANE_DEBUG_MESH
1188 trace->info() <<
"FOUND " << uid <<
' ' << z->m_item->uniqueId() <<
' ' << z->m_element.name()
1189 <<
' ' << z->m_item;
1192#ifdef ARCANE_DEBUG_MESH
1194 trace->info() <<
"FOUND " << uid <<
" NOT HERE";
1201 for (ItemInternalXmlMap::const_iterator i(items_internal.begin()); i != items_internal.end(); ++i) {
1202 const ItemInternalXml& item_xml = i->second;
1203 Item item = item_xml.m_item;
1204 const XmlNode& xitem = item_xml.m_element;
1206 trace->error() <<
"Item " << kind_name <<
":" << item.uniqueId()
1207 <<
"unknown in reference mesh";
1212 ItemWithNodes item_with_node(item);
1213 XmlNode xitem_node = xitem.child(ustr_nodes);
1214 Integer ref_nb_node = xitem_node.attr(ustr_count).valueAsInteger();
1215 Integer nb_node = item_with_node.nbNode();
1216 if (ref_nb_node != nb_node) {
1217 trace->error() <<
"Item " << kind_name <<
":" << item.uniqueId()
1218 <<
": number of nodes (" << nb_node <<
") "
1219 <<
"different than reference (" << ref_nb_node <<
")";
1224 m_items_unique_id.
reserve(ref_nb_node);
1225 String s = xitem_node.value();
1226 _stringToIds(s, m_items_unique_id);
1227 bool is_bad =
false;
1228 for (
NodeEnumerator i_node(item_with_node.nodes()); i_node(); ++i_node) {
1229 if (m_items_unique_id[i_node.index()] != i_node->uniqueId()) {
1237 ostr() <<
"Item " << kind_name <<
":" << item.uniqueId()
1239 for (
NodeEnumerator i_node(item_with_node.nodes()); i_node(); ++i_node) {
1240 ostr() <<
' ' << i_node->uniqueId();
1242 ostr() <<
") different than reference (" << s <<
")";
1243 trace->error() << ostr.str();
1253 elem = xitem.child(ustr_ghost1);
1255 elem = xitem.child(ustr_cells);
1257 _stringToIds(elem.value(), m_items_unique_id);
1258 local_ids.resize(m_items_unique_id.
size());
1260 StringBuilder not_found;
1261 bool has_not_found =
false;
1262 for (Integer uui = 0, uuis = m_items_unique_id.
size(); uui < uuis; ++uui) {
1263 if (local_ids[uui] == NULL_ITEM_ID) {
1265 not_found += m_items_unique_id[uui];
1267 has_not_found =
true;
1270 if (has_not_found) {
1272 trace->info() <<
"ERROR: One or more ghost cells of cell "
1273 << ItemPrinter(item) <<
" are not in the sub-domain"
1274 <<
" ref='" << elem.value() <<
"' not_found='" << not_found <<
'\'';
1276 trace->info() <<
"ERROR: One or more cells with node "
1277 << ItemPrinter(item) <<
" are not in the sub-domain"
1278 <<
" ref='" << elem.value() <<
"' not_found='" << not_found <<
'\'';
1292void MeshUtilsCheckConnectivity::
1295 ITraceMng* trace = m_mesh->
traceMng();
1297 trace->
info() <<
"Checking mesh checkMeshConnectivity()";
1299 XmlNode root_node = m_doc_node.
child(String(
"mesh-connectivity"));
1301 trace->warning() <<
"Incorrect connectivity file";
1304 XmlNode nodes_root = root_node.
child(
"nodes");
1305 XmlNode faces_root = root_node.
child(
"faces");
1306 XmlNode cells_root = root_node.
child(
"cells");
1308 _read(
IK_Node, m_nodes_internal, nodes_root,
"node");
1309 _read(
IK_Face, m_faces_internal, faces_root,
"face");
1310 _read(
IK_Cell, m_cells_internal, cells_root,
"cell");
1312 String ustr_groups(
"groups");
1313 String ustr_group(
"group");
1314 String ustr_count(
"count");
1316 XmlNode groups_root = root_node.child(ustr_groups);
1318 const ItemGroup& group = *i_group;
1319 if (group.isLocalToSubDomain() || group.isOwn())
1321 XmlNode group_elem = groups_root.childWithNameAttr(ustr_group, String(group.name()));
1322 if (group_elem.null()) {
1324 trace->error() <<
"Unable to find group <" << group.name()
1325 <<
"> in reference file";
1328 Integer size = group_elem.attr(ustr_count).valueAsInteger();
1329 m_items_unique_id.
reserve(size);
1330 _stringToIds(group_elem.value(), m_items_unique_id);
1332 if (ref_size != size) {
1333 trace->error() <<
"Number of items in group <" << group.name()
1334 <<
"> (" << size <<
" different than reference (" << ref_size;
1341 trace->fatal() <<
"Error(s) while checking mesh";
1352checkMeshProperties(
IMesh* mesh,
bool is_sorted,
bool has_no_hole,
bool check_faces)
1360 bool has_error =
false;
1364 for (IItemFamilyCollection::Enumerator i(mesh->itemFamilies()); ++i;) {
1366 if (!check_faces && ik ==
IK_Face)
1387 ARCANE_FATAL(
"Missing required mesh properties (sorted and/or no hole)");
1395printItems(std::ostream& ostr,
const String& name,
ItemGroup item_group)
1397 ostr <<
" ------- " << name <<
'\n';
1411 bool need_swap_orientation =
false;
1412 Integer min_node_index = 0;
1413 Integer nb_node = before_ids.
size();
1417 if (before_ids[0] < before_ids[1]) {
1418 after_ids[0] = before_ids[0];
1419 after_ids[1] = before_ids[1];
1422 after_ids[0] = before_ids[1];
1423 after_ids[1] = before_ids[0];
1440 Int64 min_node = INT64_MAX;
1441 for (Integer k = 0; k < nb_node; ++k) {
1442 Int64
id = before_ids[k];
1443 if (
id < min_node) {
1448 Int64 next_node = before_ids[(min_node_index + 1) % nb_node];
1449 Int64 prev_node = before_ids[(min_node_index + (nb_node - 1)) % nb_node];
1452 if(next_node==min_node)
1454 next_node = before_ids[(min_node_index + (nb_node + 2)) % nb_node];
1457 if(prev_node==min_node)
1459 prev_node = before_ids[(min_node_index + (nb_node - 2)) % nb_node];
1460 incr2 = nb_node - 1 ;
1462 if (next_node > prev_node)
1463 need_swap_orientation =
true;
1464 if (need_swap_orientation) {
1465 for (Integer k = 0; k < nb_node; ++k) {
1466 Integer index = (nb_node - k + min_node_index + incr) % nb_node;
1467 after_ids[k] = before_ids[index];
1471 for (Integer k = 0; k < nb_node; ++k) {
1472 Integer index = (k + min_node_index + incr2) % nb_node;
1473 after_ids[k] = before_ids[index];
1476 return need_swap_orientation;
1487 bool need_swap_orientation =
false;
1488 Integer min_node_index = 0;
1489 Integer nb_node = nodes_unique_id.
size();
1493 if (nodes_unique_id[0] < nodes_unique_id[1]) {
1516 Int64 min_node = INT64_MAX;
1517 for (Integer k = 0; k < nb_node; ++k) {
1518 Int64
id = nodes_unique_id[k];
1519 if (
id < min_node) {
1524 Int64 next_node = nodes_unique_id[(min_node_index + 1) % nb_node];
1525 Int64 prev_node = nodes_unique_id[(min_node_index + (nb_node - 1)) % nb_node];
1528 if(next_node==min_node)
1530 next_node = nodes_unique_id[(min_node_index + 2) % nb_node];
1533 if(prev_node==min_node)
1535 prev_node = nodes_unique_id[(min_node_index + (nb_node - 2)) % nb_node];
1536 incr2 = nb_node - 1 ;
1538 if (next_node > prev_node)
1539 need_swap_orientation =
true;
1540 if (need_swap_orientation) {
1541 for (Integer k = 0; k < nb_node; ++k) {
1542 Integer index = (nb_node - k + min_node_index + incr) % nb_node;
1543 new_index[k] = index;
1547 for (Integer k = 0; k < nb_node; ++k) {
1548 Integer index = (k + min_node_index + incr2) % nb_node;
1549 new_index[k] = index;
1552 return need_swap_orientation;
1561 Integer n = face_nodes_local_id.
size();
1562 for (Integer i = 0, s = node.
nbFace(); i < s; ++i) {
1566 bool same_face =
true;
1567 for (Integer zz = 0; zz < n; ++zz)
1568 if (f.
node(zz).
localId() != face_nodes_local_id[zz]) {
1585 Integer n = face_nodes_unique_id.
size();
1586 for (Integer i = 0, s = node.
nbFace(); i < s; ++i) {
1590 bool same_face =
true;
1591 for (Integer zz = 0; zz < n; ++zz)
1592 if (f.
node(zz).
uniqueId() != face_nodes_unique_id[zz]) {
1609 Integer n = items.
size();
1611 ARCANE_FATAL(
"Can not remove item lid={0} because list is empty", local_id);
1615 if (items[0] == local_id)
1620 if (items[n] == local_id)
1622 for (Integer i = 0; i < n; ++i) {
1623 if (items[i] == local_id) {
1624 for (Integer z = i; z < n; ++z)
1625 items[z] = items[z + 1];
1638shrinkMeshGroups(
IMesh* mesh)
1641 group.internal()->shrinkMemory();
1643 meshvisitor::visitGroups(mesh, f);
1650printMeshGroupsMemoryUsage(
IMesh* mesh, Int32 print_level)
1653 Int64 total_capacity = 0;
1654 Int64 total_computed_capacity = 0;
1661 total_capacity += c;
1663 total_computed_capacity += c;
1664 if (print_level >= 1)
1666 <<
" nb_ref=" << p->
nbRef() <<
" size=" << p->
size()
1667 <<
" capacity=" << c;
1669 meshvisitor::visitGroups(mesh, f);
1670 tm->
info() <<
"MeshGroupsMemoryUsage: capacity = " << total_capacity
1671 <<
" computed_capacity=" << total_computed_capacity;
1672 return total_capacity *
sizeof(Int32);
1687 tm->
info(4) <<
"Dumping VariableSynchronizerTopology filename=" << filename;
1688 Int32 nb_comm_rank = comm_ranks.
size();
1691 for (Integer i = 0; i < nb_comm_rank; ++i)
1694 JSONWriter json_writer(JSONWriter::FormatFlags::None);
1695 json_writer.beginObject();
1700 json_writer.write(
"NbNeighbor", all_nb_comm_ranks);
1705 json_writer.write(
"NeighborsRank", all_neighbor_ranks);
1710 json_writer.write(
"NeighborsSize", all_nb_items_by_rank);
1720 json_writer.endObject();
1723 std::ofstream ofile(filename.
localstr());
1724 auto bytes = json_writer.getBuffer().
bytes();
1725 ofile.write(
reinterpret_cast<const char*
>(bytes.data()), bytes.size());
1738 friend bool operator<(
const MyIdsToTest& a,
const MyIdsToTest& b)
1740 return a.ids < b.ids;
1742 static constexpr int MAX_SIZE = 16;
1746 std::array<Int32, MAX_SIZE> ids = {};
1749 void _computePatternOccurence(
const ItemGroup& items,
const String& message,
1750 IndexedItemConnectivityViewBase2 cty)
1752 std::map<MyIdsToTest, Int32> occurence_map;
1753 Int32 nb_skipped = 0;
1756 MyIdsToTest diff_ids;
1760 bool is_skipped =
false;
1761 for (ItemLocalId sub_item : cty.items(item)) {
1762 if (index >= MyIdsToTest::MAX_SIZE) {
1767 lid0 = sub_item.localId();
1768 diff_ids.ids[index] = sub_item.localId() - lid0;
1775 ++occurence_map[diff_ids];
1777 ITraceMng* tm = items.mesh()->traceMng();
1778 tm->info() <<
"Occurence: " << message <<
" group=" << items.name()
1779 <<
" nb=" << items.size() <<
" map_size=" << occurence_map.size()
1780 <<
" nb_skipped=" << nb_skipped;
1785computeConnectivityPatternOccurence(
IMesh* mesh)
1791 _computePatternOccurence(mesh->
allNodes(),
"NodeCells", cty.nodeCell());
1792 _computePatternOccurence(mesh->
allNodes(),
"NodeFaces", cty.nodeFace());
1793 _computePatternOccurence(mesh->
allFaces(),
"FaceCells", cty.faceCell());
1794 _computePatternOccurence(mesh->
allFaces(),
"FaceNodes", cty.faceNode());
1795 _computePatternOccurence(mesh->
allCells(),
"CellNodes", cty.cellNode());
1796 _computePatternOccurence(mesh->
allCells(),
"CellFaces", cty.cellFace());
1803markMeshConnectivitiesAsMostlyReadOnly(
IMesh* mesh,
RunQueue* queue,
bool do_prefetch)
1809 const String tag_name =
"ArcaneConnectivity";
1815 if (!v->
hasTag(tag_name))
1820 VariableUtils::prefetchVariableAsync(v, queue);
1840impl::ItemBase MeshUtils::
1841findOneItem(IItemFamily* family, ItemUniqueId unique_id)
1843 ItemInternal* v = family->findOneItem(unique_id);
1852namespace MeshUtils::impl
1855 Int64 _getMaxUniqueId(
const ItemGroup& group, Int64 max_uid)
1859 if (max_uid < item.uniqueId())
1860 max_uid = item.uniqueId();
1870getMaxItemUniqueIdCollective(
IMesh* mesh)
1872 Int64 max_uid = NULL_ITEM_UNIQUE_ID;
1873 max_uid = impl::_getMaxUniqueId(mesh->
allNodes(), max_uid);
1874 max_uid = impl::_getMaxUniqueId(mesh->
allEdges(), max_uid);
1875 max_uid = impl::_getMaxUniqueId(mesh->
allCells(), max_uid);
1876 max_uid = impl::_getMaxUniqueId(mesh->
allFaces(), max_uid);
1886 const String& expected_hash,
bool print_hash,
1898 Item item{ *iitem };
1899 own_items_uid.
add(item.uniqueId());
1903 std::sort(global_items_uid.
begin(), global_items_uid.
end());
1909 tm->
info() <<
"HASH_RESULT family=" << family->
name()
1910 <<
" v=" << hash_str <<
" expected=" << expected_hash;
1911 if (!expected_hash.
empty() && hash_str != expected_hash)
1912 ARCANE_FATAL(
"Bad hash for uniqueId() for family '{0}' v={1} expected='{2}'",
1913 family->
fullName(), hash_str, expected_hash);
1922 Integer nb_item = items.
size();
1925 uids[iitem.index()] = iitem->uniqueId();
1939 Int32 nb_node = nodes_unique_id.
size();
1943 Int64 uid0 = nodes_unique_id[0];
1944 Int64 hash = Hasher::hashfunc(uid0);
1945 for (Int32 i = 1; i < nb_node; ++i) {
1946 Int64 next_hash = Hasher::hashfunc(nodes_unique_id[i]);
1947 hash ^= next_hash + 0x9e3779b9 + (hash << 6) + (hash >> 2);
1949 Int64 truncated_uid0 = uid0 & ((1 << 30) - 1);
1950 Int64 truncated_hash = hash & ((1LL << 31) - 1);
1951 Int64 new_uid = truncated_uid0 + (truncated_hash << 31);
1952 ARCANE_ASSERT(new_uid > 0, (
"UniqueId is not > 0"));
#define ARCANE_CHECK_POINTER(ptr)
Macro retournant le pointeur ptr s'il est non nul ou lancant une exception s'il est nul.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Fonctions mathématiques diverses.
Fonctions utilitaires sur le maillage.
Fonctions utilitaires sur les variables.
File d'exécution pour un accélérateur.
Vue sur les informations des mailles.
EnumeratorT< ItemGroup > Enumerator
Type d'un itérateur sur toute la collection.
Informations sur l'allocation d'une donnée.
Vue sur les informations des arêtes.
Cell cell(Int32 i) const
i-ème maille de l'arête
Face face(Int32 i) const
i-ème face de l'arête
Int32 nbFace() const
Nombre de faces connectées à l'arête.
Int32 nbNode() const
Nombre de sommets de l'arête.
Int32 nbCell() const
Nombre de mailles connectées à l'arête.
Vue sur les informations des faces.
Cell frontCell() const
Maille devant la face (maille nulle si aucune)
Cell cell(Int32 i) const
i-ème maille de la face
Int32 nbCell() const
Nombre de mailles de la face (1 ou 2)
Edge edge(Int32 i) const
i-ème arête de la face
Int32 nbEdge() const
Nombre d'arêtes de la face.
Cell backCell() const
Maille derrière la face (maille nulle si aucune)
Informations sur le type flottant.
Interface d'un algorithme de hashage.
virtual void computeHash64(Span< const Byte > input, ByteArray &output)
Calcule la valeur du hash pour le tableau input.
Interface d'une famille d'entités.
virtual ItemGroup allItems() const =0
Groupe de toutes les entités.
virtual ItemInternal * findOneItem(Int64 unique_id)=0
Entité de numéro unique unique_id.
virtual IParallelMng * parallelMng() const =0
Gestionnaire de parallélisme associé
virtual String name() const =0
Nom de la famille.
virtual ITraceMng * traceMng() const =0
Gestionnaire de trace associé
virtual String fullName() const =0
Nom complet de la famille (avec celui du maillage)
virtual void itemsUniqueIdToLocalId(Int32ArrayView local_ids, Int64ConstArrayView unique_ids, bool do_fatal=true) const =0
Converti un tableau de numéros uniques en numéros locaux.
virtual ITraceMng * traceMng()=0
Gestionnaire de message associé
virtual IItemFamily * nodeFamily()=0
Retourne la famille des noeuds.
virtual Integer nbCell()=0
Nombre de mailles du maillage.
virtual FaceGroup allFaces()=0
Groupe de toutes les faces.
virtual Integer nbEdge()=0
Nombre d'arêtes du maillage.
virtual IItemFamily * itemFamily(eItemKind ik)=0
Retourne la famille d'entité de type ik.
virtual IItemFamily * edgeFamily()=0
Retourne la famille des arêtes.
virtual Integer nbNode()=0
Nombre de noeuds du maillage.
virtual IItemFamily * faceFamily()=0
Retourne la famille des faces.
virtual NodeGroup allNodes()=0
Groupe de tous les noeuds.
virtual CellGroup allCells()=0
Groupe de toutes les mailles.
virtual Integer nbFace()=0
Nombre de faces du maillage.
virtual IItemFamily * cellFamily()=0
Retourne la famille des mailles.
virtual EdgeGroup allEdges()=0
Groupe de toutes les arêtes.
virtual IParallelMng * parallelMng()=0
Gestionnaire de parallèlisme.
virtual ItemInternalList itemsInternal(eItemKind)=0
Tableau interne des éléments du maillage de type type.
virtual TiedInterfaceCollection tiedInterfaces()=0
Liste des interfaces semi-conformes.
virtual SharedVariableNodeReal3 sharedNodesCoordinates()=0
Coordonnées des noeuds.
virtual ItemGroupCollection groups()=0
Liste des groupes.
virtual IPrimaryMesh * toPrimaryMesh()=0
Retourne l'instance sous la forme d'un IPrimaryMesh.
virtual IVariableMng * variableMng() const =0
Gestionnaire de variable associé
Interface du gestionnaire de parallélisme pour un sous-domaine.
virtual void gatherVariable(ConstArrayView< char > send_buf, Array< char > &recv_buf, Int32 rank)=0
Effectue un regroupement sur tous les processeurs.
virtual ITraceMng * traceMng() const =0
Gestionnaire de traces.
virtual Int32 commRank() const =0
Rang de cette instance dans le communicateur.
virtual void allGatherVariable(ConstArrayView< char > send_buf, Array< char > &recv_buf)=0
Effectue un regroupement sur tous les processeurs.
virtual Int32 commSize() const =0
Nombre d'instance dans le communicateur.
virtual void gather(ConstArrayView< char > send_buf, ArrayView< char > recv_buf, Int32 rank)=0
Effectue un regroupement sur un processeurs. Il s'agit d'une opération collective....
virtual char reduce(eReduceType rt, char v)=0
Effectue la réduction de type rt sur le réel v et retourne la valeur.
virtual VariableNodeReal3 & nodesCoordinates()=0
Coordonnées des noeuds.
Interface d'un classe gérant une semi-conformité du maillage.
Interface du gestionnaire de variables.
virtual VariableCollection usedVariables()=0
Liste des variables utilisées.
Interface d'un service de synchronisation de variable.
virtual Int32ConstArrayView communicatingRanks()=0
Rangs des sous-domaines avec lesquels on communique.
virtual IParallelMng * parallelMng()=0
Gestionnaire parallèle associé
virtual Int32ConstArrayView sharedItems(Int32 index)=0
Liste des ids locaux des entités partagées avec un sous-domaine.
virtual bool hasTag(const String &tagname)=0
true si la variable possède le tag tagname
virtual void setAllocationInfo(const DataAllocationInfo &v)=0
Positionne les informations sur l'allocation.
virtual MeshHandle meshHandle() const =0
Maillage auquel est associé la variable.
static IXmlDocumentHolder * loadFromFile(const String &filename, ITraceMng *tm)
Charge un document XML.
Classe de base pour les entités du maillage.
Integer nbEdge() const
Nombre d'arêtes de l'entité ou nombre d'arêtes connectés à l'entités (pour les noeuds)
ItemUniqueId uniqueId() const
Numéro unique de l'entité
Integer nbCell() const
Nombre de mailles connectées à l'entité (pour les noeuds, arêtes et faces)
Int32 owner() const
Numéro du sous-domaine propriétaire de l'entité
Integer nbFace() const
Nombre de faces de l'entité ou nombre de faces connectés à l'entités (pour les noeuds et arêtes)
Integer nbNode() const
Nombre de noeuds de l'entité
virtual Integer nbRef() const
Nombre de références sur le groupe.
Integer size() const
Nombre d'entités du groupe.
Int64 capacity() const
Nombre d'éléments alloués.
bool hasComputeFunctor() const
Indique si le groupe est calculé
Groupe d'entités de maillage.
const String & name() const
Nom du groupe.
bool isLocalToSubDomain() const
Vrai si le groupe est local au sous-domaine.
ItemGroup own() const
Groupe équivalent à celui-ci mais contenant uniquement les éléments propres au sous-domaine.
Classe utilitaire pour imprimer les infos sur une entité.
static eItemKind kind()
Genre de l'entité
Identifiant unique d'une entité.
Vue sur un vecteur d'entités.
Int32 size() const
Nombre d'éléments du vecteur.
Elément de maillage s'appuyant sur des noeuds (Edge,Face,Cell).
Node node(Int32 i) const
i-ème noeud de l'entité
Int32 nbNode() const
Nombre de noeuds de l'entité
Classe de base d'un élément de maillage.
constexpr Int32 localId() const
Identifiant local de l'entité dans le sous-domaine du processeur.
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
constexpr bool null() const
true si l'entité est nul (i.e. non connecté au maillage)
impl::ItemBase itemBase() const
Partie interne de l'entité.
IMesh * meshOrNull() const
Retourne le maillage associé à cette instance.
Vue sur les informations des noeuds.
Cell cell(Int32 i) const
i-ème maille du noeud
CellConnectedListViewType cells() const
Liste des mailles du noeud.
Face face(Int32 i) const
i-ème face du noeud
Int32 nbFace() const
Nombre de faces connectées au noeud.
Int32 nbCell() const
Nombre de mailles connectées au noeud.
Classe gérant un vecteur de réel de dimension 3.
Face semi-conforme du maillage.
Face face() const
Face soudée.
Noeud semi-conforme du maillage.
Node node() const
Noeud lié
Real2 isoCoordinates() const
Coordonnées iso-barycentriques du noeud.
Vue sur les connectivités standards d'un maillage non structuré.
XmlNode child(const String &name) const
Noeud fils de celui-ci de nom name.
Integer size() const
Nombre d'éléments du vecteur.
Vue modifiable d'un tableau d'un type T.
constexpr Integer size() const noexcept
Retourne la taille du tableau.
Classe de base des vecteurs 1D de données.
iterator begin()
Itérateur sur le premier élément du tableau.
void reserve(Int64 new_capacity)
Réserve le mémoire pour new_capacity éléments.
void resize(Int64 s)
Change le nombre d'éléments du tableau à s.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Span< const T > constSpan() const
Vue constante sur ce tableau.
void clear()
Supprime les éléments du tableau.
iterator end()
Itérateur sur le premier élément après la fin du tableau.
Vue constante d'un tableau de type T.
constexpr Integer size() const noexcept
Nombre d'éléments du tableau.
Interface du gestionnaire de traces.
virtual TraceMessage info()=0
Flot pour un message d'information.
virtual TraceMessage error()=0
Flot pour un message d'erreur.
Vue d'un tableau d'éléments de type T.
constexpr __host__ __device__ SizeType size() const noexcept
Retourne la taille du tableau.
constexpr Span< const Byte > bytes() const ARCCORE_NOEXCEPT
Retourne la conversion de l'instance dans l'encodage UTF-8.
Chaîne de caractères unicode.
bool empty() const
Vrai si la chaîne est vide (nulle ou "")
const char * localstr() const
Retourne la conversion de l'instance dans l'encodage UTF-8.
Positionne une classe de message.
Formattage du flot en longueur.
Vecteur 1D de données avec sémantique par valeur (style STL).
ItemEnumeratorT< Node > NodeEnumerator
Enumérateurs sur des noeuds.
Integer toInteger(Real r)
Converti un Int64 en un Integer.
String toHexaString(ByteConstArrayView input)
Converti un tableau d'octet en sa représentation hexadécimale.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Array< Int64 > Int64Array
Tableau dynamique à une dimension d'entiers 64 bits.
Integer arcaneCheckArraySize(unsigned long long size)
Vérifie que size peut être converti dans un 'Integer' pour servir de taille à un tableau....
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
bool operator<(const Item &item1, const Item &item2)
Compare deux entités.
SharedMeshVariableScalarRefT< Node, Real3 > SharedVariableNodeReal3
Grandeur au noeud de type coordonnées.
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
eItemKind
Genre d'entité de maillage.
@ IK_Particle
Entité de maillage de genre particule.
@ IK_Node
Entité de maillage de genre noeud.
@ IK_Cell
Entité de maillage de genre maille.
@ IK_Face
Entité de maillage de genre face.
@ IK_Edge
Entité de maillage de genre arête.
const char * itemKindName(eItemKind kind)
Nom du genre d'entité.
Collection< ITiedInterface * > TiedInterfaceCollection
Collection d'interfaces liées.
Int32 Integer
Type représentant un entier.