41 if (psi_.needReference())
43 if (Pstream::master())
45 internalCoeffs_[
patchi][facei].component(cmpt) +=
46 diag()[psi_.mesh().boundary()[
patchi].faceCells()[facei]];
48 boundaryCoeffs_[
patchi][facei].component(cmpt) +=
49 diag()[psi_.mesh().boundary()[
patchi].faceCells()[facei]]
64 Info(this->mesh().comm())
65 <<
"fvMatrix<Type>::solve(const dictionary& solverControls) : "
66 "solving fvMatrix<Type>"
81 if (
type ==
"segregated")
83 return solveSegregated(solverControls);
85 else if (
type ==
"coupled")
87 return solveCoupled(solverControls);
94 ) <<
"Unknown type " <<
type
95 <<
"; currently supported solver types are segregated and coupled"
111 Info(this->mesh().comm())
112 <<
"fvMatrix<Type>::solveSegregated"
113 "(const dictionary& solverControls) : "
114 "solving fvMatrix<Type>"
123 "fvMatrix<Type>::solveSegregated",
134 addBoundarySource(source);
136 typename Type::labelType validComponents
138 psi.mesh().template validComponents<Type>()
141 for (
direction cmpt=0; cmpt<Type::nComponents; cmpt++)
143 if (validComponents[cmpt] == -1)
continue;
148 addBoundaryDiag(
diag(), cmpt);
154 boundaryCoeffs_.component(cmpt)
159 internalCoeffs_.component(cmpt)
163 psi.boundaryField().scalarInterfaces();
177 updateMatrixInterfaces
197 )->solve(psiCmpt, sourceCmpt, cmpt);
201 solverPerf.
print(
Info(this->mesh().comm()));
204 solverPerfVec.
replace(cmpt, solverPerf);
205 solverPerfVec.solverName() = solverPerf.
solverName();
207 psi.primitiveFieldRef().replace(cmpt, psiCmpt);
211 psi.correctBoundaryConditions();
215 return solverPerfVec;
227 Info(this->mesh().comm())
228 <<
"fvMatrix<Type>::solveCoupled"
229 "(const dictionary& solverControls) : "
230 "solving fvMatrix<Type>"
238 coupledMatrix.diag() =
diag();
239 coupledMatrix.upper() = upper();
240 coupledMatrix.lower() = lower();
241 coupledMatrix.source() = source();
243 addBoundaryDiag(coupledMatrix.diag(), 0);
244 addBoundarySource(coupledMatrix.source(),
false);
246 coupledMatrix.interfaces() =
psi.boundaryFieldRef().interfaces();
247 coupledMatrix.interfacesUpper() = boundaryCoeffs().
component(0);
248 coupledMatrix.interfacesLower() = internalCoeffs().
component(0);
263 coupledMatrixSolver->solve(
psi)
268 solverPerf.
print(
Info(this->mesh().comm()));
271 psi.correctBoundaryConditions();
285 psi_.mesh().solution().solverDict
289 !psi_.mesh().schemes().steady()
290 && solutionControl::finalIteration(psi_.mesh())
302 fvMat_.psi_.mesh().solution().solverDict
306 !fvMat_.psi_.mesh().schemes().steady()
319 psi_.mesh().solution().solverDict
321 !psi_.mesh().schemes().steady()
335 psi_.mesh().solution().solverDict
339 !psi_.mesh().schemes().steady()
356 for (
direction cmpt=0; cmpt<Type::nComponents; cmpt++)
358 scalarField psiCmpt(psi_.primitiveField().component(cmpt));
365 boundaryCoeffs_.component(cmpt)
374 res.
component(cmpt) - boundaryDiagCmpt*psiCmpt,
376 psi_.boundaryField().scalarInterfaces(),
402 const tmp<fvMatrix<Type>>& tfvm,
406 SolverPerformance<Type> solverPerf =
407 const_cast<fvMatrix<Type>&
>(tfvm()).
solve(
name);
424 SolverPerformance<Type> solverPerf =
425 const_cast<fvMatrix<Type>&
>(tfvm()).
solve();
void replace(const direction, const UList< cmptType > &)
Replace a component field of the field.
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Generic GeometricField class.
void replace(const direction, const GeometricField< cmptType, PatchField, GeoMesh > &)
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
LduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
DemandDrivenMeshObject to store the solver performance residuals of all the fields of the type it is ...
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A list of keyword definitions, which are a keyword followed by any number of values (e....
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T, if not found return the given default.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
SolverPerformance< Type > solve()
Solve returning the solution statistics.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
autoPtr< fvSolver > solver()
Construct and return the solver.
SolverPerformance< Type > solve(const dictionary &)
Solve segregated or coupled returning the solution statistics.
SolverPerformance< Type > solve()
Solve returning the solution statistics.
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.
SolverPerformance< Type > solveCoupled(const dictionary &)
Solve coupled returning the solution statistics.
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.
Abstract base-class for lduMatrix solvers.
void residual(scalarField &rA, const scalarField &psi, const scalarField &source, const FieldField< Field, scalar > &interfaceBouCoeffs, const lduInterfaceFieldPtrsList &interfaces, const direction cmpt) const
Traits class for primitives.
static bool finalIteration(const objectRegistry ®istry)
Lookup solutionControl from the objectRegistry and return finalIter.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
A class for handling words, derived from string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
const volScalarField & psi
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
SolverPerformance< Type > solve(fvMatrix< Type > &, const word &)
Solve returning the solution statistics given convergence tolerance.