faMatrix< Type > Class Template Reference

A special matrix type and solver, designed for finite area solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise. More...

Classes

class  faSolver
 

Public Types

typedef GeometricField< Type, faPatchField, areaMeshpsiFieldType
 Field type for psi. More...
 
typedef GeometricField< Type, faePatchField, edgeMeshfaceFluxFieldType
 Field type for face flux (for non-orthogonal correction) More...
 
typedef GeometricField< Type, faePatchField, edgeMesh > * faceFluxFieldPtrType
 Declare return type of the faceFluxCorrectionPtr() function. More...
 

Public Member Functions

 ClassName ("faMatrix")
 
 faMatrix (const GeometricField< Type, faPatchField, areaMesh > &psi, const dimensionSet &ds)
 Construct given a field to solve for. More...
 
 faMatrix (const faMatrix< Type > &)
 Copy construct. More...
 
 faMatrix (const GeometricField< Type, faPatchField, areaMesh > &psi, Istream &is)
 Construct from Istream given field to solve for. More...
 
tmp< faMatrix< Type > > clone () const
 Clone. More...
 
virtual ~faMatrix ()
 Destructor. More...
 
const GeometricField< Type, faPatchField, areaMesh > & psi () const
 
const dimensionSetdimensions () const
 
Field< Type > & source ()
 
const Field< Type > & source () const
 
const FieldField< Field, Type > & internalCoeffs () const
 
FieldField< Field, Type > & internalCoeffs ()
 
const FieldField< Field, Type > & boundaryCoeffs () const
 
FieldField< Field, Type > & boundaryCoeffs ()
 
faceFluxFieldPtrTypefaceFluxCorrectionPtr ()
 Return pointer to face-flux non-orthogonal correction field. More...
 
bool hasFaceFluxCorrection () const noexcept
 True if face-flux non-orthogonal correction field exists. More...
 
void setValues (const labelUList &faceLabels, const Type &value)
 
void setValues (const labelUList &faceLabels, const UList< Type > &values)
 
void setValues (const labelUList &faceLabels, const UIndirectList< Type > &values)
 
void setReference (const label facei, const Type &value, const bool forceReference=false)
 Set reference level for solution. More...
 
void setReferences (const labelUList &faceLabels, const Type &value, const bool forceReference=false)
 Set reference level for solution. More...
 
void setReferences (const labelUList &faceLabels, const UList< Type > &values, const bool forceReference=false)
 Set reference level for solution. More...
 
void setComponentReference (const label patchi, const label facei, const direction cmpt, const scalar value)
 
void relax (const scalar alpha)
 Relax matrix (for steady-state solution). More...
 
void relax ()
 Relax matrix (for steady-state solution). More...
 
SolverPerformance< Type > solve (const dictionary &)
 Solve returning the solution statistics. More...
 
SolverPerformance< Type > solve ()
 Solve returning the solution statistics. More...
 
tmp< Field< Type > > residual () const
 Return the matrix residual. More...
 
tmp< scalarFieldD () const
 Return the matrix diagonal. More...
 
tmp< areaScalarFieldA () const
 Return the central coefficient. More...
 
tmp< GeometricField< Type, faPatchField, areaMesh > > H () const
 Return the H operation source. More...
 
tmp< GeometricField< Type, faePatchField, edgeMesh > > flux () const
 Return the face-flux field from the matrix. More...
 
void operator= (const faMatrix< Type > &)
 
void operator= (const tmp< faMatrix< Type >> &)
 
void negate ()
 
void operator+= (const faMatrix< Type > &)
 
void operator+= (const tmp< faMatrix< Type >> &)
 
void operator-= (const faMatrix< Type > &)
 
void operator-= (const tmp< faMatrix< Type >> &)
 
void operator+= (const GeometricField< Type, faPatchField, areaMesh > &)
 
void operator+= (const tmp< GeometricField< Type, faPatchField, areaMesh >> &)
 
void operator-= (const GeometricField< Type, faPatchField, areaMesh > &)
 
