14#include "arcane/utils/CheckedConvert.h"
15#include "arcane/utils/PlatformUtils.h"
16#include "arcane/utils/Real2.h"
17#include "arcane/utils/MD5HashAlgorithm.h"
20#include "arcane/core/MeshKind.h"
21#include "arcane/core/Directory.h"
23#include "arcane/core/ITimeLoopMng.h"
24#include "arcane/core/ITimeLoopService.h"
25#include "arcane/core/ITimeLoop.h"
26#include "arcane/core/TimeLoopEntryPointInfo.h"
27#include "arcane/core/IMesh.h"
28#include "arcane/core/IItemFamily.h"
29#include "arcane/core/ItemPrinter.h"
30#include "arcane/core/IParallelMng.h"
32#include "arcane/core/IMesh.h"
33#include "arcane/core/IItemFamily.h"
34#include "arcane/core/IMeshModifier.h"
35#include "arcane/core/IMeshUtilities.h"
36#include "arcane/core/ServiceBuilder.h"
38#include "arcane/core/MeshStats.h"
39#include "arcane/core/IPostProcessorWriter.h"
40#include "arcane/core/IVariableMng.h"
41#include "arcane/core/SimpleSVGMeshExporter.h"
42#include "arcane/core/IGhostLayerMng.h"
44#include "arcane/cartesianmesh/ICartesianMesh.h"
45#include "arcane/cartesianmesh/AMRZonePosition.h"
46#include "arcane/cartesianmesh/CellDirectionMng.h"
47#include "arcane/cartesianmesh/FaceDirectionMng.h"
48#include "arcane/cartesianmesh/NodeDirectionMng.h"
49#include "arcane/cartesianmesh/CartesianConnectivity.h"
50#include "arcane/cartesianmesh/CartesianMeshAMRMng.h"
51#include "arcane/cartesianmesh/CartesianMeshRenumberingInfo.h"
52#include "arcane/cartesianmesh/ICartesianMeshPatch.h"
53#include "arcane/cartesianmesh/CartesianMeshUtils.h"
54#include "arcane/cartesianmesh/CartesianMeshCoarsening2.h"
55#include "arcane/cartesianmesh/CartesianMeshPatchListView.h"
57#include "arcane/tests/ArcaneTestGlobal.h"
58#include "arcane/tests/AMRCartesianMeshTester_axl.h"
59#include "arcane/tests/CartesianMeshTestUtils.h"
67using namespace Arcane;
74class AMRCartesianMeshTesterModule
75:
public ArcaneAMRCartesianMeshTesterObject
80 ~AMRCartesianMeshTesterModule();
88 void buildInit()
override;
89 void compute()
override;
102 Int32 m_nb_expected_patch = 0;
103 bool m_merge_patches =
true;
111 void _mergePatches();
112 void _reduceNbGhostLayers();
114 void _computeCenters();
115 void _processPatches();
116 void _writePostProcessing();
117 void _checkUniqueIds();
118 void _testDirections();
119 void _checkDirections();
131AMRCartesianMeshTesterModule::
133: ArcaneAMRCartesianMeshTesterObject(mbi)
139, m_cartesian_mesh(nullptr)
146AMRCartesianMeshTesterModule::
147~AMRCartesianMeshTesterModule()
156void AMRCartesianMeshTesterModule::
159 String time_loop_name(
"AMRCartesianMeshTestLoop");
165 List<TimeLoopEntryPointInfo> clist;
166 clist.add(TimeLoopEntryPointInfo(
"AMRCartesianMeshTester.buildInit"));
171 List<TimeLoopEntryPointInfo> clist;
172 clist.add(TimeLoopEntryPointInfo(
"AMRCartesianMeshTester.init"));
177 List<TimeLoopEntryPointInfo> clist;
178 clist.add(TimeLoopEntryPointInfo(
"AMRCartesianMeshTester.compute"));
184 clist.add(
"AMRCartesianMeshTester");
187 clist.add(
"ArcanePostProcessing");
188 clist.add(
"ArcaneCheckpoint");
189 clist.add(
"ArcaneLoadBalance");
199void AMRCartesianMeshTesterModule::
202 if (subDomain()->isContinue())
205 m_global_deltat.assign(1.0);
207 IItemFamily* cell_family = defaultMesh()->cellFamily();
218 IItemFamily* face_family = defaultMesh()->faceFamily();
233void AMRCartesianMeshTesterModule::
236 info() <<
"AMR Init";
238 IMesh* mesh = defaultMesh();
240 IItemFamily* cell_family = mesh->
cellFamily();
248 IItemFamily* face_family = defaultMesh()->faceFamily();
263 m_utils =
makeRef(
new CartesianMeshTestUtils(m_cartesian_mesh,acceleratorMng()));
265 m_merge_patches = options()->mergePatches();
267 if (!subDomain()->isContinue()) {
270 if (m_merge_patches) {
273 _reduceNbGhostLayers();
279 const bool do_coarse_at_init = options()->coarseAtInit();
281 const Integer dimension = defaultMesh()->dimension();
283 m_nb_expected_patch = 1 + options()->refinement2d().size();
284 else if (dimension==3)
285 m_nb_expected_patch = 1 + options()->refinement3d().size();
288 if (do_coarse_at_init)
289 ++m_nb_expected_patch;
291 if (subDomain()->isContinue())
292 m_cartesian_mesh->recreateFromDump();
294 m_cartesian_mesh->computeDirections();
295 CartesianMeshRenumberingInfo renumbering_info;
298 if (options()->coarseAtInit())
300 m_cartesian_mesh->renumberItemsUniqueId(renumbering_info);
303 info() <<
"MaxUid for mesh=" << MeshUtils::getMaxItemUniqueIdCollective(m_cartesian_mesh->mesh());
311 for(
Integer idir=0, nb_dir=dimension; idir<nb_dir; ++idir){
312 CellDirectionMng cdm(m_cartesian_mesh->cellDirection(idir));
316 DirCell cc(cdm.cell(*icell));
317 Cell next = cc.next();
318 Cell prev = cc.previous();
323 m_density[icell] += 5.0;
328 DirCell cc(cdm[icell]);
330 info() <<
"CELL: cell=" << ItemPrinter(*icell)
331 <<
" next=" << ItemPrinter(cc.next())
332 <<
" previous=" << ItemPrinter(cc.previous());
335 m_density[icell] += 5.0;
338 info() <<
"NB_BOUNDARY1=" << nb_boundary1 <<
" NB_BOUNDARY2=" << nb_boundary2;
340 bool is_amr = m_nb_expected_patch!=1;
341 if (options()->verbosityLevel()==0)
342 m_utils->setNbPrint(5);
343 m_utils->testAll(is_amr);
344 _writePostProcessing();
353void AMRCartesianMeshTesterModule::
356 IMesh* mesh = m_cartesian_mesh->mesh();
357 bool print_hash =
true;
358 bool with_ghost = options()->hashWithGhost();
359 MD5HashAlgorithm hash_algo;
360 MeshUtils::checkUniqueIdsHashCollective(mesh->
nodeFamily(), &hash_algo, options()->nodesUidHash(),
361 print_hash, with_ghost);
362 MeshUtils::checkUniqueIdsHashCollective(mesh->
faceFamily(), &hash_algo, options()->facesUidHash(),
363 print_hash, with_ghost);
364 MeshUtils::checkUniqueIdsHashCollective(mesh->
cellFamily(), &hash_algo, options()->cellsUidHash(),
365 print_hash, with_ghost);
371void AMRCartesianMeshTesterModule::
374 const bool do_check =
true;
375 const bool is_verbose = options()->verbosityLevel()>=1;
377 const Int32 dimension = defaultMesh()->dimension();
379 bool without_coarse_zone =
true;
381 without_coarse_zone = options()->coarseZone2d().empty();
382 else if (dimension == 3)
383 without_coarse_zone = options()->coarseZone3d().empty();
392 Integer nb_expected_patch = m_nb_expected_patch;
394 Integer nb_patch = m_cartesian_mesh->nbPatch();
395 if (without_coarse_zone && nb_expected_patch != nb_patch && !m_merge_patches)
396 ARCANE_FATAL(
"Bad number of patchs expected={0} value={1}",nb_expected_patch,nb_patch);
398 IParallelMng* pm = parallelMng();
402 UniqueArray<Int32> nb_cells_expected(options()->expectedNumberOfCellsInPatchs);
403 if (nb_cells_expected.size()!=nb_patch)
404 ARCANE_FATAL(
"Bad size ({0}, expected={1}) for option '{2}'",
405 nb_cells_expected.size(),nb_patch,options()->expectedNumberOfCellsInPatchs.name());
408 bool has_expected_ghost_cells = options()->expectedNumberOfGhostCellsInPatchs.isPresent();
410 has_expected_ghost_cells =
false;
412 UniqueArray<Int32> nb_ghost_cells_expected(options()->expectedNumberOfGhostCellsInPatchs);
413 if (has_expected_ghost_cells && (nb_ghost_cells_expected.size()!=nb_patch))
414 ARCANE_FATAL(
"Bad size ({0}, expected={1}) for option '{2}'",
415 nb_ghost_cells_expected.size(), nb_patch, options()->expectedNumberOfGhostCellsInPatchs.name());
417 for(
Integer i=0; i<nb_patch; ++i ){
418 ICartesianMeshPatch* p = m_cartesian_mesh->patch(i);
420 info() <<
"Patch cell_group=" << patch_cells.name() <<
" nb_cell=" << patch_cells.size();
422 m_cell_patch_variables.add(cellv);
425 (*cellv)[icell] = 2.0;
428 CellGroup patch_own_cell = patch_cells.own();
429 UniqueArray<Int64> own_cells_uid;
433 info() <<
"Patch i=" << i <<
" cell=" << ItemPrinter(*icell);
434 own_cells_uid.
add(cell.uniqueId());
438 UniqueArray<Int64> global_cells_uid;
440 std::sort(global_cells_uid.
begin(),global_cells_uid.
end());
442 info() <<
"GlobalUids Patch=" << i <<
" NB=" << nb_global_uid
443 <<
" expected=" << nb_cells_expected[i];
445 if (do_check && nb_cells_expected[i]!=nb_global_uid)
446 ARCANE_FATAL(
"Bad number of cells for patch I={0} N={1} expected={2}",
447 i,nb_global_uid,nb_cells_expected[i]);
449 for(
Integer c=0; c<nb_global_uid; ++c )
450 info() <<
"GlobalUid Patch=" << i <<
" I=" << c <<
" cell_uid=" << global_cells_uid[c];
453 if (has_expected_ghost_cells){
454 Int32 local_nb_ghost_cell = patch_cells.size() - patch_own_cell.
size();
456 pinfo() <<
"NbGhostCells my_rank=" << comm_rank <<
" local=" << local_nb_ghost_cell <<
" total=" << total;
457 if (total!=nb_ghost_cells_expected[i])
458 ARCANE_FATAL(
"Bad number of ghost cells for patch I={0} N={1} expected={2}",
459 i,total,nb_ghost_cells_expected[i]);
463 if (dimension==2 && options()->dumpSvg()){
464 String filename = String::format(
"Patch{0}-{1}-{2}.svg",i,comm_rank,comm_size);
465 Directory directory = subDomain()->exportDirectory();
466 String full_filename = directory.
file(filename);
467 std::ofstream ofile(full_filename.
localstr());
468 SimpleSVGMeshExporter exporter(ofile);
469 exporter.write(patch_cells);
477void AMRCartesianMeshTesterModule::
480 IMesh* mesh = defaultMesh();
488 for( NodeLocalId inode : cell.
nodes() )
489 center += nodes_coord[inode];
491 m_cell_center[icell] = center;
501 for( NodeLocalId inode : face.
nodes() )
502 center += nodes_coord[inode];
504 m_face_center[iface] = center;
512void AMRCartesianMeshTesterModule::
515 CartesianMeshAMRMng amr_mng(m_cartesian_mesh);
516 amr_mng.enableOverlapLayer(
false);
519 if (options()->coarseAtInit()){
521 m_cartesian_mesh->computeDirections();
523 info() <<
"Doint initial coarsening";
534 amr_mng.createSubLevel();
536 CartesianMeshPatchListView patches = m_cartesian_mesh->patches();
537 Int32 nb_patch = patches.size();
540 info() <<
"NB_PATCH=" << nb_patch;
541 for( CartesianPatch p : patches){
542 info() <<
"Patch i=" << index <<
" nb_cell=" << p.
cells().
size();
550 Int32 dim = defaultMesh()->dimension();
552 for (
const auto& x : options()->refinement2d()) {
553 amr_mng.refineZone({ x->position(), x->length() });
554 m_cartesian_mesh->computeDirections();
558 for (
const auto& x : options()->refinement3d()) {
559 amr_mng.refineZone({ x->position(), x->length() });
560 m_cartesian_mesh->computeDirections();
568void AMRCartesianMeshTesterModule::
571 Int32 dim = defaultMesh()->dimension();
572 CartesianMeshAMRMng amr_mng(m_cartesian_mesh);
576 for (
auto& x : options()->coarseZone2d()) {
581 amr_mng.coarseZone({ { x->position() }, { x->length() } });
582 m_cartesian_mesh->computeDirections();
587 for (
auto& x : options()->coarseZone3d()) {
592 amr_mng.coarseZone({ { x->position() }, { x->length() } });
593 m_cartesian_mesh->computeDirections();
601void AMRCartesianMeshTesterModule::
604 CartesianMeshAMRMng amr_mng(m_cartesian_mesh);
605 amr_mng.mergePatches();
607 m_cartesian_mesh->computeDirections();
613void AMRCartesianMeshTesterModule::
614_reduceNbGhostLayers()
616 for (
auto& x : options()->reduceNbGhostLayers()) {
617 Integer final_nb_ghost_layer{ m_cartesian_mesh->reduceNbGhostLayers(x->level(), x->nbGhostLayers()) };
619 if (parallelMng()->commSize() != 1 && final_nb_ghost_layer != x->nbGhostLayers()) {
629void AMRCartesianMeshTesterModule::
657 for(
Int32 j=0; j<nb_children; ++j ) {
658 Real sub_density = 0.0;
661 for(
Integer k=0; k<sub_cell_nb_node; ++k )
662 sub_density += m_node_density[sub_cell.
node(k)];
663 sub_density /= (
Real)sub_cell_nb_node;
664 m_density[sub_cell] =sub_density;
672void AMRCartesianMeshTesterModule::
685 for(
Integer idir=0; idir<nb_dir; ++idir){
686 m_old_density.copy(m_density);
689 info() <<
"Direction=" << idir <<
" cells=" << cdm.innerCells().name()
690 <<
" n=" << cdm.innerCells().size();
694 Cell next = cc.next();
695 Cell prev = cc.previous();
696 Real d = m_old_density[icell] + m_old_density[next] + m_old_density[prev];
697 m_density[icell] = d / 3.0;
705 Cell next = cc.next();
706 Cell prev = cc.previous();
707 Real d = m_old_density[icell];
710 d += m_old_density[next];
714 d += m_old_density[prev];
717 m_density[icell] = d / n;
727 for(
Integer i=0; i<nb_cell; ++i )
728 density += m_density[node.
cell(i)];
729 density /= (
Real)nb_cell;
730 m_node_density[inode] = density;
737void AMRCartesianMeshTesterModule::
747 Integer nb_dir = defaultMesh()->dimension();
748 for(
Integer idir=0; idir<nb_dir; ++idir){
749 CellDirectionMng cdm(m_cartesian_mesh->cellDirection(idir));
752 DirCell cc(cdm[icell]);
753 Cell next = cc.next();
754 Cell prev = cc.previous();
755 Real d = m_density[icell];
758 d += m_density[next];
762 d += m_density[prev];
765 m_density[icell] = d / n;
773void AMRCartesianMeshTesterModule::
774_writePostProcessing()
776 info() <<
"Post-process AMR";
777 IPostProcessorWriter* post_processor = options()->postProcessor();
778 Directory output_directory = Directory(subDomain()->exportDirectory(),
"amrtestpost1");
780 info() <<
"Creating output dir '" << output_directory.
path() <<
"' for export";
781 UniqueArray<Real> times;
782 times.
add(m_global_time());
784 post_processor->
setMesh(defaultMesh());
787 VariableList variables;
791 variables.add(v->variable());
794 groups.add(allCells());
795 for( CartesianPatch p : m_cartesian_mesh->patches() )
796 groups.add(p.
cells());
798 IVariableMng* vm = subDomain()->variableMng();
805void AMRCartesianMeshTesterModule::
808 Integer nb_patch = m_cartesian_mesh->nbPatch();
809 Integer nb_dir = m_cartesian_mesh->mesh()->dimension();
810 NodeDirectionMng node_dm2;
811 for(
Integer ipatch=0; ipatch<nb_patch; ++ipatch ){
812 ICartesianMeshPatch* p = m_cartesian_mesh->patch(ipatch);
813 for(
Integer idir=0; idir<nb_dir; ++idir ){
816 NodeGroup dm_all_nodes = node_dm.allNodes();
818 DirNode dir_node(node_dm[inode]);
819 DirNode dir_node2(node_dm2[inode]);
820 Node prev_node = dir_node.previous();
821 Node next_node = dir_node.next();
822 Node prev_node2 = dir_node2.previous();
823 Node next_node2 = dir_node2.next();
824 m_utils->checkSameId(prev_node, prev_node2);
825 m_utils->checkSameId(next_node, next_node2);
831void AMRCartesianMeshTesterModule::
834 m_cartesian_mesh->computeDirections();
835 IMesh* mesh = m_cartesian_mesh->mesh();
836 bool print_hash =
true;
838 auto check_hash = [&](
const IItemFamily* item_family,
const String& expected_hash, ArrayView<Int64> own_items_uid_around,
Integer nb_items_around) {
842 info() <<
"HASH_RESULT direction items of family=" << item_family->
name()
843 <<
" v= " << cell_hash <<
" expected= " << expected_hash;
846 if (cell_hash != expected_hash)
847 ARCANE_FATAL(
"Bad hash for uniqueId() for direction items of family '{0}' v='{1}' expected='{2}'",
848 item_family->
fullName(), cell_hash, expected_hash);
851 if (!options()->cellsDirectionHash().empty()) {
852 debug() <<
"Check cells direction hash";
853 UniqueArray<Int64> own_cells_uid_around_cells;
855 check_hash(mesh->
cellFamily(), options()->cellsDirectionHash(), own_cells_uid_around_cells, nb_items_around);
857 if (!options()->facesDirectionHash().empty()) {
858 debug() <<
"Check faces direction hash";
859 UniqueArray<Int64> own_cells_uid_around_faces;
861 check_hash(mesh->
faceFamily(), options()->facesDirectionHash(), own_cells_uid_around_faces, nb_items_around);
864 if (!options()->nodesDirectionHash().empty()) {
865 debug() <<
"Check nodes direction hash";
866 UniqueArray<Int64> own_nodes_uid_around_nodes;
868 check_hash(mesh->
nodeFamily(), options()->nodesDirectionHash(), own_nodes_uid_around_nodes, nb_items_around);
886 Integer size_of_once_case_around = nb_items_around + 1;
891 parallelMng()->allGatherVariable(own_items_uid_around, global_items_uid_around);
896 for (
Int64 i = 0; i < global_items_uid_around.
size(); i += size_of_once_case_around) {
897 Int64 uid = global_items_uid_around[i];
898 ARCANE_ASSERT((uid != -1), (
"Un uid dans le tableau est = -1"));
899 global_items_uid[index++] = &(global_items_uid_around[i]);
903 std::sort(global_items_uid.
begin(), global_items_uid.
end(),
908 final_all_items_uid.
resize(global_items_uid_around.
size());
911 Int64 previous_uid = -1;
913 for (
Int64* ptr_uid : global_items_uid) {
914 if (*ptr_uid == previous_uid) {
917 previous_uid = *ptr_uid;
918 for (
Integer iaround = 0; iaround < size_of_once_case_around; ++iaround) {
919 final_all_items_uid[index++] = ptr_uid[iaround];
947 if (pm->
commSize() != 1 &&
mesh->ghostLayerMng()->nbGhostLayer() == 0) {
951 Integer nb_patch = m_cartesian_mesh->nbPatch();
953 Integer nb_items =
mesh->cellFamily()->allItems().own().size();
956 constexpr Integer nb_items_per_dir = 2;
961 Integer size_of_once_case_around = nb_dir * nb_items_per_dir + 1;
963 own_cells_uid_around_cells.
resize(nb_items * size_of_once_case_around, -1);
967 own_cells_uid_around_cells[index] = icell->uniqueId();
968 index += size_of_once_case_around;
977 ARCANE_ASSERT((uid != -1), (
"Uid ne peut pas être égal à -1"));
979 for (
Integer i = 0; i < own_cells_uid_around_cells.
size(); i += size_of_once_case_around) {
980 if (own_cells_uid_around_cells[i] == uid) {
981 Integer pos_final = i + 1 + (dir * nb_items_per_dir);
982 Integer pos_pred = pos_final + ipred;
983 Integer pos_succ = pos_final + isucc;
984 if (own_cells_uid_around_cells[pos_pred] != -1 && own_cells_uid_around_cells[pos_pred] != uid_pred) {
985 ARCANE_FATAL(
"Problème de cohérence entre les patchs (uid={0} -- old_uid_pred={1} -- new_uid_pred={2})", uid, own_cells_uid_around_cells[pos_pred], uid_pred);
987 if (own_cells_uid_around_cells[pos_succ] != -1 && own_cells_uid_around_cells[pos_succ] != uid_succ) {
988 ARCANE_FATAL(
"Problème de cohérence entre les patchs (uid={0} -- old_uid_succ={1} -- new_uid_succ={2})", uid, own_cells_uid_around_cells[pos_succ], uid_succ);
990 own_cells_uid_around_cells[pos_pred] = uid_pred;
991 own_cells_uid_around_cells[pos_succ] = uid_succ;
997 for (
Integer idir = 0; idir < nb_dir; ++idir) {
1003 set_value(idir, icell->uniqueId(), prev.uniqueId(), next.uniqueId());
1007 for (
Integer ipatch = 0; ipatch < nb_patch; ++ipatch) {
1009 for (
Integer idir = 0; idir < nb_dir; ++idir) {
1015 set_value(idir, icell->uniqueId(), prev.uniqueId(), next.uniqueId());
1020 return size_of_once_case_around-1;
1038 if (pm->
commSize() != 1 &&
mesh->ghostLayerMng()->nbGhostLayer() == 0) {
1042 Integer nb_patch = m_cartesian_mesh->nbPatch();
1044 Integer nb_items =
mesh->faceFamily()->allItems().own().size();
1047 constexpr Integer nb_items_per_dir = 2;
1052 Integer size_of_once_case_around = nb_items_per_dir * nb_patch + 1;
1054 own_cells_uid_around_faces.
resize(nb_items * size_of_once_case_around, -1);
1058 own_cells_uid_around_faces[index] = iitem->uniqueId();
1059 index += size_of_once_case_around;
1067 ARCANE_ASSERT((uid != -1), (
"Uid ne peut pas être égal à -1"));
1069 for (
Integer i = 0; i < own_cells_uid_around_faces.
size(); i += size_of_once_case_around) {
1070 if (own_cells_uid_around_faces[i] == uid) {
1071 Integer pos_final = i + 1 + ipatch * nb_items_per_dir;
1072 Integer pos_pred = pos_final + ipred;
1073 Integer pos_succ = pos_final + isucc;
1074 if (own_cells_uid_around_faces[pos_pred] != -1 && own_cells_uid_around_faces[pos_pred] != uid_pred) {
1075 ARCANE_FATAL(
"Problème de cohérence entre les patchs (uid={0} -- old_uid_pred={1} -- new_uid_pred={2})", uid, own_cells_uid_around_faces[pos_pred], uid_pred);
1077 if (own_cells_uid_around_faces[pos_succ] != -1 && own_cells_uid_around_faces[pos_succ] != uid_succ) {
1078 ARCANE_FATAL(
"Problème de cohérence entre les patchs (uid={0} -- old_uid_succ={1} -- new_uid_succ={2})", uid, own_cells_uid_around_faces[pos_succ], uid_succ);
1080 own_cells_uid_around_faces[pos_pred] = uid_pred;
1081 own_cells_uid_around_faces[pos_succ] = uid_succ;
1098 for (
Integer ipatch = 0; ipatch < nb_patch; ++ipatch) {
1100 for (
Integer idir = 0; idir < nb_dir; ++idir) {
1106 set_value(ipatch, iface->uniqueId(), prev.uniqueId(), next.uniqueId());
1111 return size_of_once_case_around-1;
1134 if (pm->
commSize() != 1 &&
mesh->ghostLayerMng()->nbGhostLayer() == 0) {
1138 Integer nb_patch = m_cartesian_mesh->nbPatch();
1140 Integer nb_items =
mesh->nodeFamily()->allItems().own().size();
1143 constexpr Integer nb_items_per_dir = 2;
1148 Integer size_of_once_case_around = nb_dir * nb_items_per_dir * nb_patch + 1;
1150 own_nodes_uid_around_nodes.
resize(nb_items * size_of_once_case_around, -1);
1154 own_nodes_uid_around_nodes[index] = iitem->uniqueId();
1155 index += size_of_once_case_around;
1165 ARCANE_ASSERT((uid != -1), (
"Uid ne peut pas être égal à -1"));
1167 for (
Integer i = 0; i < own_nodes_uid_around_nodes.
size(); i += size_of_once_case_around) {
1168 if (own_nodes_uid_around_nodes[i] == uid) {
1169 Integer pos_final = i + 1 + ipatch * (nb_items_per_dir * nb_dir) + dir * nb_items_per_dir;
1170 Integer pos_pred = pos_final + ipred;
1171 Integer pos_succ = pos_final + isucc;
1172 if (own_nodes_uid_around_nodes[pos_pred] != -1 && own_nodes_uid_around_nodes[pos_pred] != uid_pred) {
1173 ARCANE_FATAL(
"Problème de cohérence entre les patchs (uid={0} -- old_uid_pred={1} -- new_uid_pred={2})", uid, own_nodes_uid_around_nodes[pos_pred], uid_pred);
1175 if (own_nodes_uid_around_nodes[pos_succ] != -1 && own_nodes_uid_around_nodes[pos_succ] != uid_succ) {
1176 ARCANE_FATAL(
"Problème de cohérence entre les patchs (uid={0} -- old_uid_succ={1} -- new_uid_succ={2})", uid, own_nodes_uid_around_nodes[pos_succ], uid_succ);
1178 own_nodes_uid_around_nodes[pos_pred] = uid_pred;
1179 own_nodes_uid_around_nodes[pos_succ] = uid_succ;
1196 for (
Integer ipatch = 0; ipatch < nb_patch; ++ipatch) {
1198 for (
Integer idir = 0; idir < nb_dir; ++idir) {
1204 set_value(idir, ipatch, inode->uniqueId(), prev.uniqueId(), next.uniqueId());
1209 return size_of_once_case_around-1;
1215void AMRCartesianMeshTesterModule::
1224 test_var[icell] = 1;
1226 test_var.synchronize();
1228 if (test_var[icell] != 1) {
1240void AMRCartesianMeshTesterModule::
1246 Real3 min_pos = position;
1247 Real3 max_pos = min_pos + length;
1249 if ((icell->level() == level) || (level == -1 && icell->nbHChildren() == 0)) {
1250 Real3 center = m_cell_center[icell];
1251 bool is_inside_x = center.
x > min_pos.
x && center.
x < max_pos.
x;
1252 bool is_inside_y = center.
y > min_pos.
y && center.
y < max_pos.
y;
1253 bool is_inside_z = (center.
z > min_pos.
z && center.
z < max_pos.
z) || !is_3d;
1254 if (is_inside_x && is_inside_y && is_inside_z) {
1255 cells_in_patch.
add(icell.itemLocalId());
#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.
Module de test pour les infos sur les maillages cartésiens.
Integer _cellsUidAroundFaces(UniqueArray< Int64 > &own_cells_uid_around_faces)
Méthode permettant de récupérer un tableau contenant les mailles autour des faces.
Integer _cellsUidAroundCells(UniqueArray< Int64 > &own_cells_uid_around_cells)
Méthode permettant de récupérer un tableau contenant les mailles autour des mailles.
Integer _nodesUidAroundNodes(UniqueArray< Int64 > &own_nodes_uid_around_nodes)
Méthode permettant de récupérer un tableau contenant les noeuds autour des noeuds.
void _computeSubCellDensity(Cell cell)
Calcule la densité d'une maille AMR.
String _checkDirectionUniqueIdsHashCollective(ArrayView< Int64 > own_items_uid_around, Integer nb_items_around)
Méthode permettant de calculer un hash à partir d'un tableau d'items "autour".
Integer size() const
Nombre d'éléments du vecteur.
Vue modifiable d'un tableau d'un type T.
iterator end()
Itérateur sur le premier élément après la fin du tableau.
void resize(Int64 s)
Change le nombre d'éléments du tableau à s.
iterator begin()
Itérateur sur le premier élément du tableau.
Span< const T > constSpan() const
Vue constante sur ce tableau.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
void setSortAfterRenumbering(bool v)
Indique si on retrie les entités après renumérotation.
void setParentPatch(CartesianPatch patch)
Numéro du patch parent pour la renumérotation.
void setRenumberPatchMethod(Int32 v)
Méthode pour renuméroter les patchs.
Infos sur les mailles d'une direction spécifique X,Y ou Z d'un maillage structuré.
CellGroup allCells() const
Groupe de toutes les mailles dans la direction.
DirCell cell(Cell c) const
Maille direction correspondant à la maille c.
Int32 nbHChildren() const
Nombre d'enfants pour l'AMR.
Cell hChild(Int32 i) const
i-ème enfant AMR
void clear()
Supprime tous les éléments de la collection.
Maille avant et après une maille suivant une direction.
Cell previous() const
Maille avant.
Cell next() const
Maille après.
Infos sur maille avant et après une face suivant une direction.
Cell nextCell() const
Maille après.
Cell previousCell() const
Maille avant.
Noeud avant et après un noeud suivant une direction.
Node next() const
Maille après.
Node previous() const
Maille avant.
String file(const String &file_name) const override
Retourne le chemin complet du fichier file_name dans le répertoire.
bool createDirectory() const override
Créé le répertoire.
String path() const override
Retourne le chemin du répertoire.
Infos sur les face d'une direction spécifique X,Y ou Z d'un maillage structuré.
DirFace face(Face f) const
Face direction correspondant à la face f.
FaceGroup allFaces() const
Groupe de toutes les faces dans la direction.
Interface d'un patch AMR d'un maillage cartésien.
virtual CellGroup cells()=0
Groupe de mailles du patch.
virtual NodeDirectionMng & nodeDirection(eMeshDirection dir)=0
Liste des noeuds dans la direction dir.
virtual FaceDirectionMng & faceDirection(eMeshDirection dir)=0
Liste des faces dans la direction dir.
virtual CellDirectionMng & cellDirection(eMeshDirection dir)=0
Liste des mailles dans la direction dir.
Interface d'un maillage cartésien.
static ICartesianMesh * getReference(const MeshHandleOrMesh &mesh, bool create=true)
Récupère ou créé la référence associée à mesh.
virtual CellDirectionMng cellDirection(eMeshDirection dir)=0
Liste des mailles dans la direction dir.
virtual IMesh * mesh() const =0
Maillage associé à ce maillage cartésien.
virtual ItemGroup createGroup(const String &name, Int32ConstArrayView local_ids, bool do_override=false)=0
Créé un groupe d'entités de nom name contenant les entités local_ids.
virtual String name() const =0
Nom de la famille.
virtual String fullName() const =0
Nom complet de la famille (avec celui du maillage)
virtual IItemFamily * nodeFamily()=0
Retourne la famille des noeuds.
virtual IItemFamily * faceFamily()=0
Retourne la famille des faces.
virtual NodeGroup allNodes()=0
Groupe de tous les noeuds.
virtual IItemFamily * cellFamily()=0
Retourne la famille des mailles.
virtual VariableNodeReal3 & nodesCoordinates()=0
Coordonnées des noeuds.
Interface du gestionnaire de parallélisme pour un sous-domaine.
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 bool isParallel() const =0
Retourne true si l'exécution est parallèle.
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 void setVariables(VariableCollection variables)=0
Positionne la liste des variables à sortir.
virtual void setTimes(RealConstArrayView times)=0
Positionne la liste des temps.
virtual void setGroups(ItemGroupCollection groups)=0
Positionne la liste des groupes à sortir.
virtual void setBaseDirectoryName(const String &dirname)=0
Positionne le nom du répertoire de sortie des fichiers. Ce répertoire doit exister.
virtual void setMesh(IMesh *mesh)
Positionne le maillage.
Interface du gestionnaire d'un sous-domaine.
virtual ITimeLoopMng * timeLoopMng()=0
Retourne le gestionnaire de la boucle en temps.
virtual ITimeLoop * createTimeLoop(const String &name)=0
Crée une boucle en temps de nom name.
virtual void registerTimeLoop(ITimeLoop *time_loop)=0
Enregistrement et choix de la boucle en temps.
virtual void setRequiredModulesName(const StringCollection &)=0
Positionne la liste des des modules obligatoires.
virtual void setOptionalModulesName(const StringCollection &)=0
Positionne la liste des des modules facultatifs.
static const char * WBuild
appelé lors de la lecture du jeu de données
static const char * WComputeLoop
appelé pendant la boucle de calcul
virtual void setEntryPoints(const String &where, const TimeLoopEntryPointInfoCollection &)=0
Positionne la liste des noms des points d'entrée pour le point d'appel where.
static const char * WInit
appelé pendant l'initialisation, l'initialisation d'une reprise ou d'un nouveau cas
virtual void writePostProcessing(IPostProcessorWriter *writer)=0
Ecrit les variables pour un post-traitement.
Integer size() const
Nombre d'éléments du groupe.
Node node(Int32 i) const
i-ème noeud de l'entité
NodeConnectedListViewType nodes() const
Liste des noeuds de l'entité
Int32 nbNode() const
Nombre de noeuds de l'entité
Classe de base d'un élément de maillage.
constexpr bool null() const
true si l'entité est nul (i.e. non connecté au maillage)
Calcule la fonction de hashage MD5 d'un tableau.
void computeHash64(Span< const Byte > input, ByteArray &output) override
Calcule la valeur du hash pour le tableau input.
Informations pour construire un module.
Infos sur les noeuds d'une direction spécifique X,Y ou Z d'un maillage structuré.
NodeGroup allNodes() const
Groupe de tous les noeuds dans la direction.
DirNode node(Node n) const
Noeud direction correspondant au noeud n.
Cell cell(Int32 i) const
i-ème maille du noeud
Int32 nbCell() const
Nombre de mailles connectées au noeud.
Classe gérant un vecteur de réel de dimension 3.
Référence à une instance.
Chaîne de caractères unicode.
const char * localstr() const
Retourne la conversion de l'instance dans l'encodage UTF-8.
Vecteur 1D de données avec sémantique par valeur (style STL).
Paramètres nécessaires à la construction d'une variable.
ItemGroupT< Cell > CellGroup
Groupe de mailles.
ItemGroupT< Node > NodeGroup
Groupe de noeuds.
MeshVariableScalarRefT< Cell, Real > VariableCellReal
Grandeur au centre des mailles de type réel.
MeshVariableScalarRefT< Cell, Real3 > VariableCellReal3
Grandeur au centre des mailles de type coordonnées.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
MeshVariableScalarRefT< Face, Real3 > VariableFaceReal3
Grandeur aux faces de type coordonnées.
MeshVariableScalarRefT< Node, Real > VariableNodeReal
Grandeur au noeud de type réel.
MeshVariableScalarRefT< Cell, Int32 > VariableCellInt32
Grandeur au centre des mailles de type entier 32 bits.
String toHexaString(ByteConstArrayView input)
Converti un tableau d'octet en sa représentation hexadécimale.
@ ReduceSum
Somme des valeurs.
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
List< ItemGroup > ItemGroupList
Tableau de groupes d'éléments du maillage.
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
List< String > StringList
Tableau de chaînes de caractères unicode.
double Real
Type représentant un réel.
Impl::SpanTypeFromSize< conststd::byte, SizeType >::SpanType asBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converti la vue en un tableau d'octets non modifiables.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Créé une référence sur un pointeur.
@ Cell
Le maillage est AMR par maille.
std::int32_t Int32
Type entier signé sur 32 bits.
Real y
deuxième composante du triplet
Real z
troisième composante du triplet
Real x
première composante du triplet