14#include "arcane/utils/NotImplementedException.h"
15#include "arcane/utils/ArgumentException.h"
17#include "arcane/IMesh.h"
18#include "arcane/ItemPairGroup.h"
19#include "arcane/ItemGroup.h"
20#include "arcane/IItemFamily.h"
22#include "arcane/mesh/BasicItemPairGroupComputeFunctor.h"
42BasicItemPairGroupComputeFunctor::
43BasicItemPairGroupComputeFunctor(ITraceMng* tm)
46 _addComputeAdjency(IK_Cell,IK_Cell,IK_Node,
47 &BasicItemPairGroupComputeFunctor::_computeCellCellNodeAdjency);
48 _addComputeAdjency(IK_Cell,IK_Cell,IK_Face,
49 &BasicItemPairGroupComputeFunctor::_computeCellCellFaceAdjency);
50 _addComputeAdjency(IK_Node,IK_Node,IK_Cell,
51 &BasicItemPairGroupComputeFunctor::_computeNodeNodeCellAdjency);
52 _addComputeAdjency(IK_Face,IK_Cell,IK_Node,
53 &BasicItemPairGroupComputeFunctor::_computeFaceCellNodeAdjency);
54 _addComputeAdjency(IK_Face,IK_Face,IK_Node,
55 &BasicItemPairGroupComputeFunctor::_computeFaceFaceNodeAdjency);
56 _addComputeAdjency(IK_Cell,IK_Face,IK_Face,
57 &BasicItemPairGroupComputeFunctor::_computeCellFaceFaceAdjency);
58 _addComputeAdjency(IK_Node,IK_Node,IK_Face,
59 &BasicItemPairGroupComputeFunctor::_computeNodeNodeFaceAdjency);
60 _addComputeAdjency(IK_Node,IK_Node,IK_Edge,
61 &BasicItemPairGroupComputeFunctor::_computeNodeNodeEdgeAdjency);
62 _addComputeAdjency(IK_Face,IK_Face,IK_Edge,
63 &BasicItemPairGroupComputeFunctor::_computeFaceFaceEdgeAdjency);
64 _addComputeAdjency(IK_Face,IK_Face,IK_Cell,
65 &BasicItemPairGroupComputeFunctor::_computeFaceFaceCellAdjency);
71void BasicItemPairGroupComputeFunctor::
72computeAdjency(ItemPairGroup adjency_array,eItemKind link_kind,
76 throw ArgumentException(A_FUNCINFO,
"nb_layer should be 1");
77 eItemKind item_kind = adjency_array.itemKind();
78 eItemKind sub_item_kind = adjency_array.subItemKind();
79 AdjencyType atype(item_kind,sub_item_kind,link_kind);
80 auto i = m_compute_adjency_functions.find(atype);
81 if (i==m_compute_adjency_functions.end()){
82 String s = String::format(
"Invalid adjency computation item_kind={0} sub_item_kind={1} link_item_kind={2}",
83 item_kind,sub_item_kind,link_kind);
84 throw NotImplementedException(A_FUNCINFO,s);
86 auto acf =
new AdjencyComputeFunctor(
this,adjency_array.internal(),i->second);
87 adjency_array.internal()->setComputeFunctor(acf);
88 adjency_array.invalidate();
94void BasicItemPairGroupComputeFunctor::
95_addComputeAdjency(eItemKind ik,eItemKind sik,eItemKind lik,ComputeFunctor f)
97 m_compute_adjency_functions.insert(std::make_pair(AdjencyType(ik,sik,lik),f));
103void BasicItemPairGroupComputeFunctor::
104_computeAdjency(ItemPairGroupImpl* array,
105 GetItemVectorViewFunctor get_link_item_enumerator,
106 GetItemVectorViewFunctor get_sub_item_enumerator)
108 const ItemGroup& group = array->itemGroup();
109 const ItemGroup& sub_group = array->subItemGroup();
110 auto& indexes = array->unguardedIndexes();
112 auto& sub_items_local_id = array->unguardedLocalIds();
113 sub_items_local_id.clear();
115 IItemFamily* sub_family = sub_group.itemFamily();
116 const Integer max_sub_id = sub_family->maxLocalId();
119 IItemFamily* family = group.itemFamily();
120 const Integer max_id = family->maxLocalId();
122 const Integer forbidden_value = NULL_ITEM_ID;
123 const Integer undef_value = max_id+1;
124 items_list.fill(forbidden_value);
127 items_list[iitem.itemLocalId()] = undef_value;
133 Integer local_id = iitem.itemLocalId();
135 if (items_list[local_id] != forbidden_value)
136 items_list[local_id] = local_id;
137 for( Item linkitem : get_link_item_enumerator(item) ){
138 for( Item subitem : get_sub_item_enumerator(linkitem) ){
139 Int32 sub_local_id = subitem.localId();
140 if (items_list[sub_local_id]==forbidden_value || items_list[sub_local_id]==local_id)
142 items_list[sub_local_id] = local_id;
143 sub_items_local_id.add(sub_local_id);
146 indexes.add(sub_items_local_id.largeSize());
153void BasicItemPairGroupComputeFunctor::
154_computeCellCellFaceAdjency(ItemPairGroupImpl* array)
156 const ItemGroup& group = array->itemGroup();
157 const ItemGroup& sub_group = array->subItemGroup();
158 auto& indexes = array->unguardedIndexes();
160 auto& sub_items_local_id = array->unguardedLocalIds();
161 sub_items_local_id.clear();
163 IItemFamily* sub_family = sub_group.itemFamily();
164 const Integer max_sub_id = sub_family->maxLocalId();
167 IItemFamily* family = group.itemFamily();
168 const Integer max_id = family->maxLocalId();
170 const Integer forbidden_value = NULL_ITEM_ID;
171 const Integer undef_value = max_id+1;
172 items_list.fill(forbidden_value);
175 items_list[icell.itemLocalId()] = undef_value;
182 for( Face face : cell.faces() ){
183 if (face.nbCell()!=2)
185 Cell back_cell = face.backCell();
186 Cell front_cell = face.frontCell();
189 const Integer sub_local_id = (back_cell==cell)?front_cell.localId():back_cell.localId();
190 if (items_list[sub_local_id] == forbidden_value)
192 sub_items_local_id.add(sub_local_id);
194 indexes.add(sub_items_local_id.largeSize());
201void BasicItemPairGroupComputeFunctor::
202_computeFaceCellNodeAdjency(ItemPairGroupImpl* array)
204 const ItemGroup& group = array->itemGroup();
205 const ItemGroup& sub_group = array->subItemGroup();
206 auto& indexes = array->unguardedIndexes();
208 auto& sub_items_local_id = array->unguardedLocalIds();
209 sub_items_local_id.clear();
211 IItemFamily* sub_family = sub_group.itemFamily();
212 const Integer max_sub_id = sub_family->maxLocalId();
215 IItemFamily* family = group.itemFamily();
216 const Integer max_id = family->maxLocalId();
218 const Integer forbidden_value = NULL_ITEM_ID;
219 const Integer undef_value = max_id+1;
220 items_list.fill(forbidden_value);
223 items_list[icell.itemLocalId()] = undef_value;
229 Int32 local_id = face.localId();
230 for( Node node : face.nodes() ){
231 for( Cell isubcell : node.cells() ){
232 Int32 sub_local_id = isubcell.localId();
233 if (items_list[sub_local_id]==forbidden_value || items_list[sub_local_id]==local_id)
235 items_list[sub_local_id] = local_id;
236 sub_items_local_id.add(sub_local_id);
239 indexes.add(sub_items_local_id.largeSize());
246void BasicItemPairGroupComputeFunctor::
247_computeCellFaceFaceAdjency(ItemPairGroupImpl* array)
249 const ItemGroup& group = array->itemGroup();
250 const ItemGroup& sub_group = array->subItemGroup();
251 auto& indexes = array->unguardedIndexes();
253 auto& sub_items_local_id = array->unguardedLocalIds();
254 sub_items_local_id.clear();
256 IItemFamily* sub_family = sub_group.itemFamily();
257 const Integer max_sub_id = sub_family->maxLocalId();
260 IItemFamily* family = group.itemFamily();
261 const Integer max_id = family->maxLocalId();
263 const Integer forbidden_value = NULL_ITEM_ID;
264 const Integer undef_value = max_id+1;
265 items_list.fill(forbidden_value);
268 items_list[iface.itemLocalId()] = undef_value;
274 for( FaceLocalId iface : cell.faceIds() ){
275 Int32 sub_local_id = iface.localId();
277 if (items_list[sub_local_id]==forbidden_value )
280 sub_items_local_id.add(sub_local_id);
282 indexes.add(sub_items_local_id.largeSize());
289void BasicItemPairGroupComputeFunctor::
290_computeCellCellNodeAdjency(ItemPairGroupImpl* array)
292 GetItemVectorViewFunctor x = [](Item cell){
return cell.toCell().nodes(); };
293 GetItemVectorViewFunctor y = [](Item node){
return node.toNode().cells(); };
295 return _computeAdjency(array,x,y);
301void BasicItemPairGroupComputeFunctor::
302_computeNodeNodeCellAdjency(ItemPairGroupImpl* array)
304 GetItemVectorViewFunctor x = [](Item node){
return node.toNode().cells(); };
305 GetItemVectorViewFunctor y = [](Item cell){
return cell.toCell().nodes(); };
307 return _computeAdjency(array,x,y);
313void BasicItemPairGroupComputeFunctor::
314_computeFaceFaceNodeAdjency(ItemPairGroupImpl* array)
316 GetItemVectorViewFunctor x = [](Item face){
return face.toFace().nodes(); };
317 GetItemVectorViewFunctor y = [](Item node){
return node.toNode().faces(); };
319 return _computeAdjency(array,x,y);
325void BasicItemPairGroupComputeFunctor::
326_computeNodeNodeFaceAdjency(ItemPairGroupImpl* array)
328 GetItemVectorViewFunctor x = [](Item node){
return node.toNode().faces(); };
329 GetItemVectorViewFunctor y = [](Item face){
return face.toFace().nodes(); };
331 return _computeAdjency(array,x,y);
337void BasicItemPairGroupComputeFunctor::
338_computeNodeNodeEdgeAdjency(ItemPairGroupImpl* array)
340 GetItemVectorViewFunctor x = [](Item node){
return node.toNode().edges(); };
341 GetItemVectorViewFunctor y = [](Item edge){
return edge.toEdge().nodes(); };
343 return _computeAdjency(array,x,y);
349void BasicItemPairGroupComputeFunctor::
350_computeFaceFaceEdgeAdjency(ItemPairGroupImpl* array)
352 GetItemVectorViewFunctor x = [](Item face){
return face.toFace().edges(); };
353 GetItemVectorViewFunctor y = [](Item edge){
return edge.toEdge().faces(); };
355 return _computeAdjency(array,x,y);
361void BasicItemPairGroupComputeFunctor::
362_computeFaceFaceCellAdjency(ItemPairGroupImpl* array)
364 GetItemVectorViewFunctor x = [](Item face){
return face.toFace().cells(); };
365 GetItemVectorViewFunctor y = [](Item cell){
return cell.toCell().faces(); };
367 return _computeAdjency(array,x,y);
Lecteur des fichiers de maillage via la bibliothèque LIMA.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
eItemKind
Genre d'entité de maillage.
Int32 Integer
Type représentant un entier.