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
172 dirn.removeCollinear(unitAxis1);
196 bitSet markPoints(
p.nPoints());
197 for (
const edge&
e :
p.boundaryEdges())
200 markPoints.
set(
e.first());
201 markPoints.set(
e.second());
213 void Foam::faMesh::calcLduAddressing()
const 216 <<
"Calculating addressing" <<
endl;
221 <<
"lduPtr_ already allocated" 225 lduPtr_ = std::make_unique<faMeshLduAddressing>(*this);
229 void Foam::faMesh::calcPatchStarts()
const 232 <<
"Calculating patch starts" <<
endl;
237 <<
"patchStarts already allocated" 241 patchStartsPtr_ = std::make_unique<labelList>(
boundary().patchStarts());
245 void 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_)
276 bitOrOp<labelHashSet>(),
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;
314 leVector.removeCollinear(edgeLine.
unitVec());
323 leVector *= edgeLine.
mag()/
s;
328 leVector *= edgeLine.
mag()/
s *
sign(leVector & centreToEdge);
348 const vector minVector(vector::uniform(0.57735*SMALL));
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)
415 const linePointRef edgeLine(edges_[edgei].line(localPoints));
422 fCentres[edgeOwner()[edgei]]
435 <<
"Using geometryOrder == 0 : " 436 "weighted edge normals, without processor connectivity" 442 for (label edgei = 0; edgei < nInternalEdges_; ++edgei)
444 const linePointRef edgeLine(edges_[edgei].line(localPoints));
451 fCentres[edgeOwner()[edgei]]
457 fCentres[edgeNeighbour()[edgei]]
463 for (label edgei = nInternalEdges_; edgei < nEdges_; ++edgei)
465 const linePointRef edgeLine(edges_[edgei].line(localPoints));
472 fCentres[edgeOwner()[edgei]]
480 bitSet nbrBoundaryAdjust;
485 DynamicList<UPstream::Request> requests
490 PtrList<vectorField> nbrEdgeNormals(
boundary().size());
497 label patchOffset = nInternalEdges_;
501 const faPatch& fap =
boundary()[patchi];
503 auto edgeNorms = edgeNormals.
slice(patchOffset, fap.nEdges());
504 patchOffset += edgeNorms.size();
506 const auto* fapp = isA<processorFaPatch>(fap);
510 const label nbrProci = fapp->neighbProcNo();
514 nbrEdgeNormals.emplace(patchi, edgeNorms.size());
519 requests.emplace_back(),
521 nbrEdgeNormals[patchi]
527 requests.emplace_back(),
533 else if (isA<wedgeFaPatch>(fap))
536 const auto& wedgePatch = refCast<const wedgeFaPatch>(fap);
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_;
575 const faPatch& fap =
boundary()[patchi];
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)
615 const faPatch& fap =
boundary()[patchi];
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)
654 const linePointRef edgeLine(edges_[edgei].line(localPoints));
656 edgeNormals[edgei].removeCollinear(edgeLine.
unitVec());
657 edgeNormals[edgei].normalise();
666 void 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),
725 const faPatch& fap =
boundary()[patchi];
729 edgeNormals.boundaryField()[patchi];
731 label edgei = fap.start();
737 fCentres[edgeOwner()[edgei]],
738 edges_[edgei].line(localPoints),
739 bndEdgeNormals[patchEdgei]
763 void 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();
820 for (
const edge&
e :
boundary()[patchi].patchSlice(edges_))
822 *iter =
e.mag(localPoints);
825 if (
mag(*iter) < SMALL)
837 void 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();
901 for (
const edge&
e :
boundary()[patchi].patchSlice(edges_))
903 *iter =
e.centre(localPoints);
912 centres.boundaryFieldRef().evaluateCoupled<processorFaPatch>();
917 void 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();
970 for (
const edge&
e :
boundary()[patchi].patchSlice(edges_))
972 *iter =
e.centre(localPoints);
980 void Foam::faMesh::calcS()
const 983 <<
"Calculating areas" <<
endl;
988 <<
"S() already allocated" 992 SPtr_ = std::make_unique<DimensionedField<scalar, areaMesh>>
1006 auto& areas = *SPtr_;
1013 UIndirectList<vector> meshFaceAreas(
mesh().faceAreas(),
faceLabels());
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)
1052 void 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];
1126 faceNormals.boundaryFieldRef().evaluateCoupled<processorFaPatch>();
1131 void 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_;
1183 const faPatch& fap =
boundary()[patchi];
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();
1235 const faPatch& fap =
boundary()[patchi];
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();
1260 void 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);
1300 void 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)
1319 edgeTransformTensors.set(edgei,
new Field<tensor>(3,
tensor::I));
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];
1339 edgeCtr -= skewCorrectionVectors().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];
1388 edgeCtr -= skewCorrectionVectors()
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];
1430 edgeCtr -= skewCorrectionVectors()
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;
1507 void Foam::faMesh::calcPointAreaNormals(
vectorField& result)
const 1510 <<
"Calculating pointAreaNormals : face dual method" <<
endl;
1512 result.resize_nocopy(
nPoints());
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;
1553 const faPatch& fap =
boundary()[patchi];
1555 if (isA<wedgeFaPatch>(fap))
1559 const auto& wedgePatch = refCast<const wedgeFaPatch>(fap);
1561 const labelList& patchPoints = wedgePatch.pointLabels();
1568 wedgePatch.centreNormal()
1572 for (
const label pti : patchPoints)
1578 if (wedgePatch.axisPoint() > -1)
1580 result[wedgePatch.axisPoint()] =
1584 &result[wedgePatch.axisPoint()]
1591 const auto& procPatch = refCast<const processorFaPatch>(fap);
1593 const labelList& patchPoints = procPatch.pointLabels();
1594 const labelList& nbrPatchPoints = procPatch.neighbPoints();
1597 procPatch.nonGlobalPatchPoints();
1603 UIndirectList<vector>(result, patchPoints)
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();
1654 UIndirectList<vector>(result, spLabels)
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();
1699 Map<vector> fpNormals(4*nBoundaryEdges());
1701 for (
const label patchi : nbrBoundaryAdjust)
1703 const faPatch& fap =
boundary()[patchi];
1705 if (fap.ngbPolyPatchIndex() < 0)
1708 <<
"Neighbour polyPatch index is not defined " 1709 <<
"for faPatch " << fap.name()
1714 for (
const label edgei : fap.edgeLabels())
1716 const edge&
e =
patch().edges()[edgei];
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()));
1747 void 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];
1761 const labelList curFaces(faceSet.toc());
1765 for (
const label facei : curFaces)
1767 const labelList& facePoints = faces[facei];
1768 pointSet.insert(facePoints);
1770 pointSet.erase(curPoint);
1773 if (pointSet.size() < 5)
1776 <<
"WARNING: Extending point set for fitting." <<
endl;
1780 for (
const label facei : curFaces)
1783 faceSet.insert(curFaceFaces);
1785 curFaces = faceSet.toc();
1789 for (
const label facei : curFaces)
1791 const labelList& facePoints = faces[facei];
1792 pointSet.insert(facePoints);
1794 pointSet.erase(curPoint);
1795 curPoints = pointSet.toc();
1800 for (label i=0; i<curPoints.size(); ++i)
1807 coordSystem::cartesian cs
1816 p = cs.localPosition(
p);
1826 for (label i = 0; i <
allPoints.size(); ++i)
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;
1872 const faPatch& fap =
boundary()[patchI];
1876 const processorFaPatch& procPatch =
1877 refCast<const processorFaPatch>(
boundary()[patchI]);
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;
1896 const labelList curFaces(faceSet.toc());
1900 for (
const label facei : curFaces)
1902 const labelList& facePoints = faces[facei];
1903 pointSet.insert(facePoints);
1905 pointSet.erase(curPoint);
1908 for (label i=0; i<curPoints.size(); ++i)
1917 OPstream toNeighbProc
1920 procPatch.neighbProcNo(),
1921 toNgbProcLsPoints.size_bytes()
1922 + toNgbProcLsPointStarts.size_bytes()
1927 << toNgbProcLsPoints
1928 << toNgbProcLsPointStarts;
1933 for (
const faPatch& fap :
boundary())
1937 const processorFaPatch& procPatch =
1938 refCast<const processorFaPatch>(fap);
1940 const labelList& patchPointLabels = procPatch.pointLabels();
1942 labelList fromNgbProcLsPointStarts(patchPointLabels.size(),
Zero);
1946 IPstream fromNeighbProc
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]];
1971 faceSet.
insert(pointFaces[curPoint]);
1977 for (
const label facei : curFaces)
1979 const labelList& facePoints = faces[facei];
1980 pointSet.insert(facePoints);
1982 pointSet.erase(curPoint);
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];
2034 const scalar tol = 0.001*treeBoundBox(allPointsExt).mag();
2037 for (
const point& pt : allPointsExt)
2039 bool duplicate =
false;
2040 for (label i = 0; i < nAllPoints; ++i)
2060 <<
"There are no enough points for quadrics " 2061 <<
"fitting for a point at processor patch" 2069 dir.removeCollinear(axis);
2072 const coordinateSystem cs(
"cs", origin, axis, dir);
2090 for (label i=0; i<
allPoints.size(); ++i)
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];
2155 const labelList curFaces(faceSet.toc());
2158 for (
const label facei : curFaces)
2160 const labelList& facePoints = faces[facei];
2161 pointSet.insert(facePoints);
2163 pointSet.erase(curPoint);
2170 tol = 0.001*treeBoundBox(locPoints).mag();
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);
2235 coordinateSystem cs(
"cs", origin, axis, dir);
2254 for (label i=0; i<
allPoints.size(); ++i)
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()]
2355 const faPatch& fap =
boundary()[patchi];
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;
dimensionedScalar sign(const dimensionedScalar &ds)
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix by subtracting the matrix multiplied by the current fi...
labelList internalPoints() const
Return internal point labels.
Point unitVec() const
Return the unit vector (start-to-end)
const polyBoundaryMesh & pbm
void size(const label n)
Older name for setAddressableSize.
void set(const bitSet &bitset)
Set specified bits from another bitset.
tmp< edgeScalarField > edgeLengthCorrection() const
Return edge length correction.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
scalar mag() const
The magnitude (length) of the line.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedTensor skew(const dimensionedTensor &dt)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline '\n' character (0x0a)
labelList sortedToc() const
The indices of the on bits as a sorted labelList.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelPair whichPatchFace(const label meshFacei) const
Lookup mesh face index and return (patchi, patchFacei) tuple or (-1, meshFacei) for internal faces...
static bool & parRun() noexcept
Test if this a parallel run.
static int & msgType() noexcept
Message tag of standard messages.
SubList< vector > subList
Declare type of subList.
static vector areaInvDistSqrWeightedNormalFaceTriangle(const linePointRef &edgeLine, const point &faceCentre)
label k
Boltzmann constant.
Ignore writing from objectRegistry::writeObject()
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
const dimensionSet dimless
Dimensionless.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
labelList faceLabels(nFaceLabels)
List< labelList > labelListList
List of labelList.
Namespace of functions to calculate explicit derivatives.
static vector areaNormalFaceTriangle(const linePointRef &edgeLine, const point &faceCentre)
dimensionedScalar asin(const dimensionedScalar &ds)
static void waitRequests()
Wait for all requests to finish.
UList< label > labelUList
A UList of labels.
static void imposeMinVectorLength(vectorField &fld)
virtual const objectRegistry & thisDb() const
Reference to the mesh database.
#define forAll(list, i)
Loop across all elements in list.
static int geometryOrder() noexcept
Return the current geometry treatment.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
List< face > faceList
List of faces.
A list of faces which address into the list of points.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
dimensionedScalar cos(const dimensionedScalar &ds)
line< point, const point & > linePointRef
A line using referred points.
SubList< T > slice(const label pos, label len=-1)
Return SubList slice (non-const access) - no range checking.
static const Identity< scalar > I
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ const Field< vector > edgeCentres(faMeshTools::flattenEdgeField(aMesh.edgeCentres(), true))
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
#define DebugInFunction
Report an information message using Foam::Info.
static void combineReduce(T &value, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) applying cop to inplace combine value from different processors...
GeometricField< vector, faePatchField, edgeMesh > edgeVectorField
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
PointRef a() const noexcept
The first point.
GeometricField< scalar, faePatchField, edgeMesh > edgeScalarField
PointRef b() const noexcept
The second point.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
#define DebugInfo
Report an information message using Foam::Info.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Pair< label > labelPair
A pair of labels.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
static Foam::bitSet markupBoundaryPoints(const uindirectPrimitivePatch &p)
bool hasFaceAreas() const noexcept
tmp< GeometricField< Type, faPatchField, areaMesh > > edgeIntegrate(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
const Vector< label > N(dict.get< Vector< label >>("N"))
Point centre() const
Return centre (centroid)
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;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Point vec() const
Return start-to-end vector.
const vectorField & faceCentres() const
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual linear/tree communicat...
labelList boundaryPoints() const
Return boundary point labels.
static word meshSubDir
The mesh sub-directory name (usually "faMesh")
vector point
Point is a vector.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
static vector calcLeVector(const point &faceCentre, const linePointRef &edgeLine, const vector &edgeNormal)
Calculate the 'Le' vector from faceCentre to edge centre.
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
const vectorField & faceAreas() const
const std::string patch
OpenFOAM patch number as a std::string.
static bool write(const UPstream::commsTypes commsType, const int toProcNo, const char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, UPstream::Request *req=nullptr, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Write buffer contents to given processor.
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
A class for managing temporary objects.
"buffered" : (MPI_Bsend, MPI_Recv)
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))
Vector< Cmpt > & removeCollinear(const Vector< Cmpt > &unitVec)
Inplace removal of components that are collinear to the given unit vector.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
Tensor of scalars, i.e. Tensor<scalar>.
Defines the attributes of an object for which implicit objectRegistry management is supported...
tmp< edgeVectorField > unitLe() const
Return normalised edge length vectors.
SquareMatrix< scalar > scalarSquareMatrix
GeometricField< vector, faPatchField, areaMesh > areaVectorField
static vector areaInvDistSqrWeightedNormalDualEdge(const point &basePoint, const point &rightPoint, const point &leftPoint, const point ¢rePoint)
Do not request registration (bool: false)
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
static tensor rotation_e3e1(const vector &unitAxis1, vector dirn)
const dimensionSet dimArea(sqr(dimLength))
forAllConstIters(mixture.phases(), phase)
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...
RectangularMatrix< scalar > scalarRectangularMatrix
static std::streamsize read(const UPstream::commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, UPstream::Request *req=nullptr)
Read buffer contents from given processor.
vector areaNormal() const
The area normal - with magnitude equal to area of triangle.
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
static constexpr const zero Zero
Global zero (0)
static vector areaInvDistSqrWeightedNormal(const vector &a, const vector &b)