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
135 fvMat_.addBoundaryDiag(fvMat_.diag(), 0);
138 fvMat_.addBoundarySource(totalSource,
false);
141 solver_->read(solverControls);
145 psi.primitiveFieldRef(),
154 fvMat_.diag() = saveDiag;
156 psi.correctBoundaryConditions();
158 psi.mesh().data().setSolverPerformance(
psi.name(), solverPerf);
173 <<
"fvMatrix<scalar>::solveSegregated" 174 "(const dictionary& solverControls) : " 175 "solving fvMatrix<scalar>" 193 if (psi_.
mesh().fluxRequired(psi_.
name()))
217 PtrDynList<lduInterfaceField> newInterfaces;
220 interfaces = this->
psi(0).boundaryField().scalarInterfaces();
227 tmp<scalarField> tpsi;
232 const_cast<GeometricField<scalar, fvPatchField, volMesh>&
> 243 for (label fieldi = 0; fieldi <
nMatrices(); fieldi++)
246 const auto& psiInternal = this->
psi(fieldi).primitiveField();
248 forAll(psiInternal, localCellI)
250 psi[cellOffset + localCellI] = psiInternal[localCellI];
265 )->solve(
psi, totalSource);
269 for (label fieldi = 0; fieldi <
nMatrices(); fieldi++)
272 const_cast<GeometricField<scalar, fvPatchField, volMesh>&
> 279 forAll(psiInternal, localCellI)
281 psiInternal[localCellI] =
psi[localCellI + cellOffset];
295 if (psi_.
mesh().fluxRequired(psi_.
name()))
311 for (label fieldi = 0; fieldi <
nMatrices(); fieldi++)
314 const_cast<GeometricField<scalar, fvPatchField, volMesh>&
> 319 localPsi.correctBoundaryConditions();
320 localPsi.mesh().data().setSolverPerformance
338 ConstPrecisionAdaptor<solveScalar, scalar> tpsi(psif);
341 tmp<solveScalarField> tres
346 source_ - boundaryDiag*psif,
353 ConstPrecisionAdaptor<scalar, solveScalar> tres_s(tres);
365 "H(" + psi_.
name() +
')',
370 auto& Hphi = tHphi.ref();
375 Hphi.primitiveFieldRef() /= psi_.
mesh().V();
376 Hphi.correctBoundaryConditions();
392 auto& H1_ = tH1.ref();
397 H1_.primitiveFieldRef() /= psi_.
mesh().V();
398 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
conserve primitiveFieldRef()+
#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)
const Mesh & mesh() const noexcept
Return mesh.
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.
lduPrimitiveMeshAssembly * lduMeshPtr()
Access to lduPrimitiveMeshAssembly.
OSstream & masterStream(const label communicator)
Return OSstream for output operations on the master process only, Snull on other processes.
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))
A scalar instance of fvMatrix.
autoPtr< fvSolver > solver()
Construct and return the solver.
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.
const dimensionSet & dimensions() const noexcept
Return dimensions.
static constexpr const zero Zero
Global zero (0)