Commit 9da17e04 authored by Henry's avatar Henry
Browse files

SRFPimpleFoam: upgraded from OpenFOAM-1.7.x for OpenFOAM-dev

parent cedfb1b2
......@@ -3,6 +3,7 @@ cd ${0%/*} || exit 1 # run from this directory
set -x
wmake
wmake SRFPimpleFoam
wmake pimpleDyMFoam
# ----------------------------------------------------------------- end-of-file
SRFPimpleFoam.C
EXE = $(FOAM_APPBIN)/SRFPimpleFoam
EXE_INC = \
-I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-lincompressibleTransportModels \
-lincompressibleTurbulenceModel \
-lincompressibleRASModels \
-lincompressibleLESModels \
-lfiniteVolume \
-lmeshTools
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ 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/>.
Application
SRFPimpleFoam
Description
Large time-step transient solver for incompressible, flow in a single
rotating frame using the PIMPLE (merged PISO-SIMPLE) algorithm.
Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "turbulenceModel.H"
#include "pimpleControl.H"
#include "SRFModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"
#include "initContinuityErrs.H"
pimpleControl pimple(mesh);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
#include "readTimeControls.H"
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
// --- Pressure-velocity PIMPLE corrector loop
for (pimple.start(); pimple.loop(); pimple++)
{
if (pimple.nOuterCorr() != 1)
{
p.storePrevIter();
}
#include "UrelEqn.H"
// --- PISO loop
for (int corr=0; corr<pimple.nCorr(); corr++)
{
#include "pEqn.H"
}
// Update the absolute velocity
U = Urel + SRF->U();
if (pimple.turbCorr())
{
turbulence->correct();
}
}
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //
// Relative momentum predictor
tmp<fvVectorMatrix> UrelEqn
(
fvm::ddt(Urel)
+ fvm::div(phi, Urel)
+ turbulence->divDevReff(Urel)
+ SRF->Su()
);
UrelEqn().relax();
solve(UrelEqn() == -fvc::grad(p));
Info<< "Reading field p\n" << endl;
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field Urel\n" << endl;
volVectorField Urel
(
IOobject
(
"Urel",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading/calculating face flux field phi\n" << endl;
surfaceScalarField phi
(
IOobject
(
"phi",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
linearInterpolate(Urel) & mesh.Sf()
);
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell(p, mesh.solutionDict().subDict("PIMPLE"), pRefCell, pRefValue);
singlePhaseTransportModel laminarTransport(Urel, phi);
autoPtr<incompressible::turbulenceModel> turbulence
(
incompressible::turbulenceModel::New(Urel, phi, laminarTransport)
);
Info<< "Creating SRF model\n" << endl;
autoPtr<SRF::SRFModel> SRF
(
SRF::SRFModel::New(Urel)
);
// Create the absolute velocity
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
Urel + SRF->U()
);
volScalarField rAUrel = 1.0/UrelEqn().A();
Urel = rAUrel*UrelEqn().H();
if (pimple.nCorr() <= 1)
{
UrelEqn.clear();
}
phi = (fvc::interpolate(Urel) & mesh.Sf())
+ fvc::ddtPhiCorr(rAUrel, Urel, phi);
adjustPhi(phi, Urel, p);
// Non-orthogonal pressure corrector loop
for (int nonOrth=0; nonOrth<=pimple.nNonOrthCorr(); nonOrth++)
{
// Pressure corrector
fvScalarMatrix pEqn
(
fvm::laplacian(rAUrel, p) == fvc::div(phi)
);
pEqn.setReference(pRefCell, pRefValue);
pEqn.solve
(
mesh.solver(p.select(pimple.finalInnerIter(corr, nonOrth)))
);
if (nonOrth == pimple.nNonOrthCorr())
{
phi -= pEqn.flux();
}
}
#include "continuityErrs.H"
p.relax();
// Momentum corrector
Urel -= rAUrel*fvc::grad(p);
Urel.correctBoundaryConditions();
......@@ -369,6 +369,7 @@ $(SRF)/SRFModel/SRFModel/SRFModel.C
$(SRF)/SRFModel/SRFModel/SRFModelNew.C
$(SRF)/SRFModel/rpm/rpm.C
$(SRF)/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C
$(SRF)/derivedFvPatchFields/SRFFreestreamVelocityFvPatchVectorField/SRFFreestreamVelocityFvPatchVectorField.C
fieldSources = $(general)/fieldSources
$(fieldSources)/pressureGradientExplicitSource/pressureGradientExplicitSource.C
......
/*---------------------------------------------------------------------------* \
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ 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 "SRFFreestreamVelocityFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "SRFModel.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::SRFFreestreamVelocityFvPatchVectorField::
SRFFreestreamVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
inletOutletFvPatchVectorField(p, iF),
UInf_(vector::zero)
{}
Foam::SRFFreestreamVelocityFvPatchVectorField::
SRFFreestreamVelocityFvPatchVectorField
(
const SRFFreestreamVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
inletOutletFvPatchVectorField(ptf, p, iF, mapper),
UInf_(ptf.UInf_)
{}
Foam::SRFFreestreamVelocityFvPatchVectorField::
SRFFreestreamVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
inletOutletFvPatchVectorField(p, iF),
UInf_(dict.lookup("UInf"))
{
fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
}
Foam::SRFFreestreamVelocityFvPatchVectorField::
SRFFreestreamVelocityFvPatchVectorField
(
const SRFFreestreamVelocityFvPatchVectorField& srfvpvf
)
:
inletOutletFvPatchVectorField(srfvpvf),
UInf_(srfvpvf.UInf_)
{}
Foam::SRFFreestreamVelocityFvPatchVectorField::
SRFFreestreamVelocityFvPatchVectorField
(
const SRFFreestreamVelocityFvPatchVectorField& srfvpvf,
const DimensionedField<vector, volMesh>& iF
)
:
inletOutletFvPatchVectorField(srfvpvf, iF),
UInf_(srfvpvf.UInf_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::SRFFreestreamVelocityFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
// Get reference to the SRF model
const SRF::SRFModel& srf =
db().lookupObject<SRF::SRFModel>("SRFProperties");
scalar time = this->db().time().value();
scalar theta = time*mag(srf.omega().value());
refValue() =
cos(theta)*UInf_ + sin(theta)*(srf.axis() ^ UInf_)
- srf.velocity(patch().Cf());
// Set the inlet-outlet choice based on the direction of the freestream
valueFraction() = 1.0 - pos(refValue() & patch().Sf());
mixedFvPatchField<vector>::updateCoeffs();
}
void Foam::SRFFreestreamVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchVectorField::write(os);
os.writeKeyword("UInf") << UInf_ << token::END_STATEMENT << nl;
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchVectorField,
SRFFreestreamVelocityFvPatchVectorField
);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::SRFVelocityFvPatchVectorField
Description
Freestream velocity patch to be used with SRF model
to apply the appropriate rotation transformation in time and space.
SourceFiles
SRFVelocityFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef SRFFreestreamVelocityFvPatchVectorField_H
#define SRFFreestreamVelocityFvPatchVectorField_H
#include "inletOutletFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class SRFFreestreamVelocityFvPatchVectorField Declaration
\*---------------------------------------------------------------------------*/
class SRFFreestreamVelocityFvPatchVectorField
:
public inletOutletFvPatchVectorField
{
// Private data
//- Velocity of the free stream in the absolute frame
vector UInf_;
public:
//- Runtime type information
TypeName("SRFFreestreamVelocity");
// Constructors
//- Construct from patch and internal field
SRFFreestreamVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
SRFFreestreamVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given SRFFreestreamVelocityFvPatchVectorField
// onto a new patch
SRFFreestreamVelocityFvPatchVectorField
(
const SRFFreestreamVelocityFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
SRFFreestreamVelocityFvPatchVectorField
(
const SRFFreestreamVelocityFvPatchVectorField&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new SRFFreestreamVelocityFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
SRFFreestreamVelocityFvPatchVectorField
(
const SRFFreestreamVelocityFvPatchVectorField&,
const DimensionedField<vector, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return tmp<fvPatchVectorField>
(
new SRFFreestreamVelocityFvPatchVectorField(*this, iF)
);
}
// Member functions
// Access
//- Return the velocity at infinity
const vector& UInf() const
{
return UInf_;
}
//- Return reference to the velocity at infinity to allow adjustment
vector& UInf()
{
return UInf_;
}
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();