COMP: adapt solveScalar to scalar for GAMG residual calculation

STYLE: use tmp<xyz>::New factory in matrix operations

COMP: fix bad non-access tmp access (in unused faceH method)
This commit is contained in:
Mark Olesen 2023-05-10 14:52:24 +02:00
parent 62a68eeea0
commit c7fc4891ae
7 changed files with 16 additions and 18 deletions

View File

@ -261,7 +261,7 @@ Foam::tmp<Foam::Field<Type>> Foam::LduMatrix<Type, DType, LUType>::residual
const Field<Type>& psi
) const
{
tmp<Field<Type>> trA(new Field<Type>(psi.size()));
auto trA = tmp<Field<Type>>::New(psi.size());
residual(trA.ref(), psi);
return trA;
}

View File

@ -142,8 +142,8 @@ Foam::LduMatrix<Type, DType, LUType>::faceH(const Field<Type>& psi) const
const labelUList& l = lduAddr().lowerAddr();
const labelUList& u = lduAddr().upperAddr();
tmp<Field<Type>> tfaceHpsi(new Field<Type> (Lower.size()));
Field<Type> & faceHpsi = tfaceHpsi();
auto tfaceHpsi = tmp<Field<Type>>::New(Lower.size());
auto& faceHpsi = tfaceHpsi.ref();
for (label face=0; face<l.size(); face++)
{

View File

@ -297,7 +297,7 @@ Foam::tmp<Foam::Field<Foam::solveScalar>> Foam::lduMatrix::residual
const direction cmpt
) const
{
tmp<solveScalarField> trA(new solveScalarField(psi.size()));
auto trA = tmp<solveScalarField>::New(psi.size());
residual(trA.ref(), psi, source, interfaceBouCoeffs, interfaces, cmpt);
return trA;
}

View File

@ -35,16 +35,11 @@ Description
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::lduMatrix::H(const Field<Type>& psi) const
{
tmp<Field<Type>> tHpsi
(
new Field<Type>(lduAddr().size(), Zero)
);
auto tHpsi = tmp<Field<Type>>::New(lduAddr().size(), Zero);
if (lowerPtr_ || upperPtr_)
{
Field<Type> & Hpsi = tHpsi.ref();
Type* __restrict__ HpsiPtr = Hpsi.begin();
Type* __restrict__ HpsiPtr = tHpsi.ref().begin();
const Type* __restrict__ psiPtr = psi.begin();
@ -88,8 +83,8 @@ Foam::lduMatrix::faceH(const Field<Type>& psi) const
const labelUList& l = lduAddr().lowerAddr();
const labelUList& u = lduAddr().upperAddr();
tmp<Field<Type>> tfaceHpsi(new Field<Type> (Lower.size()));
Field<Type> & faceHpsi = tfaceHpsi.ref();
auto tfaceHpsi = tmp<Field<Type>>::New(Lower.size());
auto& faceHpsi = tfaceHpsi.ref();
for (label face=0; face<l.size(); face++)
{

View File

@ -194,8 +194,8 @@ Foam::tmp<Foam::labelField> Foam::pairGAMGAgglomeration::agglomerate
// go through the faces and create clusters
tmp<labelField> tcoarseCellMap(new labelField(nFineCells, -1));
labelField& coarseCellMap = tcoarseCellMap.ref();
auto tcoarseCellMap = tmp<labelField>::New(nFineCells, -1);
auto& coarseCellMap = tcoarseCellMap.ref();
nCoarseCells = 0;
label celli;

View File

@ -254,7 +254,10 @@ void Foam::GAMGSolver::Vcycle
(
coarseSources[leveli],
coarseCorrFields[leveli],
coarseSources[leveli],
ConstPrecisionAdaptor<scalar, solveScalar>
(
coarseSources[leveli]
)(),
interfaceLevelsBouCoeffs_[leveli],
interfaceLevels_[leveli],
cmpt

View File

@ -173,8 +173,8 @@ Foam::tmp<Foam::labelField> Foam::cyclicGAMGInterface::internalFieldTransfer
const cyclicGAMGInterface& nbr = neighbPatch();
const labelUList& nbrFaceCells = nbr.faceCells();
tmp<labelField> tpnf(new labelField(size()));
labelField& pnf = tpnf.ref();
auto tpnf = tmp<labelField>::New(size());
auto& pnf = tpnf.ref();
forAll(pnf, facei)
{