Merge branch 'master' of /home/dm4/OpenFOAM/repositories/OpenFOAM-dev

This commit is contained in:
mattijs
2013-12-12 08:57:47 +00:00
25 changed files with 109 additions and 52 deletions

View File

@ -91,10 +91,7 @@ K = 0.5*magSqr(U);
{ {
rhoUf = fvc::interpolate(rho*U); rhoUf = fvc::interpolate(rho*U);
surfaceVectorField n(mesh.Sf()/mesh.magSf()); surfaceVectorField n(mesh.Sf()/mesh.magSf());
rhoUf += rhoUf += n*(fvc::absolute(phi, rho, U)/mesh.magSf() - (n & rhoUf));
mesh.Sf()
*(fvc::absolute(phi, rho, U) - (mesh.Sf() & rhoUf))
/sqr(mesh.magSf());
} }
if (thermo.dpdt()) if (thermo.dpdt())

View File

@ -107,10 +107,7 @@ K = 0.5*magSqr(U);
{ {
rhoUf = fvc::interpolate(rho*U); rhoUf = fvc::interpolate(rho*U);
surfaceVectorField n(mesh.Sf()/mesh.magSf()); surfaceVectorField n(mesh.Sf()/mesh.magSf());
rhoUf += rhoUf += n*(fvc::absolute(phi, rho, U)/mesh.magSf() - (n & rhoUf));
mesh.Sf()
*(fvc::absolute(phi, rho, U) - (mesh.Sf() & rhoUf))
/sqr(mesh.magSf());
} }
if (thermo.dpdt()) if (thermo.dpdt())

View File

@ -42,8 +42,5 @@ U.correctBoundaryConditions();
{ {
rhoUf = fvc::interpolate(rho*U); rhoUf = fvc::interpolate(rho*U);
surfaceVectorField n(mesh.Sf()/mesh.magSf()); surfaceVectorField n(mesh.Sf()/mesh.magSf());
rhoUf += rhoUf += n*(fvc::absolute(phi, rho, U)/mesh.magSf() - (n & rhoUf));
mesh.Sf()
*(fvc::absolute(phi, rho, U) - (mesh.Sf() & rhoUf))
/sqr(mesh.magSf());
} }

View File

@ -51,7 +51,7 @@ fvOptions.correct(U);
{ {
Uf = fvc::interpolate(U); Uf = fvc::interpolate(U);
surfaceVectorField n(mesh.Sf()/mesh.magSf()); surfaceVectorField n(mesh.Sf()/mesh.magSf());
Uf += mesh.Sf()*(phi - (mesh.Sf() & Uf))/sqr(mesh.magSf()); Uf += n*(phi/mesh.magSf() - (n & Uf));
} }
// Make the fluxes relative to the mesh motion // Make the fluxes relative to the mesh motion

View File

@ -93,10 +93,7 @@ K = 0.5*magSqr(U);
{ {
rhoUf = fvc::interpolate(rho*U); rhoUf = fvc::interpolate(rho*U);
surfaceVectorField n(mesh.Sf()/mesh.magSf()); surfaceVectorField n(mesh.Sf()/mesh.magSf());
rhoUf += rhoUf += n*(fvc::absolute(phi, rho, U)/mesh.magSf() - (n & rhoUf));
mesh.Sf()
*(fvc::absolute(phi, rho, U) - (mesh.Sf() & rhoUf))
/sqr(mesh.magSf());
} }
if (thermo.dpdt()) if (thermo.dpdt())

View File

@ -85,6 +85,6 @@
{ {
Uf = fvc::interpolate(U); Uf = fvc::interpolate(U);
surfaceVectorField n(mesh.Sf()/mesh.magSf()); surfaceVectorField n(mesh.Sf()/mesh.magSf());
Uf += mesh.Sf()*(phiv - (mesh.Sf() & Uf))/sqr(mesh.magSf()); Uf += n*(phiv/mesh.magSf() - (n & Uf));
} }
} }

View File

@ -114,7 +114,7 @@
{ {
Uf = fvc::interpolate(U); Uf = fvc::interpolate(U);
surfaceVectorField n(mesh.Sf()/mesh.magSf()); surfaceVectorField n(mesh.Sf()/mesh.magSf());
Uf += mesh.Sf()*(phi - (mesh.Sf() & Uf))/sqr(mesh.magSf()); Uf += n*(phi/mesh.magSf() - (n & Uf));
} }
// Make the fluxes relative to the mesh motion // Make the fluxes relative to the mesh motion

