44template<
class Type,
class ResultType,
class CellToFaceOp>
49 const CellToFaceOp& cop,
55 const auto& Sf =
mesh.Sf();
56 const auto& P =
mesh.owner();
57 const auto&
N =
mesh.neighbour();
58 const auto&
pbm =
mesh.boundaryMesh();
74 pfld.patchNeighbourField(slice);
75 isCoupled.
set(pfld.patch().index());
85 const auto& Sfi = Sf.primitiveField();
92 const label nCells =
mesh.nCells();
93 const label nIntFaces =
mesh.nInternalFaces();
95 for (label celli = 0; celli < nCells; celli++)
97 const auto& cFaces =
cells[celli];
98 auto& res = sfi[celli];
100 for (
const label facei : cFaces)
102 if (facei < nIntFaces)
114 if (P[facei] != celli)
118 sfi[celli] += faceVal;
122 const label patchi =
patchID[facei-nIntFaces];
123 const label patchFacei = facei-
pbm[patchi].start();
124 const label offset = nCells+
pbm[patchi].offset();
125 const auto& pSf = Sf.boundaryField()[patchi];
128 if (isCoupled(patchi))
131 const ResultType faceVal
138 vfi[offset+patchFacei]
141 sfi[celli] += faceVal;
146 const ResultType faceVal
152 vfi[offset+patchFacei],
156 sfi[celli] += faceVal;
164 for (label facei=0; facei<P.size(); facei++)
166 const label ownCelli = P[facei];
167 const label neiCelli =
N[facei];
169 const ResultType faceVal
179 sfi[ownCelli] += faceVal;
180 sfi[neiCelli] -= faceVal;
186 const auto& pFaceCells =
mesh.boundary()[patchi].faceCells();
187 const label offset =
mesh.nCells()+
pbm[patchi].offset();
188 const auto& pSf = Sf.boundaryField()[patchi];
191 if (isCoupled(patchi))
196 for (label facei=0; facei<pFaceCells.size(); facei++)
199 const ResultType faceVal
205 vfi[pFaceCells[facei]],
210 sfi[pFaceCells[facei]] += faceVal;
215 for (label facei=0; facei<pFaceCells.size(); facei++)
218 const ResultType faceVal
228 sfi[pFaceCells[facei]] += faceVal;
245template<
class Type,
class FType,
class ResultType,
class CellToFaceOp>
249 const GeometricField<Type, fvPatchField, volMesh>& vf,
250 const GeometricField<FType, fvsPatchField, surfaceMesh>& sadd,
251 const CellToFaceOp& cop,
252 GeometricField<ResultType, fvPatchField, volMesh>& result,
256 const fvMesh&
mesh = vf.mesh();
257 const auto& Sf =
mesh.Sf();
258 const auto& P =
mesh.owner();
259 const auto&
N =
mesh.neighbour();
261 const auto& vfi = vf.primitiveField();
262 auto& sfi = result.primitiveFieldRef();
268 const auto& Sfi = Sf.primitiveField();
269 const auto&
lambda = lambdas.primitiveField();
270 const auto& saddi = sadd.primitiveField();
272 for (label facei=0; facei<P.size(); facei++)
274 const label ownCelli = P[facei];
275 const label neiCelli =
N[facei];
277 const ResultType faceVal
289 sfi[ownCelli] += faceVal;
290 sfi[neiCelli] -= faceVal;
298 const label oldSize = vf.constCast().boundaryEvaluate
300 [](
const auto& pfld, UList<Type>& slice)
304 pfld.patchNeighbourField(slice);
311 const auto& pFaceCells =
mesh.boundary()[patchi].faceCells();
312 const auto& pSf = Sf.boundaryField()[patchi];
313 const auto& pvf = vf.boundaryField()[patchi];
314 const auto& pLambda = lambdas.boundaryField()[patchi];
315 const auto& psadd = sadd.boundaryField()[patchi];
322 const label offset =
mesh.nCells()+pvf.patch().offset();
324 for (label facei=0; facei<pFaceCells.size(); facei++)
327 const ResultType faceVal
333 vfi[pFaceCells[facei]],
339 sfi[pFaceCells[facei]] += faceVal;
344 for (label facei=0; facei<pFaceCells.size(); facei++)
347 const ResultType faceVal
359 sfi[pFaceCells[facei]] += faceVal;
365 vf.constCast().resize(oldSize);
370 result.correctBoundaryConditions();
391 const CellToFaceOp& cop,
397 const auto& Sf =
mesh.Sf();
398 const auto& P =
mesh.owner();
399 const auto&
N =
mesh.neighbour();
408 const auto& Sfi = Sf.primitiveField();
413 for (label facei=0; facei<P.size(); facei++)
415 const label ownCelli = P[facei];
416 const label neiCelli =
N[facei];
418 const ResultType faceVal
432 resulti[ownCelli] += faceVal;
433 resulti[neiCelli] -= faceVal;
447 pfld.patchNeighbourField(slice);
454 const auto& pFaceCells =
mesh.boundary()[patchi].faceCells();
455 const auto& pSf = Sf.boundaryField()[patchi];
466 const label offset =
mesh.nCells()+pvf.patch().offset();
468 for (label facei=0; facei<pFaceCells.size(); facei++)
471 const ResultType faceVal
478 vfi[pFaceCells[facei]],
487 resulti[pFaceCells[facei]] += faceVal;
492 for (label facei=0; facei<pFaceCells.size(); facei++)
495 const ResultType faceVal
509 resulti[pFaceCells[facei]] += faceVal;
525template<
class Type,
class ResultType,
class CombineOp>
529 const GeometricField<Type, fvPatchField, volMesh>& vf,
530 const CombineOp& cop,
531 GeometricField<ResultType, fvPatchField, volMesh>& result
534 const fvMesh&
mesh = vf.mesh();
539 auto& sfi = result.primitiveFieldRef();
542 result.correctBoundaryConditions();
546template<
class Type,
class ResultType,
class CombineOp>
552 const CombineOp& cop,
557 const auto& Sf =
mesh.Sf();
558 const auto& P =
mesh.owner();
559 const auto&
N =
mesh.neighbour();
566 const auto& Sfi = Sf.primitiveField();
568 for (label facei=0; facei<P.size(); facei++)
570 const label ownCelli = P[facei];
571 const label neiCelli =
N[facei];
582 sfi[ownCelli] += ownLs[facei]*faceVal;
583 sfi[neiCelli] -= neiLs[facei]*faceVal;
593 [](
const auto& pfld, UList<Type>& slice)
597 pfld.patchNeighbourField(slice);
604 const auto& pFaceCells =
mesh.boundary()[patchi].faceCells();
605 const auto& pSf = Sf.boundaryField()[patchi];
614 const label offset =
mesh.nCells()+pvf.patch().offset();
616 for (label facei=0; facei<pFaceCells.size(); facei++)
623 vfi[pFaceCells[facei]],
628 sfi[pFaceCells[facei]] += pOwnLs[facei]*faceVal;
633 for (label facei=0; facei<pFaceCells.size(); facei++)
640 vfi[pFaceCells[facei]],
644 sfi[pFaceCells[facei]] += pOwnLs[facei]*faceVal;
657template<
class Type,
class ResultType,
class CellToFaceOp>
663 const CellToFaceOp& cop,
670 const auto& Sf =
mesh.Sf();
671 const auto& P =
mesh.owner();
672 const auto&
N =
mesh.neighbour();
679 const auto& Sfi = Sf.primitiveField();
682 for (label facei=0; facei<P.size(); facei++)
684 const label ownCelli = P[facei];
685 const label neiCelli =
N[facei];
687 const ResultType faceVal
697 sfi[ownCelli] += faceVal;
698 sfi[neiCelli] -= faceVal;
707 [](
const auto& pfld, UList<Type>& slice)
711 pfld.patchNeighbourField(slice);
722 const auto& pFaceCells =
mesh.boundary()[patchi].faceCells();
723 const auto& pSf = Sf.boundaryField()[patchi];
727 const label offset =
mesh.nCells()+pvf.patch().offset();
734 for (label facei=0; facei<pFaceCells.size(); facei++)
736 const label ownCelli = pFaceCells[facei];
739 const ResultType faceVal
750 sfi[ownCelli] += faceVal;
758 for (label facei=0; facei<pFaceCells.size(); facei++)
760 const label ownCelli = pFaceCells[facei];
763 const ResultType faceVal
774 sfi[ownCelli] += faceVal;
790template<
class Type,
class ResultType,
class CellToFaceOp>
794 const GeometricField<Type, fvPatchField, volMesh>& vf,
795 const GeometricField<Type, fvsPatchField, surfaceMesh>& sadd,
797 const CellToFaceOp& cop,
799 GeometricField<ResultType, fvPatchField, volMesh>& result,
803 const fvMesh&
mesh = vf.mesh();
804 const auto& Sf =
mesh.Sf();
805 const auto& P =
mesh.owner();
806 const auto&
N =
mesh.neighbour();
808 const auto& vfi = vf.primitiveField();
809 auto& sfi = result.primitiveFieldRef();
813 const auto& Sfi = Sf.primitiveField();
814 const auto& dc = deltaCoeffs.primitiveField();
815 const auto& saddi = sadd.primitiveField();
817 for (label facei=0; facei<P.size(); facei++)
819 const label ownCelli = P[facei];
820 const label neiCelli =
N[facei];
822 const ResultType faceVal
833 sfi[ownCelli] += faceVal;
834 sfi[neiCelli] -= faceVal;
842 const label oldSize = vf.constCast().boundaryEvaluate
844 [](
const auto& pfld, UList<Type>& slice)
848 pfld.patchNeighbourField(slice);
859 const auto& pFaceCells =
mesh.boundary()[patchi].faceCells();
860 const auto& pSf = Sf.boundaryField()[patchi];
861 const auto& pvf = vf.boundaryField()[patchi];
862 const auto& pdc = deltaCoeffs.boundaryField()[patchi];
863 const auto& psadd = sadd.boundaryField()[patchi];
865 const label offset =
mesh.nCells()+pvf.patch().offset();
872 for (label facei=0; facei<pFaceCells.size(); facei++)
874 const label ownCelli = pFaceCells[facei];
877 const ResultType faceVal
889 sfi[ownCelli] += faceVal;
897 for (label facei=0; facei<pFaceCells.size(); facei++)
899 const label ownCelli = pFaceCells[facei];
902 const ResultType faceVal
914 sfi[ownCelli] += faceVal;
920 vf.constCast().resize(oldSize);
925 result.correctBoundaryConditions();
930template<
class Type,
class GType,
class ResultType,
class CellToFaceOp>
934 const GeometricField<GType, fvPatchField, volMesh>&
gamma,
937 const GeometricField<Type, fvPatchField, volMesh>& vf,
939 const CellToFaceOp& cop,
941 GeometricField<ResultType, fvPatchField, volMesh>& result,
945 const fvMesh&
mesh = vf.mesh();
946 const auto& Sf =
mesh.Sf();
947 const auto& P =
mesh.owner();
948 const auto&
N =
mesh.neighbour();
950 const auto& gammai =
gamma.primitiveField();
951 const auto& vfi = vf.primitiveField();
952 auto& sfi = result.primitiveFieldRef();
956 const auto& Sfi = Sf.primitiveField();
957 const auto& weights = gammaWeights.primitiveField();
958 const auto& dc = deltaCoeffs.primitiveField();
960 for (label facei=0; facei<P.size(); facei++)
962 const label ownCelli = P[facei];
963 const label neiCelli =
N[facei];
965 const ResultType faceVal
980 sfi[ownCelli] += faceVal;
981 sfi[neiCelli] -= faceVal;
989 const label oldSize = vf.constCast().boundaryEvaluate
991 [](
const auto& pfld, UList<Type>& slice)
995 pfld.patchNeighbourField(slice);
1004 (void)
gamma.constCast().boundaryEvaluate
1006 [](
const auto& pfld, UList<GType>& slice)
1010 pfld.patchNeighbourField(slice);
1017 const auto& pFaceCells =
mesh.boundary()[patchi].faceCells();
1018 const auto& pSf = Sf.boundaryField()[patchi];
1019 const auto& pvf = vf.boundaryField()[patchi];
1020 const auto& pdc = deltaCoeffs.boundaryField()[patchi];
1021 const auto& pweights = gammaWeights.boundaryField()[patchi];
1022 const auto& pgamma =
gamma.boundaryField()[patchi];
1024 const label offset =
mesh.nCells()+pvf.patch().offset();
1033 for (label facei=0; facei<pFaceCells.size(); facei++)
1035 const label ownCelli = pFaceCells[facei];
1038 const ResultType faceVal
1047 gammai[offset+facei],
1055 sfi[ownCelli] += faceVal;
1063 for (label facei=0; facei<pFaceCells.size(); facei++)
1065 const label ownCelli = pFaceCells[facei];
1068 const ResultType faceVal
1076 pTraits<GType>::zero,
1080 pTraits<Type>::zero,
1085 sfi[ownCelli] += faceVal;
1091 vf.constCast().resize(oldSize);
1092 gamma.constCast().resize(oldSize);
1097 result.correctBoundaryConditions();
1102template<
class Type,
class GType,
class ResultType,
class CellToFaceOp>
1106 const GeometricField<GType, fvPatchField, volMesh>&
gamma,
1109 const GeometricField<Type, fvPatchField, volMesh>& vf,
1111 const GeometricField<Type, fvsPatchField, surfaceMesh>& sadd,
1113 const CellToFaceOp& cop,
1115 GeometricField<ResultType, fvPatchField, volMesh>& result,
1119 const fvMesh&
mesh = vf.mesh();
1120 const auto& Sf =
mesh.Sf();
1121 const auto& P =
mesh.owner();
1122 const auto&
N =
mesh.neighbour();
1124 const auto& gammai =
gamma.primitiveField();
1125 const auto& vfi = vf.primitiveField();
1126 auto& sfi = result.primitiveFieldRef();
1130 const auto& Sfi = Sf.primitiveField();
1131 const auto& weights = gammaWeights.primitiveField();
1132 const auto& dc = deltaCoeffs.primitiveField();
1133 const auto& saddi = sadd.primitiveField();
1135 for (label facei=0; facei<P.size(); facei++)
1137 const label ownCelli = P[facei];
1138 const label neiCelli =
N[facei];
1140 const ResultType faceVal
1157 sfi[ownCelli] += faceVal;
1158 sfi[neiCelli] -= faceVal;
1166 const label oldSize = vf.constCast().boundaryEvaluate
1168 [](
const auto& pfld, UList<Type>& slice)
1172 pfld.patchNeighbourField(slice);
1181 (void)
gamma.constCast().boundaryEvaluate
1183 [](
const auto& pfld, UList<GType>& slice)
1187 pfld.patchNeighbourField(slice);
1194 const auto& pFaceCells =
mesh.boundary()[patchi].faceCells();
1195 const auto& pSf = Sf.boundaryField()[patchi];
1196 const auto& pvf = vf.boundaryField()[patchi];
1197 const auto& pdc = deltaCoeffs.boundaryField()[patchi];
1198 const auto& pweights = gammaWeights.boundaryField()[patchi];
1199 const auto& pgamma =
gamma.boundaryField()[patchi];
1200 const auto& psadd = sadd.boundaryField()[patchi];
1202 const label offset =
mesh.nCells()+pvf.patch().offset();
1206 for (label facei=0; facei<pFaceCells.size(); facei++)
1208 const label ownCelli = pFaceCells[facei];
1211 const ResultType faceVal
1220 gammai[offset+facei],
1230 sfi[ownCelli] += faceVal;
1238 for (label facei=0; facei<pFaceCells.size(); facei++)
1240 const label ownCelli = pFaceCells[facei];
1243 const ResultType faceVal
1251 pTraits<GType>::zero,
1255 pTraits<Type>::zero,
1262 sfi[ownCelli] += faceVal;
1268 vf.constCast().resize(oldSize);
1269 gamma.constCast().resize(oldSize);
1274 result.correctBoundaryConditions();
1296 const CellToFaceOp& cop,
1303 const auto& Sf =
mesh.Sf();
1304 const auto& P =
mesh.owner();
1305 const auto&
N =
mesh.neighbour();
1314 const auto& Sfi = Sf.primitiveField();
1318 for (label facei=0; facei<P.size(); facei++)
1320 const label ownCelli = P[facei];
1321 const label neiCelli =
N[facei];
1323 const ResultType faceVal
1342 sfi[ownCelli] += faceVal;
1343 sfi[neiCelli] -= faceVal;
1357 pfld.patchNeighbourField(slice);
1372 pfld.patchNeighbourField(slice);
1383 pfld.patchNeighbourField(slice);
1390 const auto& pFaceCells =
mesh.boundary()[patchi].faceCells();
1391 const auto& pSf = Sf.boundaryField()[patchi];
1394 const auto& pweights = gammaWeights.
boundaryField()[patchi];
1398 const label offset =
mesh.nCells()+pvf.patch().offset();
1409 for (label facei=0; facei<pFaceCells.size(); facei++)
1411 const label ownCelli = pFaceCells[facei];
1414 const ResultType faceVal
1423 gamma0i[offset+facei],
1426 gamma1i[offset+facei],
1433 sfi[ownCelli] += faceVal;
1440 for (label facei=0; facei<pFaceCells.size(); facei++)
1442 const label ownCelli = pFaceCells[facei];
1445 const ResultType faceVal
1464 sfi[ownCelli] += faceVal;
1482template<
class Type,
class FType,
class ResultType,
class CellToFaceOp>
1486 const GeometricField<Type, fvPatchField, volMesh>& vf,
1487 const GeometricField<FType, fvsPatchField, surfaceMesh>& sf,
1488 const CellToFaceOp& cop,
1489 GeometricField<ResultType, fvsPatchField, surfaceMesh>& result
1492 const fvMesh&
mesh = vf.mesh();
1493 const auto& Sf =
mesh.Sf();
1494 const auto& P =
mesh.owner();
1495 const auto&
N =
mesh.neighbour();
1497 const auto& vfi = vf.primitiveField();
1501 const auto& Sfi = Sf.primitiveField();
1502 const auto& weight = weights.primitiveField();
1503 const auto& sfi = sf.primitiveField();
1505 auto& resulti = result.primitiveFieldRef();
1507 for (label facei=0; facei<P.size(); facei++)
1509 const label ownCelli = P[facei];
1510 const label neiCelli =
N[facei];
1531 const label oldSize = vf.constCast().boundaryEvaluate
1533 [](
const auto& pfld, UList<Type>& slice)
1537 pfld.patchNeighbourField(slice);
1544 const auto& pFaceCells =
mesh.boundary()[patchi].faceCells();
1545 const auto& pSf = Sf.boundaryField()[patchi];
1546 const auto& pvf = vf.boundaryField()[patchi];
1547 const auto& pweight = weights.boundaryField()[patchi];
1548 const auto& psf = sf.boundaryField()[patchi];
1549 auto& presult = result.boundaryFieldRef()[patchi];
1551 const label offset =
mesh.nCells()+pvf.patch().offset();
1558 for (label facei=0; facei<pFaceCells.size(); facei++)
1566 vfi[pFaceCells[facei]],
1577 for (label facei=0; facei<pFaceCells.size(); facei++)
1586 pTraits<Type>::zero,
1597 vf.constCast().resize(oldSize);
1614 const CellToFaceOp& cop,
1619 const auto& Sf =
mesh.Sf();
1620 const auto& P =
mesh.owner();
1621 const auto&
N =
mesh.neighbour();
1628 const auto& Sfi = Sf.primitiveField();
1633 for (label facei=0; facei<P.size(); facei++)
1635 const label ownCelli = P[facei];
1636 const label neiCelli =
N[facei];
1665 pfld.patchNeighbourField(slice);
1677 pfld.patchNeighbourField(slice);
1684 const auto& pFaceCells =
mesh.boundary()[patchi].faceCells();
1685 const auto& pSf = Sf.boundaryField()[patchi];
1691 const label offset =
mesh.nCells()+pvf0.patch().offset();
1693 if (pvf0.coupled() || pvf1.coupled())
1700 for (label facei=0; facei<pFaceCells.size(); facei++)
1709 vf0i[pFaceCells[facei]],
1712 vf1i[pFaceCells[facei]],
1721 for (label facei=0; facei<pFaceCells.size(); facei++)
const polyBoundaryMesh & pbm
const Mesh & mesh() const noexcept
Return const reference to mesh.
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content.
Generic GeometricField class.
this_type & constCast() const noexcept
Return non-const reference to this field.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
label boundaryEvaluate(const Cop &cop)
Evaluate boundary functions using the field storage:
void correctBoundaryConditions()
Correct boundary field.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
A non-owning sub-view of a List (allocated or unallocated storage).
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of entries in the list.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void set(const bitSet &bitset)
Set specified bits from another bitset.
Mesh data needed to do the Finite Volume discretisation.
A traits class, which is primarily used for primitives and vector-space.
Surface integrate surfaceField creating a volField. Surface sum a surfaceField creating a volField.
Namespace of functions to calculate explicit derivatives.
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
void GaussOp(const surfaceScalarField &lambdas, const GeometricField< Type, fvPatchField, volMesh > &vf, const CombineOp &cop, GeometricField< ResultType, fvPatchField, volMesh > &result)
void surfaceOp(const GeometricField< Type, fvPatchField, volMesh > &vf, const surfaceVectorField &ownLs, const surfaceVectorField &neiLs, const CombineOp &cop, GeometricField< ResultType, fvPatchField, volMesh > &result)
tmp< GeometricField< Type, fvPatchField, volMesh > > surfaceSum(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
void surfaceSnSum(const surfaceScalarField &deltaCoeffs, const GeometricField< Type, fvPatchField, volMesh > &vf, const CellToFaceOp &cop, GeometricField< ResultType, fvPatchField, volMesh > &result, const bool doCorrectBoundaryConditions)
sum of snGrad
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
static void doCorrectBoundaryConditions(bool correctBCs, VolumeField< Type > &field)
static constexpr const zero Zero
Global zero (0).
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
#define forAll(list, i)
Loop across all elements in list.
const Vector< label > N(dict.get< Vector< label > >("N"))