ENH: FDICSmoother: solveScalar support. Fixes #1410.

This commit is contained in:
mattijs
2019-08-27 10:14:43 +01:00
committed by Andrew Heather
parent 5201999a38
commit a19a71c0b7
2 changed files with 17 additions and 21 deletions

View File

@ -26,7 +26,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "FDICSmoother.H" #include "FDICSmoother.H"
#include "FDICPreconditioner.H" #include "DICPreconditioner.H"
#include "PrecisionAdaptor.H" #include "PrecisionAdaptor.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -59,13 +59,13 @@ Foam::FDICSmoother::FDICSmoother
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces interfaces
), ),
rD_(matrix_.diag()), rD_(matrix_.diag().size()),
rDuUpper_(matrix_.upper().size()), rDuUpper_(matrix_.upper().size()),
rDlUpper_(matrix_.upper().size()) rDlUpper_(matrix_.upper().size())
{ {
scalar* __restrict__ rDPtr = rD_.begin(); solveScalar* __restrict__ rDPtr = rD_.begin();
scalar* __restrict__ rDuUpperPtr = rDuUpper_.begin(); solveScalar* __restrict__ rDuUpperPtr = rDuUpper_.begin();
scalar* __restrict__ rDlUpperPtr = rDlUpper_.begin(); solveScalar* __restrict__ rDlUpperPtr = rDlUpper_.begin();
const label* const __restrict__ uPtr = const label* const __restrict__ uPtr =
matrix_.lduAddr().upperAddr().begin(); matrix_.lduAddr().upperAddr().begin();
@ -74,19 +74,12 @@ Foam::FDICSmoother::FDICSmoother
const scalar* const __restrict__ upperPtr = const scalar* const __restrict__ upperPtr =
matrix_.upper().begin(); matrix_.upper().begin();
const label nCells = rD_.size();
const label nFaces = matrix_.upper().size(); const label nFaces = matrix_.upper().size();
for (label face=0; face<nFaces; face++) const scalarField& diag = matrix_.diag();
{ std::copy(diag.begin(), diag.end(), rD_.begin());
rDPtr[uPtr[face]] -= sqr(upperPtr[face])/rDPtr[lPtr[face]];
}
// Generate reciprocal FDIC DICPreconditioner::calcReciprocalD(rD_, matrix_);
for (label cell=0; cell<nCells; cell++)
{
rDPtr[cell] = 1.0/rDPtr[cell];
}
for (label face=0; face<nFaces; face++) for (label face=0; face<nFaces; face++)
{ {
@ -106,8 +99,8 @@ void Foam::FDICSmoother::smooth
const label nSweeps const label nSweeps
) const ) const
{ {
const scalar* const __restrict__ rDuUpperPtr = rDuUpper_.begin(); const solveScalar* const __restrict__ rDuUpperPtr = rDuUpper_.begin();
const scalar* const __restrict__ rDlUpperPtr = rDlUpper_.begin(); const solveScalar* const __restrict__ rDlUpperPtr = rDlUpper_.begin();
const label* const __restrict__ uPtr = const label* const __restrict__ uPtr =
matrix_.lduAddr().upperAddr().begin(); matrix_.lduAddr().upperAddr().begin();
@ -130,7 +123,10 @@ void Foam::FDICSmoother::smooth
cmpt cmpt
); );
rA *= rD_; forAll(rA, i)
{
rA[i] *= rD_[i];
}
const label nFaces = matrix_.upper().size(); const label nFaces = matrix_.upper().size();
for (label face=0; face<nFaces; face++) for (label face=0; face<nFaces; face++)

View File

@ -59,9 +59,9 @@ class FDICSmoother
// Private data // Private data
//- The reciprocal preconditioned diagonal //- The reciprocal preconditioned diagonal
scalarField rD_; solveScalarField rD_;
scalarField rDuUpper_; solveScalarField rDuUpper_;
scalarField rDlUpper_; solveScalarField rDlUpper_;
public: public: