45 if (psi_.needReference())
47 if (Pstream::master())
49 internalCoeffs_[patchi][facei].component(cmpt) +=
50 diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]];
52 boundaryCoeffs_[patchi][facei].component(cmpt) +=
53 diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]]
63 const dictionary& solverControls
67 if (psi_.mesh().name() != polyMesh::defaultRegion)
76 <<
"fvMatrix<Type>::solveSegregatedOrCoupled" 77 "(const dictionary& solverControls) : " 78 "solving fvMatrix<Type>" 83 if (solverControls.getOrDefault<label>(
"maxIter", -1) == 0)
85 return SolverPerformance<Type>();
88 word
type(solverControls.getOrDefault<word>(
"type",
"segregated"));
90 if (
type ==
"segregated")
92 return solveSegregated(solverControls);
94 else if (
type ==
"coupled")
96 return solveCoupled(solverControls);
101 <<
"Unknown type " <<
type 102 <<
"; currently supported solver types are segregated and coupled" 113 const dictionary& solverControls
119 <<
"Implicit option is not allowed for type: " << Type::typeName
126 <<
"fvMatrix<Type>::solveSegregated" 127 "(const dictionary& solverControls) : " 128 "solving fvMatrix<Type>" 133 solverControls.getOrDefault<
int>
139 auto&
psi = psi_.constCast();
141 SolverPerformance<Type> solverPerfVec
143 "fvMatrix<Type>::solveSegregated",
149 Field<Type> source(source_);
154 addBoundarySource(source);
156 typename Type::labelType validComponents
158 psi.mesh().template validComponents<Type>()
163 if (validComponents[cmpt] == -1)
continue;
168 addBoundaryDiag(
diag(), cmpt);
172 FieldField<Field, scalar> bouCoeffsCmpt
174 boundaryCoeffs_.component(cmpt)
177 FieldField<Field, scalar> intCoeffsCmpt
179 internalCoeffs_.component(cmpt)
183 psi.boundaryField().scalarInterfaces();
189 PrecisionAdaptor<solveScalar, scalar> sourceCmpt_ss(sourceCmpt);
190 ConstPrecisionAdaptor<solveScalar, scalar> psiCmpt_ss(psiCmpt);
192 const label startRequest = UPstream::nRequests();
204 updateMatrixInterfaces
221 psi.name() + pTraits<Type>::componentNames[cmpt],
227 )->
solve(psiCmpt, sourceCmpt, cmpt);
234 solverPerfVec.replace(cmpt, solverPerf);
235 solverPerfVec.solverName() = solverPerf.solverName();
237 psi.primitiveFieldRef().replace(cmpt, psiCmpt);
241 psi.correctBoundaryConditions();
243 psi.mesh().data().setSolverPerformance(
psi.name(), solverPerfVec);
245 return solverPerfVec;
258 <<
"fvMatrix<Type>::solveCoupled" 259 "(const dictionary& solverControls) : " 260 "solving fvMatrix<Type>" 271 auto&
psi = psi_.constCast();
273 LduMatrix<Type, scalar, scalar> coupledMatrix(
psi.mesh());
274 coupledMatrix.diag() =
diag();
275 coupledMatrix.upper() =
upper();
276 coupledMatrix.lower() =
lower();
277 coupledMatrix.source() = source();
279 addBoundaryDiag(coupledMatrix.diag(), 0);
280 addBoundarySource(coupledMatrix.source(),
false);
282 coupledMatrix.interfaces() =
psi.boundaryFieldRef().interfaces();
283 coupledMatrix.interfacesUpper() = boundaryCoeffs().component(0);
284 coupledMatrix.interfacesLower() = internalCoeffs().component(0);
286 autoPtr<typename LduMatrix<Type, scalar, scalar>::solver>
297 SolverPerformance<Type> solverPerf
299 coupledMatrixSolver->solve(
psi)
307 psi.correctBoundaryConditions();
309 psi.mesh().data().setSolverPerformance(
psi.name(), solverPerf);
318 return this->solveSegregatedOrCoupled(solverDict());
328 return psi_.mesh().solve(*
this, solverControls);
336 return solver(solverDict());
343 return solve(fvMat_.solverDict());
365 auto& res = tres.ref();
379 boundaryCoeffs_.component(cmpt)
388 res.component(cmpt) - boundaryDiagCmpt*psiCmpt,
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
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
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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...
Ostream & endl(Ostream &os)
Add newline and flush stream.
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 ...
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
A field of fields is a PtrList of fields with reference counting.
SolverPerformance< Type > solveCoupled(const dictionary &)
Solve coupled returning the solution statistics.
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
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.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Abstract base-class for lduMatrix solvers.
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
SolverPerformance< Type > solveSegregatedOrCoupled()
Solve segregated or coupled returning the solution statistics.
int debug
Static debugging option.
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
void replace(const direction, const FieldField< Field, cmptType > &)
Replace a component field of the field.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
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.
autoPtr< fvSolver > solver()
Construct and return the solver.
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
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...
const volScalarField & psi
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.
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.
tmp< Field< Type > > residual() const
Return the matrix residual.
SolverPerformance< Type > solve()
Solve returning the solution statistics.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
SolverPerformance< scalar > solverPerformance
SolverPerformance instantiated for a scalar.
const dictionary & solverDict() const
Return the solver dictionary for psi, taking into account finalIteration.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)