Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
UnstructuredMeshAllocateBuildInfo.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 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/* UnstructuredMeshAllocateBuildInfo.cc (C) 2000-2023 */
9/* */
10/* Informations pour allouer les entités d'un maillage non structuré. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/UnstructuredMeshAllocateBuildInfo.h"
15#include "arcane/core/internal/UnstructuredMeshAllocateBuildInfoInternal.h"
16
17#include "arcane/utils/Array.h"
18#include "arcane/utils/ITraceMng.h"
19#include "arcane/utils/FatalErrorException.h"
20
21#include "arcane/core/IPrimaryMesh.h"
22#include "arcane/core/ItemTypeId.h"
23#include "arcane/core/IMeshInitialAllocator.h"
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
35{
36 public:
37
38 explicit Impl(IPrimaryMesh* mesh)
39 : m_mesh(mesh)
40 {
41 m_internal.m_p = this;
42 }
43
44 void addCell(ItemTypeId type_id, Int64 cell_uid, SmallSpan<const Int64> nodes_uid)
45 {
46 m_cells_infos.add(type_id);
47 m_cells_infos.add(cell_uid);
48 m_cells_infos.addRange(nodes_uid);
49 ++m_nb_cell;
50 }
51
52 public:
53
54 IPrimaryMesh* m_mesh = nullptr;
55 Int32 m_mesh_dimension = -1;
56 UniqueArray<Int64> m_cells_infos;
57 Int32 m_nb_cell = 0;
59};
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
63
64/*---------------------------------------------------------------------------*/
65/*---------------------------------------------------------------------------*/
66
67ConstArrayView<Int64> UnstructuredMeshAllocateBuildInfoInternal::
68cellsInfos() const
69{
70 return m_p->m_cells_infos;
71}
72
73/*---------------------------------------------------------------------------*/
74/*---------------------------------------------------------------------------*/
75
76Int32 UnstructuredMeshAllocateBuildInfoInternal::
77meshDimension() const
78{
79 return m_p->m_mesh_dimension;
80}
81
82/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
84
85Int32 UnstructuredMeshAllocateBuildInfoInternal::
86nbCell() const
87{
88 return m_p->m_nb_cell;
89}
90
91/*---------------------------------------------------------------------------*/
92/*---------------------------------------------------------------------------*/
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
96
97UnstructuredMeshAllocateBuildInfo::
98UnstructuredMeshAllocateBuildInfo(IPrimaryMesh* mesh)
99: m_p(new Impl(mesh))
100{
101}
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
105
106UnstructuredMeshAllocateBuildInfo::
107~UnstructuredMeshAllocateBuildInfo()
108{
109 delete m_p;
110}
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114
116setMeshDimension(Int32 v)
117{
118 m_p->m_mesh_dimension = v;
119}
120
121/*---------------------------------------------------------------------------*/
122/*---------------------------------------------------------------------------*/
123
126{
127 m_p->addCell(type_id, cell_uid, nodes_uid);
128}
129
130/*---------------------------------------------------------------------------*/
131/*---------------------------------------------------------------------------*/
132
135{
136 IPrimaryMesh* pm = m_p->m_mesh;
137
138 IMeshInitialAllocator* a = pm->initialAllocator();
139 if (!a)
140 ARCANE_FATAL("Mesh implementation has no IMeshInitialAllocator");
141
142 IUnstructuredMeshInitialAllocator* specific_allocator = a->unstructuredMeshAllocator();
144 ARCANE_FATAL("Mesh does not support 'IUnstructuredMeshInitialAllocator'");
145
146 pm->traceMng()->info() << "Allocate mesh from UnstructuredMeshAllocateBuildInfo";
147 specific_allocator->allocate(*this);
148}
149
150/*---------------------------------------------------------------------------*/
151/*---------------------------------------------------------------------------*/
152
158
159/*---------------------------------------------------------------------------*/
160/*---------------------------------------------------------------------------*/
161
167
168/*---------------------------------------------------------------------------*/
169/*---------------------------------------------------------------------------*/
170
171} // End namespace Arcane
172
173/*---------------------------------------------------------------------------*/
174/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Interface d'allocation des entités du maillage.
virtual ITraceMng * traceMng() const =0
Gestionnaire de traces.
Allocateur pour les maillages non structurés.
Type d'une entité (Item).
Definition ItemTypeId.h:32
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
void allocateMesh()
Alloue le maillage avec les mailles ajoutées lors de l'appel à addCell().
UnstructuredMeshAllocateBuildInfoInternal * _internal()
Partie interne réservée à Arcane.
void setMeshDimension(Int32 v)
Positionne la dimension du maillage.
void preAllocate(Int32 nb_cell, Int64 nb_connectivity_node)
Pre-alloue la mémoire.
void addCell(ItemTypeId type_id, Int64 cell_uid, SmallSpan< const Int64 > nodes_uid)
Ajoute une maille au maillage.
void reserve(Int64 new_capacity)
Réserve le mémoire pour new_capacity éléments.
void addRange(ConstReferenceType val, Int64 n)
Ajoute n élément de valeur val à la fin du tableau.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
TraceMessage info() const
Flot pour un message d'information.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-