A little discuss about fvMatrix fvMesh lduMatrix lduMesh in OpenFOAMfvMatrix inherit lduMatrix, therefore it has the function of lduMatrix. To have a deeper look at the linear system (E.g. AX = b) we are going to solve, we need to know the matrix A of the linear system. E.g. if we have:
1 | fvScalarMatrix TEqn |
corresponding to equation:
The fvm in OpenFOAM means implicit disretization. Therefore, a linear system of
In fvMatrix.H, there are several access functions called:
1 | // Member Functions |
In lduMatrix, there are several access functions called:
1 | // Member Functions |
The lduMesh_ in lduMatrix is defined as:
1 | //- LDU mesh reference |
So, when you call lduAddr() in lduMatrix, it is actually calls the lduAddr() function in lduMesh class (because of the return of the function).
1 |
|
1 |
|
The lduMesh_ which is defined as:
1 | //- LDU mesh reference |
will be initialized with psi.mesh() which has a type of fvMesh. There is no doubt this is logical cause lduMesh is the base class of fvMesh. Therefore we we call lduAddr() in lduMatrix.H :
1 | //- Return the LDU addressing |
It is actually calling the lduAddr() function in class fvMesh:
1 | const Foam::lduAddressing& Foam::fvMesh::lduAddr() const |
The interesting thing is, in all the constructor of fvMesh, lduPtr_ are all defined as a nullptr. Therefore, the if loop has to run first. After the first run of the if loop, it will not be called again cause lduPtr_ is not a nullptr anymore. The *this here represents the fvMesh class objects. The lduPtr_ is defined in fvMesh.H as:
1 | mutable fvMeshLduAddressing* lduPtr_; |
In fvMeshLduAddressing.H, there will be LDU addressing informations:
1 | // Member Functions |
To conclude, TEqn which has a type of fvScalarMatrix (actually fvMatrix<Scalar>) will be used here. There are several cases can happen:
If we call
TEqn.dimensions(), functiondimensions()in classfvMatrixwill be called. This is the same for functionpsi(),source(),internalCoeffs(),boundaryCoeffs()andfaceFluxCorrectionPtr().If we call
TEqn.mesh(), functionmesh()in classlduMatrixwill be called. This is the same forlower(),diag()andupper(). The last three functions are always used in peeping the coefficients in matrix of the linear equation.If we call
TEqn.lduAddr(), functionlduAddr()inlduMatrixwill be called first. Then, we will have a tunnel to check some mesh LDU addressing. As what has been mentioned,lduMesh_will be initilized with a type offvMesh. So, it will call thelduAddr()function infvMeshclass, which will return a objects of type offvMeshLduAddressing. Then we can further call the access functionlowerAddr(),upperAddr(),patchAddr(const label i)andpatchSchedule()infvMeshLduAddressingclass. It should be noted thatfvMeshLduAddressingis a subclass oflduAddressing. Therefore, in functionlduAddr(), the return type islduAddressing&.