View File

@ -55,10 +55,10 @@ int main(int argc, char *argv[])
pimpleControl pimple(mesh); pimpleControl pimple(mesh);
#include "createFields.H" #include "createFields.H"
#include "createUf.H"
#include "readTimeControls.H" #include "readTimeControls.H"
#include "createPrghCorrTypes.H" #include "createPrghCorrTypes.H"
#include "correctPhi.H" #include "correctPhi.H"
#include "createUf.H"
#include "CourantNo.H" #include "CourantNo.H"
#include "setInitialDeltaT.H" #include "setInitialDeltaT.H"

View File

@ -67,7 +67,7 @@
{ {
Uf = fvc::interpolate(U); Uf = fvc::interpolate(U);
surfaceVectorField n(mesh.Sf()/mesh.magSf()); surfaceVectorField n(mesh.Sf()/mesh.magSf());
Uf += mesh.Sf()*(phi - (mesh.Sf() & Uf))/sqr(mesh.magSf()); Uf += n*(phi/mesh.magSf() - (n & Uf));
} }
// Make the fluxes relative to the mesh motion // Make the fluxes relative to the mesh motion

View File

@ -65,10 +65,10 @@ int main(int argc, char *argv[])
pimpleControl pimple(mesh); pimpleControl pimple(mesh);
#include "createFields.H" #include "createFields.H"
#include "createUf.H"
#include "readTimeControls.H" #include "readTimeControls.H"
#include "createPcorrTypes.H" #include "createPcorrTypes.H"
#include "../interFoam/interDyMFoam/correctPhi.H" #include "../interFoam/interDyMFoam/correctPhi.H"
#include "createUf.H"
#include "CourantNo.H" #include "CourantNo.H"
#include "setInitialDeltaT.H" #include "setInitialDeltaT.H"

View File

