Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
CartesianConnectivity.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* CartesianConnectivity.cc (C) 2000-2023 */
9/* */
10/* Maillage cartésien. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/NotSupportedException.h"
15
16#include "arcane/cartesianmesh/CartesianConnectivity.h"
17
18#include "arcane/IMesh.h"
19#include "arcane/IItemFamily.h"
20#include "arcane/VariableTypes.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31void CartesianConnectivity::
32_setStorage(ArrayView<Index> nodes_to_cell, ArrayView<Index> cells_to_node,
33 const Permutation* permutation)
34{
35 m_nodes_to_cell = nodes_to_cell;
36 m_cells_to_node = cells_to_node;
37 m_permutation = permutation;
38}
39
40/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------*/
42/*
43 * \brief Calcule les infos de connectivité
44 *
45 * Pour chaque noeud,détermine les 4 mailles autour en fonction des coordonnées
46 * des mailles. Fait de même pour les quatres noeuds d'une maille.
47 */
48void CartesianConnectivity::
49_computeInfos(IMesh* mesh, VariableNodeReal3& nodes_coord,
50 VariableCellReal3& cells_coord)
51{
52 m_nodes = NodeInfoListView(mesh->nodeFamily());
53 m_cells = CellInfoListView(mesh->cellFamily());
54
55 if (mesh->dimension() == 2 || mesh->dimension() == 1)
56 _computeInfos2D(mesh, nodes_coord, cells_coord);
57 else if (mesh->dimension() == 3)
58 _computeInfos3D(mesh, nodes_coord, cells_coord);
59 else
60 throw NotSupportedException(A_FUNCINFO, "Unknown mesh dimension");
61}
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
66void CartesianConnectivity::
67_computeInfos2D(IMesh* mesh, VariableNodeReal3& nodes_coord,
68 VariableCellReal3& cells_coord)
69{
70 CartesianConnectivity& cc = *this;
71 IItemFamily* node_family = mesh->nodeFamily();
72 IItemFamily* cell_family = mesh->cellFamily();
73
74 ENUMERATE_NODE (inode, node_family->allItems()) {
75 Node node = *inode;
76 Real3 node_coord = nodes_coord[inode];
77 Index& idx = cc._index(node);
78 idx.fill(NULL_ITEM_LOCAL_ID);
79 Integer nb_cell = node.nbCell();
80 for (Integer i = 0; i < nb_cell; ++i) {
81 Cell cell = node.cell(i);
82 Int32 cell_lid = cell.localId();
83 Real3 cell_coord = cells_coord[cell];
84 if (cell_coord.y > node_coord.y) {
85 if (cell_coord.x > node_coord.x)
86 idx.v[P_UpperRight] = cell_lid;
87 else
88 idx.v[P_UpperLeft] = cell_lid;
89 }
90 else {
91 if (cell_coord.x > node_coord.x)
92 idx.v[P_LowerRight] = cell_lid;
93 else
94 idx.v[P_LowerLeft] = cell_lid;
95 }
96 }
97 }
98
99 ENUMERATE_CELL (icell, cell_family->allItems()) {
100 Cell cell = *icell;
101 Real3 cell_coord = cells_coord[cell];
102 Index& idx = _index(cell);
103 idx.fill(NULL_ITEM_LOCAL_ID);
104 Integer nb_node = cell.nbNode();
105 for (Integer i = 0; i < nb_node; ++i) {
106 Node node = cell.node(i);
107 Int32 node_lid = node.localId();
108 Real3 node_coord = nodes_coord[node];
109 if (node_coord.y > cell_coord.y) {
110 if (node_coord.x > cell_coord.x)
111 idx.v[P_UpperRight] = node_lid;
112 else
113 idx.v[P_UpperLeft] = node_lid;
114 }
115 else {
116 if (node_coord.x > cell_coord.x)
117 idx.v[P_LowerRight] = node_lid;
118 else
119 idx.v[P_LowerLeft] = node_lid;
120 }
121 }
122 }
123}
124
125/*---------------------------------------------------------------------------*/
126/*---------------------------------------------------------------------------*/
127
128void CartesianConnectivity::
129_computeInfos3D(IMesh* mesh, VariableNodeReal3& nodes_coord,
130 VariableCellReal3& cells_coord)
131{
132 CartesianConnectivity& cc = *this;
133 IItemFamily* node_family = mesh->nodeFamily();
134 IItemFamily* cell_family = mesh->cellFamily();
135
136 ENUMERATE_NODE (inode, node_family->allItems()) {
137 Node node = *inode;
138 Real3 node_coord = nodes_coord[inode];
139 Index& idx = cc._index(node);
140 idx.fill(NULL_ITEM_LOCAL_ID);
141 Integer nb_cell = node.nbCell();
142 for (Integer i = 0; i < nb_cell; ++i) {
143 Cell cell = node.cell(i);
144 Int32 cell_lid = cell.localId();
145 Real3 cell_coord = cells_coord[cell];
146
147 if (cell_coord.z > node_coord.z) {
148 if (cell_coord.y > node_coord.y) {
149 if (cell_coord.x > node_coord.x)
150 idx.v[P_TopZUpperRight] = cell_lid;
151 else
152 idx.v[P_TopZUpperLeft] = cell_lid;
153 }
154 else {
155 if (cell_coord.x > node_coord.x)
156 idx.v[P_TopZLowerRight] = cell_lid;
157 else
158 idx.v[P_TopZLowerLeft] = cell_lid;
159 }
160 }
161 else {
162 if (cell_coord.y > node_coord.y) {
163 if (cell_coord.x > node_coord.x)
164 idx.v[P_UpperRight] = cell_lid;
165 else
166 idx.v[P_UpperLeft] = cell_lid;
167 }
168 else {
169 if (cell_coord.x > node_coord.x)
170 idx.v[P_LowerRight] = cell_lid;
171 else
172 idx.v[P_LowerLeft] = cell_lid;
173 }
174 }
175 }
176 }
177
178 ENUMERATE_CELL (icell, cell_family->allItems()) {
179 Cell cell = *icell;
180 Real3 cell_coord = cells_coord[cell];
181 Index& idx = _index(cell);
182 idx.fill(NULL_ITEM_LOCAL_ID);
183 Integer nb_node = cell.nbNode();
184 for (Integer i = 0; i < nb_node; ++i) {
185 Node node = cell.node(i);
186 Int32 node_lid = node.localId();
187 Real3 node_coord = nodes_coord[node];
188
189 if (node_coord.z > cell_coord.z) {
190 if (node_coord.y > cell_coord.y) {
191 if (node_coord.x > cell_coord.x)
192 idx.v[P_TopZUpperRight] = node_lid;
193 else
194 idx.v[P_TopZUpperLeft] = node_lid;
195 }
196 else {
197 if (node_coord.x > cell_coord.x)
198 idx.v[P_TopZLowerRight] = node_lid;
199 else
200 idx.v[P_TopZLowerLeft] = node_lid;
201 }
202 }
203 else {
204 if (node_coord.y > cell_coord.y) {
205 if (node_coord.x > cell_coord.x)
206 idx.v[P_UpperRight] = node_lid;
207 else
208 idx.v[P_UpperLeft] = node_lid;
209 }
210 else {
211 if (node_coord.x > cell_coord.x)
212 idx.v[P_LowerRight] = node_lid;
213 else
214 idx.v[P_LowerLeft] = node_lid;
215 }
216 }
217 }
218 }
219}
220
221/*---------------------------------------------------------------------------*/
222/*---------------------------------------------------------------------------*/
223/*!
224 * \brief Calcule les permutations des 8 ePosition pour chaque direction.
225 *
226 * La direction de référence est X.
227 */
228void CartesianConnectivity::Permutation::
229compute()
230{
231 Int32 p[3][8] = {
232 { 0, 1, 2, 3, 4, 5, 6, 7 },
233 { 3, 0, 1, 2, 7, 4, 5, 6 },
234 { 1, 5, 6, 2, 0, 4, 7, 3 }
235 };
236
237 for (Int32 i = 0; i < 3; ++i)
238 for (Int32 j = 0; j < 8; ++j)
239 permutation[i][j] = static_cast<ePosition>(p[i][j]);
240}
241
242/*---------------------------------------------------------------------------*/
243/*---------------------------------------------------------------------------*/
244
245} // End namespace Arcane
246
247/*---------------------------------------------------------------------------*/
248/*---------------------------------------------------------------------------*/
#define ENUMERATE_CELL(name, group)
Enumérateur générique d'un groupe de mailles.
#define ENUMERATE_NODE(name, group)
Enumérateur générique d'un groupe de noeuds.
MeshVariableScalarRefT< Cell, Real3 > VariableCellReal3
Grandeur au centre des mailles de type coordonnées.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.