void operator-= (const tmp< GeometricField< Type, faPatchField, areaMesh >> &)
 
void operator+= (const dimensioned< Type > &)
 
void operator-= (const dimensioned< Type > &)
 
void operator*= (const areaScalarField &)
 
void operator*= (const tmp< areaScalarField > &)
 
void operator*= (const dimensioned< scalar > &)
 
template<>
void setComponentReference (const label patchI, const label edgeI, const direction, const scalar value)
 
template<>
Foam::solverPerformance solve (const dictionary &solverControls)
 
template<>
Foam::tmp< Foam::scalarFieldresidual () const
 
template<>
Foam::tmp< Foam::areaScalarFieldH () const
 
template<>
void setComponentReference (const label patchi, const label facei, const direction, const scalar value)
 
template<>
SolverPerformance< scalar > solve (const dictionary &)
 
template<>
tmp< scalarFieldresidual () const
 
template<>
tmp< areaScalarFieldH () const
 

Protected Member Functions

template<class Type2 >
void addToInternalField (const labelUList &addr, const Field< Type2 > &pf, Field< Type2 > &intf) const
 Add patch contribution to internal field. More...
 
template<class Type2 >
void addToInternalField (const labelUList &addr, const tmp< Field< Type2 >> &tpf, Field< Type2 > &intf) const
 
template<class Type2 >
void subtractFromInternalField (const labelUList &addr, const Field< Type2 > &pf, Field< Type2 > &intf) const
 Subtract patch contribution from internal field. More...
 
template<class Type2 >
void subtractFromInternalField (const labelUList &addr, const tmp< Field< Type2 >> &tpf, Field< Type2 > &intf) const
 
void addBoundaryDiag (scalarField &diag, const direction cmpt) const
 
void addCmptAvBoundaryDiag (scalarField &diag) const
 
void addBoundarySource (Field< Type > &source, const bool couples=true) const
 
template<template< class > class ListType>
void setValuesFromList (const labelUList &faceLabels, const ListType< Type > &values)
 Set solution in given faces to the specified values. More...
 

Friends

class faSolver
 Declare friendship with the faSolver class. More...
 
Ostreamoperator (Ostream &, const faMatrix< Type > &)
 

Detailed Description

template<class Type>
class Foam::faMatrix< Type >

A special matrix type and solver, designed for finite area solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.

Finite-Area matrix.

Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.

Source files
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.

Definition at line 43 of file faMatricesFwd.H.

Member Typedef Documentation

◆ psiFieldType

Field type for psi.

Definition at line 83 of file faMatrix.H.

◆ faceFluxFieldType

Field type for face flux (for non-orthogonal correction)

Definition at line 88 of file faMatrix.H.

◆ faceFluxFieldPtrType

Declare return type of the faceFluxCorrectionPtr() function.

Definition at line 305 of file faMatrix.H.

Constructor & Destructor Documentation

◆ faMatrix() [1/3]

faMatrix ( const GeometricField< Type, faPatchField, areaMesh > &  psi,
const dimensionSet ds 
)

Construct given a field to solve for.

Definition at line 185 of file faMatrix.C.

References GeometricField< Type, PatchField, GeoMesh >::boundaryFieldRef(), DebugInFunction, Foam::endl(), forAll, psi, GeometricField< Type, PatchField, GeoMesh >::Boundary::updateCoeffs(), and Foam::Zero.

Here is the call graph for this function:

◆ faMatrix() [2/3]

faMatrix ( const faMatrix< Type > &  fam)

Copy construct.

Definition at line 237 of file faMatrix.C.

References DebugInFunction, and Foam::endl().

Here is the call graph for this function:

◆ faMatrix() [3/3]

faMatrix ( const GeometricField< Type, faPatchField, areaMesh > &  psi,
Istream is 
)

Construct from Istream given field to solve for.

Definition at line 265 of file faMatrix.C.

References DebugInFunction, Foam::endl(), forAll, psi, and Foam::Zero.

Here is the call graph for this function:

◆ ~faMatrix()

~faMatrix ( )
virtual

Destructor.