@ -68,7 +68,7 @@
{ {
Uf = fvc::interpolate(U); Uf = fvc::interpolate(U);
surfaceVectorField n(mesh.Sf()/mesh.magSf()); surfaceVectorField n(mesh.Sf()/mesh.magSf());
Uf += mesh.Sf()*(phi - (mesh.Sf() & Uf))/sqr(mesh.magSf()); Uf += n*(phi/mesh.magSf() - (n & Uf));
} }
// Make the fluxes relative to the mesh motion // Make the fluxes relative to the mesh motion

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -125,6 +125,9 @@ public:
//- Maximum number of iterations in the solver //- Maximum number of iterations in the solver
label maxIter_; label maxIter_;
//- Minimum number of iterations in the solver
label minIter_;
//- Final convergence tolerance //- Final convergence tolerance
Type tolerance_; Type tolerance_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -135,6 +135,7 @@ Foam::LduMatrix<Type, DType, LUType>::solver::solver
controlDict_(solverDict), controlDict_(solverDict),
maxIter_(1000), maxIter_(1000),
minIter_(0),
tolerance_(1e-6*pTraits<Type>::one), tolerance_(1e-6*pTraits<Type>::one),
relTol_(pTraits<Type>::zero) relTol_(pTraits<Type>::zero)
{ {
@ -148,6 +149,7 @@ template<class Type, class DType, class LUType>
void Foam::LduMatrix<Type, DType, LUType>::solver::readControls() void Foam::LduMatrix<Type, DType, LUType>::solver::readControls()
{ {
readControl(controlDict_, maxIter_, "maxIter"); readControl(controlDict_, maxIter_, "maxIter");
readControl(controlDict_, minIter_, "minIter");
readControl(controlDict_, tolerance_, "tolerance"); readControl(controlDict_, tolerance_, "tolerance");
readControl(controlDict_, relTol_, "relTol"); readControl(controlDict_, relTol_, "relTol");
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -104,7 +104,11 @@ Foam::PBiCCCG<Type, DType, LUType>::solve
solverPerf.finalResidual() = solverPerf.initialResidual(); solverPerf.finalResidual() = solverPerf.initialResidual();
// --- Check convergence, solve if not converged // --- Check convergence, solve if not converged
if (!solverPerf.checkConvergence(this->tolerance_, this->relTol_)) if
(
this->minIter_ > 0
|| !solverPerf.checkConvergence(this->tolerance_, this->relTol_)
)
{ {
// --- Select and construct the preconditioner // --- Select and construct the preconditioner
autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner> autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner>
@ -182,8 +186,11 @@ Foam::PBiCCCG<Type, DType, LUType>::solve
} while } while
( (
solverPerf.nIterations()++ < this->maxIter_ (
&& !(solverPerf.checkConvergence(this->tolerance_, this->relTol_)) solverPerf.nIterations()++ < this->maxIter_
&& !solverPerf.checkConvergence(this->tolerance_, this->relTol_)
)
|| solverPerf.nIterations() < this->minIter_
); );
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -92,7 +92,11 @@ Foam::PCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
solverPerf.finalResidual() = solverPerf.initialResidual(); solverPerf.finalResidual() = solverPerf.initialResidual();
// --- Check convergence, solve if not converged // --- Check convergence, solve if not converged
if (!solverPerf.checkConvergence(this->tolerance_, this->relTol_)) if
(
this->minIter_ > 0
|| !solverPerf.checkConvergence(this->tolerance_, this->relTol_)
)
{ {
// --- Select and construct the preconditioner // --- Select and construct the preconditioner
autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner> autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner>
@ -174,8 +178,11 @@ Foam::PCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
} while } while
( (
solverPerf.nIterations()++ < this->maxIter_ (
&& !(solverPerf.checkConvergence(this->tolerance_, this->relTol_)) solverPerf.nIterations()++ < this->maxIter_
&& !solverPerf.checkConvergence(this->tolerance_, this->relTol_)
)
|| solverPerf.nIterations() < this->minIter_
); );
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -113,7 +113,11 @@ Foam::SmoothSolver<Type, DType, LUType>::solve(Field<Type>& psi) const
// Check convergence, solve if not converged // Check convergence, solve if not converged
if (!solverPerf.checkConvergence(this->tolerance_, this->relTol_)) if
(
this->minIter_ > 0
|| !solverPerf.checkConvergence(this->tolerance_, this->relTol_)
)
{ {
autoPtr<typename LduMatrix<Type, DType, LUType>::smoother> autoPtr<typename LduMatrix<Type, DType, LUType>::smoother>
smootherPtr = LduMatrix<Type, DType, LUType>::smoother::New smootherPtr = LduMatrix<Type, DType, LUType>::smoother::New
@ -140,8 +144,11 @@ Foam::SmoothSolver<Type, DType, LUType>::solve(Field<Type>& psi) const
); );
} while } while
( (
(solverPerf.nIterations() += nSweeps_) < this->maxIter_ (
&& !(solverPerf.checkConvergence(this->tolerance_, this->relTol_)) (solverPerf.nIterations() += nSweeps_) < this->maxIter_
&& !solverPerf.checkConvergence(this->tolerance_, this->relTol_)
)
|| solverPerf.nIterations() < this->minIter_
); );
} }
} }

View File

@ -31,7 +31,7 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(lduMatrix, 1); defineTypeNameAndDebug(lduMatrix, 1);
} }

View File

@ -107,6 +107,9 @@ public:
//- Maximum number of iterations in the solver //- Maximum number of iterations in the solver
label maxIter_; label maxIter_;
//- Minimum number of iterations in the solver
label minIter_;
//- Final convergence tolerance //- Final convergence tolerance
scalar tolerance_; scalar tolerance_;

View File

@ -164,6 +164,7 @@ Foam::lduMatrix::solver::solver
void Foam::lduMatrix::solver::readControls() void Foam::lduMatrix::solver::readControls()
{ {
maxIter_ = controlDict_.lookupOrDefault<label>("maxIter", 1000); maxIter_ = controlDict_.lookupOrDefault<label>("maxIter", 1000);
minIter_ = controlDict_.lookupOrDefault<label>("minIter", 0);
tolerance_ = controlDict_.lookupOrDefault<scalar>("tolerance", 1e-6); tolerance_ = controlDict_.lookupOrDefault<scalar>("tolerance", 1e-6);
relTol_ = controlDict_.lookupOrDefault<scalar>("relTol", 0); relTol_ = controlDict_.lookupOrDefault<scalar>("relTol", 0);
} }

View File

