14#include "arcane/mesh/TiedInterfaceMng.h"
15#include "arcane/mesh/DynamicMesh.h"
16#include "arcane/mesh/FaceFamily.h"
18#include "arcane/mesh/TiedInterface.h"
20#include "arcane/XmlNode.h"
21#include "arcane/IMesh.h"
22#include "arcane/ISubDomain.h"
23#include "arcane/ICaseDocument.h"
24#include "arcane/CaseNodeNames.h"
25#include "arcane/IParallelMng.h"
26#include "arcane/IMeshPartitionConstraintMng.h"
27#include "arcane/IMeshUtilities.h"
28#include "arcane/ArcaneException.h"
40TiedInterfaceMng(DynamicMesh* mesh)
41: TraceAccessor(mesh->traceMng())
43, m_sub_domain(mesh->subDomain())
45, m_tied_interface_items_info(VariableBuildInfo(m_sub_domain,m_name+
"TiedInterfaceItemsInfo"))
46, m_tied_interface_nodes_iso(VariableBuildInfo(m_sub_domain,m_name+
"TiedInterfaceNodesIso"))
47, m_tied_interface_face_groups(VariableBuildInfo(m_sub_domain,m_name+
"TiedInterfaceFaceGroups"))
59 m_tied_constraint = 0;
61 _deleteTiedInterfaces();
67void TiedInterfaceMng::
68computeTiedInterfaces(
const XmlNode& mesh_node)
70 ICaseDocument* doc = subDomain()->caseDocument();
71 CaseNodeNames* cnn = doc->caseNodeNames();
72 String tied_interfaces_name = cnn->tied_interfaces;
73 String tied_interface_not_structured_name = cnn->tied_interfaces_not_structured;
74 String tied_interfaces_planar_tolerance = cnn->tied_interfaces_planar_tolerance;
75 String semi_conform_name = cnn->tied_interfaces_semi_conform;
76 String name_attribute = cnn->tied_interfaces_slave;
77 XmlNode tied_interface_elem = mesh_node.child(tied_interfaces_name);
78 XmlNodeList child_list = tied_interface_elem.children(semi_conform_name);
79 bool has_error =
false;
81 IParallelMng* pm = m_mesh->parallelMng();
83 UniqueArray<FaceGroup> interfaces_group;
84 UniqueArray<bool> is_structured_list;
85 UniqueArray<Real> planar_tolerance_list;
86 FaceFamily& face_family = m_mesh->trueFaceFamily();
87 for(
auto& i : child_list ){
88 XmlNode group_attr = i.attr(name_attribute);
89 if (group_attr.null()){
90 error() <<
"Attribute '" << name_attribute <<
"' missing";
94 String group_name = i.attrValue(name_attribute);
95 FaceGroup face_group = face_family.findGroup(group_name);
96 if (face_group.null()){
97 error() <<
"Can't find the interface '" << group_name <<
"'";
101 if (interfaces_group.contains(face_group)){
102 error() <<
"The group '" << group_name <<
"' is already present in list of tied interfaces.";
106 interfaces_group.add(face_group);
108 bool is_not_structured = i.attr(tied_interface_not_structured_name).valueAsBoolean();
109 info() <<
"** NOT STRUCTURED? = " << is_not_structured;
110 is_structured_list.add(!is_not_structured);
111 XmlNode tolerance_node = i.attr(tied_interfaces_planar_tolerance);
112 if (tolerance_node.null()) {
113 planar_tolerance_list.add(0.);
115 planar_tolerance_list.add(tolerance_node.valueAsReal());
119 fatal() <<
"Can't determine the tied interfaces";
125 FaceGroup g1 = face_family.findGroup(
"SOUDURE");
127 g1 = face_family.findGroup(
"SOUDURES");
130 if (!interfaces_group.contains(g1)){
131 info() <<
"Add automatically the group '" << g1.
name() <<
"' to the list of tied interfaces";
132 interfaces_group.add(g1);
133 is_structured_list.add(
true);
134 planar_tolerance_list.add(0.0);
137 info() <<
"built-in group " << g1.name() <<
" already in list of tied interfaces";
141 Integer nb_interface = interfaces_group.size();
142 IItemFamily* cell_family = m_mesh->cellFamily();
143 if (nb_interface!=0){
151 cells_owner[iitem] = (*iitem).owner();
155 TiedInterface::PartitionConstraintBase* c = TiedInterface::createConstraint(m_mesh,interfaces_group);
156 m_tied_constraint = c;
157 IMeshPartitionConstraintMng* pcmng = m_mesh->partitionConstraintMng();
158 pcmng->addConstraint(c);
159 pcmng->computeAndApplyConstraints();
161 cells_owner.synchronize();
162 m_mesh->utilities()->changeOwnersFromCells();
163 m_mesh->setDynamic(
true);
164 m_mesh->exchangeItems();
166 c->setInitialRepartition(
false);
168 for( Integer i=0, is=interfaces_group.size(); i<is; ++i ){
169 FaceGroup face_group = interfaces_group[i];
170 info() <<
" Semi-conform interface name=" << face_group.
name();
171 TiedInterface* tied_interface =
new TiedInterface(m_mesh);
172 if (planar_tolerance_list[i] > 0)
173 tied_interface->setPlanarTolerance(planar_tolerance_list[i]);
174 tied_interface->build(face_group,is_structured_list[i]);
178 m_true_tied_interfaces.add(tied_interface);
179 m_tied_interfaces.add(tied_interface);
180 face_family.applyTiedInterface(tied_interface);
183 face_family.endUpdate();
184 face_family.prepareForDump();
186 prepareTiedInterfacesForDump();
192void TiedInterfaceMng::
193prepareTiedInterfacesForDump()
195 Integer nb_tied_interface = m_tied_interfaces.count();
196 m_tied_interface_face_groups.resize(nb_tied_interface*2);
200 Integer nb_tied_node_per_interface = 0;
201 Integer nb_tied_face_per_interface = 0;
202 for( Integer i=0; i<nb_tied_interface; ++i ){
203 ITiedInterface* ti = m_tied_interfaces[i];
205 TiedInterfaceNodeList nodes = ti->tiedNodes();
206 nb_tied_node_per_interface += nodes.dim1Size();
207 for( Integer zz=0, zs=nodes.dim1Size(); zz<zs; ++zz )
208 total_nb_node += nodes[zz].size();
210 TiedInterfaceFaceList faces = ti->tiedFaces();
211 nb_tied_face_per_interface += faces.dim1Size();
212 for( Integer zz=0, zs=faces.dim1Size(); zz<zs; ++zz )
213 total_nb_face += faces[zz].size();
216 Integer items_info_size = total_nb_node + total_nb_face +
217 nb_tied_node_per_interface + nb_tied_face_per_interface + nb_tied_interface*2;
219 Integer nodes_iso_size = total_nb_node;
221 m_tied_interface_items_info.resize(items_info_size);
222 m_tied_interface_nodes_iso.resize(nodes_iso_size);
226 for( Integer i=0; i<nb_tied_interface; ++i ){
227 ITiedInterface* ti = m_tied_interfaces[i];
229 TiedInterfaceNodeList nodes = ti->tiedNodes();
230 Integer nb_node = nodes.dim1Size();
231 m_tied_interface_items_info[items_info_index] = nb_node;
233 for( Integer zz=0; zz<nb_node; ++zz ){
234 Integer nb_node2 = nodes[zz].size();
235 m_tied_interface_items_info[items_info_index] = nb_node2;
239 for( Integer zz=0; zz<nb_node; ++zz ){
240 Integer nb_node2 = nodes[zz].size();
241 for( Integer zz2=0; zz2<nb_node2; ++zz2 ){
242 m_tied_interface_items_info[items_info_index] = nodes[zz][zz2].node().uniqueId().asInt64();
244 m_tied_interface_nodes_iso[nodes_iso_index] = nodes[zz][zz2].isoCoordinates();
249 TiedInterfaceFaceList faces = ti->tiedFaces();
250 Integer nb_face = faces.dim1Size();
251 m_tied_interface_items_info[items_info_index] = nb_face;
253 for( Integer zz=0; zz<nb_face; ++zz ){
254 Integer nb_face2 = faces[zz].size();
255 m_tied_interface_items_info[items_info_index] = nb_face2;
259 for( Integer zz=0; zz<nb_face; ++zz ){
260 Integer nb_face2 = faces[zz].size();
261 for( Integer zz2=0; zz2<nb_face2; ++zz2 ){
262 m_tied_interface_items_info[items_info_index] = faces[zz][zz2].face().uniqueId().asInt64();
267 debug() <<
"ITEMS_INFO_INDEX=" << items_info_index <<
" N=" << items_info_size;
268 debug() <<
"NODES_ISO_INDEX=" << nodes_iso_index <<
" N=" << nodes_iso_size;
269 if (nodes_iso_index!=nodes_iso_size)
270 throw InternalErrorException(A_FUNCINFO,
"Bad size for 'nodes_iso_index'");
271 if (items_info_index!=items_info_size)
272 throw InternalErrorException(A_FUNCINFO,
"Bad size for 'items_info_index'");
273 for( Integer i=0; i<nb_tied_interface; ++i ){
274 ITiedInterface* ti = m_tied_interfaces[i];
275 m_tied_interface_face_groups[(i*2)] = ti->masterInterfaceName();
276 m_tied_interface_face_groups[(i*2)+1] = ti->slaveInterfaceName();
283void TiedInterfaceMng::
284readTiedInterfacesFromDump()
286 _deleteTiedInterfaces();
287 Integer nb_tied_interface = m_tied_interface_face_groups.size() / 2;
292 IItemFamily* node_family = m_mesh->nodeFamily();
293 FaceFamily& face_family = m_mesh->trueFaceFamily();
294 NodeInfoListView nodes_internal(node_family);
295 FaceInfoListView faces_internal(&face_family);
296 UniqueArray<TiedNode> nodes;
297 UniqueArray<TiedFace> faces;
299 for( Integer i=0; i<nb_tied_interface; ++i ){
300 TiedInterface* tied_interface =
new TiedInterface(m_mesh);
301 String master_group_name = m_tied_interface_face_groups[(i*2)];
302 String slave_group_name = m_tied_interface_face_groups[(i*2)+1];
303 tied_interface->reload(&face_family,master_group_name,slave_group_name);
304 FaceGroup master_group = tied_interface->masterInterface();
305 FaceGroup slave_group = tied_interface->slaveInterface();
306 m_tied_interfaces.add(tied_interface);
307 m_true_tied_interfaces.add(tied_interface);
312 for( Integer zz=0; zz<nb_node; ++zz ){
315 items_size[zz] = nb_node2;
317 tied_interface->resizeNodes(items_size);
319 for( Integer zz=0; zz<nb_node; ++zz ){
320 Integer nb_node2 = items_size[zz];
322 local_ids.resize(nb_node2);
324 node_family->itemsUniqueIdToLocalId(local_ids,unique_ids,
true);
325 items_info_index += nb_node2;
327 for( Integer zz2=0; zz2<nb_node2; ++zz2 ){
328 Node node(nodes_internal[local_ids[zz2]]);
329 nodes.add(TiedNode(zz2,node,m_tied_interface_nodes_iso[nodes_iso_index]));
332 tied_interface->setNodes(zz,nodes);
337 items_size.resize(nb_face);
338 for( Integer zz=0; zz<nb_face; ++zz ){
341 items_size[zz] = nb_face2;
343 tied_interface->resizeFaces(items_size);
344 UniqueArray<TiedFace> faces2;
345 for( Integer zz=0; zz<nb_face; ++zz ){
346 Integer nb_face2 = items_size[zz];
348 local_ids.resize(nb_face2);
350 face_family.itemsUniqueIdToLocalId(local_ids,unique_ids,
true);
351 items_info_index += nb_face2;
352 for( Integer zz2=0; zz2<nb_face2; ++zz2 ){
353 Face face(faces_internal[local_ids[zz2]]);
354 faces2.add(TiedFace(zz2,face));
356 tied_interface->setFaces(zz,faces2);
358 info() <<
"Read interface nb_face=" << nb_face <<
" nb_node=" << nb_node;
362 if (!m_tied_constraint){
363 info() <<
"Rebuilding tied interface constraints";
364 UniqueArray<FaceGroup> interface_groups;
365 for( Integer i=0, n=m_true_tied_interfaces.size(); i<n; ++i )
366 interface_groups.add(m_true_tied_interfaces[i]->slaveInterface());
368 Integer nb_interface = interface_groups.size();
369 if (nb_interface!=0){
370 TiedInterface::PartitionConstraintBase* c = TiedInterface::createConstraint(m_mesh,interface_groups);
371 m_tied_constraint = c;
372 IMeshPartitionConstraintMng* pcmng = m_mesh->partitionConstraintMng();
373 pcmng->addConstraint(c);
375 c->setInitialRepartition(
false);
383void TiedInterfaceMng::
384_applyTiedInterfaceStructuration(TiedInterface* tied_interface)
394 TiedInterfaceNodeList nodes = tied_interface->tiedNodes();
395 for( Integer zz=0, zs=nodes.dim1Size(); zz<zs; ++zz ){
396 Integer current_nb_node = nodes[zz].size();
399 for( Integer i=0; i<current_nb_node; ++i ){
400 Real2 iso_val = nodes[zz][i].isoCoordinates();
401 info() <<
"ISO zz=" << zz <<
" i=" << i <<
" v=" << iso_val <<
" old=" << old_y;
402 if (iso_val.y>old_y){
406 info() <<
"COMPUTED M = "<< computed_m;
417void TiedInterfaceMng::
418_deleteTiedInterfaces()
420 for( Integer i=0, is=m_tied_interfaces.count(); i<is; ++i )
421 delete m_tied_interfaces[i];
422 m_tied_interfaces.clear();
423 m_true_tied_interfaces.clear();
virtual bool isParallel() const =0
Retourne true si l'exécution est parallèle.
const String & name() const
Nom du groupe.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
ItemGroupT< Face > FaceGroup
Groupe de faces.
ItemVariableScalarRefT< Int32 > VariableItemInt32
Grandeur de type entier 32 bits.
Integer arcaneCheckArraySize(unsigned long long size)
Vérifie que size peut être converti dans un 'Integer' pour servir de taille à un tableau....
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
UniqueArray< Integer > IntegerUniqueArray
Tableau dynamique à une dimension d'entiers.
Int32 Integer
Type représentant un entier.