Arcane  v4.1.0.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MeshUtils.h
Aller à la documentation de ce fichier.
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* MeshUtils.h (C) 2000-2025 */
9/* */
10/* Fonctions utilitaires diverses sur le maillage. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_MESHUTILS_H
13#define ARCANE_CORE_MESHUTILS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/FunctorUtils.h"
19
20#include "arcane/core/Item.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Arcane
33{
34class XmlNode;
36} // namespace Arcane
37
38/*---------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------*/
40
41namespace Arcane::MeshUtils
42{
43extern "C++" ARCANE_CORE_EXPORT void
44writeMeshItemInfo(ISubDomain*, Cell cell, bool depend_info = true);
45extern "C++" ARCANE_CORE_EXPORT void
46writeMeshItemInfo(ISubDomain*, Node node, bool depend_info = true);
47extern "C++" ARCANE_CORE_EXPORT void
48writeMeshItemInfo(ISubDomain*, Edge edge, bool depend_info = true);
49extern "C++" ARCANE_CORE_EXPORT void
50writeMeshItemInfo(ISubDomain*, Face face, bool depend_info = true);
51
52/*---------------------------------------------------------------------------*/
53/*---------------------------------------------------------------------------*/
72extern "C++" ARCANE_CORE_EXPORT bool
74
75extern "C++" ARCANE_CORE_EXPORT bool
77
78/*---------------------------------------------------------------------------*/
79/*---------------------------------------------------------------------------*/
102extern "C++" ARCANE_CORE_EXPORT bool
104
105/*---------------------------------------------------------------------------*/
106/*---------------------------------------------------------------------------*/
117extern "C++" ARCANE_CORE_EXPORT Face
118getFaceFromNodesLocalId(Node node, Int32ConstArrayView face_nodes_local_id);
119
120ARCANE_DEPRECATED_REASON("Y2025: Use getFaceFromNodesLocalId() instead")
121inline Face
122getFaceFromNodesLocal(Node node, Int32ConstArrayView face_nodes_local_id)
123{
124 return getFaceFromNodesLocalId(node, face_nodes_local_id);
125}
126
127/*---------------------------------------------------------------------------*/
128/*---------------------------------------------------------------------------*/
139extern "C++" ARCANE_CORE_EXPORT Face
140getFaceFromNodesUniqueId(Node node, Int64ConstArrayView face_nodes_unique_id);
141
142ARCANE_DEPRECATED_REASON("Y2025: Use getFaceFromNodesUniqueId() instead")
143inline Face
144getFaceFromNodesUnique(Node node, Int64ConstArrayView face_nodes_unique_id)
145{
146 return getFaceFromNodesUniqueId(node, face_nodes_unique_id);
147}
148
149/*---------------------------------------------------------------------------*/
150/*---------------------------------------------------------------------------*/
154extern "C++" ARCANE_CORE_EXPORT Int64
155generateHashUniqueId(SmallSpan<const Int64> nodes_unique_id);
156
157/*---------------------------------------------------------------------------*/
158/*---------------------------------------------------------------------------*/
159
167extern "C++" ARCANE_CORE_EXPORT void
168removeItemAndKeepOrder(Int32ArrayView items, Int32 local_id);
169
170/*---------------------------------------------------------------------------*/
171/*---------------------------------------------------------------------------*/
183extern "C++" ARCANE_CORE_EXPORT void
184checkMeshProperties(IMesh* mesh, bool is_sorted, bool has_no_hole, bool check_faces);
185
192extern "C++" ARCANE_CORE_EXPORT void
193writeMeshInfosSorted(IMesh* mesh, const String& file_name);
194
195extern "C++" ARCANE_CORE_EXPORT void
196writeMeshInfos(IMesh* mesh, const String& file_name);
197
203extern "C++" ARCANE_CORE_EXPORT void
204writeMeshConnectivity(IMesh* mesh, const String& file_name);
205
206extern "C++" ARCANE_CORE_EXPORT void
207checkMeshConnectivity(IMesh* mesh, const XmlNode& root_node, bool check_sub_domain);
208
209extern "C++" ARCANE_CORE_EXPORT void
210checkMeshConnectivity(IMesh* mesh, const String& file_name, bool check_sub_domain);
211
217extern "C++" ARCANE_CORE_EXPORT void
218printItems(std::ostream& ostr, const String& name, ItemGroup item_group);
219
228extern "C++" ARCANE_CORE_EXPORT Int64
229printMeshGroupsMemoryUsage(IMesh* mesh, Int32 print_level);
230
232extern "C++" ARCANE_CORE_EXPORT void
233shrinkMeshGroups(IMesh* mesh);
234
241extern "C++" ARCANE_CORE_EXPORT void
242dumpSynchronizerTopologyJSON(IVariableSynchronizer* var_syncer, const String& filename);
243
248extern "C++" ARCANE_CORE_EXPORT void
249computeConnectivityPatternOccurence(IMesh* mesh);
250
251/*---------------------------------------------------------------------------*/
252/*---------------------------------------------------------------------------*/
269extern "C++" ARCANE_CORE_EXPORT void
270markMeshConnectivitiesAsMostlyReadOnly(IMesh* mesh, RunQueue* q = nullptr,
271 bool do_prefetch = false);
272
273/*---------------------------------------------------------------------------*/
274/*---------------------------------------------------------------------------*/
275/*
276 * \brief Retourne l'entité de la famille \a family de numéro unique \a unique_id.
277 *
278 * Si aucune entité avec cet \a unique_id n'est trouvé, retourne l'entité nulle.
279 *
280 * \pre family->hasUniqueIdMap() == true
281 */
282extern "C++" ARCANE_CORE_EXPORT ItemBase
283findOneItem(IItemFamily* family, Int64 unique_id);
284
285/*---------------------------------------------------------------------------*/
286/*---------------------------------------------------------------------------*/
287/*
288 * \brief Retourne l'entité de la famille \a family de numéro unique \a unique_id.
289 *
290 * Si aucune entité avec cet \a unique_id n'est trouvé, retourne l'entité nulle.
291 *
292 * \pre family->hasUniqueIdMap() == true
293 */
294extern "C++" ARCANE_CORE_EXPORT ItemBase
295findOneItem(IItemFamily* family, ItemUniqueId unique_id);
296
297/*---------------------------------------------------------------------------*/
298/*---------------------------------------------------------------------------*/
302extern "C++" ARCANE_CORE_EXPORT void
303visitGroups(IItemFamily* family, IFunctorWithArgumentT<ItemGroup&>* functor);
304
305/*---------------------------------------------------------------------------*/
306/*---------------------------------------------------------------------------*/
310extern "C++" ARCANE_CORE_EXPORT void
311visitGroups(IMesh* mesh, IFunctorWithArgumentT<ItemGroup&>* functor);
312
313/*---------------------------------------------------------------------------*/
314/*---------------------------------------------------------------------------*/
329template <typename LambdaType> inline void
330visitGroups(IItemFamily* family, const LambdaType& f)
331{
333 // Il faut caster en le bon type pour que le compilateur utilise la bonne surcharge.
335 visitGroups(family, sf_addr);
336}
337
338/*---------------------------------------------------------------------------*/
339/*---------------------------------------------------------------------------*/
354template <typename LambdaType> inline void
355visitGroups(IMesh* mesh, const LambdaType& f)
356{
358 // Il faut caster en le bon pour que le compilateur utilise la bonne surcharge.
360 visitGroups(mesh, sf_addr);
361}
362
363namespace impl
364{
365 inline Int64 computeCapacity(Int64 size)
366 {
368 }
369} // namespace impl
370
371/*---------------------------------------------------------------------------*/
372/*---------------------------------------------------------------------------*/
389template <typename DataType> inline bool
390checkResizeArray(Array<DataType>& array, Int64 new_size, bool force_resize)
391{
392 return Arcane::MemoryUtils::checkResizeArrayWithCapacity(array, new_size, force_resize);
393}
394
395/*---------------------------------------------------------------------------*/
396/*---------------------------------------------------------------------------*/
403extern "C++" ARCANE_CORE_EXPORT ItemUniqueId
404getMaxItemUniqueIdCollective(IMesh* mesh);
405
406/*---------------------------------------------------------------------------*/
407/*---------------------------------------------------------------------------*/
427extern "C++" ARCANE_CORE_EXPORT void
428checkUniqueIdsHashCollective(IItemFamily* family, IHashAlgorithm* hash_algo,
429 const String& expected_hash, bool print_hash_value,
430 bool include_ghost);
431
432/*---------------------------------------------------------------------------*/
433/*---------------------------------------------------------------------------*/
437extern "C++" ARCANE_CORE_EXPORT void
438fillUniqueIds(ItemVectorView items,Array<Int64>& uids);
439
440/*---------------------------------------------------------------------------*/
441/*---------------------------------------------------------------------------*/
442
448extern "C++" ARCANE_CORE_EXPORT Ref<IIndexedIncrementalItemConnectivity>
449computeNodeNodeViaEdgeConnectivity(IMesh* mesh, const String& connectivity_name);
450
451/*---------------------------------------------------------------------------*/
452/*---------------------------------------------------------------------------*/
459extern "C++" ARCANE_CORE_EXPORT Ref<IIndexedIncrementalItemConnectivity>
460computeBoundaryNodeNodeViaEdgeConnectivity(IMesh* mesh, const String& connectivity_name);
461
462/*---------------------------------------------------------------------------*/
463/*---------------------------------------------------------------------------*/
472extern "C++" ARCANE_CORE_EXPORT void
473computeAndSetOwnerForNodes(IMesh* mesh);
474
475/*---------------------------------------------------------------------------*/
476/*---------------------------------------------------------------------------*/
485extern "C++" ARCANE_CORE_EXPORT void
486computeAndSetOwnerForEdges(IMesh* mesh);
487
488/*---------------------------------------------------------------------------*/
489/*---------------------------------------------------------------------------*/
498extern "C++" ARCANE_CORE_EXPORT void
499computeAndSetOwnerForFaces(IMesh* mesh);
500
501/*---------------------------------------------------------------------------*/
502/*---------------------------------------------------------------------------*/
503
504} // namespace Arcane::MeshUtils
505
506/*---------------------------------------------------------------------------*/
507/*---------------------------------------------------------------------------*/
508
509namespace Arcane::mesh_utils
510{
511// Using pour compatibilité avec l'existant.
512// Ces using ont été ajoutés pour la version 3.10 de Arcane (juin 2023).
513// On pourra les rendre obsolètes début 2024.
514using MeshUtils::checkMeshConnectivity;
515using MeshUtils::checkMeshProperties;
516using MeshUtils::computeConnectivityPatternOccurence;
517using MeshUtils::dumpSynchronizerTopologyJSON;
518using MeshUtils::getFaceFromNodesLocal;
519using MeshUtils::getFaceFromNodesUnique;
520using MeshUtils::printItems;
521using MeshUtils::printMeshGroupsMemoryUsage;
522using MeshUtils::removeItemAndKeepOrder;
523using MeshUtils::reorderNodesOfFace;
524using MeshUtils::reorderNodesOfFace2;
525using MeshUtils::shrinkMeshGroups;
526using MeshUtils::writeMeshConnectivity;
527using MeshUtils::writeMeshInfos;
528using MeshUtils::writeMeshInfosSorted;
529using MeshUtils::writeMeshItemInfo;
530
531/*---------------------------------------------------------------------------*/
532/*---------------------------------------------------------------------------*/
533
534} // namespace Arcane::mesh_utils
535
536/*---------------------------------------------------------------------------*/
537/*---------------------------------------------------------------------------*/
538
539#endif
bool checkResizeArray(Array< DataType > &array, Int64 new_size, bool force_resize)
Redimensionne un tableau qui est indexé par des 'ItemLocalId'.
Definition MeshUtils.h:390
bool reorderNodesOfFace(Int64ConstArrayView before_ids, Int64ArrayView after_ids)
Réordonne les noeuds d'une face.
void visitGroups(IItemFamily *family, IFunctorWithArgumentT< ItemGroup & > *functor)
Visite l'ensemble des groupes de family avec le functor functor.
bool reorderNodesOfFace2(Int64ConstArrayView nodes_unique_id, Int32ArrayView new_index)
Réordonne les noeuds d'une face.
Face getFaceFromNodesLocalId(Node node, Int32ConstArrayView face_nodes_local_id)
Recherche une entité face à partir des numéros locaux de ces noeuds.
Fonctions de gestion mémoire et des allocateurs.
Int64 computeCapacity(Int64 size)
Calcule une capacité adaptée pour une taille de size.
Tableau d'items de types quelconques.
Face d'une maille.
Definition Item.h:964
Interface d'un fonctor avec argument mais sans valeur de retour.
Interface d'un algorithme de hashage.
Interface d'une famille d'entités.
Definition IItemFamily.h:84
Interface d'un service de synchronisation de variable.
Identifiant unique d'une entité.
Vue sur un vecteur d'entités.
Noeud d'un maillage.
Definition Item.h:582
Référence à une instance.
Functor générique utilisant la classe std::function.
Chaîne de caractères unicode.
Noeud d'un arbre DOM.
Definition XmlNode.h:51
Int32 checkResizeArrayWithCapacity(Array< DataType > &array, Int64 new_size, bool force_resize)
Redimensionne un tableau en ajoutant une réserve de mémoire.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
ArrayView< Int64 > Int64ArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
Definition UtilsTypes.h:467
std::int64_t Int64
Type entier signé sur 64 bits.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:498
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
Definition UtilsTypes.h:496
ArrayView< Int32 > Int32ArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:469
@ Cell
Le maillage est AMR par maille.
Definition MeshKind.h:52