@@ -50,6 +50,8 @@ CartesianPatchGroup::
5050CartesianPatchGroup (ICartesianMesh* cmesh)
5151: m_cmesh(cmesh)
5252, m_index_new_patches(1 )
53+ , m_size_of_overlap_layer_sub_top_level(0 )
54+ , m_higher_level(0 )
5355{}
5456
5557/* ---------------------------------------------------------------------------*/
@@ -171,6 +173,9 @@ addPatch(CellGroup cell_group, Integer group_index)
171173 position.setMinPoint ({ min[MD_DirX], min[MD_DirY], min[MD_DirZ] });
172174 position.setMaxPoint ({ max[MD_DirX], max[MD_DirY], max[MD_DirZ] });
173175 position.setLevel (level_r);
176+
177+ if (level_r > m_higher_level)
178+ m_higher_level = level_r;
174179 }
175180
176181 auto * cdi = new CartesianMeshPatch (m_cmesh, group_index, position);
@@ -364,6 +369,14 @@ applyPatchEdit(bool remove_empty_patches)
364369 _removeMultiplePatches (m_patches_to_delete);
365370 m_patches_to_delete.clear ();
366371 }
372+
373+ m_higher_level = 0 ;
374+ for (const auto patch : m_amr_patches_pointer) {
375+ const Integer level = patch->_internalApi ()->positionRef ().level ();
376+ if (level > m_higher_level) {
377+ m_higher_level = level;
378+ }
379+ }
367380}
368381
369382/* ---------------------------------------------------------------------------*/
@@ -399,6 +412,9 @@ updateLevelsBeforeAddGroundPatch()
399412 // Sinon, on "surélève" le niveau des patchs vu qu'il va y avoir le patch "-1"
400413 else {
401414 patch->_internalApi ()->positionRef ().setLevel (level + 1 );
415+ if (level + 1 > m_higher_level) {
416+ m_higher_level = level + 1 ;
417+ }
402418 }
403419 }
404420}
@@ -504,11 +520,17 @@ mergePatches()
504520void CartesianPatchGroup::
505521refine (bool clear_refine_flag)
506522{
523+ // TODO : Le paramètre clear_refine_flag doit être à true pour l'instant.
524+ // À cause des mailles de recouvrements, on doit regénérer les patchs
525+ // de tous les niveaux à chaque fois. Pour que ça fonctionne, il
526+ // faudrait demander le nombre de niveaux qui sera généré en tout,
527+ // pour cette itération, pour calculer en avance la taille de la
528+ // couche de recouvrement de chaque niveau.
507529 if (m_cmesh->mesh ()->meshKind ().meshAMRKind () != eMeshAMRKind::PatchCartesianMeshOnly) {
508530 ARCANE_FATAL (" Method available only with AMR PatchCartesianMeshOnly" );
509531 }
510532 Integer dimension = m_cmesh->mesh ()->dimension ();
511- Integer nb_overlap_cells = 1 ;
533+ Integer nb_overlap_cells = m_size_of_overlap_layer_sub_top_level ;
512534 Integer min_level = 0 ;
513535 Integer future_max_level = -1 ; // Désigne le niveau max qui aura des enfants, donc le futur level max +1.
514536 Integer old_max_level = -1 ; // Mais s'il reste des mailles à des niveaux plus haut, il faut les retirer.
@@ -558,7 +580,7 @@ refine(bool clear_refine_flag)
558580 AMRPatchPosition all_level;
559581 all_level.setLevel (level);
560582 all_level.setMinPoint ({ 0 , 0 , 0 });
561- all_level.setMaxPoint ({ static_cast <Integer>( numbering->globalNbCellsX (level)), static_cast <Integer>( numbering->globalNbCellsY (level)), static_cast <Integer>( numbering->globalNbCellsZ (level) ) });
583+ all_level.setMaxPoint ({ numbering->globalNbCellsX (level), numbering->globalNbCellsY (level), numbering->globalNbCellsZ (level) });
562584 all_level.setOverlapLayerSize (nb_overlap_cells);
563585
564586 AMRPatchPositionSignature sig (all_level, m_cmesh, &all_patches);
@@ -843,6 +865,35 @@ availableGroupIndex()
843865/* ---------------------------------------------------------------------------*/
844866/* ---------------------------------------------------------------------------*/
845867
868+ void CartesianPatchGroup::
869+ setOverlapLayerSizeTopLevel (Integer size_of_overlap_layer_top_level)
870+ {
871+ m_size_of_overlap_layer_sub_top_level = (size_of_overlap_layer_top_level + 1 ) / 2 ;
872+ }
873+
874+ /* ---------------------------------------------------------------------------*/
875+ /* ---------------------------------------------------------------------------*/
876+
877+ Integer CartesianPatchGroup::
878+ overlapLayerSize (Integer level)
879+ {
880+ if (level < 0 || level > m_higher_level) {
881+ ARCANE_FATAL (" Level doesn't exist" );
882+ }
883+ if (level == m_higher_level) {
884+ return m_size_of_overlap_layer_sub_top_level * 2 ;
885+ }
886+ Integer nb_overlap_cells = m_size_of_overlap_layer_sub_top_level;
887+ for (Integer i = m_higher_level - 1 ; i > level; --i) {
888+ nb_overlap_cells /= 2 ;
889+ nb_overlap_cells += 1 ;
890+ }
891+ return nb_overlap_cells;
892+ }
893+
894+ /* ---------------------------------------------------------------------------*/
895+ /* ---------------------------------------------------------------------------*/
896+
846897void CartesianPatchGroup::
847898_addPatchInstance (Ref<CartesianMeshPatch> v)
848899{
@@ -1233,6 +1284,9 @@ _splitPatch(Integer index_patch, const AMRPatchPosition& part_to_remove)
12331284void CartesianPatchGroup::
12341285_addCutPatch (const AMRPatchPosition& new_patch_position, CellGroup parent_patch_cell_group)
12351286{
1287+ // Si cette méthode est utilisé par une autre méthode que _splitPatch(),
1288+ // voir si la mise à jour de m_higher_level est nécessaire.
1289+ // (jusque-là, ce n'est pas utile vu qu'il y aura appel à applyPatchEdit()).
12361290 if (parent_patch_cell_group.null ())
12371291 ARCANE_FATAL (" Null cell group" );
12381292
@@ -1250,7 +1304,7 @@ _addCutPatch(const AMRPatchPosition& new_patch_position, CellGroup parent_patch_
12501304 Int64 pos_x = numbering->cellUniqueIdToCoordX (*icell);
12511305 Int64 pos_y = numbering->cellUniqueIdToCoordY (*icell);
12521306 Int64 pos_z = numbering->cellUniqueIdToCoordZ (*icell);
1253- if (new_patch_position.isIn (pos_x, pos_y, pos_z)) { // TODO : Ajouter overlap dans .arc
1307+ if (new_patch_position.isIn (pos_x, pos_y, pos_z)) {
12541308 cells_local_id.add (icell.localId ());
12551309 }
12561310 }
@@ -1293,6 +1347,10 @@ _addPatch(const AMRPatchPosition& new_patch_position)
12931347 CellGroup parent_cells = cell_family->createGroup (patch_group_name, cells_local_id, true );
12941348 _addCellGroup (parent_cells, cdi);
12951349
1350+ if (new_patch_position.level () > m_higher_level) {
1351+ m_higher_level = new_patch_position.level ();
1352+ }
1353+
12961354 // m_cmesh->traceMng()->info() << "_addPatch()"
12971355 // << " -- m_amr_patch_cell_groups : " << m_amr_patch_cell_groups_all.size()
12981356 // << " -- m_amr_patches : " << m_amr_patches.size()
0 commit comments