@ -69,7 +69,11 @@ Foam::solverPerformance Foam::GAMGSolver::solve
// Check convergence, solve if not converged // Check convergence, solve if not converged
if (!solverPerf.checkConvergence(tolerance_, relTol_)) if
(
minIter_ > 0
|| !solverPerf.checkConvergence(tolerance_, relTol_)
)
{ {
// Create coarse grid correction fields // Create coarse grid correction fields
PtrList<scalarField> coarseCorrFields; PtrList<scalarField> coarseCorrFields;
@ -131,8 +135,11 @@ Foam::solverPerformance Foam::GAMGSolver::solve
} }
} while } while
( (
++solverPerf.nIterations() < maxIter_ (
&& !(solverPerf.checkConvergence(tolerance_, relTol_)) ++solverPerf.nIterations() < maxIter_
&& !solverPerf.checkConvergence(tolerance_, relTol_)
)
|| solverPerf.nIterations() < minIter_
); );
} }

View File

@ -120,7 +120,11 @@ Foam::solverPerformance Foam::PBiCG::solve
solverPerf.finalResidual() = solverPerf.initialResidual(); solverPerf.finalResidual() = solverPerf.initialResidual();
// --- Check convergence, solve if not converged // --- Check convergence, solve if not converged
if (!solverPerf.checkConvergence(tolerance_, relTol_)) if
(
minIter_ > 0
|| !solverPerf.checkConvergence(tolerance_, relTol_)
)
{ {
// --- Select and construct the preconditioner // --- Select and construct the preconditioner
autoPtr<lduMatrix::preconditioner> preconPtr = autoPtr<lduMatrix::preconditioner> preconPtr =
@ -192,8 +196,11 @@ Foam::solverPerformance Foam::PBiCG::solve
/normFactor; /normFactor;
} while } while
( (
solverPerf.nIterations()++ < maxIter_ (
&& !(solverPerf.checkConvergence(tolerance_, relTol_)) solverPerf.nIterations()++ < maxIter_
&& !solverPerf.checkConvergence(tolerance_, relTol_)
)
|| solverPerf.nIterations() < minIter_
); );
} }

View File

@ -111,7 +111,11 @@ Foam::solverPerformance Foam::PCG::solve
solverPerf.finalResidual() = solverPerf.initialResidual(); solverPerf.finalResidual() = solverPerf.initialResidual();
// --- Check convergence, solve if not converged // --- Check convergence, solve if not converged
if (!solverPerf.checkConvergence(tolerance_, relTol_)) if
(
minIter_ > 0
|| !solverPerf.checkConvergence(tolerance_, relTol_)
)
{ {
// --- Select and construct the preconditioner // --- Select and construct the preconditioner
autoPtr<lduMatrix::preconditioner> preconPtr = autoPtr<lduMatrix::preconditioner> preconPtr =
@ -177,8 +181,11 @@ Foam::solverPerformance Foam::PCG::solve
} while } while
( (
solverPerf.nIterations()++ < maxIter_ (
&& !(solverPerf.checkConvergence(tolerance_, relTol_)) solverPerf.nIterations()++ < maxIter_
&& !solverPerf.checkConvergence(tolerance_, relTol_)
)
|| solverPerf.nIterations() < minIter_
); );
} }

View File

@ -138,7 +138,11 @@ Foam::solverPerformance Foam::smoothSolver::solve
// Check convergence, solve if not converged // Check convergence, solve if not converged
if (!solverPerf.checkConvergence(tolerance_, relTol_)) if
(
minIter_ > 0
|| !solverPerf.checkConvergence(tolerance_, relTol_)
)
{ {
autoPtr<lduMatrix::smoother> smootherPtr = lduMatrix::smoother::New autoPtr<lduMatrix::smoother> smootherPtr = lduMatrix::smoother::New
( (
@ -176,8 +180,11 @@ Foam::solverPerformance Foam::smoothSolver::solve
)/normFactor; )/normFactor;
} while } while
( (
(solverPerf.nIterations() += nSweeps_) < maxIter_ (
&& !(solverPerf.checkConvergence(tolerance_, relTol_)) (solverPerf.nIterations() += nSweeps_) < maxIter_
&& !solverPerf.checkConvergence(tolerance_, relTol_)
)
|| solverPerf.nIterations() < minIter_
); );
} }
} }

View File

@ -46,9 +46,14 @@ surfaceVectorField rhoUf
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
linearInterpolate(rho*U) fvc::interpolate(rho*U)
); );
{
surfaceVectorField n(mesh.Sf()/mesh.magSf());
rhoUf += n*(phi/mesh.magSf() - (n & rhoUf));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif

View File

@ -46,9 +46,15 @@ surfaceVectorField Uf
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
linearInterpolate(U) fvc::interpolate(U)
); );
{
surfaceVectorField n(mesh.Sf()/mesh.magSf());
Uf += n*(phi/mesh.magSf() - (n & Uf));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif