mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -284,7 +284,8 @@ $(lduInterfaceFields)/cyclicLduInterfaceField/cyclicLduInterfaceField.C
|
||||
GAMG = $(lduMatrix)/solvers/GAMG
|
||||
$(GAMG)/GAMGSolver.C
|
||||
$(GAMG)/GAMGSolverAgglomerateMatrix.C
|
||||
$(GAMG)/GAMGSolverScalingFactor.C
|
||||
$(GAMG)/GAMGSolverInterpolate.C
|
||||
$(GAMG)/GAMGSolverScale.C
|
||||
$(GAMG)/GAMGSolverSolve.C
|
||||
|
||||
GAMGInterfaces = $(GAMG)/interfaces
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -71,6 +71,7 @@ Foam::GAMGSolver::GAMGSolver
|
||||
postSweepsLevelMultiplier_(1),
|
||||
maxPostSweeps_(4),
|
||||
nFinestSweeps_(2),
|
||||
interpolateCorrection_(false),
|
||||
scaleCorrection_(matrix.symmetric()),
|
||||
directSolveCoarsest_(false),
|
||||
agglomeration_(GAMGAgglomeration::New(matrix_, controlDict_)),
|
||||
@ -174,6 +175,7 @@ void Foam::GAMGSolver::readControls()
|
||||
);
|
||||
controlDict_.readIfPresent("maxPostSweeps", maxPostSweeps_);
|
||||
controlDict_.readIfPresent("nFinestSweeps", nFinestSweeps_);
|
||||
controlDict_.readIfPresent("interpolateCorrection", interpolateCorrection_);
|
||||
controlDict_.readIfPresent("scaleCorrection", scaleCorrection_);
|
||||
controlDict_.readIfPresent("directSolveCoarsest", directSolveCoarsest_);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -46,6 +46,8 @@ SourceFiles
|
||||
GAMGSolverCalcAgglomeration.C
|
||||
GAMGSolverMakeCoarseMatrix.C
|
||||
GAMGSolverOperations.C
|
||||
GAMGSolverInterpolate.C
|
||||
GAMGSolverScale.C
|
||||
GAMGSolverSolve.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -97,6 +99,10 @@ class GAMGSolver
|
||||
//- Number of smoothing sweeps on finest mesh
|
||||
label nFinestSweeps_;
|
||||
|
||||
//- Choose if the corrections should be interpolated after injection.
|
||||
// By default corrections are not interpolated.
|
||||
bool interpolateCorrection_;
|
||||
|
||||
//- Choose if the corrections should be scaled.
|
||||
// By default corrections for symmetric matrices are scaled
|
||||
// but not for asymmetric matrices.
|
||||
@ -154,32 +160,34 @@ class GAMGSolver
|
||||
//- Agglomerate coarse matrix
|
||||
void agglomerateMatrix(const label fineLevelIndex);
|
||||
|
||||
//- Calculate and return the scaling factor from Acf, coarseSource
|
||||
//- Interpolate the correction after injected prolongation
|
||||
void interpolate
|
||||
(
|
||||
scalarField& psi,
|
||||
scalarField& Apsi,
|
||||
const lduMatrix& m,
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
const scalarField& source,
|
||||
const direction cmpt
|
||||
) const;
|
||||
|
||||
//- Calculate and apply the scaling factor from Acf, coarseSource
|
||||
// and coarseField.
|
||||
// At the same time do a Jacobi iteration on the coarseField using
|
||||
// the Acf provided after the coarseField values are used for the
|
||||
// scaling factor.
|
||||
scalar scalingFactor
|
||||
void scale
|
||||
(
|
||||
scalarField& field,
|
||||
const scalarField& source,
|
||||
const scalarField& Acf,
|
||||
const scalarField& D
|
||||
) const;
|
||||
|
||||
//- Calculate Acf and calculate and return the scaling factor.
|
||||
scalar scalingFactor
|
||||
(
|
||||
scalarField& Acf,
|
||||
const lduMatrix& A,
|
||||
scalarField& field,
|
||||
const FieldField<Field, scalar>& interfaceLevelBouCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaceLevel,
|
||||
const scalarField& source,
|
||||
const direction cmpt
|
||||
) const;
|
||||
|
||||
|
||||
//- Initialise the data structures for the V-cycle
|
||||
void initVcycle
|
||||
(
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GAMGSolver.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::GAMGSolver::interpolate
|
||||
(
|
||||
scalarField& psi,
|
||||
scalarField& Apsi,
|
||||
const lduMatrix& m,
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
const scalarField& source,
|
||||
const direction cmpt
|
||||
) const
|
||||
{
|
||||
scalar* __restrict__ psiPtr = psi.begin();
|
||||
|
||||
const label* const __restrict__ uPtr = m.lduAddr().upperAddr().begin();
|
||||
const label* const __restrict__ lPtr = m.lduAddr().lowerAddr().begin();
|
||||
|
||||
const scalar* const __restrict__ diagPtr = m.diag().begin();
|
||||
const scalar* const __restrict__ upperPtr = m.upper().begin();
|
||||
const scalar* const __restrict__ lowerPtr = m.lower().begin();
|
||||
|
||||
Apsi = 0;
|
||||
scalar* __restrict__ ApsiPtr = Apsi.begin();
|
||||
|
||||
m.initMatrixInterfaces
|
||||
(
|
||||
interfaceBouCoeffs,
|
||||
interfaces,
|
||||
psi,
|
||||
Apsi,
|
||||
cmpt
|
||||
);
|
||||
|
||||
register const label nFaces = m.upper().size();
|
||||
for (register label face=0; face<nFaces; face++)
|
||||
{
|
||||
ApsiPtr[uPtr[face]] += lowerPtr[face]*psiPtr[lPtr[face]];
|
||||
ApsiPtr[lPtr[face]] += upperPtr[face]*psiPtr[uPtr[face]];
|
||||
}
|
||||
|
||||
m.updateMatrixInterfaces
|
||||
(
|
||||
interfaceBouCoeffs,
|
||||
interfaces,
|
||||
psi,
|
||||
Apsi,
|
||||
cmpt
|
||||
);
|
||||
|
||||
register const label nCells = m.diag().size();
|
||||
for (register label celli=0; celli<nCells; celli++)
|
||||
{
|
||||
psiPtr[celli] = -ApsiPtr[celli]/(diagPtr[celli]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,38 +28,11 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::GAMGSolver::scalingFactor
|
||||
void Foam::GAMGSolver::scale
|
||||
(
|
||||
scalarField& field,
|
||||
const scalarField& source,
|
||||
const scalarField& Acf,
|
||||
const scalarField& D
|
||||
) const
|
||||
{
|
||||
scalar scalingFactorNum = 0.0;
|
||||
scalar scalingFactorDenom = 0.0;
|
||||
|
||||
forAll(field, i)
|
||||
{
|
||||
scalingFactorNum += source[i]*field[i];
|
||||
scalingFactorDenom += Acf[i]*field[i];
|
||||
|
||||
// While the matrix-multiply done for the scaling it is
|
||||
// possible to perform a point-Jacobi smoothing operation cheaply
|
||||
field[i] += (source[i] - Acf[i])/D[i];
|
||||
}
|
||||
|
||||
vector2D scalingVector(scalingFactorNum, scalingFactorDenom);
|
||||
reduce(scalingVector, sumOp<vector2D>());
|
||||
return scalingVector.x()/stabilise(scalingVector.y(), VSMALL);
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::GAMGSolver::scalingFactor
|
||||
(
|
||||
scalarField& Acf,
|
||||
const lduMatrix& A,
|
||||
scalarField& field,
|
||||
const FieldField<Field, scalar>& interfaceLevelBouCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaceLevel,
|
||||
const scalarField& source,
|
||||
@ -75,13 +48,30 @@ Foam::scalar Foam::GAMGSolver::scalingFactor
|
||||
cmpt
|
||||
);
|
||||
|
||||
return scalingFactor
|
||||
(
|
||||
field,
|
||||
source,
|
||||
Acf,
|
||||
A.diag()
|
||||
);
|
||||
scalar scalingFactorNum = 0.0;
|
||||
scalar scalingFactorDenom = 0.0;
|
||||
|
||||
forAll(field, i)
|
||||
{
|
||||
scalingFactorNum += source[i]*field[i];
|
||||
scalingFactorDenom += Acf[i]*field[i];
|
||||
}
|
||||
|
||||
vector2D scalingVector(scalingFactorNum, scalingFactorDenom);
|
||||
reduce(scalingVector, sumOp<vector2D>());
|
||||
scalar sf = scalingVector.x()/stabilise(scalingVector.y(), VSMALL);
|
||||
|
||||
if (debug >= 2)
|
||||
{
|
||||
Pout<< sf << " ";
|
||||
}
|
||||
|
||||
const scalarField& D = A.diag();
|
||||
|
||||
forAll(field, i)
|
||||
{
|
||||
field[i] = sf*field[i] + (source[i] - sf*Acf[i])/D[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,6 +28,7 @@ License
|
||||
#include "BICCG.H"
|
||||
#include "SubField.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::solverPerformance Foam::GAMGSolver::solve
|
||||
@ -173,23 +174,16 @@ void Foam::GAMGSolver::Vcycle
|
||||
// but not on the coarsest level because it evaluates to 1
|
||||
if (scaleCorrection_ && leveli < coarsestLevel - 1)
|
||||
{
|
||||
scalar sf = scalingFactor
|
||||
scale
|
||||
(
|
||||
coarseCorrFields[leveli],
|
||||
const_cast<scalarField&>(ACf.operator const scalarField&()),
|
||||
matrixLevels_[leveli],
|
||||
coarseCorrFields[leveli],
|
||||
interfaceLevelsBouCoeffs_[leveli],
|
||||
interfaceLevels_[leveli],
|
||||
coarseSources[leveli],
|
||||
cmpt
|
||||
);
|
||||
|
||||
if (debug >= 2)
|
||||
{
|
||||
Pout<< sf << " ";
|
||||
}
|
||||
|
||||
coarseCorrFields[leveli] *= sf;
|
||||
}
|
||||
|
||||
// Correct the residual with the new solution
|
||||
@ -246,7 +240,7 @@ void Foam::GAMGSolver::Vcycle
|
||||
coarseCorrFields[leveli].size()
|
||||
);
|
||||
|
||||
// Only store the preSmoothedCoarseCorrField is pre-smoothing is used
|
||||
// Only store the preSmoothedCoarseCorrField if pre-smoothing is used
|
||||
if (nPreSweeps_)
|
||||
{
|
||||
preSmoothedCoarseCorrField.assign(coarseCorrFields[leveli]);
|
||||
@ -259,38 +253,47 @@ void Foam::GAMGSolver::Vcycle
|
||||
leveli + 1
|
||||
);
|
||||
|
||||
// Scale coarse-grid correction field
|
||||
// but not on the coarsest level because it evaluates to 1
|
||||
if (scaleCorrection_ && leveli < coarsestLevel - 1)
|
||||
{
|
||||
// Create A.psi for this coarse level as a sub-field of Apsi
|
||||
scalarField::subField ACf
|
||||
(
|
||||
Apsi,
|
||||
coarseCorrFields[leveli].size()
|
||||
);
|
||||
// Create A.psi for this coarse level as a sub-field of Apsi
|
||||
scalarField::subField ACf
|
||||
(
|
||||
Apsi,
|
||||
coarseCorrFields[leveli].size()
|
||||
);
|
||||
|
||||
scalar sf = scalingFactor
|
||||
scalarField& ACfRef =
|
||||
const_cast<scalarField&>(ACf.operator const scalarField&());
|
||||
|
||||
if (interpolateCorrection_)
|
||||
{
|
||||
interpolate
|
||||
(
|
||||
const_cast<scalarField&>(ACf.operator const scalarField&()),
|
||||
matrixLevels_[leveli],
|
||||
coarseCorrFields[leveli],
|
||||
ACfRef,
|
||||
matrixLevels_[leveli],
|
||||
interfaceLevelsBouCoeffs_[leveli],
|
||||
interfaceLevels_[leveli],
|
||||
coarseSources[leveli],
|
||||
cmpt
|
||||
);
|
||||
|
||||
|
||||
if (debug >= 2)
|
||||
{
|
||||
Pout<< sf << " ";
|
||||
}
|
||||
|
||||
coarseCorrFields[leveli] *= sf;
|
||||
}
|
||||
|
||||
// Only add the preSmoothedCoarseCorrField is pre-smoothing is used
|
||||
// Scale coarse-grid correction field
|
||||
// but not on the coarsest level because it evaluates to 1
|
||||
if (scaleCorrection_ && leveli < coarsestLevel - 1)
|
||||
{
|
||||
scale
|
||||
(
|
||||
coarseCorrFields[leveli],
|
||||
ACfRef,
|
||||
matrixLevels_[leveli],
|
||||
interfaceLevelsBouCoeffs_[leveli],
|
||||
interfaceLevels_[leveli],
|
||||
coarseSources[leveli],
|
||||
cmpt
|
||||
);
|
||||
}
|
||||
|
||||
// Only add the preSmoothedCoarseCorrField if pre-smoothing is used
|
||||
if (nPreSweeps_)
|
||||
{
|
||||
coarseCorrFields[leveli] += preSmoothedCoarseCorrField;
|
||||
@ -317,36 +320,38 @@ void Foam::GAMGSolver::Vcycle
|
||||
0
|
||||
);
|
||||
|
||||
if (scaleCorrection_)
|
||||
if (interpolateCorrection_)
|
||||
{
|
||||
// Calculate finest level scaling factor
|
||||
scalar fsf = scalingFactor
|
||||
interpolate
|
||||
(
|
||||
finestCorrection,
|
||||
Apsi,
|
||||
matrix_,
|
||||
finestCorrection,
|
||||
interfaceBouCoeffs_,
|
||||
interfaces_,
|
||||
finestResidual,
|
||||
cmpt
|
||||
);
|
||||
|
||||
if (debug >= 2)
|
||||
{
|
||||
Pout<< fsf << endl;
|
||||
}
|
||||
|
||||
forAll(psi, i)
|
||||
{
|
||||
psi[i] += fsf*finestCorrection[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (scaleCorrection_)
|
||||
{
|
||||
forAll(psi, i)
|
||||
{
|
||||
psi[i] += finestCorrection[i];
|
||||
}
|
||||
// Scale the finest level correction
|
||||
scale
|
||||
(
|
||||
finestCorrection,
|
||||
Apsi,
|
||||
matrix_,
|
||||
interfaceBouCoeffs_,
|
||||
interfaces_,
|
||||
finestResidual,
|
||||
cmpt
|
||||
);
|
||||
}
|
||||
|
||||
forAll(psi, i)
|
||||
{
|
||||
psi[i] += finestCorrection[i];
|
||||
}
|
||||
|
||||
smoothers[0].smooth
|
||||
|
||||
@ -92,35 +92,6 @@ reconstruct
|
||||
|
||||
return treconField;
|
||||
}
|
||||
/*
|
||||
{
|
||||
typedef typename outerProduct<vector, Type>::type GradType;
|
||||
|
||||
const fvMesh& mesh = ssf.mesh();
|
||||
|
||||
tmp<GeometricField<GradType, fvPatchField, volMesh> > treconField
|
||||
(
|
||||
new GeometricField<GradType, fvPatchField, volMesh>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"volIntegrate("+ssf.name()+')',
|
||||
ssf.instance(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
inv(surfaceSum(sqr(mesh.Sf())/mesh.magSf()))
|
||||
& surfaceSum((mesh.Sf()/mesh.magSf())*ssf),
|
||||
zeroGradientFvPatchField<GradType>::typeName
|
||||
)
|
||||
);
|
||||
|
||||
treconField().correctBoundaryConditions();
|
||||
|
||||
return treconField;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
template<class Type>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -131,7 +131,7 @@ thermoTemp .{10}
|
||||
thermoSpecieName .{18}
|
||||
thermoDate .{6}
|
||||
thermoFormula .{20}
|
||||
thermoPhase S|L|G
|
||||
thermoPhase S|L|G|C
|
||||
thermoLowTemp .{10}
|
||||
thermoHighTemp .{10}
|
||||
thermoCommonTemp .{8}
|
||||
@ -439,15 +439,9 @@ bool finishReaction = false;
|
||||
|
||||
<readThermoSpecieName>{thermoSpecieName} {
|
||||
string specieString(foamSpecieString(YYText()));
|
||||
size_t spacePos = specieString.find(' ');
|
||||
if (spacePos != string::npos)
|
||||
{
|
||||
currentSpecieName = specieString(0, spacePos);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentSpecieName = specieString;
|
||||
}
|
||||
specieString.replaceAll(" ", "_");
|
||||
size_t strEnd = specieString.find_last_not_of('_');
|
||||
currentSpecieName = specieString.substr(0, strEnd + 1);
|
||||
BEGIN(readThermoDate);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user