40 const bool validBoundary
46 <<
"boundary already exists"
50 globalMeshDataPtr_.reset(
nullptr);
52 boundary_.transfer(plist);
54 setPrimitiveMeshData();
58 boundary_.checkDefinition();
66 const bool validBoundary
72 addFaPatches(plist, validBoundary);
78 const word& patchName,
83 if (!patchName.empty())
85 onePatchDict.
add(
"name", patchName);
87 if (!patchType.empty())
89 onePatchDict.
add(
"type", patchType);
92 return createPatchList
103 const dictionary& bndDict,
104 const word& emptyPatchName,
105 const dictionary* defaultPatchDefinition
111 DynamicList<faPatchData> faPatchDefs(bndDict.size() + 8);
112 for (
const entry& dEntry : bndDict)
114 if (!dEntry.isDict())
117 <<
"Not a dictionary entry: " << dEntry.name() <<
nl;
120 const dictionary& patchDict = dEntry.dict();
123 faPatchDefs.append(faPatchData());
125 auto& patchDef = faPatchDefs.last();
126 patchDef.name_ = dEntry.keyword();
127 patchDef.type_ = patchDict.get<word>(
"type");
132 if (patchDict.readIfPresent(
"ownerPolyPatch", patchName))
134 patchDef.ownerPolyPatchId_ = pbm.findPatchID(patchName);
135 if (patchDef.ownerPolyPatchId_ < 0)
138 <<
"ownerPolyPatch " << patchName <<
" not found"
144 patchDict.readEntry(
"neighbourPolyPatch", patchName);
146 patchDef.neighPolyPatchId_ = pbm.findPatchID(patchName);
147 if (patchDef.neighPolyPatchId_ < 0)
150 <<
"neighbourPolyPatch " << patchName <<
" not found"
157 if (!emptyPatchName.empty())
159 faPatchDefs.append(faPatchData());
161 auto& patchDef = faPatchDefs.last();
162 patchDef.name_ = emptyPatchName;
163 patchDef.type_ =
"empty";
166 label nWarnUndefinedPatch(5);
169 const label undefPatchIndex = faPatchDefs.size();
171 faPatchDefs.append(faPatchData());
173 auto& patchDef = faPatchDefs.last();
174 patchDef.name_ =
"undefined";
175 patchDef.type_ =
"patch";
177 if (defaultPatchDefinition)
181 (*defaultPatchDefinition).readIfPresent(
"name", patchDef.name_)
186 nWarnUndefinedPatch = 0;
188 (*defaultPatchDefinition).readIfPresent(
"type", patchDef.type_);
195 List<Pair<patchTuple>> bndEdgeConnections
197 this->getBoundaryEdgeConnections()
201 this->setBoundaryConnections(bndEdgeConnections);
205 labelList patchDefLookup(bndEdgeConnections.size(), -1);
207 Map<labelHashSet> procConnections;
213 forAll(bndEdgeConnections, connecti)
215 const Pair<patchTuple>& connection = bndEdgeConnections[connecti];
216 const auto& a = connection.first();
217 const auto&
b = connection.second();
221 if (a.is_finiteArea())
223 if (
b.is_finiteArea())
226 if (a.procNo() ==
b.procNo())
229 <<
"Processor-processor addressing error:" <<
nl
230 <<
"Both connections have the same processor: "
234 else if (a.is_localProc())
236 procConnections(
b.procNo()).
insert(connecti);
240 procConnections(a.procNo()).
insert(connecti);
245 else if (a.is_localProc())
247 patchPair.first() = a.realPatchi();
248 patchPair.second() =
b.realPatchi();
251 else if (
b.is_finiteArea() &&
b.is_localProc())
253 patchPair.first() =
b.realPatchi();
254 patchPair.second() = a.realPatchi();
261 label bestPatchDefi = -1;
263 const label nPatchDefs = (patchPair.valid() ? faPatchDefs.size() : 0);
265 for (label patchDefi = 0; patchDefi < nPatchDefs; ++patchDefi)
267 const int match = faPatchDefs[patchDefi].matchPatchPair(patchPair);
271 bestPatchDefi = patchDefi;
274 else if (
match == 2 && bestPatchDefi < 0)
277 bestPatchDefi = patchDefi;
281 if (bestPatchDefi < 0)
283 bestPatchDefi = undefPatchIndex;
286 patchDefLookup[connecti] = bestPatchDefi;
287 patchDefsUsed.insert(bestPatchDefi);
291 if (!
returnReduce(patchDefsUsed.found(undefPatchIndex), orOp<bool>()))
293 faPatchDefs.remove(undefPatchIndex);
297 patchDefsUsed.insert(undefPatchIndex);
302 forAll(patchDefLookup, connecti)
304 if (patchDefLookup[connecti] == undefPatchIndex)
306 const auto& connection = bndEdgeConnections[connecti];
308 const auto& a = connection.first();
309 const auto&
b = connection.second();
311 if (a.is_localProc() && a.is_finiteArea())
313 badEdges.insert(a.patchEdgei());
315 else if (
b.is_localProc() &&
b.is_finiteArea())
317 badEdges.insert(
b.patchEdgei());
320 if (badEdges.size() <= nWarnUndefinedPatch)
322 Pout<<
"Undefined connection: "
323 <<
"(patch:" << a.realPatchi()
324 <<
" face:" << a.meshFacei()
325 <<
") and (patch:" <<
b.realPatchi()
326 <<
" face:" <<
b.meshFacei() <<
") connects: "
327 << pbm[a.realPatchi()].
name() <<
" to "
328 << pbm[
b.realPatchi()].name() <<
nl;
333 if ((nBadEdges =
returnReduce(badEdges.size(), sumOp<label>())) > 0)
338 Info<<
"Had " << nBadEdges <<
'/'
340 <<
" undefined edge connections, added to defaultPatch: "
341 << faPatchDefs[undefPatchIndex].name_ <<
nl;
343 if (nWarnUndefinedPatch)
349 patch().localPoints(),
353 mesh().time().globalPath()
354 / (
"faMesh-construct.undefEdges")
371 Map<label> procToDefLookup(2*procConnections.size());
373 faPatchDefs.reserve(faPatchDefs.size() + procConnections.size());
375 for (
const label otherProci : procConnections.sortedToc())
377 const label patchDefi = faPatchDefs.size();
378 procToDefLookup.insert(otherProci, patchDefi);
381 faPatchDefs.append(faPatchData());
382 auto& patchDef = faPatchDefs.last();
392 DynamicList<label> selectEdges(bndEdgeConnections.size());
393 label nOffProcessorEdges = 0;
395 for (
const label patchDefi : patchDefsUsed.sortedToc())
397 auto& patchDef = faPatchDefs[patchDefi];
403 forAll(patchDefLookup, connecti)
405 if (patchDefLookup[connecti] == patchDefi)
407 const auto& a = bndEdgeConnections[connecti].first();
408 const auto&
b = bndEdgeConnections[connecti].second();
410 if (a.is_localProc() && a.is_finiteArea())
412 selectEdges.append(a.patchEdgei());
414 else if (
b.is_localProc() &&
b.is_finiteArea())
416 selectEdges.append(
b.patchEdgei());
421 <<
"Error in programming logic" <<
nl
425 if (a.is_localProc() !=
b.is_localProc())
427 ++nOffProcessorEdges;
430 patchDefLookup[connecti] = -2;
438 patchDef.edgeLabels_ = selectEdges;
443 Pout<<
"Had " << nOffProcessorEdges
444 <<
" patch edges connected off-processor" <<
endl;
449 <<
" patch edges connected off-processor" <<
endl;
454 for (
const label otherProci : procToDefLookup.sortedToc())
456 const label patchDefi = procToDefLookup[otherProci];
458 auto& patchDef = faPatchDefs[patchDefi];
464 for (
const label connecti : procConnections(otherProci).sortedToc())
466 const auto& connection = bndEdgeConnections[connecti];
467 const auto& a = connection.first();
468 const auto&
b = connection.second();
470 if (a.is_localProc())
472 selectEdges.append(a.patchEdgei());
474 else if (
b.is_localProc())
476 selectEdges.append(
b.patchEdgei());
481 <<
"Error in programming logic" <<
nl
485 patchDefLookup[connecti] = -2;
491 patchDef.edgeLabels_ = selectEdges;
498 PtrList<faPatch> newPatches(faPatchDefs.size());
500 for (faPatchData& patchDef : faPatchDefs)
508 patchDef.dict(
false),
515 newPatches[
nPatches].resetEdges(std::move(patchDef.edgeLabels_));
523 Pout<<
"Created new finiteArea patches:" <<
nl;
524 for (
const faPatch&
p : newPatches)
526 Pout<<
" size: " <<
p.size()
527 <<
" name:" <<
p.name()
528 <<
" type:" <<
p.type() <<
nl;
532 Pout<<
"addressed: " << nTotal
533 <<
'/' <<
patch().nBoundaryEdges() <<
" edges" <<
endl;