74 return s < ROOTVSMALL ?
Zero : (a ^
b) /
s;
84 const point& basePoint,
85 const point& rightPoint,
86 const point& leftPoint,
87 const point& centrePoint
90 const vector mid(centrePoint - basePoint);
96 0.5*(rightPoint - basePoint),
102 0.5*(leftPoint - basePoint)
124 const point& faceCentre
131 (edgeLine.
a() - faceCentre),
132 (edgeLine.
b() - faceCentre)
143 const point& faceCentre
196 bitSet markPoints(
p.nPoints());
197 for (
const edge&
e :
p.boundaryEdges())
200 markPoints.
set(
e.first());
201 markPoints.
set(
e.second());
213void Foam::faMesh::calcLduAddressing()
const
216 <<
"Calculating addressing" <<
endl;
221 <<
"lduPtr_ already allocated"
225 lduPtr_ = std::make_unique<faMeshLduAddressing>(*
this);
229void Foam::faMesh::calcPatchStarts()
const
232 <<
"Calculating patch starts" <<
endl;
237 <<
"patchStarts already allocated"
241 patchStartsPtr_ = std::make_unique<labelList>(
boundary().patchStarts());
245void Foam::faMesh::calcWhichPatchFaces()
const
248 if (polyPatchFacesPtr_ || polyPatchIdsPtr_)
251 <<
"Already allocated polyPatchFaces/polyPatchIds"
257 polyPatchFacesPtr_ = std::make_unique<List<labelPair>>
265 for (
const labelPair& tup : *polyPatchFacesPtr_)
267 ids.insert(tup.first());
281 polyPatchIdsPtr_ = std::make_unique<labelList>(ids.sortedToc());
296 const point& faceCentre,
301 const vector centreToEdge(edgeLine.
centre() - faceCentre);
303 vector leVector(edgeLine.
vec() ^ edgeNormal);
305 scalar
s(
mag(leVector));
313 leVector = centreToEdge;
323 leVector *= edgeLine.
mag()/
s;
328 leVector *= edgeLine.
mag()/
s *
sign(leVector & centreToEdge);
349 const scalar minLenSqr(SMALL*SMALL);
353 if (v.magSqr() < minLenSqr)
369 auto& edgeNormals = tedgeNormals.ref();
387 <<
"Using geometryOrder < 0 : "
388 "simplified edge area-normals, without processor connectivity"
392 for (label edgei = 0; edgei < nInternalEdges_; ++edgei)
394 const linePointRef edgeLine(edges_[edgei].line(localPoints));
401 fCentres[edgeOwner()[edgei]]
407 fCentres[edgeNeighbour()[edgei]]
413 for (label edgei = nInternalEdges_; edgei < nEdges_; ++edgei)
422 fCentres[edgeOwner()[edgei]]
435 <<
"Using geometryOrder == 0 : "
436 "weighted edge normals, without processor connectivity"
442 for (label edgei = 0; edgei < nInternalEdges_; ++edgei)
451 fCentres[edgeOwner()[edgei]]
457 fCentres[edgeNeighbour()[edgei]]
463 for (label edgei = nInternalEdges_; edgei < nEdges_; ++edgei)
472 fCentres[edgeOwner()[edgei]]
497 label patchOffset = nInternalEdges_;
503 auto edgeNorms = edgeNormals.
slice(patchOffset, fap.nEdges());
504 patchOffset += edgeNorms.size();
510 const label nbrProci = fapp->neighbProcNo();
514 nbrEdgeNormals.emplace(patchi, edgeNorms.size());
519 requests.emplace_back(),
521 nbrEdgeNormals[patchi]
527 requests.emplace_back(),
543 wedgePatch.centreNormal()
549 e.removeCollinear(wedgeNorm);
557 else if (correctPatchPointNormals(patchi) && !fap.coupled())
560 nbrBoundaryAdjust.set(patchi);
567 if (!requests.empty())
571 patchOffset = nInternalEdges_;
577 auto edgeNorms = edgeNormals.
slice(patchOffset, fap.nEdges());
578 patchOffset += edgeNorms.size();
580 if (nbrEdgeNormals.set(patchi))
582 const vectorField& nbrNorms = nbrEdgeNormals[patchi];
584 forAll(edgeNorms, patchEdgei)
586 edgeNorms[patchEdgei] += nbrNorms[patchEdgei];
598 && hasPatchPointNormalsCorrection()
603 <<
"Apply " << nbrBoundaryAdjust.count()
604 <<
" boundary neighbour corrections" <<
nl;
608 (void)this->haloFaceNormals();
611 label patchOffset = nInternalEdges_;
613 for (
const label patchi : nbrBoundaryAdjust)
617 auto edgeNorms = edgeNormals.
slice(patchOffset, fap.nEdges());
618 patchOffset += edgeNorms.size();
620 if (fap.ngbPolyPatchIndex() < 0)
623 <<
"Neighbour polyPatch index is not defined "
624 <<
"for faPatch " << fap.name()
638 vectorField nbrNorms(this->haloFaceNormals(patchi));
640 const label nPatchEdges =
min(edgeNorms.size(), nbrNorms.size());
642 for (label patchEdgei = 0; patchEdgei < nPatchEdges; ++patchEdgei)
644 edgeNorms[patchEdgei].removeCollinear(nbrNorms[patchEdgei]);
652 forAll(edgeNormals, edgei)
656 edgeNormals[edgei].removeCollinear(edgeLine.unitVec());
657 edgeNormals[edgei].normalise();
666void Foam::faMesh::calcLe()
const
669 <<
"Calculating local edges" <<
endl;
674 <<
"LePtr_ already allocated"
678 LePtr_ = std::make_unique<edgeVectorField>
683 mesh().pointsInstance(),
711 for (label edgei = 0; edgei < nInternalEdges_; ++edgei)
715 fCentres[edgeOwner()[edgei]],
716 edges_[edgei].
line(localPoints),
729 edgeNormals.boundaryField()[patchi];
731 label edgei = fap.start();
737 fCentres[edgeOwner()[edgei]],
738 edges_[edgei].
line(localPoints),
739 bndEdgeNormals[patchEdgei]
763void Foam::faMesh::calcMagLe()
const
766 <<
"Calculating local edge magnitudes" <<
endl;
771 <<
"magLe() already allocated"
775 magLePtr_ = std::make_unique<edgeScalarField>
780 mesh().pointsInstance(),
796 auto iter = magLe.primitiveFieldRef().begin();
798 for (
const edge&
e : internalEdges())
800 *iter =
e.mag(localPoints);
803 if (
mag(*iter) < SMALL)
814 auto& bfld = magLe.boundaryFieldRef();
818 auto iter = bfld[patchi].begin();
822 *iter =
e.mag(localPoints);
825 if (
mag(*iter) < SMALL)
837void Foam::faMesh::calcFaceCentres()
const
840 <<
"Calculating face centres" <<
endl;
845 <<
"areaCentres already allocated"
849 faceCentresPtr_ = std::make_unique<areaVectorField>
854 mesh().pointsInstance(),
873 if (
mesh().hasFaceCentres())
877 centres.primitiveFieldRef()
883 auto iter = centres.primitiveFieldRef().begin();
885 for (
const face&
f : faces())
887 *iter =
f.centre(localPoints);
895 auto& bfld = centres.boundaryFieldRef();
899 auto iter = bfld[patchi].begin();
903 *iter =
e.centre(localPoints);
917void Foam::faMesh::calcEdgeCentres()
const
920 <<
"Calculating edge centres" <<
endl;
925 <<
"edgeCentres already allocated"
929 edgeCentresPtr_ = std::make_unique<edgeVectorField>
934 mesh().pointsInstance(),
953 auto iter = centres.primitiveFieldRef().begin();
955 for (
const edge&
e : internalEdges())
957 *iter =
e.centre(localPoints);
964 auto& bfld = centres.boundaryFieldRef();
968 auto iter = bfld[patchi].begin();
972 *iter =
e.centre(localPoints);
980void Foam::faMesh::calcS()
const
983 <<
"Calculating areas" <<
endl;
988 <<
"S() already allocated"
992 SPtr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
1006 auto& areas = *SPtr_;
1010 if (
mesh().hasFaceAreas())
1015 auto&
fld = areas.field();
1022 if (
mag(
fld[facei]) < SMALL)
1034 auto iter = areas.field().begin();
1036 for (
const face&
f : faces())
1038 *iter =
f.mag(localPoints);
1041 if (
mag(*iter) < SMALL)
1052void Foam::faMesh::calcFaceAreaNormals()
const
1055 <<
"Calculating face area normals" <<
endl;
1057 if (faceAreaNormalsPtr_)
1060 <<
"faceAreaNormals already allocated"
1064 faceAreaNormalsPtr_ = std::make_unique<areaVectorField>
1069 mesh().pointsInstance(),
1085 auto&
fld = faceNormals.primitiveFieldRef();
1087 if (
mesh().hasFaceAreas())
1096 auto iter =
fld.begin();
1098 for (
const face&
f : faces())
1100 *iter =
f.areaNormal(localPoints);
1114 const auto& edgeNormalsBoundary = edgeAreaNormals().boundaryField();
1118 faceNormals.boundaryFieldRef()[patchi]
1119 = edgeNormalsBoundary[patchi];
1131void Foam::faMesh::calcEdgeAreaNormals()
const
1134 <<
"Calculating edge area normals" <<
endl;
1136 if (edgeAreaNormalsPtr_)
1139 <<
"edgeAreaNormalsPtr_ already allocated"
1143 edgeAreaNormalsPtr_ = std::make_unique<edgeVectorField>
1148 mesh().pointsInstance(),
1172 edgeAreaNormals.primitiveFieldRef()
1177 auto& bfld = edgeAreaNormals.boundaryFieldRef();
1179 label patchOffset = nInternalEdges_;
1188 bfld[patchi].size(),
1192 patchOffset += fap.nEdges();
1205 const vectorField& pointNormals = pointAreaNormals();
1212 auto&
fld = edgeAreaNormals.primitiveFieldRef();
1216 const edge&
e = edges_[edgei];
1220 fld[edgei] = (pointNormals[
e.
first()] + pointNormals[
e.second()]);
1222 fld[edgei].removeCollinear(edgeLine.unitVec());
1223 fld[edgei].normalise();
1231 auto& bfld = edgeAreaNormals.boundaryFieldRef();
1237 auto& pfld = bfld[patchi];
1241 forAll(bndEdges, patchEdgei)
1243 const edge&
e = bndEdges[patchEdgei];
1248 (pointNormals[
e.
first()] + pointNormals[
e.second()]);
1250 pfld[patchEdgei].removeCollinear(edgeLine.unitVec());
1251 pfld[patchEdgei].normalise();
1260void Foam::faMesh::calcFaceCurvatures()
const
1263 <<
"Calculating face curvatures" <<
endl;
1265 if (faceCurvaturesPtr_)
1268 <<
"faceCurvaturesPtr_ already allocated"
1272 faceCurvaturesPtr_ = std::make_unique<areaScalarField>
1277 mesh().pointsInstance(),
1296 faceCurvatures =
sign(kN&faceAreaNormals())*
mag(kN);
1300void Foam::faMesh::calcEdgeTransformTensors()
const
1303 <<
"Calculating edge transformation tensors" <<
endl;
1305 if (edgeTransformTensorsPtr_)
1308 <<
"edgeTransformTensorsPtr_ already allocated"
1312 edgeTransformTensorsPtr_ =
1313 std::make_unique<FieldField<Field, tensor>>(nEdges_);
1314 auto& edgeTransformTensors = *edgeTransformTensorsPtr_;
1317 for (label edgei = 0; edgei < nEdges_; ++edgei)
1329 for (label edgei = 0; edgei < nInternalEdges_; ++edgei)
1331 const label ownFacei = owner()[edgei];
1332 const label neiFacei = neighbour()[edgei];
1333 auto& tensors = edgeTransformTensors[edgei];
1335 vector edgeCtr = Ce.internalField()[edgei];
1346 Ne.internalField()[edgei],
1347 (edgeCtr - Cf.internalField()[ownFacei])
1354 Nf.internalField()[ownFacei],
1355 (edgeCtr - Cf.internalField()[ownFacei])
1362 Nf.internalField()[neiFacei],
1363 (Cf.internalField()[neiFacei] - edgeCtr)
1374 vectorField nbrCf(Cf.boundaryField()[patchi].patchNeighbourField());
1375 vectorField nbrNf(Nf.boundaryField()[patchi].patchNeighbourField());
1377 forAll(edgeFaces, bndEdgei)
1379 const label ownFacei = edgeFaces[bndEdgei];
1380 const label meshEdgei(
boundary()[patchi].start() + bndEdgei);
1382 auto& tensors = edgeTransformTensors[meshEdgei];
1384 vector edgeCtr = Ce.boundaryField()[patchi][bndEdgei];
1389 .boundaryField()[patchi][bndEdgei];
1396 Ne.boundaryField()[patchi][bndEdgei],
1397 (edgeCtr - Cf.internalField()[ownFacei])
1404 Nf.internalField()[ownFacei],
1405 (edgeCtr - Cf.internalField()[ownFacei])
1413 (nbrCf[bndEdgei] - edgeCtr)
1419 forAll(edgeFaces, bndEdgei)
1421 const label ownFacei = edgeFaces[bndEdgei];
1422 const label meshEdgei(
boundary()[patchi].start() + bndEdgei);
1424 auto& tensors = edgeTransformTensors[meshEdgei];
1426 vector edgeCtr = Ce.boundaryField()[patchi][bndEdgei];
1431 .boundaryField()[patchi][bndEdgei];
1438 Ne.boundaryField()[patchi][bndEdgei],
1439 (edgeCtr - Cf.internalField()[ownFacei])
1446 Nf.internalField()[ownFacei],
1447 (edgeCtr - Cf.internalField()[ownFacei])
1461 <<
"Calculating internal points" <<
endl;
1466 return markPoints.sortedToc();
1473 <<
"Calculating boundary points" <<
endl;
1507void Foam::faMesh::calcPointAreaNormals(
vectorField& result)
const
1510 <<
"Calculating pointAreaNormals : face dual method" <<
endl;
1512 result.resize_nocopy(
nPoints());
1516 const faceList& faces = patch().localFaces();
1521 for (
const face&
f : faces)
1523 const label nVerts(
f.size());
1526 for (
const label fp :
f)
1528 centrePoint +=
points[fp];
1530 centrePoint /= nVerts;
1532 for (label i = 0; i < nVerts; ++i)
1534 const label pt0 =
f.thisLabel(i);
1549 bitSet nbrBoundaryAdjust;
1561 const labelList& patchPoints = wedgePatch.pointLabels();
1568 wedgePatch.centreNormal()
1572 for (
const label pti : patchPoints)
1574 result[pti].removeCollinear(
N);
1578 if (wedgePatch.axisPoint() > -1)
1580 result[wedgePatch.axisPoint()] =
1584 &result[wedgePatch.axisPoint()]
1593 const labelList& patchPoints = procPatch.pointLabels();
1594 const labelList& nbrPatchPoints = procPatch.neighbPoints();
1597 procPatch.nonGlobalPatchPoints();
1610 procPatch.neighbProcNo(),
1616 patchPointNormals.resize_nocopy(nbrPatchPoints.size());
1622 procPatch.neighbProcNo(),
1627 for (
const label pti : nonGlobalPatchPoints)
1629 result[patchPoints[pti]] +=
1630 patchPointNormals[nbrPatchPoints[pti]];
1638 else if (correctPatchPointNormals(patchi) && !fap.coupled())
1641 nbrBoundaryAdjust.set(patchi);
1647 if (globalData().nGlobalPoints())
1649 const labelList& spLabels = globalData().sharedPointLabels();
1650 const labelList& addr = globalData().sharedPointAddr();
1659 globalData().nGlobalPoints(),
1665 gpNormals[addr[i]] += spNormals[i];
1673 spNormals[i] = gpNormals[addr[i]];
1676 forAll(spNormals, pointI)
1678 result[spLabels[pointI]] = spNormals[pointI];
1685 hasPatchPointNormalsCorrection()
1690 <<
"Apply " << nbrBoundaryAdjust.count()
1691 <<
" boundary neighbour corrections" <<
nl;
1697 const auto& haloNormals = this->haloFaceNormals();
1701 for (
const label patchi : nbrBoundaryAdjust)
1705 if (fap.ngbPolyPatchIndex() < 0)
1708 <<
"Neighbour polyPatch index is not defined "
1709 <<
"for faPatch " << fap.name()
1714 for (
const label edgei : fap.edgeLabels())
1719 const vector& fnorm = haloNormals[edgei - nInternalEdges_];
1721 fpNormals(
e.
first()) += fnorm;
1722 fpNormals(
e.second()) += fnorm;
1738 const label pointi = iter.key();
1739 result[pointi].removeCollinear(
normalised(iter.val()));
1747void Foam::faMesh::calcPointAreaNormalsByQuadricsFit(
vectorField& result)
const
1749 const labelList intPoints(internalPoints());
1750 const labelList bndPoints(boundaryPoints());
1756 forAll(intPoints, pointI)
1758 label curPoint = intPoints[pointI];
1765 for (
const label facei : curFaces)
1767 const labelList& facePoints = faces[facei];
1776 <<
"WARNING: Extending point set for fitting." <<
endl;
1780 for (
const label facei : curFaces)
1789 for (
const label facei : curFaces)
1791 const labelList& facePoints = faces[facei];
1800 for (label i=0; i<curPoints.size(); ++i)
1811 allPoints[0] -
points[curPoint]
1814 for (
point&
p : allPoints)
1816 p = cs.localPosition(
p);
1826 for (label i = 0; i <
allPoints.size(); ++i)
1828 M[i][0] =
sqr(allPoints[i].
x());
1829 M[i][1] =
sqr(allPoints[i].
y());
1837 for (label i = 0; i < MtM.n(); ++i)
1839 for (label j = 0; j < MtM.m(); ++j)
1841 for (label
k = 0;
k <
M.n(); ++
k)
1843 MtM[i][j] +=
M[
k][i]*
M[
k][j]*W[
k];
1850 for (label i=0; i<MtR.size(); ++i)
1852 for (label j=0; j<
M.n(); ++j)
1862 curNormal = cs.globalVector(curNormal);
1864 curNormal *=
sign(curNormal&result[curPoint]);
1866 result[curPoint] = curNormal;
1879 const labelList& patchPointLabels = procPatch.pointLabels();
1881 labelList toNgbProcLsPointStarts(patchPointLabels.size(),
Zero);
1884 10*patchPointLabels.size(),
1889 for (label pointI=0; pointI<patchPointLabels.size(); ++pointI)
1891 label curPoint = patchPointLabels[pointI];
1893 toNgbProcLsPointStarts[pointI] =
nPoints;
1900 for (
const label facei : curFaces)
1902 const labelList& facePoints = faces[facei];
1908 for (label i=0; i<curPoints.size(); ++i)
1914 toNgbProcLsPoints.setSize(
nPoints);
1920 procPatch.neighbProcNo(),
1921 toNgbProcLsPoints.size_bytes()
1922 + toNgbProcLsPointStarts.size_bytes()
1927 << toNgbProcLsPoints
1928 << toNgbProcLsPointStarts;
1940 const labelList& patchPointLabels = procPatch.pointLabels();
1942 labelList fromNgbProcLsPointStarts(patchPointLabels.size(),
Zero);
1949 procPatch.neighbProcNo(),
1950 10*patchPointLabels.size()*
sizeof(
vector)
1951 + fromNgbProcLsPointStarts.size_bytes()
1956 >> fromNgbProcLsPoints
1957 >> fromNgbProcLsPointStarts;
1961 procPatch.nonGlobalPatchPoints();
1963 forAll(nonGlobalPatchPoints, pointI)
1966 patchPointLabels[nonGlobalPatchPoints[pointI]];
1968 procPatch.neighbPoints()[nonGlobalPatchPoints[pointI]];
1977 for (
const label facei : curFaces)
1979 const labelList& facePoints = faces[facei];
1985 label nAllPoints = curPoints.size();
1987 if (curNgbPoint == fromNgbProcLsPointStarts.size() - 1)
1990 fromNgbProcLsPoints.size()
1991 - fromNgbProcLsPointStarts[curNgbPoint];
1996 fromNgbProcLsPointStarts[curNgbPoint + 1]
1997 - fromNgbProcLsPointStarts[curNgbPoint];
2002 for (label i=0; i<curPoints.size(); ++i)
2004 allPointsExt[counter++] =
points[curPoints[i]];
2007 if (curNgbPoint == fromNgbProcLsPointStarts.size() - 1)
2011 label i=fromNgbProcLsPointStarts[curNgbPoint];
2012 i<fromNgbProcLsPoints.size();
2016 allPointsExt[counter++] = fromNgbProcLsPoints[i];
2023 label i=fromNgbProcLsPointStarts[curNgbPoint];
2024 i<fromNgbProcLsPointStarts[curNgbPoint+1];
2028 allPointsExt[counter++] = fromNgbProcLsPoints[i];
2037 for (
const point& pt : allPointsExt)
2039 bool duplicate =
false;
2040 for (label i = 0; i < nAllPoints; ++i)
2042 if (pt.dist(allPoints[i]) < tol)
2060 <<
"There are no enough points for quadrics "
2061 <<
"fitting for a point at processor patch"
2069 dir.removeCollinear(axis);
2080 allPoints[pI] = cs.localPosition(allPoints[pI]);
2090 for (label i=0; i<
allPoints.size(); ++i)
2092 M[i][0] =
sqr(allPoints[i].
x());
2093 M[i][1] =
sqr(allPoints[i].
y());
2101 for (label i = 0; i < MtM.n(); ++i)
2103 for (label j = 0; j < MtM.m(); ++j)
2105 for (label
k = 0;
k <
M.n(); ++
k)
2107 MtM[i][j] +=
M[
k][i]*
M[
k][j]*W[
k];
2114 for (label i = 0; i < MtR.size(); ++i)
2116 for (label j = 0; j <
M.n(); ++j)
2126 curNormal = cs.globalVector(curNormal);
2128 curNormal *=
sign(curNormal&result[curPoint]);
2130 result[curPoint] = curNormal;
2136 if (globalData().nGlobalPoints() > 0)
2138 const labelList& spLabels = globalData().sharedPointLabels();
2140 const labelList& addr = globalData().sharedPointAddr();
2142 for (label
k=0;
k<globalData().nGlobalPoints(); ++
k)
2146 const label curSharedPointIndex = addr.find(
k);
2150 if (curSharedPointIndex != -1)
2152 label curPoint = spLabels[curSharedPointIndex];
2158 for (
const label facei : curFaces)
2160 const labelList& facePoints = faces[facei];
2175 if (curSharedPointIndex != -1)
2177 label curPoint = spLabels[curSharedPointIndex];
2179 label nAllPoints = 0;
2180 forAll(procLsPoints, procI)
2182 nAllPoints += procLsPoints[procI].size();
2188 forAll(procLsPoints, procI)
2190 forAll(procLsPoints[procI], pointI)
2192 bool duplicate =
false;
2193 for (label i=0; i<nAllPoints; ++i)
2200 - procLsPoints[procI][pointI]
2213 procLsPoints[procI][pointI];
2223 <<
"There are no enough points for quadratic "
2224 <<
"fitting for a global processor point "
2232 dir.removeCollinear(axis);
2239 forAll(allPoints, pointI)
2244 allPoints[pointI] = cs.localPosition(allPoints[pointI]);
2254 for (label i=0; i<
allPoints.size(); ++i)
2256 M[i][0] =
sqr(allPoints[i].
x());
2257 M[i][1] =
sqr(allPoints[i].
y());
2264 for (label i = 0; i < MtM.n(); ++i)
2266 for (label j = 0; j < MtM.m(); ++j)
2268 for (label
k = 0;
k <
M.n(); ++
k)
2270 MtM[i][j] +=
M[
k][i]*
M[
k][j]*W[
k];
2276 for (label i = 0; i < MtR.size(); ++i)
2278 for (label j = 0; j <
M.n(); ++j)
2288 curNormal = cs.globalVector(curNormal);
2290 curNormal *=
sign(curNormal&result[curPoint]);
2292 result[curPoint] = curNormal;
2307 <<
"Calculating edge length correction" <<
endl;
2313 "edgeLengthCorrection",
2314 mesh().pointsInstance(),
2326 const vectorField& pointNormals = pointAreaNormals();
2328 const auto angleCorrection =
2341 fld[edgei] = angleCorrection
2343 pointNormals[edges_[edgei].start()],
2344 pointNormals[edges_[edgei].
end()]
2358 label edgei = fap.start();
2362 pfld[patchEdgei] = angleCorrection
2364 pointNormals[edges_[edgei].start()],
2365 pointNormals[edges_[edgei].
end()]
2384 mesh().pointsInstance(),
2393 (this->Le() / this->magLe())
2400 return tunitVectors;
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Info<< " "<< writer.output().name()<< nl;}{ const Field< vector > edgeCentres(faMeshTools::flattenEdgeField(aMesh.edgeCentres(), true))
labelList faceLabels(nFaceLabels)
const polyBoundaryMesh & pbm
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
void normalise()
Inplace normalise this field. Generally a no-op except for vector fields.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
List< Key > toc() const
The table of contents (the keys) in unsorted order.
label size() const noexcept
The number of elements in table.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
void clear()
Remove all entries from table.
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Input inter-processor communications stream.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
SubList< vector > subList
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
A HashTable to objects of type <T> with a label key.
Output inter-processor communications stream.
static void combineReduce(T &value, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) applying cop to inplace combine value from different processors.
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual communication.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
static std::streamsize read(const UPstream::commsTypes commsType, const int fromProcNo, Type *buffer, std::streamsize count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, UPstream::Request *req=nullptr)
Receive buffer contents (contiguous types) from given processor.
A List with indirect addressing. Like IndirectList but does not store addressing.
T & first()
Access first element of the list, position [0].
SubList< T > slice(const label pos, label len=-1)
Return SubList slice (non-const access) - no range checking.
static bool write(const UPstream::commsTypes commsType, const int toProcNo, const Type *buffer, std::streamsize count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, UPstream::Request *req=nullptr, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Write buffer contents (contiguous types only) to given processor.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
@ buffered
"buffered" : (MPI_Bsend, MPI_Recv)
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static int & msgType() noexcept
Message tag of standard messages.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static void waitRequests()
Wait for all requests to finish.
static Form uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
Vector< Cmpt > & normalise(const scalar tol=ROOTVSMALL)
Inplace normalise the vector by its magnitude.
Vector< Cmpt > & removeCollinear(const Vector< Cmpt > &unitVec)
Inplace removal of components that are collinear to the given unit vector.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void flip()
Invert all bits in the addressable region.
labelList sortedToc() const
The indices of the on bits as a sorted labelList.
void set(const bitSet &bitset)
Set specified bits from another bitset.
scalar mag() const
The magnitude/length of the bounding box diagonal.
A Cartesian coordinate system.
Base class for coordinate system specification, the default coordinate system type is cartesian .
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
labelList internalPoints() const
Return internal point labels.
virtual const objectRegistry & thisDb() const
Reference to the mesh database.
static int geometryOrder() noexcept
Return the current geometry treatment.
tmp< edgeVectorField > unitLe() const
Return normalised edge length vectors.
const uindirectPrimitivePatch & patch() const
Return constant reference to primitive patch.
const fileName & pointsInstance() const
Return the current instance directory for points.
tmp< edgeScalarField > edgeLengthCorrection() const
Return edge length correction.
const vectorField & pointAreaNormals() const
Return point area normals.
static word meshSubDir
The mesh sub-directory name (usually "faMesh").
labelList boundaryPoints() const
Return boundary point labels.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
label start() const
Patch start in edge list.
A face is a list of labels corresponding to mesh vertices.
PointRef a() const noexcept
The first point.
Point centre() const
Return centre (centroid).
scalar mag() const
The magnitude (length) of the line.
Point unitVec() const
Return the unit vector (start-to-end).
PointRef b() const noexcept
The second point.
Point vec() const
Return start-to-end vector.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
labelPair whichPatchFace(const label meshFacei) const
Lookup mesh face index and return (patchi, patchFacei) tuple or (-1, meshFacei) for internal faces.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Skew-correction vectors for the skewness-corrected interpolation scheme.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Standard boundBox with extra functionality for use in octree.
vector areaNormal() const
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Namespace of functions to calculate explicit derivatives.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugInFunction
Report an information message using Foam::Info.
tmp< GeometricField< Type, faPatchField, areaMesh > > edgeIntegrate(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
const std::string patch
OpenFOAM patch number as a std::string.
static vector calcLeVector(const point &faceCentre, const linePointRef &edgeLine, const vector &edgeNormal)
Calculate the 'Le' vector from faceCentre to edge centre.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Pair< label > labelPair
A pair of labels.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
dimensionedScalar asin(const dimensionedScalar &ds)
GeometricField< vector, faePatchField, edgeMesh > edgeVectorField
const dimensionSet dimless
Dimensionless.
List< labelList > labelListList
List of labelList.
static void imposeMinVectorLength(vectorField &fld)
dimensionedScalar sign(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
RectangularMatrix< scalar > scalarRectangularMatrix
dimensionedSymmTensor sqr(const dimensionedVector &dv)
static vector areaInvDistSqrWeightedNormal(const vector &a, const vector &b)
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
static vector areaInvDistSqrWeightedNormalFaceTriangle(const linePointRef &edgeLine, const point &faceCentre)
const dimensionSet dimArea(sqr(dimLength))
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
List< face > faceList
List of faces.
static vector areaInvDistSqrWeightedNormalDualEdge(const point &basePoint, const point &rightPoint, const point &leftPoint, const point ¢rePoint)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static Foam::bitSet markupBoundaryPoints(const uindirectPrimitivePatch &p)
GeometricField< vector, faPatchField, areaMesh > areaVectorField
GeometricField< scalar, faePatchField, edgeMesh > edgeScalarField
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
line< point, const point & > linePointRef
A line using referred points.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
static tensor rotation_e3e1(const vector &unitAxis1, vector dirn)
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
SquareMatrix< scalar > scalarSquareMatrix
vector point
Point is a vector.
static vector areaNormalFaceTriangle(const linePointRef &edgeLine, const point &faceCentre)
static constexpr const zero Zero
Global zero (0).
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix by subtracting the matrix multiplied by the current fi...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
void LUsolve(scalarSquareMatrix &matrix, List< Type > &source)
Solve the matrix using LU decomposition with pivoting returning the LU form of the matrix and the sol...
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
dimensionedScalar cos(const dimensionedScalar &ds)
dimensionedTensor skew(const dimensionedTensor &dt)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
const Vector< label > N(dict.get< Vector< label > >("N"))