48 if (psi_.needReference())
50 if (Pstream::master())
52 internalCoeffs_[patchi][facei] +=
53 diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]];
55 boundaryCoeffs_[patchi][facei] +=
56 diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]]
67 const dictionary& solverControls
71 if (psi_.mesh().name() != polyMesh::defaultRegion)
80 <<
"fvMatrix<scalar>::solver(const dictionary& solverControls) : " 81 "solver for fvMatrix<scalar>" 86 addBoundaryDiag(
diag(), 0);
89 psi_.boundaryField().scalarInterfaces();
92 autoPtr<fvMatrix<scalar>::fvSolver> solverPtr
94 new fvMatrix<scalar>::fvSolver
128 auto&
psi = fvMat_.psi().constCast();
131 fvMat_.addBoundaryDiag(fvMat_.diag(), 0);
134 fvMat_.addBoundarySource(totalSource,
false);
137 solver_->read(solverControls);
141 psi.primitiveFieldRef(),
150 fvMat_.diag() = saveDiag;
152 psi.correctBoundaryConditions();
154 psi.mesh().data().setSolverPerformance(
psi.name(), solverPerf);
169 <<
"fvMatrix<scalar>::solveSegregated" 170 "(const dictionary& solverControls) : " 171 "solving fvMatrix<scalar>" 189 if (psi_.
mesh().fluxRequired(psi_.
name()))
213 PtrDynList<lduInterfaceField> newInterfaces;
216 interfaces = this->
psi(0).boundaryField().scalarInterfaces();
223 tmp<scalarField> tpsi;
226 tpsi.ref(psi_.
constCast().primitiveFieldRef());
233 for (label fieldi = 0; fieldi <
nMatrices(); fieldi++)
236 const auto& psiInternal = this->
psi(fieldi).primitiveField();
238 forAll(psiInternal, localCellI)
240 psi[cellOffset + localCellI] = psiInternal[localCellI];
255 )->solve(
psi, totalSource);
259 for (label fieldi = 0; fieldi <
nMatrices(); fieldi++)
262 this->
psi(fieldi).constCast().primitiveFieldRef();
266 forAll(psiInternal, localCellI)
268 psiInternal[localCellI] =
psi[localCellI + cellOffset];
282 if (psi_.
mesh().fluxRequired(psi_.
name()))
298 for (label fieldi = 0; fieldi <
nMatrices(); fieldi++)
300 auto& localPsi = this->
psi(fieldi).constCast();
302 localPsi.correctBoundaryConditions();
303 localPsi.mesh().data().setSolverPerformance
321 ConstPrecisionAdaptor<solveScalar, scalar> tpsi(psif);
324 tmp<solveScalarField> tres
329 source_ - boundaryDiag*psif,
336 ConstPrecisionAdaptor<scalar, solveScalar> tres_s(tres);
348 "H(" + psi_.
name() +
')',
353 auto& Hphi = tHphi.ref();
358 Hphi.primitiveFieldRef() /= psi_.
mesh().V();
359 Hphi.correctBoundaryConditions();
375 auto& H1_ = tH1.ref();
380 H1_.primitiveFieldRef() /= psi_.
mesh().V();
381 H1_.correctBoundaryConditions();
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
const scalarField & diag() const
void size(const label n)
Older name for setAddressableSize.
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
void addBoundaryDiag(scalarField &diag, const direction cmpt) const
void createOrUpdateLduPrimitiveAssembly()
Create or update ldu assembly.
Field< solveScalar > solveScalarField
A list of keyword definitions, which are a keyword followed by a number of values (eg...
const labelList & cellOffsets() const
Return cellOffsets.
const word & name() const noexcept
Return the object name.
void residual(solveScalarField &rA, const solveScalarField &psi, const scalarField &source, const FieldField< Field, scalar > &interfaceBouCoeffs, const lduInterfaceFieldPtrsList &interfaces, const direction cmpt) const
lduInterfaceFieldPtrsList scalarInterfaces() const
Return a list of pointers for each patch field with only those pointing to interfaces being set...
void manipulateMatrix(direction cmp)
Manipulate matrix.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< GeometricField< Type, fvPatchField, volMesh > > H() const
Return the H operation source.
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.
#define addProfiling(Name,...)
Define profiling trigger with specified name and description string. The description is generated by ...
const dimensionSet dimVol(dimVolume)
Older spelling for dimVolume.
tmp< volScalarField > H1() const
Return H(1)
tmp< scalarField > H1() const
#define forAll(list, i)
Loop across all elements in list.
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
const GeometricField< Type, fvPatchField, volMesh > & psi(const label i=0) const
Return psi.
void setSize(const label n)
Alias for resize()
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
SolverPerformance< Type > solve()
Solve returning the solution statistics.
void setInterfaces(lduInterfaceFieldPtrsList &, PtrDynList< lduInterfaceField > &newInterfaces)
Set interfaces.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const scalarField & lower() const
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
void transferFvMatrixCoeffs()
Transfer lower, upper, diag and source to this fvMatrix.
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())
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions and patch type. [Takes current timeN...
bool asymmetric() const noexcept
Matrix is asymmetric (ie, full)
static autoPtr< solver > New(const word &solverName, const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls)
Return a new solver of given type.
int debug
Static debugging option.
this_type & constCast() const noexcept
Return non-const reference to this field.
const dimensionSet & dimensions() const noexcept
Return dimensions.
lduPrimitiveMeshAssembly * lduMeshPtr()
Access to lduPrimitiveMeshAssembly.
const scalarField & upper() const
const lduMesh & mesh() const noexcept
Return the LDU mesh from which the addressing is obtained.
const lduAddressing & lduAddr() const
Return the LDU addressing.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
OSstream & masterStream(int communicator)
Return OSstream for output operations on the master process only, Snull on other processes.
A scalar instance of fvMatrix.
autoPtr< fvSolver > solver()
Construct and return the solver.
const Mesh & mesh() const noexcept
Return const reference to mesh.
void setLduMesh(const lduMesh &m)
Set the LDU mesh containing the addressing.
messageStream Info
Information stream (stdout output on master, null elsewhere)
void addBoundarySource(Field< Type > &source, const bool couples=true) const
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
void setComponentReference(const label patchi, const label facei, const direction cmpt, const scalar value)
Set reference level for a component of the solution on a given patch face.
SolverPerformance< Type > solveSegregated(const dictionary &)
Solve segregated returning the solution statistics.
tmp< Field< Type > > H(const Field< Type > &) const
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
A class for managing temporary objects.
static const word & extrapolatedCalculatedType() noexcept
The type name for extrapolatedCalculated patch fields combines zero-gradient and calculated.
tmp< Field< Type > > residual() const
Return the matrix residual.
void setBounAndInterCoeffs()
Manipulate boundary/internal coeffs for coupling.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
SolverPerformance< scalar > solverPerformance
SolverPerformance instantiated for a scalar.
static constexpr const zero Zero
Global zero (0)