48 if (psi_.needReference())
52 internalCoeffs_[patchi][facei] +=
53 diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]];
55 boundaryCoeffs_[patchi][facei] +=
56 diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]]
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
97 lduMatrix::solver::New
125 solverPerformance::debug
128 auto&
psi = fvMat_.psi().constCast();
131 fvMat_.addBoundaryDiag(fvMat_.diag(), 0);
134 fvMat_.addBoundarySource(totalSource,
false);
137 solver_->read(solverControls);
141 psi.primitiveFieldRef(),
147 solverPerf.
print(
Info.masterStream(fvMat_.mesh().comm()));
150 fvMat_.diag() = saveDiag;
152 psi.correctBoundaryConditions();
154 psi.mesh().data().setSolverPerformance(
psi.name(), solverPerf);
168 Info.masterStream(this->
mesh().comm())
169 <<
"fvMatrix<scalar>::solveSegregated"
170 "(const dictionary& solverControls) : "
171 "solving fvMatrix<scalar>"
179 solverPerformance::debug
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();
A const Field/List wrapper with possible data conversion.
const Mesh & mesh() const noexcept
Return const reference to mesh.
const dimensionSet & dimensions() const noexcept
Return dimensions.
lduInterfaceFieldPtrsList scalarInterfaces() const
Return a list of pointers for each patch field with only those pointing to interfaces being set.
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())
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
const word & name() const noexcept
Return the object name.
void setSize(label n)
Alias for resize().
A dynamically resizable PtrList with allocation management.
void size(const label n)
Older name for setAddressableSize.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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...
Solver class returned by the solver function used for systems in which it is useful to cache the solv...
SolverPerformance< Type > solve()
Solve returning the solution statistics.
autoPtr< fvSolver > solver()
Construct and return the solver.
SolverPerformance< scalar > solve(const dictionary &)
void manipulateMatrix(direction cmp)
Manipulate matrix.
void transferFvMatrixCoeffs()
Transfer lower, upper, diag and source to this fvMatrix.
tmp< volScalarField > H1() const
Return H(1).
void createOrUpdateLduPrimitiveAssembly()
Create or update ldu assembly.
void addBoundarySource(Field< Type > &source, const bool couples=true) const
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.
void setInterfaces(lduInterfaceFieldPtrsList &, PtrDynList< lduInterfaceField > &newInterfaces)
Set interfaces.
tmp< GeometricField< Type, fvPatchField, volMesh > > H() const
Return the H operation source.
tmp< Field< Type > > residual() const
Return the matrix residual.
void addBoundaryDiag(scalarField &diag, const direction cmpt) const
SolverPerformance< Type > solveSegregated(const dictionary &)
Solve segregated returning the solution statistics.
const GeometricField< Type, fvPatchField, volMesh > & psi(const label i=0) const
Return psi.
lduPrimitiveMeshAssembly * lduMeshPtr()
Access to lduPrimitiveMeshAssembly.
void setBounAndInterCoeffs()
Manipulate boundary/internal coeffs for coupling.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
static const word & extrapolatedCalculatedType() noexcept
The type name for extrapolatedCalculated patch fields combines zero-gradient and calculated.
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.
tmp< scalarField > H1() const
const lduAddressing & lduAddr() const
Return the LDU addressing.
bool asymmetric() const noexcept
Matrix is asymmetric (ie, full).
void residual(solveScalarField &rA, const solveScalarField &psi, const scalarField &source, const FieldField< Field, scalar > &interfaceBouCoeffs, const lduInterfaceFieldPtrsList &interfaces, const direction cmpt) const
const scalarField & diag() const
const scalarField & upper() const
void setLduMesh(const lduMesh &m)
Set the LDU mesh containing the addressing.
tmp< Field< Type > > H(const Field< Type > &) const
const scalarField & lower() const
const lduMesh & mesh() const noexcept
Return the LDU mesh from which the addressing is obtained.
const labelList & cellOffsets() const
Return cellOffsets.
OSstream & masterStream(int communicator)
Return OSstream for output operations on the master process only, Snull on other processes.
static word defaultRegion
Return the default region name.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
bool fluxRequired(const word &name) const
Get flux-required for given name, or default.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
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
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
A scalar instance of fvMatrix.
Namespace for handling debugging switches.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Field< solveScalar > solveScalarField
static constexpr const zero Zero
Global zero (0).
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
SolverPerformance< scalar > solverPerformance
SolverPerformance instantiated for a scalar.
const dimensionSet dimVol(dimVolume)
Older spelling for dimVolume.
#define addProfiling(Name,...)
Define profiling trigger with specified name and description string. The description is generated by ...
#define forAll(list, i)
Loop across all elements in list.