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]]
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)
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"
126 <<
"fvMatrix<Type>::solveSegregated"
127 "(const dictionary& solverControls) : "
128 "solving fvMatrix<Type>"
144 "fvMatrix<Type>::solveSegregated",
155 addBoundarySource(source);
157 typename Type::labelType validComponents
159 psi.mesh().template validComponents<Type>()
164 if (validComponents[cmpt] == -1)
continue;
169 addBoundaryDiag(
diag(), cmpt);
175 boundaryCoeffs_.component(cmpt)
180 internalCoeffs_.component(cmpt)
184 psi.boundaryField().scalarInterfaces();
193 const label startRequest = Pstream::nRequests();
205 updateMatrixInterfaces
220 solverPerf = lduMatrix::solver::New
228 )->solve(psiCmpt, sourceCmpt, cmpt);
235 solverPerfVec.
replace(cmpt, solverPerf);
236 solverPerfVec.solverName() = solverPerf.
solverName();
238 psi.primitiveFieldRef().replace(cmpt, psiCmpt);
242 psi.correctBoundaryConditions();
244 psi.mesh().setSolverPerformance(
psi.name(), solverPerfVec);
246 return solverPerfVec;
259 <<
"fvMatrix<Type>::solveCoupled"
260 "(const dictionary& solverControls) : "
261 "solving fvMatrix<Type>"
276 coupledMatrix.diag() =
diag();
277 coupledMatrix.upper() = upper();
278 coupledMatrix.lower() = lower();
279 coupledMatrix.source() = source();
281 addBoundaryDiag(coupledMatrix.diag(), 0);
282 addBoundarySource(coupledMatrix.source(),
false);
284 coupledMatrix.interfaces() =
psi.boundaryFieldRef().interfaces();
285 coupledMatrix.interfacesUpper() = boundaryCoeffs().
component(0);
286 coupledMatrix.interfacesLower() = internalCoeffs().
component(0);
301 coupledMatrixSolver->solve(
psi)
309 psi.correctBoundaryConditions();
311 psi.mesh().setSolverPerformance(
psi.name(), solverPerf);
323 return psi_.mesh().solve(*
this, solverControls);
331 return solver(solverDict());
338 return solve(fvMat_.solverDict());
358 for (
direction cmpt=0; cmpt<Type::nComponents; cmpt++)
367 boundaryCoeffs_.component(cmpt)
376 res.
component(cmpt) - boundaryDiagCmpt*psiCmpt,
A const Field/List wrapper with possible data conversion.
A field of fields is a PtrList of fields with reference counting.
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.
lduInterfaceFieldPtrsList scalarInterfaces() const
Generic GeometricField class.
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
void replace(const direction d, const GeometricField< cmptType, PatchField, GeoMesh > &gcf)
Replace specified field component with content from another field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
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,...
A non-const Field/List wrapper with possible data conversion.
void size(const label n)
Older name for setAddressableSize.
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
tmp< Field< Type > > residual() const
Return the matrix residual.
SolverPerformance< Type > solve()
Solve returning the solution statistics.
autoPtr< fvSolver > solver()
Construct and return the solver.
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)
SolverPerformance< Type > solveSegregatedOrCoupled(const dictionary &)
Solve segregated or coupled returning the solution statistics.
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.
const dictionary & solverDict() const
Return the solver dictionary taking into account finalIteration.
Abstract base-class for lduMatrix solvers.
OSstream & masterStream(const label communicator)
static constexpr direction nComponents
Number of components in bool is 1.
A traits class, which is primarily used for primitives.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
const volScalarField & psi
Foam::word regionName(Foam::polyMesh::defaultRegion)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static constexpr const zero Zero
Global zero (0)
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
static const char *const typeName
The type name used in ensight case files.