57 <<
"addressing (" << addr.
size()
58 <<
") and field (" << pf.
size() <<
") are different sizes" <<
endl
64 intf[addr[facei]] += pf[facei];
73 const labelUList& addr,
74 const tmp<Field<Type2>>& tpf,
95 <<
"addressing (" << addr.
size()
96 <<
") and field (" << pf.
size() <<
") are different sizes" <<
endl
102 intf[addr[facei]] -= pf[facei];
111 const labelUList& addr,
112 const tmp<Field<Type2>>& tpf,
128 for (label fieldi = 0; fieldi < nMatrices(); ++fieldi)
130 const auto& bpsi = this->
psi(fieldi).boundaryField();
134 const label patchi = globalPatchID(fieldi, ptfi);
140 lduAddr().patchAddr(patchi),
141 internalCoeffs_[patchi].
component(solveCmpt),
153 for (label fieldi = 0; fieldi < nMatrices(); fieldi++)
155 const auto& bpsi = this->
psi(fieldi).boundaryField();
159 const label patchi = globalPatchID(fieldi, ptfi);
164 lduAddr().patchAddr(patchi),
165 cmptAv(internalCoeffs_[patchi]),
181 for (label fieldi = 0; fieldi < nMatrices(); fieldi++)
183 const auto& bpsi = this->
psi(fieldi).boundaryField();
187 const fvPatchField<Type>& ptf = bpsi[ptfi];
189 const label patchi = globalPatchID(fieldi, ptfi);
193 const Field<Type>& pbc = boundaryCoeffs_[patchi];
199 lduAddr().patchAddr(patchi),
206 const tmp<Field<Type>> tpnf = ptf.patchNeighbourField();
207 const Field<Type>& pnf = tpnf();
209 const labelUList& addr = lduAddr().patchAddr(patchi);
213 source[addr[facei]] +=
224template<
template<
class>
class ListType>
227 const labelUList& cellLabels,
228 const ListType<Type>& values
231 const fvMesh&
mesh = psi_.mesh();
241 GeometricField<Type, fvPatchField, volMesh>&
251 if (symmetric() || asymmetric())
255 const label celli = cellLabels[i];
256 const Type& value =
values[i];
258 for (
const label facei :
cells[celli])
260 const label patchi =
mesh.boundaryMesh().patchID(facei);
266 if (celli == own[facei])
268 source_[nei[facei]] -=
upper()[facei]*value;
272 source_[own[facei]] -=
upper()[facei]*value;
275 upper()[facei] = 0.0;
279 if (celli == own[facei])
281 source_[nei[facei]] -=
lower()[facei]*value;
285 source_[own[facei]] -=
upper()[facei]*value;
288 upper()[facei] = 0.0;
289 lower()[facei] = 0.0;
294 if (internalCoeffs_[patchi].size())
296 const label patchFacei =
297 mesh.boundaryMesh()[patchi].whichFace(facei);
299 internalCoeffs_[patchi][patchFacei] = Zero;
300 boundaryCoeffs_[patchi][patchFacei] = Zero;
311 const label celli = cellLabels[i];
312 const Type& value =
values[i];
315 source_[celli] = value*Diag[celli];
323 const auto& bpsi = this->
psi(fieldi).boundaryField();
328 if (bpsi[patchi].useImplicit())
332 Pout<<
"fvMatrix<Type>::checkImplicit "
333 <<
" field:" << this->
psi(fieldi).
name()
335 << this->
psi(fieldi).mesh().
name()
336 <<
" patch:" << bpsi[patchi].patch().name()
347 lduAssemblyName_ = word(
"lduAssembly") + idName;
350 return !idName.empty();
374 <<
"Constructing fvMatrix<Type> for field " << psi_.
name() <<
endl;
393 auto& psiRef = this->
psi(0);
394 const label currentStatePsi = psiRef.eventNo();
395 psiRef.boundaryFieldRef().updateCoeffs();
396 psiRef.eventNo() = currentStatePsi;
405 useImplicit_(
fvm.useImplicit_),
406 lduAssemblyName_(
fvm.lduAssemblyName_),
407 nMatrix_(
fvm.nMatrix_),
408 dimensions_(
fvm.dimensions_),
409 source_(
fvm.source_),
410 internalCoeffs_(
fvm.internalCoeffs_),
411 boundaryCoeffs_(
fvm.boundaryCoeffs_)
414 <<
"Copying fvMatrix<Type> for field " << psi_.
name() <<
endl;
416 if (
fvm.faceFluxCorrectionPtr_)
418 faceFluxCorrectionPtr_ = std::make_unique<faceFluxFieldType>
420 *(fvm.faceFluxCorrectionPtr_)
429 lduMatrix(tmat.constCast(), tmat.movable()),
431 useImplicit_(tmat().useImplicit_),
432 lduAssemblyName_(tmat().lduAssemblyName_),
433 nMatrix_(tmat().nMatrix_),
434 dimensions_(tmat().dimensions_),
435 source_(tmat.constCast().source_, tmat.movable()),
436 internalCoeffs_(tmat.constCast().internalCoeffs_, tmat.movable()),
437 boundaryCoeffs_(tmat.constCast().boundaryCoeffs_, tmat.movable())
440 <<
"Copy/move fvMatrix<Type> for field " << psi_.
name() <<
endl;
442 if (tmat().faceFluxCorrectionPtr_)
446 faceFluxCorrectionPtr_ =
447 std::move(tmat.constCast().faceFluxCorrectionPtr_);
449 else if (tmat().faceFluxCorrectionPtr_)
451 faceFluxCorrectionPtr_ = std::make_unique<faceFluxFieldType>
453 *(tmat().faceFluxCorrectionPtr_)
468 <<
"Destroying fvMatrix<Type> for field " << psi_.name() <<
endl;
470 subMatrices_.clear();
483 interfaces.
setSize(internalCoeffs_.size());
484 for (label fieldi = 0; fieldi < nMatrices(); fieldi++)
489 forAll (fieldInterfaces, patchi)
491 label globalPatchID = lduMeshPtr()->patchMap()[fieldi][patchi];
493 if (globalPatchID != -1)
495 if (fieldInterfaces.
set(patchi))
505 lduMeshPtr()->interfaces()[globalPatchID]
507 bpsi[patchi].internalField()
510 interfaces.
set(globalPatchID, &newInterfaces.
last());
521 lduMeshPtr()->interfaces()[globalPatchID]
523 bpsi[patchi].internalField()
526 interfaces.
set(globalPatchID, &newInterfaces.
last());
536 lduMeshPtr()->interfaces()[globalPatchID]
538 bpsi[patchi].internalField()
541 interfaces.
set(globalPatchID, &newInterfaces.
last());
545 interfaces.
set(globalPatchID, &fieldInterfaces[patchi]);
565 const labelList& patchMap = ptr->patchMap()[fieldi];
569 const label globalPtchId = patchMap[patchi];
571 if (globalPtchId != -1)
574 const Field<Type> saveContrib(fluxContrib[globalPtchId]);
575 contrib[patchi].setSize(psi_.boundaryField()[patchi].size()),
584 psi_.boundaryField()[patchi].patchInternalField()
589 if (this->
psi(fieldi).boundaryField()[patchi].
coupled())
595 psi_.boundaryField()[patchi].patchNeighbourField()
600 else if (globalPtchId == -1)
603 this->
psi(fieldi).
mesh().boundaryMesh()[patchi];
605 if (
pp.masterImplicit())
608 ptr->patchLocalToGlobalMap()[fieldi][patchi];
610 const label nbrPatchId =
pp.neighbPolyPatchID();
613 const Field<Type> saveContrib(fluxContrib[virtualPatch]);
618 coeffs.
setSize(psi_.boundaryField()[patchi].size());
619 nbrCoeffs.setSize(psi_.boundaryField()[nbrPatchId].size());
626 ptr->cellBoundMap()[fieldi][patchi];
629 ptr->cellBoundMap()[fieldi][nbrPatchId];
634 forAll(saveContrib, subFaceI)
637 ptr->facePatchFaceMap()[fieldi][patchi][subFaceI];
638 const label nbrFaceId =
639 ptr->facePatchFaceMap()[fieldi][nbrPatchId][subFaceI];
641 const label nbrCellId = nbrCellIds[subFaceI];
642 const label
cellId = cellIds[subFaceI];
649 nbrCoeffs[nbrFaceId] +=
657 nbrCoeffs[nbrFaceId] +=
675 for (label fieldi = 0; fieldi < nMatrices(); fieldi++)
677 const auto&
psi = this->
psi(fieldi);
684 internalCoeffs_.setSize(interfaceI);
685 boundaryCoeffs_.setSize(interfaceI);
688 for (label fieldi = 0; fieldi < nMatrices(); fieldi++)
690 const auto&
psi = this->
psi(fieldi);
710 for (label i=0; i < nMatrices(); ++i)
721 label globalPatchId = lduMeshPtr()->patchMap()[i][patchI];
722 if (globalPatchId == -1)
727 matrix(i).boundaryCoeffs()[patchI].clone()
732 matrix(i).internalCoeffs()[patchI].clone()
741 label globalPatchId = lduMeshPtr()->patchMap()[i][patchI];
742 if (globalPatchId != -1)
744 if (matrix(i).internalCoeffs().
set(patchI))
749 matrix(i).internalCoeffs()[patchI].clone()
753 if (matrix(i).boundaryCoeffs().
set(patchI))
758 matrix(i).boundaryCoeffs()[patchI].clone()
768 label globalPatchId = lduMeshPtr()->patchMap()[i][patchI];
769 if (globalPatchId == -1)
771 const label implicitPatchId =
772 lduMeshPtr()->patchLocalToGlobalMap()[i][patchI];
776 implicitPatchId, internal[implicit].clone()
780 implicitPatchId,
boundary[implicit].clone()
800 for (label i=0; i < nMatrices(); ++i)
804 label globalPatchId = lduMeshPtr()->patchMap()[i][patchI];
806 if (globalPatchId == -1)
824 const labelList& cellMap = lduMeshPtr()->cellOffsets();
826 label newFaces = lduMeshPtr()->lduAddr().upperAddr().size();
827 label newCells = lduMeshPtr()->lduAddr().size();
834 bool asymmetricAssemby =
false;
835 for (label i=0; i < nMatrices(); ++i)
837 if (matrix(i).asymmetric())
839 asymmetricAssemby =
true;
843 for (label i=0; i < nMatrices(); ++i)
845 if (asymmetricAssemby)
850 lowerAssemb[
faceMap[i][facei]] = lowerSub[facei];
860 upperAssemb[
faceMap[i][facei]] = upperSub[facei];
865 const label globalCelli = cellMap[i] + celli;
866 diagAssemb[globalCelli] = diagSub[celli];
867 sourceAssemb[globalCelli] = sourceSub[celli];
871 if (asymmetricAssemby)
874 lower() = lowerAssemb;
877 upper() = upperAssemb;
892 psi_.mesh().thisDb().objectRegistry::template getObjectPtr
905 psi_.mesh().thisDb().objectRegistry::template cfindObject
921 psi_.mesh().time().timeName(),
922 psi_.mesh().thisDb(),
931 uFieldPtr(nMatrices());
933 for (label fieldi = 0; fieldi < nMatrices(); fieldi++)
939 &
const_cast<fvMesh&
>(meshi)
941 uFieldPtr.
set(fieldi, &this->
psi(fieldi));
946 lduPrimitiveMeshAssembly* lduAssemMeshPtr =
947 new lduPrimitiveMeshAssembly(
io, uMeshPtr);
949 lduAssemMeshPtr->store();
950 lduAssemMeshPtr->update(uFieldPtr);
953 <<
"Creating lduPrimitiveAssembly: " << lduAssemblyName_ <<
endl;
957 psi_.mesh().changing() && !psi_.mesh().upToDatePoints(*ptr)
963 psi_.mesh().setUpToDatePoints(*ptr);
966 <<
"Updating lduPrimitiveAssembly: " << lduAssemblyName_ <<
endl;
971 <<
"Using lduPrimitiveAssembly: " << lduAssemblyName_ <<
endl;
1014 const bool forceReference
1017 if ((forceReference || psi_.needReference()) && celli >= 0)
1030 const bool forceReference
1033 if (forceReference || psi_.needReference())
1035 forAll(cellLabels, celli)
1037 const label
cellId = cellLabels[celli];
1053 const bool forceReference
1056 if (forceReference || psi_.needReference())
1058 forAll(cellLabels, celli)
1060 const label
cellId = cellLabels[celli];
1074 subMatrices_.append(matrix.clone());
1077 if (dimensions_ != matrix.dimensions())
1080 <<
"incompatible dimensions for matrix addition "
1082 <<
"[" << dimensions_ <<
" ] "
1083 <<
" [" << matrix.dimensions() <<
" ]"
1087 for (label fieldi = 0; fieldi < nMatrices(); fieldi++)
1089 if (checkImplicit(fieldi))
1095 internalCoeffs_.clear();
1096 boundaryCoeffs_.clear();
1109 <<
"Relaxing " << psi_.name() <<
" by " <<
alpha <<
endl;
1111 Field<Type>& S = source();
1119 sumMagOffDiag(sumOff);
1122 forAll(psi_.boundaryField(), patchi)
1124 const fvPatchField<Type>& ptf = psi_.boundaryField()[patchi];
1128 const labelUList& pa = lduAddr().patchAddr(patchi);
1129 Field<Type>& iCoeffs = internalCoeffs_[patchi];
1133 const Field<Type>& pCoeffs = boundaryCoeffs_[patchi];
1160 scalar maxNon = 0.0;
1161 scalar sumNon = 0.0;
1164 scalar d = (sumOff[celli] -
D[celli])/
mag(
D[celli]);
1169 maxNon =
max(maxNon, d);
1198 <<
"Matrix dominance test for " << psi_.name() <<
nl
1199 <<
" number of non-dominant cells : " << nNon <<
nl
1200 <<
" maximum relative non-dominance : " << maxNon <<
nl
1201 <<
" average relative non-dominance : " << sumNon <<
nl
1210 D[celli] =
max(
mag(
D[celli]), sumOff[celli]);
1217 forAll(psi_.boundaryField(), patchi)
1223 const labelUList& pa = lduAddr().patchAddr(patchi);
1253 psi_.mesh().data().isFinalIteration()
1256 scalar relaxCoeff = 0;
1258 if (psi_.mesh().relaxEquation(
name, relaxCoeff))
1268 typename GeometricField<Type, fvPatchField, volMesh>::
1274 bFields[patchi].manipulateMatrix(*
this);
1293 forAll(psi_.boundaryField(), patchi)
1301 lduAddr().patchAddr(patchi),
1302 internalCoeffs_[patchi],
1317 "A(" + psi_.name() +
')',
1319 dimensions_/psi_.dimensions()/
dimVol,
1323 tAphi.ref().primitiveFieldRef() =
D()/psi_.mesh().V();
1324 tAphi.ref().correctBoundaryConditions();
1336 "H(" + psi_.name() +
')',
1341 auto& Hphi = tHphi.ref();
1344 for (
direction cmpt=0; cmpt<Type::nComponents; cmpt++)
1346 scalarField psiCmpt(psi_.primitiveField().component(cmpt));
1349 addBoundaryDiag(boundaryDiagCmpt, cmpt);
1350 boundaryDiagCmpt.
negate();
1351 addCmptAvBoundaryDiag(boundaryDiagCmpt);
1353 Hphi.primitiveFieldRef().replace(cmpt, boundaryDiagCmpt*psiCmpt);
1356 Hphi.primitiveFieldRef() +=
lduMatrix::H(psi_.primitiveField()) + source_;
1357 addBoundarySource(Hphi.primitiveFieldRef());
1359 Hphi.primitiveFieldRef() /= psi_.mesh().V();
1360 Hphi.correctBoundaryConditions();
1362 typename Type::labelType validComponents
1364 psi_.mesh().template validComponents<Type>()
1367 for (
direction cmpt=0; cmpt<Type::nComponents; cmpt++)
1369 if (validComponents[cmpt] == -1)
1390 dimensions_/(
dimVol*psi_.dimensions()),
1393 auto& H1_ = tH1.ref();
1397 forAll(psi_.boundaryField(), patchi)
1399 const fvPatchField<Type>& ptf = psi_.boundaryField()[patchi];
1401 if (ptf.coupled() && ptf.size())
1405 lduAddr().patchAddr(patchi),
1412 H1_.primitiveFieldRef() /= psi_.mesh().V();
1413 H1_.correctBoundaryConditions();
1424 if (!psi_.mesh().fluxRequired(psi_.name()))
1427 <<
"flux requested but " << psi_.name()
1428 <<
" not specified in the fluxRequired sub-dictionary"
1433 if (nMatrices() > 1)
1436 <<
"Flux requested but " << psi_.name()
1437 <<
" can't handle multiple fvMatrix."
1443 "flux(" + psi_.name() +
')',
1448 auto& fieldFlux = tfieldFlux.ref();
1449 fieldFlux.setOriented();
1457 forAll(InternalContrib, patchi)
1459 InternalContrib[patchi] =
1462 InternalContrib[patchi],
1463 psi_.boundaryField()[patchi].patchInternalField()
1471 mapContributions(fieldi, fluxInternalContrib, InternalContrib,
true);
1478 forAll(NeighbourContrib, patchi)
1480 if (psi_.boundaryField()[patchi].coupled())
1482 NeighbourContrib[patchi] =
1485 NeighbourContrib[patchi],
1486 psi_.boundaryField()[patchi].patchNeighbourField()
1495 mapContributions(fieldi, fluxBoundaryContrib, NeighbourContrib,
false);
1500 auto& ffbf = fieldFlux.boundaryFieldRef();
1504 ffbf[patchi] = InternalContrib[patchi] - NeighbourContrib[patchi];
1509 if (faceFluxCorrectionPtr_)
1511 fieldFlux += *faceFluxCorrectionPtr_;
1524 return psi_.mesh().solverDict(
name);
1531 return psi_.mesh().solverDict
1533 psi_.select(psi_.mesh().data().isFinalIteration())
1548 if (&psi_ != &(fvmv.psi_))
1551 <<
"different fields"
1555 dimensions_ = fvmv.dimensions_;
1557 source_ = fvmv.source_;
1558 internalCoeffs_ = fvmv.internalCoeffs_;
1559 boundaryCoeffs_ = fvmv.boundaryCoeffs_;
1561 if (faceFluxCorrectionPtr_ && fvmv.faceFluxCorrectionPtr_)
1563 *faceFluxCorrectionPtr_ = *fvmv.faceFluxCorrectionPtr_;
1565 else if (fvmv.faceFluxCorrectionPtr_)
1567 faceFluxCorrectionPtr_ = std::make_unique<faceFluxFieldType>
1569 *fvmv.faceFluxCorrectionPtr_
1573 useImplicit_ = fvmv.useImplicit_;
1574 lduAssemblyName_ = fvmv.lduAssemblyName_;
1591 internalCoeffs_.negate();
1592 boundaryCoeffs_.negate();
1594 if (faceFluxCorrectionPtr_)
1596 faceFluxCorrectionPtr_->negate();
1606 dimensions_ += fvmv.dimensions_;
1608 source_ += fvmv.source_;
1609 internalCoeffs_ += fvmv.internalCoeffs_;
1610 boundaryCoeffs_ += fvmv.boundaryCoeffs_;
1612 useImplicit_ = fvmv.useImplicit_;
1613 lduAssemblyName_ = fvmv.lduAssemblyName_;
1614 nMatrix_ = fvmv.nMatrix_;
1616 if (faceFluxCorrectionPtr_ && fvmv.faceFluxCorrectionPtr_)
1618 *faceFluxCorrectionPtr_ += *fvmv.faceFluxCorrectionPtr_;
1620 else if (fvmv.faceFluxCorrectionPtr_)
1622 faceFluxCorrectionPtr_ = std::make_unique<faceFluxFieldType>
1624 *fvmv.faceFluxCorrectionPtr_
1643 dimensions_ -= fvmv.dimensions_;
1645 source_ -= fvmv.source_;
1646 internalCoeffs_ -= fvmv.internalCoeffs_;
1647 boundaryCoeffs_ -= fvmv.boundaryCoeffs_;
1649 useImplicit_ = fvmv.useImplicit_;
1650 lduAssemblyName_ = fvmv.lduAssemblyName_;
1651 nMatrix_ = fvmv.nMatrix_;
1653 if (faceFluxCorrectionPtr_ && fvmv.faceFluxCorrectionPtr_)
1655 *faceFluxCorrectionPtr_ -= *fvmv.faceFluxCorrectionPtr_;
1657 else if (fvmv.faceFluxCorrectionPtr_)
1659 faceFluxCorrectionPtr_ = std::make_unique<faceFluxFieldType>
1661 -*fvmv.faceFluxCorrectionPtr_
1682 source() -= su.mesh().V()*su.field();
1715 source() += su.mesh().V()*su.field();
1767 dimensions_ *= dsf.dimensions();
1769 source_ *= dsf.field();
1771 forAll(boundaryCoeffs_, patchi)
1775 dsf.mesh().boundary()[patchi].patchInternalField(dsf.field())
1778 internalCoeffs_[patchi] *= pisf;
1779 boundaryCoeffs_[patchi] *= pisf;
1782 if (faceFluxCorrectionPtr_)
1785 <<
"cannot scale a matrix containing a faceFluxCorrection"
1794 const tmp<volScalarField::Internal>& tfld
1819 dimensions_ *= ds.dimensions();
1821 source_ *= ds.value();
1822 internalCoeffs_ *= ds.value();
1823 boundaryCoeffs_ *= ds.value();
1825 if (faceFluxCorrectionPtr_)
1827 *faceFluxCorrectionPtr_ *= ds.value();
1842 if (&mat1.psi() != &mat2.psi())
1845 <<
"Incompatible fields for operation\n "
1846 <<
"[" << mat1.psi().name() <<
"] "
1848 <<
" [" << mat2.psi().name() <<
"]"
1855 && mat1.dimensions() != mat2.dimensions()
1859 <<
"Incompatible dimensions for operation\n "
1860 <<
"[" << mat1.psi().name() << mat1.dimensions()/
dimVolume <<
" ] "
1862 <<
" [" << mat2.psi().name() << mat2.dimensions()/
dimVolume <<
" ]"
1883 <<
"Incompatible dimensions for operation\n "
1884 <<
"[" << mat.psi().name() << mat.dimensions()/
dimVolume <<
" ] "
1886 <<
" [" <<
fld.name() <<
fld.dimensions() <<
" ]"
1903 && mat.dimensions()/
dimVolume != dt.dimensions()
1907 <<
"Incompatible dimensions for operation\n "
1908 <<
"[" << mat.psi().name() << mat.dimensions()/
dimVolume <<
" ] "
1910 <<
" [" << dt.name() << dt.dimensions() <<
" ]"
1923 return mat.
solve(solverControls);
1948 return mat.solve(
name);
1993 tAcorr.ref().faceFluxCorrectionPtr(
nullptr);
2009 tAcorr.
ref().faceFluxCorrectionPtr(
nullptr);
2018Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2029Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2040Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2051Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2062Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2070 tC.ref().source() += su.mesh().V()*su.field();
2075Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2083 tC.ref().source() += tsu().mesh().V()*tsu().field();
2089Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2097 tC.ref().source() += tsu().mesh().V()*tsu().primitiveField();
2103Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2111 tC.ref().source() += su.mesh().V()*su.field();
2116Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2124 tC.ref().source() += tsu().mesh().V()*tsu().field();
2130Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2138 tC.ref().source() += tsu().mesh().V()*tsu().primitiveField();
2144Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2152 tC.ref().source() +=
A.psi().mesh().V()*su.value();
2157Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2165 tC.ref().source() += tC().psi().mesh().V()*su.value();
2170Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2181Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
2192Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2203Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2215Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2228Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2241Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2254Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2268Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2276 tC.ref().source() -= su.mesh().V()*su.field();
2281Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2289 tC.ref().source() -= tsu().mesh().V()*tsu().field();
2295Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2303 tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
2309Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2317 tC.ref().source() -= su.mesh().V()*su.field();
2322Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2330 tC.ref().source() -= tsu().mesh().V()*tsu().field();
2336Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2344 tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
2350Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2358 tC.ref().source() -= su.mesh().V()*su.field();
2363Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2371 tC.ref().source() -= tsu().mesh().V()*tsu().field();
2377Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2385 tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
2391Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2399 tC.ref().source() -= su.mesh().V()*su.field();
2404Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2412 tC.ref().source() -= tsu().mesh().V()*tsu().field();
2418Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2426 tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
2433Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2446Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2459Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2473Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2487Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2495 tC.ref().source() += su.mesh().V()*su.field();
2500Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2508 tC.ref().source() += tsu().mesh().V()*tsu().field();
2514Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2522 tC.ref().source() += tsu().mesh().V()*tsu().primitiveField();
2528Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2536 tC.ref().source() += su.mesh().V()*su.field();
2541Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2549 tC.ref().source() += tsu().mesh().V()*tsu().field();
2555Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2563 tC.ref().source() += tsu().mesh().V()*tsu().primitiveField();
2569Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2578 tC.ref().source() -= su.mesh().V()*su.field();
2583Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2592 tC.ref().source() -= tsu().mesh().V()*tsu().field();
2598Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2607 tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
2613Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2622 tC.ref().source() -= su.mesh().V()*su.field();
2627Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2636 tC.ref().source() -= tsu().mesh().V()*tsu().field();
2642Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2651 tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
2657Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2665 tC.ref().source() -= su.value()*
A.psi().mesh().V();
2670Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2678 tC.ref().source() -= su.value()*tC().psi().mesh().V();
2683Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2691 tC.ref().source() -= su.value()*
A.psi().mesh().V();
2696Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2704 tC.ref().source() -= su.value()*tC().psi().mesh().V();
2709Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2717 tC.ref().source() += su.value()*tC().psi().mesh().V();
2722Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2730 tC.ref().source() += su.value()*tC().psi().mesh().V();
2735Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2744 tC.ref().source() -= su.value()*
A.psi().mesh().V();
2749Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2758 tC.ref().source() -= su.value()*tC().psi().mesh().V();
2764Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2776Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2788Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2800Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2812Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2824Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2836Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2848Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2861Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
2875 auto& Mphi = tMphi.ref();
2880 for (
direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
2884 M.addBoundaryDiag(boundaryDiagCmpt, cmpt);
2885 Mphi.primitiveFieldRef().replace(cmpt, -boundaryDiagCmpt*psiCmpt);
2890 Mphi.primitiveFieldRef() =
Zero;
2893 Mphi.primitiveFieldRef() +=
M.lduMatrix::H(
psi.
field()) +
M.source();
2894 M.addBoundarySource(Mphi.primitiveFieldRef());
2896 Mphi.primitiveFieldRef() /= -
psi.
mesh().V();
2897 Mphi.correctBoundaryConditions();
2903Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
2916Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
2929Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
2942Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
2956Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
2976 <<
fvm.dimensions_ <<
nl
2977 <<
fvm.source_ <<
nl
2978 <<
fvm.internalCoeffs_ <<
nl
2979 <<
fvm.boundaryCoeffs_ <<
endl;
2997 typename E::DiagExpr,
2998 typename E::UpperExpr,
2999 typename E::LowerExpr,
3000 typename E::FaceFluxExpr,
3001 typename E::SourceExpr
3007 useImplicit_(false),
3010 dimensions_(expr.dimensions()),
3016 <<
"Constructing fvMatrix<Type> from expression for field "
3022 expr.evaluate(*
this);
3024 auto& psiRef = this->
psi(0);
3025 const label currentStatePsi = psiRef.eventNo();
3026 psiRef.boundaryFieldRef().updateCoeffs();
3027 psiRef.eventNo() = currentStatePsi;
3046 typename E::DiagExpr,
3047 typename E::UpperExpr,
3048 typename E::LowerExpr,
3049 typename E::FaceFluxExpr,
3050 typename E::SourceExpr
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
static const Foam::dimensionedScalar B("", Foam::dimless, 18.678)
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))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const DynamicField< Type > & field() const noexcept
Return const-reference to the primitive field values.
const Mesh & mesh() const noexcept
Return const reference to mesh.
Container & evaluate(Container &lst) const
Helper: assign to passed in list.
Expression wrap of const reference to fvMatrix.
A field of fields is a PtrList of fields with reference counting.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
void negate()
Inplace negate this field (negative).
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Generic GeometricField class.
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< scalar >::calculatedType())
DimensionedField< scalar, volMesh > Internal
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
@ REGISTER
Request registration (bool: true).
@ 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,...
const word & name() const noexcept
Return the object name.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
bool set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
void setSize(label n)
Alias for resize().
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name).
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A dynamically resizable PtrList with allocation management.
void append(autoPtr< T > &ptr)
Move append an element to the end of the list.
void setSize(const label n)
Same as resize().
A List with indirect addressing. Like IndirectList but does not store addressing.
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.
static int & msgType() noexcept
Message tag of standard messages.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
void setSize(const label n)
Alias for resize().
T & last()
Return reference to the last element of the list.
This boundary condition enforces a cyclic condition between a pair of boundaries, whereby communicati...
This boundary condition enforces a cyclic condition between a pair of boundaries, whereby communicati...
This boundary condition enforces a cyclic condition between a pair of boundaries.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
static bool checking(bool on) noexcept
Turn dimension checking on/off.
Generic dimensioned Type class.
const dimensionSet & dimensions() const noexcept
Return const reference to dimensions.
const word & name() const noexcept
Return const reference to name.
const Type & value() const noexcept
Return const reference to value.
A face is a list of labels corresponding to mesh vertices.
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
void operator-=(const fvMatrix< Type > &)
tmp< Field< Type > > DD() const
Return the matrix Type diagonal.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > flux() const
Return the face-flux field from the matrix.
SolverPerformance< Type > solve(const dictionary &)
Solve returning the solution statistics.
tmp< volScalarField > A() const
Return the central coefficient.
fvMatrix(const GeometricField< Type, fvPatchField, volMesh > &psi, const dimensionSet &ds)
Construct given a field to solve for.
void manipulateMatrix(direction cmp)
Manipulate matrix.
void addToInternalField(const labelUList &addr, const Field< Type2 > &pf, Field< Type2 > &intf) const
Add patch contribution to internal field.
label globalPatchID(const label fieldi, const label patchi) const
void mapContributions(label fieldi, const FieldField< Field, Type > &fluxContrib, FieldField< Field, Type > &contrib, bool internal) const
Add internal and boundary contribution to local patches.
void setReferences(const labelUList &cellLabels, const Type &value, const bool forceReference=false)
Set reference level for solution.
const FieldField< Field, Type > & internalCoeffs() const noexcept
fvBoundary scalar field containing pseudo-matrix coeffs for internal cells
void transferFvMatrixCoeffs()
Transfer lower, upper, diag and source to this fvMatrix.
void relax()
Relax matrix (for steady-state solution).
tmp< volScalarField > H1() const
Return H(1).
void operator+=(const fvMatrix< Type > &)
const fvMatrix< Type > & matrix(const label i) const
void createOrUpdateLduPrimitiveAssembly()
Create or update ldu assembly.
const FieldField< Field, Type > & boundaryCoeffs() const noexcept
fvBoundary scalar field containing pseudo-matrix coeffs for boundary cells
virtual ~fvMatrix()
Destructor.
void setValues(const labelUList &cellLabels, const Type &value)
Set solution in given cells to the specified value and eliminate the corresponding equations from the...
const dimensionSet & dimensions() const noexcept
void operator*=(const volScalarField::Internal &)
void addCmptAvBoundaryDiag(scalarField &diag) const
void addBoundarySource(Field< Type > &source, const bool couples=true) const
void setReference(const label celli, const Type &value, const bool forceReference=false)
Set reference level for solution.
void boundaryManipulate(typename GeometricField< Type, fvPatchField, volMesh >::Boundary &values)
Manipulate based on a boundary field.
void setInterfaces(lduInterfaceFieldPtrsList &, PtrDynList< lduInterfaceField > &newInterfaces)
Set interfaces.
tmp< GeometricField< Type, fvPatchField, volMesh > > H() const
Return the H operation source.
void addBoundaryDiag(scalarField &diag, const direction cmpt) const
void negate()
Inplace negate.
tmp< fvMatrix< Type > > clone() const
Construct and return a clone.
void addFvMatrix(fvMatrix< Type > &matrix)
Add fvMatrix.
tmp< scalarField > D() const
Return the matrix scalar diagonal.
void subtractFromInternalField(const labelUList &addr, const Field< Type2 > &pf, Field< Type2 > &intf) const
Subtract patch contribution from internal field.
const GeometricField< Type, fvPatchField, volMesh > & psi(const label i=0) const
Return psi.
bool checkImplicit(const label fieldi=0)
Name the implicit assembly addressing.
Expression::fvMatrixConstRefWrap< fvMatrix< Type > > expr() const
Wrap value as expression.
lduPrimitiveMeshAssembly * lduMeshPtr()
Access to lduPrimitiveMeshAssembly.
void operator=(const fvMatrix< Type > &)
void setValuesFromList(const labelUList &cellLabels, const ListType< Type > &values)
Set solution in given cells to the specified values.
Field< Type > & source() noexcept
const dictionary & solverDict() const
Return the solver dictionary for psi, taking into account finalIteration.
void setBounAndInterCoeffs()
Manipulate boundary/internal coeffs for coupling.
Mesh data needed to do the Finite Volume discretisation.
virtual bool coupled() const
True if the patch field is coupled.
static const word & extrapolatedCalculatedType() noexcept
The type name for extrapolatedCalculated patch fields combines zero-gradient and calculated.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
virtual tmp< Field< Type > > patchNeighbourField() const
Return patchField on the opposite patch of a coupled patch.
const Field< Type > & primitiveField() const noexcept
Return const-reference to the internal field values.
void clearOut()
Clear additional addressing.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
lduMatrix(const lduMesh &mesh)
Construct (without coefficients) for an LDU addressed mesh.
tmp< scalarField > H1() const
void operator=(const lduMatrix &)
Copy assignment.
tmp< Field< Type > > faceH(const Field< Type > &) const
const lduAddressing & lduAddr() const
Return the LDU addressing.
bool asymmetric() const noexcept
Matrix is asymmetric (ie, full).
const scalarField & diag() const
bool symmetric() const noexcept
Matrix is symmetric.
const scalarField & upper() const
void operator*=(const scalarField &)
tmp< Field< Type > > H(const Field< Type > &) const
void operator+=(const lduMatrix &)
const scalarField & lower() const
void sumMagOffDiag(scalarField &sumOff) const
const lduMesh & mesh() const noexcept
Return the LDU mesh from which the addressing is obtained.
void operator-=(const lduMatrix &)
An assembly of lduMatrix that is specific inter-region coupling through mapped patches.
const labelListListList & cellBoundMap() const
Return patch local sub-face to nbrCellId map.
const labelListList & patchMap() const
Return patchMap.
const labelListListList & facePatchFaceMap() const
Return patch local sub-face to local patch face map.
const labelListList & patchLocalToGlobalMap() const
Return patchLocalToGlobalMap.
void update(UPtrList< GeometricField< Type, fvPatchField, volMesh > > &psis)
Update mappings.
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
A traits class, which is primarily used for primitives and vector-space.
A patch is a list of labels that address the faces in the global face list.
bool store()
Register object with its registry and transfer ownership to the registry.
A class for managing temporary objects.
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
A class for handling words, derived from Foam::string.
const volScalarField & psi
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define DebugInFunction
Report an information message using Foam::Info.
#define InfoInFunction
Report an information message using Foam::Info.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Namespace for handling debugging switches.
const wordList internal
Standard volume internal field types (scalar, vector, tensor, etc).
Namespace of functions to calculate implicit derivatives returning a matrix.
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
void checkMethod(const faMatrix< Type > &, const faMatrix< Type > &, const char *)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
void cmptMin(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< cell > cellList
List of cell.
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh > > cmptAv(const DimensionedField< Type, GeoMesh > &f1)
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
errorManip< error > abort(error &err)
SolverPerformance< Type > solve(faMatrix< Type > &, const dictionary &solverControls)
Solve returning the solution statistics given convergence tolerance.
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
static constexpr const zero Zero
Global zero (0).
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
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...
const dimensionSet dimVolume(pow3(dimLength))
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
UList< label > labelUList
A UList of labels.
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
const dimensionSet dimVol(dimVolume)
Older spelling for dimVolume.
constexpr char nl
The newline '\n' character (0x0a).
const dimensionedScalar & D
#define forAll(list, i)
Loop across all elements in list.
conserve primitiveFieldRef()+