Definition at line 319 of file faMatrix.C.

References DebugInFunction, Foam::deleteDemandDrivenData(), and Foam::endl().

Here is the call graph for this function:

Member Function Documentation

◆ addToInternalField() [1/2]

void addToInternalField ( const labelUList addr,
const Field< Type2 > &  pf,
Field< Type2 > &  intf 
) const
protected

Add patch contribution to internal field.

Definition at line 42 of file faMatrix.C.

References Foam::abort(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, forAll, and UList< T >::size().

Here is the call graph for this function:

◆ addToInternalField() [2/2]

void addToInternalField ( const labelUList addr,
const tmp< Field< Type2 >> &  tpf,
Field< Type2 > &  intf 
) const
protected

Definition at line 66 of file faMatrix.C.

◆ subtractFromInternalField() [1/2]

void subtractFromInternalField ( const labelUList addr,
const Field< Type2 > &  pf,
Field< Type2 > &  intf 
) const
protected

Subtract patch contribution from internal field.

Definition at line 80 of file faMatrix.C.

References Foam::abort(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, forAll, and UList< T >::size().

Here is the call graph for this function:

◆ subtractFromInternalField() [2/2]

void subtractFromInternalField ( const labelUList addr,
const tmp< Field< Type2 >> &  tpf,
Field< Type2 > &  intf 
) const
protected

Definition at line 104 of file faMatrix.C.

◆ addBoundaryDiag()

void addBoundaryDiag ( scalarField diag,
const direction  cmpt 
) const
protected

Definition at line 117 of file faMatrix.C.

References Foam::component(), Foam::diag(), and forAll.

Referenced by faMatrix< Type >::residual().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addCmptAvBoundaryDiag()

void addCmptAvBoundaryDiag ( scalarField diag) const
protected

Definition at line 135 of file faMatrix.C.

References Foam::cmptAv(), Foam::diag(), and forAll.

Here is the call graph for this function:

◆ addBoundarySource()

void addBoundarySource ( Field< Type > &  source,
const bool  couples = true 
) const
protected

Definition at line 151 of file faMatrix.C.

References Foam::cmptMultiply(), faPatchField< Type >::coupled(), forAll, and faPatchField< Type >::patchNeighbourField().

Referenced by faMatrix< Type >::residual().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setValuesFromList()

void setValuesFromList ( const labelUList faceLabels,
const ListType< Type > &  values 
)
protected

Set solution in given faces to the specified values.

Definition at line 333 of file faMatrix.C.

References fvMesh::boundary(), Foam::diag(), primitiveMesh::faceEdges(), forAll, Foam::stringOps::lower(), mesh, fvMesh::neighbour(), fvMesh::owner(), primitiveFieldRef(), psi, Foam::stringOps::upper(), Foam::HashTableOps::values(), and Foam::Zero.

Here is the call graph for this function:

◆ ClassName()

ClassName ( "faMatrix< Type >"  )

◆ clone()

Foam::tmp< Foam::faMatrix< Type > > clone ( ) const

Clone.

Definition at line 309 of file faMatrix.C.

References Foam::New().

Here is the call graph for this function:

◆ psi()

const GeometricField<Type, faPatchField, areaMesh>& psi ( ) const
inline

Definition at line 255 of file faMatrix.H.

Referenced by externalFileSource::addSup(), contactHeatFluxSource::addSup(), jouleHeatingSource::addSup(), externalHeatFluxSource::addSup(), Foam::checkMethod(), optionList::constrain(), and faMatrix< Type >::solve().

Here is the caller graph for this function:

◆ dimensions()

const dimensionSet& dimensions ( ) const
inline

Definition at line 260 of file faMatrix.H.

Referenced by Foam::checkMethod(), and faMatrix< Type >::operator*=().

Here is the caller graph for this function:

◆ source() [1/2]

Field<Type>& source ( )
inline

Definition at line 265 of file faMatrix.H.

◆ source() [2/2]

const Field<Type>& source ( ) const
inline

Definition at line 270 of file faMatrix.H.

◆ internalCoeffs() [1/2]

const FieldField<Field, Type>& internalCoeffs ( ) const
inline

faBoundary scalar field containing pseudo-matrix coeffs for internal cells

Definition at line 277 of file faMatrix.H.

◆ internalCoeffs() [2/2]

FieldField<Field, Type>& internalCoeffs ( )
inline

faBoundary scalar field containing pseudo-matrix coeffs for internal cells

Definition at line 284 of file faMatrix.H.

◆ boundaryCoeffs() [1/2]

const FieldField<Field, Type>& boundaryCoeffs ( ) const
inline

faBoundary scalar field containing pseudo-matrix coeffs for boundary cells

Definition at line 291 of file faMatrix.H.

◆ boundaryCoeffs() [2/2]

FieldField<Field, Type>& boundaryCoeffs ( )
inline

faBoundary scalar field containing pseudo-matrix coeffs for boundary cells

Definition at line 298 of file faMatrix.H.

◆ faceFluxCorrectionPtr()

faceFluxFieldPtrType& faceFluxCorrectionPtr ( )
inline

Return pointer to face-flux non-orthogonal correction field.

Definition at line 308 of file faMatrix.H.

Referenced by gaussLaplacianScheme< Type >::famLaplacian().

Here is the caller graph for this function:

◆ hasFaceFluxCorrection()

bool hasFaceFluxCorrection ( ) const
inlinenoexcept

True if face-flux non-orthogonal correction field exists.

Definition at line 314 of file faMatrix.H.

References bool.

◆ setValues() [1/3]

void setValues ( const labelUList faceLabels,
const Type &  value 
)

Set solution in given faces to the specified value and eliminate the corresponding equations from the matrix.

Definition at line 422 of file faMatrix.C.

◆ setValues() [2/3]

void setValues ( const labelUList faceLabels,
const UList< Type > &  values 
)

Set solution in given faces to the specified values and eliminate the corresponding equations from the matrix.

Definition at line 433 of file faMatrix.C.

References Foam::HashTableOps::values().

Here is the call graph for this function:

◆ setValues() [3/3]

void setValues ( const labelUList faceLabels,
const UIndirectList< Type > &  values 
)

Set solution in given faces to the specified values and eliminate the corresponding equations from the matrix.

Definition at line 444 of file faMatrix.C.

References Foam::HashTableOps::values().

Here is the call graph for this function:

◆ setReference()

void setReference ( const label  facei,
const Type &  value,
const bool  forceReference = false 
)

Set reference level for solution.

Definition at line 455 of file faMatrix.C.

References Foam::diag(), and UPstream::master().

Here is the call graph for this function:

◆ setReferences() [1/2]

void setReferences ( const labelUList faceLabels,
const Type &  value,
const bool  forceReference = false 
)

Set reference level for solution.

Definition at line 474 of file faMatrix.C.

References Foam::diag(), faceId(), and forAll.

Here is the call graph for this function:

◆ setReferences() [2/2]

void setReferences ( const labelUList faceLabels,
const UList< Type > &  values,
const bool  forceReference = false 
)

Set reference level for solution.

Definition at line 497 of file faMatrix.C.

References Foam::diag(), faceId(), forAll, and Foam::HashTableOps::values().

Here is the call graph for this function:

◆ setComponentReference() [1/3]

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

Definition at line 38 of file faMatrixSolve.C.

References Foam::diag().

Here is the call graph for this function:

◆ relax() [1/2]

void relax ( const scalar  alpha)

Relax matrix (for steady-state solution).

alpha = 1 : diagonally equal alpha < 1 : ,, dominant alpha = 0 : do nothing Note: Requires positive diagonal.

Definition at line 519 of file faMatrix.C.

References Foam::constant::atomic::alpha, Foam::cmptMag(), Foam::cmptMin(), Foam::cmptMultiply(), Foam::component(), faPatchField< Type >::coupled(), D, Foam::diag(), forAll, Foam::mag(), Foam::max(), and Foam::Zero.

Referenced by jouleHeatingSource::addSup(), kinematicThinFilm::evolveRegion(), and sensitivitySurface::smoothSensitivities().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ relax() [2/2]

void relax ( )

Relax matrix (for steady-state solution).

alpha is read from controlDict

Definition at line 609 of file faMatrix.C.

References DebugInFunction, Foam::endl(), and relax().

Here is the call graph for this function:

◆ solve() [1/4]

Foam::SolverPerformance< Type > solve ( const dictionary solverControls)

Solve returning the solution statistics.

Solver controls read Istream

Definition at line 55 of file faMatrixSolve.C.

References Field< Type >::component(), DebugInFunction, Foam::diag(), Foam::endl(), dictionary::getOrDefault(), Foam::Info, Foam::New(), SolverPerformance< Type >::print(), psi, refPtr< Container< Type > >::ref(), solve(), and SolverPerformance< Type >::solverName().

Referenced by jouleHeatingSource::addSup(), kinematicThinFilm::evolveRegion(), sensitivitySurface::smoothSensitivities(), and KirchhoffShell::solveDisplacement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ solve() [2/4]

Foam::SolverPerformance< Type > solve ( )

Solve returning the solution statistics.

Solver controls read from faSolution

Definition at line 179 of file faMatrixSolve.C.

References mesh, Foam::name(), and faMatrix< Type >::psi().

Here is the call graph for this function:

◆ residual() [1/3]

◆ D()

Foam::tmp< Foam::scalarField > D ( ) const

Return the matrix diagonal.

Definition at line 625 of file faMatrix.C.

References Foam::diag(), and tmp< T >::ref().

Here is the call graph for this function:

◆ A()

Return the central coefficient.

Definition at line 634 of file faMatrix.C.

References GeometricField< Type, PatchField, GeoMesh >::correctBoundaryConditions(), D, Foam::dimArea, GeometricField< Type, PatchField, GeoMesh >::primitiveFieldRef(), and tmp< T >::ref().

Here is the call graph for this function:

◆ H() [1/3]

Return the H operation source.

Definition at line 661 of file faMatrix.C.

References GeometricField< Type, PatchField, GeoMesh >::correctBoundaryConditions(), Foam::dimArea, lduMatrix::H(), GeometricField< Type, PatchField, GeoMesh >::primitiveFieldRef(), tmp< T >::ref(), and Foam::Zero.

Here is the call graph for this function:

◆ flux()

Return the face-flux field from the matrix.

Definition at line 705 of file faMatrix.C.

References Foam::abort(), GeometricField< Type, PatchField, GeoMesh >::boundaryField(), GeometricField< Type, PatchField, GeoMesh >::boundaryFieldRef(), Foam::cmptMultiply(), lduMatrix::faceH(), Foam::FatalError, FatalErrorInFunction, forAll, GeometricField< Type, PatchField, GeoMesh >::primitiveFieldRef(), and tmp< T >::ref().

Referenced by kinematicThinFilm::evolveRegion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

void operator= ( const faMatrix< Type > &  famv)

Definition at line 787 of file faMatrix.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and lduMatrix::operator=().

Here is the call graph for this function:

◆ operator=() [2/2]

void operator= ( const tmp< faMatrix< Type >> &  tfamv)

Definition at line 820 of file faMatrix.C.

◆ negate()

void negate ( )

Definition at line 828 of file faMatrix.C.

References lduMatrix::negate().

Here is the call graph for this function:

◆ operator+=() [1/5]

void operator+= ( const faMatrix< Type > &  famv)

Definition at line 843 of file faMatrix.C.

References Foam::checkMethod(), and lduMatrix::operator+=().

Here is the call graph for this function:

◆ operator+=() [2/5]

void operator+= ( const tmp< faMatrix< Type >> &  tfamv)

Definition at line 869 of file faMatrix.C.

◆ operator-=() [1/5]

void operator-= ( const faMatrix< Type > &  famv)

Definition at line 877 of file faMatrix.C.

References Foam::checkMethod(), and lduMatrix::operator-=().

Here is the call graph for this function:

◆ operator-=() [2/5]

void operator-= ( const tmp< faMatrix< Type >> &  tfamv)

Definition at line 901 of file faMatrix.C.

◆ operator+=() [3/5]

void operator+= ( const GeometricField< Type, faPatchField, areaMesh > &  su)

Definition at line 910 of file faMatrix.C.

References Foam::checkMethod().

Here is the call graph for this function:

◆ operator+=() [4/5]

void operator+= ( const tmp< GeometricField< Type, faPatchField, areaMesh >> &  tsu)

Definition at line 921 of file faMatrix.C.

◆ operator-=() [3/5]

void operator-= ( const GeometricField< Type, faPatchField, areaMesh > &  su)

Definition at line 932 of file faMatrix.C.

References Foam::checkMethod().

Here is the call graph for this function:

◆ operator-=() [4/5]

void operator-= ( const tmp< GeometricField< Type, faPatchField, areaMesh >> &  tsu)

Definition at line 943 of file faMatrix.C.

◆ operator+=() [5/5]

void operator+= ( const dimensioned< Type > &  su)

Definition at line 954 of file faMatrix.C.

◆ operator-=() [5/5]

void operator-= ( const dimensioned< Type > &  su)

Definition at line 964 of file faMatrix.C.

◆ operator*=() [1/3]

void operator*= ( const areaScalarField vsf)

Definition at line 974 of file faMatrix.C.

References Foam::abort(), faMatrix< Type >::dimensions(), Foam::FatalError, FatalErrorInFunction, forAll, and lduMatrix::operator*=().

Here is the call graph for this function:

◆ operator*=() [2/3]

void operator*= ( const tmp< areaScalarField > &  tvsf)

Definition at line 1000 of file faMatrix.C.

◆ operator*=() [3/3]

void operator*= ( const dimensioned< scalar > &  ds)

Definition at line 1011 of file faMatrix.C.

References lduMatrix::operator*=().

Here is the call graph for this function:

◆ setComponentReference() [2/3]

void setComponentReference ( const label  patchI,
const label  edgeI,
const  direction,
const scalar  value 
)

Definition at line 40 of file faScalarMatrix.C.

References Foam::diag().

Here is the call graph for this function:

◆ solve() [3/4]

Foam::solverPerformance solve ( const dictionary solverControls)

Definition at line 57 of file faScalarMatrix.C.

References Foam::expressions::patchExpr::debug, DebugInFunction, Foam::diag(), Foam::endl(), dictionary::getOrDefault(), Foam::Info, Foam::New(), SolverPerformance< Type >::print(), psi, and solve().

Here is the call graph for this function:

◆ residual() [2/3]

Foam::tmp< Foam::scalarField > residual ( ) const

Definition at line 108 of file faScalarMatrix.C.

References psi, refPtr< Container< Type > >::ref(), and Foam::Zero.

Here is the call graph for this function:

◆ H() [2/3]

Definition at line 137 of file faScalarMatrix.C.

References GeometricField< Type, PatchField, GeoMesh >::correctBoundaryConditions(), Foam::dimArea, H(), DimensionedField< Type, GeoMesh >::mesh(), GeometricField< Type, PatchField, GeoMesh >::primitiveFieldRef(), tmp< T >::ref(), and GeometricField< Type, PatchField, GeoMesh >::ref().

Here is the call graph for this function:

◆ setComponentReference() [3/3]

void setComponentReference ( const label  patchi,
const label  facei,
const  direction,
const scalar  value 
)

◆ solve() [4/4]

SolverPerformance< scalar > solve ( const dictionary )

◆ residual() [3/3]

tmp< scalarField > residual ( ) const

◆ H() [3/3]

tmp< areaScalarField > H ( ) const

Friends And Related Function Documentation

◆ faSolver

friend class faSolver
friend

Declare friendship with the faSolver class.

Definition at line 120 of file faMatrix.H.

◆ operator

Ostream& operator ( Ostream ,
const faMatrix< Type > &   
)
friend

The documentation for this class was generated from the following files: