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

This commit is contained in:
mattijs
2011-11-03 16:09:50 +00:00
167 changed files with 2147 additions and 3292 deletions

View File

@ -5,7 +5,7 @@ rho.relax();
U = rAU*UEqn().H();
if (pimple.nCorrPIMPLE() <= 1)
if (pimple.nCorrPISO() <= 1)
{
UEqn.clear();
}

View File

@ -6,7 +6,7 @@ rho.relax();
volScalarField rAU(1.0/UEqn().A());
U = rAU*UEqn().H();
if (pimple.nCorrPIMPLE() <= 1)
if (pimple.nCorrPISO() <= 1)
{
UEqn.clear();
}

View File

@ -2,7 +2,8 @@ EXE_INC = \
-I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/finiteVolume/lnInclude
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lincompressibleTransportModels \

View File

@ -2,7 +2,8 @@ EXE_INC = \
-I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/finiteVolume/lnInclude
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lincompressibleTransportModels \

View File

@ -37,6 +37,7 @@ Description
#include "turbulenceModel.H"
#include "pimpleControl.H"
#include "SRFModel.H"
#include "IObasicSourceList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -70,3 +70,6 @@ volVectorField U
),
Urel + SRF->U()
);
IObasicSourceList sources(mesh);

View File

@ -1,7 +1,7 @@
volScalarField rAUrel(1.0/UrelEqn().A());
Urel = rAUrel*UrelEqn().H();
if (pimple.nCorrPIMPLE() <= 1)
if (pimple.nCorrPISO() <= 1)
{
UrelEqn.clear();
}

View File

@ -7,6 +7,8 @@ tmp<fvVectorMatrix> UEqn
+ turbulence->divDevReff(U)
);
sources.apply(UEqn());
UEqn().relax();
volScalarField rAU(1.0/UEqn().A());

View File

@ -40,3 +40,6 @@ autoPtr<incompressible::turbulenceModel> turbulence
(
incompressible::turbulenceModel::New(U, phi, laminarTransport)
);
IObasicSourceList sources(mesh);

View File

@ -1,6 +1,6 @@
U = rAU*UEqn().H();
if (pimple.nCorrPIMPLE() <= 1)
if (pimple.nCorrPISO() <= 1)
{
UEqn.clear();
}

View File

@ -56,3 +56,6 @@
runTime.deltaT(),
zeroGradientFvPatchScalarField::typeName
);
IObasicSourceList sources(mesh);

View File

@ -1,6 +1,6 @@
U = rAU*UEqn().H();
if (pimple.nCorrPIMPLE() <= 1)
if (pimple.nCorrPISO() <= 1)
{
UEqn.clear();
}

View File

@ -37,6 +37,7 @@ Description
#include "turbulenceModel.H"
#include "dynamicFvMesh.H"
#include "pimpleControl.H"
#include "IObasicSourceList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -36,6 +36,7 @@ Description
#include "singlePhaseTransportModel.H"
#include "turbulenceModel.H"
#include "pimpleControl.H"
#include "IObasicSourceList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,6 @@ wmake
wmake SRFSimpleFoam
wmake MRFSimpleFoam
wmake windSimpleFoam
wmake porousSimpleFoam
# ----------------------------------------------------------------- end-of-file

View File

@ -35,6 +35,7 @@ Description
#include "RASModel.H"
#include "MRFZones.H"
#include "simpleControl.H"
#include "IObasicSourceList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -4,9 +4,11 @@ EXE_INC = \
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/finiteVolume/lnInclude
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lincompressibleRASModels \
-lincompressibleTransportModels \
-lfiniteVolume
-lfiniteVolume \
-lmeshTools

View File

@ -5,8 +5,11 @@
fvm::div(phi, U)
+ turbulence->divDevReff(U)
);
mrfZones.addCoriolis(UEqn());
sources.apply(UEqn());
UEqn().relax();
solve(UEqn() == -fvc::grad(p));

View File

@ -3,10 +3,12 @@ EXE_INC = \
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/finiteVolume/lnInclude
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lincompressibleTurbulenceModel \
-lincompressibleRASModels \
-lincompressibleTransportModels \
-lfiniteVolume
-lfiniteVolume \
-lmeshTools

View File

@ -4,7 +4,8 @@ EXE_INC = \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lincompressibleRASModels \

View File

@ -35,6 +35,7 @@ Description
#include "RASModel.H"
#include "SRFModel.H"
#include "simpleControl.H"
#include "IObasicSourceList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -7,6 +7,8 @@
+ SRF->Su()
);
sources.apply(UrelEqn());
UrelEqn().relax();
solve(UrelEqn() == -fvc::grad(p));

View File

@ -56,3 +56,5 @@
(
SRF::SRFModel::New(Urel)
);
IObasicSourceList sources(mesh);

View File

@ -6,6 +6,8 @@
+ turbulence->divDevReff(U)
);
sources.apply(UEqn());
UEqn().relax();
solve(UEqn() == -fvc::grad(p));

View File

@ -39,3 +39,5 @@
(
incompressible::RASModel::New(U, phi, laminarTransport)
);
IObasicSourceList sources(mesh);

View File

@ -6,6 +6,8 @@
+ turbulence->divDevReff(U)
);
sources.apply(UEqn());
UEqn().relax();
// Include the porous media resistance and solve the momentum equation

View File

@ -35,6 +35,7 @@ Description
#include "RASModel.H"
#include "porousZones.H"
#include "simpleControl.H"
#include "IObasicSourceList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -33,6 +33,7 @@ Description
#include "singlePhaseTransportModel.H"
#include "RASModel.H"
#include "simpleControl.H"
#include "IObasicSourceList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,3 +0,0 @@
windSimpleFoam.C
EXE = $(FOAM_APPBIN)/windSimpleFoam

View File

@ -1,14 +0,0 @@
EXE_INC = \
-I.. \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lincompressibleRASModels \
-lincompressibleTransportModels \
-lfiniteVolume \
-lmeshTools

View File

@ -1,14 +0,0 @@
// Solve the Momentum equation
tmp<fvVectorMatrix> UEqn
(
fvm::div(phi, U)
+ turbulence->divDevReff(U)
);
// Add resistance on the actuation disks
actuationDisks.addSu(UEqn());
UEqn().relax();
solve(UEqn() == -fvc::grad(p));

View File

@ -41,7 +41,7 @@ Description
#include "rhoChemistryCombustionModel.H"
#include "radiationModel.H"
#include "porousZones.H"
#include "timeActivatedExplicitSource.H"
#include "IObasicSourceList.H"
#include "SLGThermo.H"
#include "fvcSmooth.H"
#include "pimpleControl.H"

View File

@ -7,9 +7,10 @@
==
rho.dimensionedInternalField()*g
+ parcels.SU(U)
+ momentumSource.Su()
);
sources.apply(UEqn);
pZones.addResistance(UEqn);
if (pimple.momentumPredictor())

View File

@ -23,7 +23,7 @@ if (solveSpecies)
{
volScalarField& Yi = Y[i];
solve
fvScalarMatrix YEqn
(
fvm::ddt(rho, Yi)
+ mvConvection->fvmDiv(phi, Yi)
@ -31,10 +31,12 @@ if (solveSpecies)
==
parcels.SYi(i, Yi)
+ combustion->R(Yi)
+ massSource.Su(i),
mesh.solver("Yi")
);
sources.apply(YEqn);
YEqn.solve(mesh.solver("Yi"));
Yi.max(0.0);
Yt += Yi;
}

View File

@ -1,27 +1,2 @@
Info<< "Creating mass source\n" << endl;
scalarTimeActivatedExplicitSourceList massSource
(
"mass",
mesh,
dimMass/dimTime/dimVolume,
composition.species()
);
Info<< "Creating momentum source\n" << endl;
vectorTimeActivatedExplicitSourceList momentumSource
(
"momentum",
mesh,
dimMass*dimVelocity/dimTime/dimVolume,
"U"
);
Info<< "Creating energy source\n" << endl;
scalarTimeActivatedExplicitSourceList energySource
(
"energy",
mesh,
dimEnergy/dimTime/dimVolume,
"h"
);
Info<< "Creating sources\n" << endl;
IObasicSourceList sources(mesh);

View File

@ -8,10 +8,11 @@
DpDt
+ parcels.Sh(hs)
+ radiation->Shs(thermo)
+ energySource.Su()
+ combustion->Sh()
);
sources.apply(hsEqn);
hsEqn.solve();
thermo.correct();

View File

@ -29,9 +29,10 @@
+ fvc::div(phi)
==
parcels.Srho()
+ massSource.SuTot()
);
sources.apply(pDDtEqn);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix pEqn

View File

@ -36,9 +36,10 @@ Description
+ fvc::div(phi)
==
parcels.Srho(rho)
+ massSource.SuTot()
);
sources.apply(rhoEqn);
rhoEqn.solve();
Info<< "rho min/max = " << min(rho).value() << ", " << max(rho).value()

View File

@ -76,7 +76,7 @@ Info<< "Time scales min/max:" << endl;
(
DpDt
+ parcels.hsTrans()/(mesh.V()*runTime.deltaT())
+ energySource.Su()
// + energySource.Su()
+ combustion->Sh()()
)
/rho

View File

@ -9,6 +9,8 @@
+ limestoneParcels.SU(U)
);
sources.apply(UEqn);
UEqn.relax();
if (pimple.momentumPredictor())

View File

@ -32,6 +32,8 @@ tmp<fv::convectionScheme<scalar> > mvConvection
+ combustion->R(Yi)
);
sources.apply(YiEqn);
YiEqn.relax();
YiEqn.solve(mesh.solver("Yi"));

View File

@ -40,7 +40,7 @@ Description
#include "basicThermoCloud.H"
#include "coalCloud.H"
#include "psiChemistryCombustionModel.H"
#include "timeActivatedExplicitSource.H"
#include "IObasicSourceList.H"
#include "radiationModel.H"
#include "SLGThermo.H"
#include "pimpleControl.H"

View File

@ -122,14 +122,8 @@
fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p)
);
Info<< "\nConstructing explicit enthalpy source" << endl;
scalarTimeActivatedExplicitSourceList enthalpySource
(
"energy",
mesh,
dimEnergy/dimTime/dimVolume,
"hs"
);
Info<< "\nConstructing sources" << endl;
IObasicSourceList sources(mesh);
volScalarField dQ
(

View File

@ -9,10 +9,11 @@
+ combustion->Sh()
+ coalParcels.Sh(hs)
+ limestoneParcels.Sh(hs)
+ enthalpySource.Su()
+ radiation->Shs(thermo)
);
sources.apply(hsEqn);
hsEqn.relax();
hsEqn.solve();

View File

@ -26,6 +26,8 @@ if (pimple.transonic())
coalParcels.Srho()
);
sources.apply(pEqn);
pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter())));
if (pimple.finalNonOrthogonalIter())
@ -54,6 +56,8 @@ else
coalParcels.Srho()
);
sources.apply(pEqn);
pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter())));
if (pimple.finalNonOrthogonalIter())

View File

@ -30,13 +30,17 @@ Description
\*---------------------------------------------------------------------------*/
{
solve
fvScalarMatrix rhoEqn
(
fvm::ddt(rho)
+ fvc::div(phi)
==
coalParcels.Srho(rho)
);
sources.apply(rhoEqn);
rhoEqn.solve();
}
// ************************************************************************* //

View File

@ -7,9 +7,10 @@
==
rho.dimensionedInternalField()*g
+ parcels.SU(U)
+ momentumSource.Su()
);
sources.apply(UEqn);
pZones.addResistance(UEqn);
if (pimple.momentumPredictor())

View File

@ -24,7 +24,7 @@ if (solveSpecies)
{
volScalarField& Yi = Y[i];
solve
fvScalarMatrix YiEqn
(
fvm::ddt(rho, Yi)
+ mvConvection->fvmDiv(phi, Yi)
@ -32,10 +32,12 @@ if (solveSpecies)
==
parcels.SYi(i, Yi)
+ combustion->R(Yi)
+ massSource.Su(i),
mesh.solver("Yi")
);
sources.apply(YiEqn);
YiEqn.solve(mesh.solver("Yi"));
Yi.max(0.0);
Yt += Yi;
}

View File

@ -1,27 +1,2 @@
Info<< "Creating mass source\n" << endl;
scalarTimeActivatedExplicitSourceList massSource
(
"mass",
mesh,
dimMass/dimTime/dimVolume,
composition.species()
);
Info<< "Creating momentum source\n" << endl;
vectorTimeActivatedExplicitSourceList momentumSource
(
"momentum",
mesh,
dimMass*dimVelocity/dimTime/dimVolume,
"U"
);
Info<< "Creating energy source\n" << endl;
scalarTimeActivatedExplicitSourceList energySource
(
"energy",
mesh,
dimEnergy/dimTime/dimVolume,
"h"
);
Info<< "Creating sources\n" << endl;
IObasicSourceList sources(mesh);

View File

@ -29,7 +29,7 @@
}
{
solve
fvScalarMatrix hsEqn
(
fvm::ddt(rho, hs)
+ mvConvection->fvmDiv(phi, hs)
@ -38,10 +38,13 @@
pWork()
+ parcels.Sh(hs)
+ radiation->Shs(thermo)
+ energySource.Su()
+ combustion->Sh()
);
sources.apply(hsEqn);
hsEqn.solve();
thermo.correct();
radiation->correct();

View File

@ -29,9 +29,10 @@
+ fvc::div(phi)
==
parcels.Srho()
+ massSource.SuTot()
);
sources.apply(pDDtEqn);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix pEqn

View File

@ -45,7 +45,7 @@ Description
#include "rhoChemistryCombustionModel.H"
#include "radiationModel.H"
#include "porousZones.H"
#include "timeActivatedExplicitSource.H"
#include "IObasicSourceList.H"
#include "SLGThermo.H"
#include "pimpleControl.H"

View File

@ -36,9 +36,10 @@ Description
+ fvc::div(phi)
==
parcels.Srho(rho)
+ massSource.SuTot()
);
sources.apply(rhoEqn);
rhoEqn.solve();
}

View File

@ -13,70 +13,176 @@
);
const dictionary& rhoDict(mechanicalProperties.subDict("rho"));
word rhoType(rhoDict.lookup("rho"));
word rhoType(rhoDict.lookup("type"));
volScalarField rho
(
IOobject
autoPtr<volScalarField> rhoPtr;
IOobject rhoIO
(
"rho",
runTime.timeName(),
runTime.timeName(0),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("zero", dimMass/dimVolume, 0.0)
);
if (rhoType == "rhoInf")
if (rhoType == "uniform")
{
rho = rhoDict.lookup("rhoInf");
scalar rhoValue(readScalar(rhoDict.lookup("value")));
rhoPtr.reset
(
new volScalarField
(
rhoIO,
mesh,
dimensionedScalar
(
"rho",
dimMass/dimVolume,
rhoValue
),
zeroGradientFvPatchField<scalar>::typeName
)
);
}
else if (rhoType == "field")
{
rhoIO.readOpt() = IOobject::MUST_READ;
rhoPtr.reset
(
new volScalarField
(
rhoIO,
mesh
)
);
}
else
{
FatalErrorIn
(
"readMechanicalProperties.H"
) << "Valid type entries are uniform or field for rho"
<< abort(FatalError);
}
volScalarField rhoE
(
IOobject
volScalarField& rho = rhoPtr();
const dictionary& EDict(mechanicalProperties.subDict("E"));
word EType(EDict.lookup("type"));
autoPtr<volScalarField> EPtr;
IOobject EIO
(
"E",
runTime.timeName(0),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("0", dimMass/dimLength/sqr(dimTime), 0.0)
);
const dictionary& EDict(mechanicalProperties.subDict("E"));
word EType(EDict.lookup("E"));
if (EType == "EInf")
if (EType == "uniform")
{
rhoE = EDict.lookup("EInf");
scalar rhoEValue(readScalar(EDict.lookup("value")));
EPtr.reset
(
new volScalarField
(
EIO,
mesh,
dimensionedScalar
(
"Erho",
dimMass/dimLength/sqr(dimTime),
rhoEValue
),
zeroGradientFvPatchField<scalar>::typeName
)
);
}
else if (EType == "field")
{
EIO.readOpt() = IOobject::MUST_READ;
EPtr.reset
(
new volScalarField
(
EIO,
mesh
)
);
}
else
{
FatalErrorIn
(
"readMechanicalProperties.H"
) << "Valid type entries are uniform or field for E"
<< abort(FatalError);
}
volScalarField& rhoE = EPtr();
volScalarField nu
(
IOobject
autoPtr<volScalarField> nuPtr;
IOobject nuIO
(
"nu",
runTime.timeName(0),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("0", dimless, 0.0)
);
const dictionary& nuDict(mechanicalProperties.subDict("nu"));
word nuType(nuDict.lookup("nu"));
word nuType(nuDict.lookup("type"));
if (nuType == "nuInf")
if (nuType == "uniform")
{
nu = nuDict.lookup("nuInf");
scalar nuValue(readScalar(nuDict.lookup("value")));
nuPtr.reset
(
new volScalarField
(
nuIO,
mesh,
dimensionedScalar
(
"nu",
dimless,
nuValue
),
zeroGradientFvPatchField<scalar>::typeName
)
);
}
else if(nuType == "field")
{
nuIO.readOpt() = IOobject::MUST_READ;
nuPtr.reset
(
new volScalarField
(
nuIO,
mesh
)
);
}
else
{
FatalErrorIn
(
"readMechanicalProperties.H"
) << "Valid type entries are uniform or field for nu"
<< abort(FatalError);
}
volScalarField& nu = nuPtr();
Info<< "Normalising E : E/rho\n" << endl;
volScalarField E = rhoE/rho;

View File

@ -46,70 +46,180 @@ volScalarField DT
if (thermalStress)
{
volScalarField C
(
IOobject
autoPtr<volScalarField> CPtr;
IOobject CIO
(
"C",
runTime.timeName(0),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("0", dimensionSet(0, 2, -2 , -1, 0), 0.0)
);
const dictionary& CDict(thermalProperties.subDict("C"));
word CType(CDict.lookup("C"));
if (CType == "CInf")
word CType(CDict.lookup("type"));
if (CType == "uniform")
{
C = CDict.lookup("CInf");
scalar CValue(readScalar(CDict.lookup("value")));
CPtr.reset
(
new volScalarField
(
CIO,
mesh,
dimensionedScalar
(
"C",
dimensionSet(0, 2, -2 , -1, 0),
CValue
),
zeroGradientFvPatchField<scalar>::typeName
)
);
}
else if(CType == "field")
{
CIO.readOpt() = IOobject::MUST_READ;
CPtr.reset
(
new volScalarField
(
CIO,
mesh
)
);
}
else
{
FatalErrorIn
(
"readThermalProperties.H"
) << "Valid type entries are uniform or field for C"
<< abort(FatalError);
}
volScalarField& C = CPtr();
volScalarField rhoK
(
IOobject
autoPtr<volScalarField> rhoKPtr;
IOobject rhoKIO
(
"k",
runTime.timeName(0),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("0", dimensionSet(1, 1, -3 , -1, 0), 0.0)
);
const dictionary& kDict(thermalProperties.subDict("k"));
word kType(kDict.lookup("k"));
if (kType == "kInf")
word kType(kDict.lookup("type"));
if (kType == "uniform")
{
rhoK = kDict.lookup("kInf");
scalar rhoKValue(readScalar(kDict.lookup("value")));
rhoKPtr.reset
(
new volScalarField
(
rhoKIO,
mesh,
dimensionedScalar
(
"rhoK",
dimensionSet(1, 1, -3 , -1, 0),
rhoKValue
),
zeroGradientFvPatchField<scalar>::typeName
)
);
}
else if (kType == "field")
{
rhoKIO.readOpt() = IOobject::MUST_READ;
rhoKPtr.reset
(
new volScalarField
(
rhoKIO,
mesh
)
);
}
else
{
FatalErrorIn
(
"readThermalProperties.H"
) << "Valid type entries are uniform or field for K"
<< abort(FatalError);
}
volScalarField alpha
(
IOobject
volScalarField& rhoK = rhoKPtr();
autoPtr<volScalarField> alphaPtr;
IOobject alphaIO
(
"alpha",
runTime.timeName(0),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("0", dimensionSet(0, 0, 0 , -1, 0), 0.0)
);
const dictionary& alphaDict(thermalProperties.subDict("alpha"));
word alphaType(alphaDict.lookup("alpha"));
if (alphaType == "alphaInf")
const dictionary& alphaDict(thermalProperties.subDict("alpha"));
word alphaType(alphaDict.lookup("type"));
if (alphaType == "uniform")
{
alpha = alphaDict.lookup("alphaInf");
scalar alphaValue(readScalar(alphaDict.lookup("value")));
alphaPtr.reset
(
new volScalarField
(
alphaIO,
mesh,
dimensionedScalar
(
"alpha",
inv(dimTemperature),
alphaValue
),
zeroGradientFvPatchField<scalar>::typeName
)
);
}
else if (alphaType == "field")
{
alphaIO.readOpt() = IOobject::MUST_READ;
alphaPtr.reset
(
new volScalarField
(
alphaIO,
mesh
)
);
}
else
{
FatalErrorIn
(
"readThermalProperties.H"
) << "Valid type entries are uniform or field for alpha"
<< abort(FatalError);
}
volScalarField& alpha = alphaPtr();
Info<< "Normalising k : k/rho\n" << endl;
volScalarField k = rhoK/rho;

View File

@ -150,13 +150,18 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
"mechanicalProperties"
);
dimensionedScalar rho(mechanicalProperties.lookup("rho"));
dimensionedScalar rhoE(mechanicalProperties.lookup("E"));
dimensionedScalar nu(mechanicalProperties.lookup("nu"));
const fvPatchField<scalar>& rho =
patch().lookupPatchField<volScalarField, scalar>("rho");
dimensionedScalar E = rhoE/rho;
dimensionedScalar mu = E/(2.0*(1.0 + nu));
dimensionedScalar lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu));
const fvPatchField<scalar>& rhoE =
patch().lookupPatchField<volScalarField, scalar>("E");
const fvPatchField<scalar>& nu =
patch().lookupPatchField<volScalarField, scalar>("nu");
scalarField E = rhoE/rho;
scalarField mu = E/(2.0*(1.0 + nu));
scalarField lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu));
Switch planeStress(mechanicalProperties.lookup("planeStress"));
@ -175,8 +180,8 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
gradient() =
(
(traction_ + pressure_*n)/rho.value() - (n & (sigmaD + sigmaExp))
)/(2.0*mu + lambda).value();
(traction_ + pressure_*n)/rho - (n & (sigmaD + sigmaExp))
)/(2.0*mu + lambda);
fixedGradientFvPatchVectorField::updateCoeffs();
}

View File

@ -378,19 +378,18 @@ $(SRF)/SRFModel/rpm/rpm.C
$(SRF)/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C
$(SRF)/derivedFvPatchFields/SRFFreestreamVelocityFvPatchVectorField/SRFFreestreamVelocityFvPatchVectorField.C
fieldSources = $(general)/fieldSources
$(fieldSources)/pressureGradientExplicitSource/pressureGradientExplicitSource.C
$(fieldSources)/timeActivatedExplicitSource/timeActivatedExplicitSource.C
basicSource = $(general)/fieldSources/basicSource
$(basicSource)/basicSource/basicSource.C
$(basicSource)/basicSource/basicSourceIO.C
$(basicSource)/basicSource/basicSourceList.C
$(basicSource)/basicSource/IObasicSourceList.C
$(basicSource)/actuationDiskSource/actuationDiskSource.C
$(basicSource)/radialActuationDiskSource/radialActuationDiskSource.C
$(basicSource)/pressureGradientExplicitSource/pressureGradientExplicitSource.C
$(basicSource)/pressureGradientExplicitSource/pressureGradientExplicitSourceIO.C
$(basicSource)/explicitSource/explicitSource.C
$(basicSource)/explicitSetValue/explicitSetValue.C
$(basicSource)/rotorDiskSource/rotorDiskSource.C
$(basicSource)/rotorDiskSource/bladeModel/bladeModel.C
$(basicSource)/rotorDiskSource/profileModel/profileModel.C
@ -398,5 +397,7 @@ $(basicSource)/rotorDiskSource/profileModel/profileModelList.C
$(basicSource)/rotorDiskSource/profileModel/lookup/lookupProfile.C
$(basicSource)/rotorDiskSource/profileModel/series/seriesProfile.C
$(basicSource)/actuationDiskSource/actuationDiskSource.C
$(basicSource)/radialActuationDiskSource/radialActuationDiskSource.C
LIB = $(FOAM_LIBBIN)/libfiniteVolume

View File

@ -35,7 +35,12 @@ License
namespace Foam
{
defineTypeNameAndDebug(actuationDiskSource, 0);
addToRunTimeSelectionTable(basicSource, actuationDiskSource, dictionary);
addToRunTimeSelectionTable
(
basicSource,
actuationDiskSource,
dictionary
);
}
@ -75,12 +80,14 @@ Foam::actuationDiskSource::actuationDiskSource
)
:
basicSource(name, modelType, dict, mesh),
coeffs_(dict.subDict(modelType + "Coeffs")),
diskDir_(coeffs_.lookup("diskDir")),
Cp_(readScalar(coeffs_.lookup("Cp"))),
Ct_(readScalar(coeffs_.lookup("Ct"))),
diskArea_(readScalar(coeffs_.lookup("diskArea")))
{
coeffs_.lookup("fieldNames") >> fieldNames_;
applied_.setSize(fieldNames_.size(), false);
Info<< " - creating actuation disk zone: "
<< this->name() << endl;
@ -90,17 +97,21 @@ Foam::actuationDiskSource::actuationDiskSource
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::actuationDiskSource::addSu(fvMatrix<vector>& UEqn)
void Foam::actuationDiskSource::addSup
(
fvMatrix<vector>& eqn,
const label fieldI
)
{
bool compressible = false;
if (UEqn.dimensions() == dimensionSet(1, 1, -2, 0, 0))
if (eqn.dimensions() == dimForce)
{
compressible = true;
}
const scalarField& cellsV = this->mesh().V();
vectorField& Usource = UEqn.source();
const vectorField& U = UEqn.psi();
const scalarField& cellsV = mesh_.V();
vectorField& Usource = eqn.source();
const vectorField& U = eqn.psi();
if (V() > VSMALL)
{
@ -111,7 +122,7 @@ void Foam::actuationDiskSource::addSu(fvMatrix<vector>& UEqn)
Usource,
cells_,
cellsV,
this->mesh().lookupObject<volScalarField>("rho"),
mesh_.lookupObject<volScalarField>("rho"),
U
);
}
@ -141,7 +152,6 @@ bool Foam::actuationDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
coeffs_ = dict.subDict(typeName + "Coeffs");
coeffs_.readIfPresent("diskDir", diskDir_);
coeffs_.readIfPresent("Cp", Cp_);
coeffs_.readIfPresent("Ct", Ct_);

View File

@ -26,17 +26,31 @@ Class
Foam::actuationDiskSource
Description
Actuation disk zone definition.
Actuation disk source
Constant values for momentum source for actuation disk
T = 2*rho*A*sqr(Uo)*a*(1-a)
U1 = (1 -a)Uo
where:
A: disk area
Uo: upstream velocity
a: 1 - Cp/Ct
U1: velocity at the disk
Sources described by:
actuationDiskSourceCoeffs
{
fieldNames (U); // names of fields to apply source
diskDir (-1 0 0); // disk direction
Cp 0.1; // power coefficient
Ct 0.5; // thrust coefficient
diskArea 5.0; // disk area
}
SourceFiles
actuationDiskSource.C
actuationDiskSourceTemplates.C
@ -46,14 +60,6 @@ SourceFiles
#ifndef actuationDiskSource_H
#define actuationDiskSource_H
#include "IOdictionary.H"
#include "coordinateSystem.H"
#include "coordinateSystems.H"
#include "wordList.H"
#include "labelList.H"
#include "DimensionedField.H"
#include "volFieldsFwd.H"
#include "fvMatricesFwd.H"
#include "basicSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -74,9 +80,6 @@ protected:
// Protected data
//- Coefficients dictionary
dictionary coeffs_;
//- Disk area normal
vector diskDir_;
@ -169,11 +172,8 @@ public:
// Public Functions
//-Source term to fvMatrix<vector>
virtual void addSu(fvMatrix<vector>& UEqn);
//-Source term to fvMatrix<scalar>
virtual void addSu(fvMatrix<scalar>& UEqn){}
//- Source term to fvMatrix<vector>
virtual void addSup(fvMatrix<vector>& eqn, const label fieldI);
// I-O

View File

@ -24,6 +24,41 @@ License
\*---------------------------------------------------------------------------*/
#include "IObasicSourceList.H"
#include "fvMesh.H"
#include "Time.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::IOobject Foam::IObasicSourceList::createIOobject
(
const fvMesh& mesh
) const
{
IOobject io
(
"sourcesProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (io.headerOk())
{
Info<< "Creating field source list from " << io.name() << nl << endl;
io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
return io;
}
else
{
Info<< "No field sources present" << nl << endl;
io.readOpt() = IOobject::NO_READ;
return io;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -32,17 +67,7 @@ Foam::IObasicSourceList::IObasicSourceList
const fvMesh& mesh
)
:
IOdictionary
(
IOobject
(
"sourcesProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
),
IOdictionary(createIOobject(mesh)),
basicSourceList(mesh, *this)
{}

View File

@ -57,6 +57,9 @@ private:
// Private Member Functions
//- Create IO object if dictionary is present
IOobject createIOobject(const fvMesh& mesh) const;
//- Disallow default bitwise copy construct
IObasicSourceList(const IObasicSourceList&);

View File

@ -25,19 +25,16 @@ License
#include "basicSource.H"
#include "fvMesh.H"
#include "volFields.H"
#include "fvMatrices.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(basicSource, 0);
defineRunTimeSelectionTable(basicSource, dictionary);
// * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
template<> const char* NamedEnum
<
basicSource::selectionModeType,
@ -120,10 +117,7 @@ void Foam::basicSource::setCellSet()
label globalCellI = returnReduce(cellI, maxOp<label>());
if (globalCellI < 0)
{
WarningIn
(
"TimeActivatedExplicitSource<Type>::setCellIds()"
)
WarningIn("basicSource::setCellIds()")
<< "Unable to find owner cell for point " << points_[i]
<< endl;
@ -152,7 +146,7 @@ void Foam::basicSource::setCellSet()
label zoneID = mesh_.cellZones().findZoneID(cellSetName_);
if (zoneID == -1)
{
FatalErrorIn("basicSource<Type>::setCellIds()")
FatalErrorIn("basicSource::setCellIds()")
<< "Cannot find cellZone " << cellSetName_ << endl
<< "Valid cellZones are " << mesh_.cellZones().names()
<< exit(FatalError);
@ -170,7 +164,7 @@ void Foam::basicSource::setCellSet()
}
default:
{
FatalErrorIn("basicSource<Type>::setCellIds()")
FatalErrorIn("basicSource::setCellIds()")
<< "Unknown selectionMode "
<< selectionModeTypeNames_[selectionMode_]
<< ". Valid selectionMode types are" << selectionModeTypeNames_
@ -205,6 +199,7 @@ Foam::basicSource::basicSource
name_(name),
mesh_(mesh),
dict_(dict),
coeffs_(dict.subDict(modelType + "Coeffs")),
active_(readBool(dict_.lookup("active"))),
timeStart_(readScalar(dict_.lookup("timeStart"))),
duration_(readScalar(dict_.lookup("duration"))),
@ -213,7 +208,9 @@ Foam::basicSource::basicSource
selectionModeTypeNames_.read(dict_.lookup("selectionMode"))
),
cellSetName_("none"),
V_(0.0)
V_(0.0),
fieldNames_(),
applied_()
{
setSelection(dict_);
@ -226,13 +223,13 @@ Foam::basicSource::basicSource
Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
(
const word& name,
const dictionary& dict,
const dictionary& coeffs,
const fvMesh& mesh
)
{
word modelType(dict.lookup("type"));
word modelType(coeffs.lookup("type"));
Info<< "Selecting model type " << modelType << endl;
Info<< "Selecting source model type " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
@ -241,16 +238,16 @@ Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
{
FatalErrorIn
(
"basicSource::New(const volVectorField&, "
"const surfaceScalarField&, transportModel&)"
"basicSource::New"
"(const name&, const dictionary&, const fvMesh&)"
) << "Unknown Model type " << modelType
<< nl << nl
<< "Valid model types are :" << nl
<< "Valid model types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<basicSource>(cstrIter()(name, modelType, dict, mesh));
return autoPtr<basicSource>(cstrIter()(name, modelType, coeffs, mesh));
}
@ -279,21 +276,103 @@ bool Foam::basicSource::isActive()
}
void Foam::basicSource::addSu(Foam::fvMatrix<vector>& Eqn)
Foam::label Foam::basicSource::applyToField(const word& fieldName) const
{
notImplemented("Foam::basicSource addSu(Foam::fvMatrix<vector>& Eqn)");
forAll(fieldNames_, i)
{
if (fieldNames_[i] == fieldName)
{
return i;
}
}
return -1;
}
void Foam::basicSource::addSu(Foam::fvMatrix<scalar>& Eqn)
void Foam::basicSource::checkApplied() const
{
notImplemented("Foam::basicSource addSu(Foam::fvMatrix<scalar>& Eqn)");
forAll(applied_, i)
{
if (!applied_[i])
{
WarningIn("void Foam::basicSource::checkApplied() const")
<< "Source " << name_ << " defined for field "
<< fieldNames_[i] << " but never used" << endl;
}
}
}
void Foam::basicSource::setValue(Foam::fvMatrix<scalar>& Eqn)
void Foam::basicSource::addSup(fvMatrix<scalar>& eqn, const label fieldI)
{
notImplemented("Foam::basicSource setValue(Foam::fvMatrix<scalar>& Eqn)");
// do nothing
}
void Foam::basicSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::addSup
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
)
{
// do nothing
}
void Foam::basicSource::addSup(fvMatrix<symmTensor>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::addSup(fvMatrix<tensor>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::setValue(fvMatrix<scalar>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::setValue(fvMatrix<vector>& eqn, const label fieldI)
{
// do nothing
}
void Foam::basicSource::setValue
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
)
{
// do nothing
}
void Foam::basicSource::setValue
(
fvMatrix<symmTensor>& eqn,
const label fieldI
)
{
// do nothing
}
void Foam::basicSource::setValue(fvMatrix<tensor>& eqn, const label fieldI)
{
// do nothing
}

View File

@ -25,52 +25,14 @@ Class
Foam::basicSource
Description
Basic source abtract class
Field source abtract base class. Provides a base set of controls, e.g.
Sources described by:
source1
{
type actuationDiskSource; // explicitSource
type scalarExplicitSource // source type
active on; // on/off switch
timeStart 0.0; // start time
duration 1000.0; // duration
selectionMode cellSet; // cellSet // points //cellZone
cellSet c0; // cellSet name
actuationDiskSourceCoeffs
{
diskDir (-1 0 0); // orientation of the disk
Cp 0.53; // Cp
Ct 0.58; // Ct
diskArea 40; // disk area
}
}
source2
{
type explicitSource;
active on;
timeStart 0.0;
duration 1000.0;
selectionMode points;
cellSet c0;
points // list of points when selectionMode = points
(
(-0.088 0.007 -0.02)
(-0.028 0.007 -0.02)
);
explicitSourceCoeffs
{
volumeMode specific; //absolute
fieldData //field data
{
k 30.7;
epsilon 1.5;
}
}
}
SourceFiles
basicSource.C
@ -81,10 +43,8 @@ SourceFiles
#ifndef basicSource_H
#define basicSource_H
#include "fvMatrices.H"
#include "fvMatricesFwd.H"
#include "cellSet.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
@ -128,8 +88,11 @@ protected:
//- Reference to the mesh database
const fvMesh& mesh_;
//- Dictionary containing the data of the source
const dictionary& dict_;
//- Top level source dictionary
dictionary dict_;
//- Dictionary containing source coefficients
dictionary coeffs_;
//- Source active flag
bool active_;
@ -155,6 +118,12 @@ protected:
//- Sum of cell volumes
scalar V_;
//- Field names to apply source to - populated by derived models
wordList fieldNames_;
//- Applied flag list - corresponds to each fieldNames_ entry
List<bool> applied_;
// Protected functions
@ -271,7 +240,7 @@ public:
inline const fvMesh& mesh() const;
//- Return dictionary
inline const dictionary& dictCoeffs() const;
inline const dictionary& coeffs() const;
//- Return const access to the source active flag
inline bool active() const;
@ -298,6 +267,9 @@ public:
//- Return const access to the cell set
inline const labelList& cells() const;
//- Set the applied flag to true for field index fieldI
inline void setApplied(const label fieldI);
// Edit
@ -314,29 +286,106 @@ public:
// Checks
//- Is the source active?
bool isActive();
virtual bool isActive();
//- Return index of field name if found in fieldNames list
virtual label applyToField(const word& fieldName) const;
//- Check that the source has been applied
virtual void checkApplied() const;
// Evaluation
//- Add source term to vector fvMatrix
virtual void addSu(fvMatrix<vector>& Eqn);
// Add explicit and implicit contributions
//- Add source term to scalar fvMatrix
virtual void addSu(fvMatrix<scalar>& Eqn);
//- Scalar
virtual void addSup
(
fvMatrix<scalar>& eqn,
const label fieldI
);
//- Set constant value on field
virtual void setValue(fvMatrix<scalar>& Eq);
//- Vector
virtual void addSup
(
fvMatrix<vector>& eqn,
const label fieldI
);
//- Spherical tensor
virtual void addSup
(
fvMatrix<symmTensor>& eqn,
const label fieldI
);
//- Symmetric tensor
virtual void addSup
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
);
//- Tensor
virtual void addSup
(
fvMatrix<tensor>& eqn,
const label fieldI
);
// Set values directly
//- Scalar
virtual void setValue
(
fvMatrix<scalar>& eqn,
const label fieldI
);
//- Vector
virtual void setValue
(
fvMatrix<vector>& eqn,
const label fieldI
);
//- Spherical tensor
virtual void setValue
(
fvMatrix<sphericalTensor>& eqn,
const label fieldI
);
//- Symmetric tensor
virtual void setValue
(
fvMatrix<symmTensor>& eqn,
const label fieldI
);
//- Tensor
virtual void setValue
(
fvMatrix<tensor>& eqn,
const label fieldI
);
// I-O
//- Write the source header information
virtual void writeHeader(Ostream&) const;
//- Write the source footer information
virtual void writeFooter(Ostream&) const;
//- Write the source properties
virtual void writeData(Ostream&) const = 0;
virtual void writeData(Ostream&) const;
//- Read source dictionary
virtual bool read(const dictionary& dict) = 0;
virtual bool read(const dictionary& dict);
};

View File

@ -38,11 +38,13 @@ inline const Foam::fvMesh& Foam::basicSource::mesh() const
return mesh_;
}
inline const Foam::dictionary& Foam::basicSource::dictCoeffs() const
inline const Foam::dictionary& Foam::basicSource::coeffs() const
{
return dict_;
return coeffs_;
}
inline bool Foam::basicSource::active() const
{
return active_;
@ -92,6 +94,12 @@ inline const Foam::labelList& Foam::basicSource::cells() const
}
inline void Foam::basicSource::setApplied(const label fieldI)
{
applied_[fieldI] = true;
}
inline bool& Foam::basicSource::active()
{
return active_;

View File

@ -27,11 +27,21 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::basicSource::writeData(Ostream& os) const
void Foam::basicSource::writeHeader(Ostream& os) const
{
os << indent << name_ << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
}
void Foam::basicSource::writeFooter(Ostream& os) const
{
os << decrIndent << indent << token::END_BLOCK << endl;
}
void Foam::basicSource::writeData(Ostream& os) const
{
os.writeKeyword("active") << active_ << token::END_STATEMENT << nl;
os.writeKeyword("timeStart") << timeStart_ << token::END_STATEMENT << nl;
os.writeKeyword("duration") << duration_ << token::END_STATEMENT << nl;
@ -70,8 +80,6 @@ void Foam::basicSource::writeData(Ostream& os) const
<< abort(FatalError);
}
}
os << decrIndent << indent << token::END_BLOCK << endl;
}
@ -80,6 +88,9 @@ bool Foam::basicSource::read(const dictionary& dict)
active_ = readBool(dict.lookup("active"));
timeStart_ = readScalar(dict.lookup("timeStart"));
duration_ = readScalar(dict.lookup("duration"));
coeffs_ = dict.subDict(type() + "Coeffs");
return true;
}

View File

@ -24,6 +24,32 @@ License
\*---------------------------------------------------------------------------*/
#include "basicSourceList.H"
#include "addToRunTimeSelectionTable.H"
#include "fvMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(basicSourceList, 0);
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::basicSourceList::checkApplied() const
{
if (mesh_.time().timeIndex() == checkTimeIndex_)
{
forAll(*this, i)
{
const basicSource& bs = this->operator[](i);
bs.checkApplied();
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -34,7 +60,8 @@ Foam::basicSourceList::basicSourceList
)
:
PtrList<basicSource>(),
mesh_(mesh)
mesh_(mesh),
checkTimeIndex_(mesh_.time().startTimeIndex() + 2)
{
label count = 0;
forAllConstIter(dictionary, dict, iter)
@ -49,6 +76,8 @@ Foam::basicSourceList::basicSourceList
this->setSize(count);
label i = 0;
forAllConstIter(dictionary, dict, iter)
{
if (iter().isDict())
{
const word& name = iter().keyword();
const dictionary& sourceDict = iter().dict();
@ -59,52 +88,16 @@ Foam::basicSourceList::basicSourceList
basicSource::New(name, sourceDict, mesh)
);
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::basicSourceList::addSu(fvMatrix<scalar>& Eqn)
{
forAll(*this, i)
{
if (this->operator[](i).isActive())
{
this->operator[](i).addSu(Eqn);
}
}
}
void Foam::basicSourceList::addSu(fvMatrix<vector>& Eqn)
{
forAll(*this, i)
{
if (this->operator[](i).isActive())
{
this->operator[](i).addSu(Eqn);
}
}
}
void Foam::basicSourceList::setValue(fvMatrix<scalar>& Eqn)
{
forAll(*this, i)
{
if (this->operator[](i).isActive())
{
this->operator[](i).setValue(Eqn);
}
}
}
bool Foam::basicSourceList::read(const dictionary& dict)
{
checkTimeIndex_ = mesh_.time().timeIndex() + 2;
bool allOk = true;
forAll(*this, i)
{

View File

@ -59,9 +59,15 @@ private:
//- Reference to the mesh database
const fvMesh& mesh_;
//- Time index to check that all defined sources have been applied
label checkTimeIndex_;
// Private Member Functions
//- Check that all sources have been applied
void checkApplied() const;
//- Disallow default bitwise copy construct
basicSourceList(const basicSourceList&);
@ -71,6 +77,10 @@ private:
public:
//- Runtime type information
TypeName("basicSourceList");
// Constructors
//- Construct from components with list of field names
@ -86,14 +96,9 @@ public:
// Evaluation
//- Add source terms to scalar fvMatrix
void addSu(fvMatrix<scalar>& Eq);
//- Add source terms to vector fvMatrix
void addSu(fvMatrix<vector>& Eq);
//- Set constant value on field
void setValue(fvMatrix<scalar>& Eq);
//- Apply sources to equation
template<class Type>
void apply(fvMatrix<Type>& eqn);
// I-O
@ -110,7 +115,6 @@ public:
Ostream& os,
const basicSourceList& sources
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -119,6 +123,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "basicSourceListTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -23,14 +23,38 @@ License
\*---------------------------------------------------------------------------*/
#include "explicitSetValue.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::List<Foam::point>&
Foam::explicitSetValue::points() const
template<class Type>
void Foam::basicSourceList::apply(fvMatrix<Type>& eqn)
{
return points_;
checkApplied();
const word& fieldName = eqn.psi().name();
forAll(*this, i)
{
basicSource& source = this->operator[](i);
label fieldI = source.applyToField(fieldName);
if (fieldI != -1)
{
source.setApplied(fieldI);
if (source.isActive())
{
if (debug)
{
Info<< "Applying source " << source.name() << " to field "
<< fieldName << endl;
}
source.addSup(eqn, fieldI);
source.setValue(eqn, fieldI);
}
}
}
}

View File

@ -21,62 +21,31 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
windSimpleFoam
Description
Steady-state solver for incompressible, turbulent flow with external
source in the momentum equation.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "RASModel.H"
#include "IObasicSourceList.H"
#include "simpleControl.H"
#ifndef makeBasicSource_H
#define makeBasicSource_H
#include "basicSource.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"
#include "initContinuityErrs.H"
#define makeBasicSource(Source, Type) \
\
defineTemplateTypeNameAndDebugWithName \
( \
Source<Type>, \
#Type#Source, \
0 \
); \
\
basicSource::adddictionaryConstructorToTable<Source<Type> > \
add##Source##Type##dictionary##ConstructorTobasicSourceTable_
IObasicSourceList actuationDisks(mesh);
simpleControl simple(mesh);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (simple.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;
// Pressure-velocity SIMPLE corrector
{
#include "UEqn.H"
#include "pEqn.H"
}
turbulence->correct();
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return 0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -23,27 +23,76 @@ License
\*---------------------------------------------------------------------------*/
template <class Type>
void Foam::explicitSetValue::setFieldValue
(
fvMatrix<Type>& Eqn,
const Type& value
) const
#include "ExplicitSetValue.H"
#include "fvMesh.H"
#include "fvMatrices.H"
#include "DimensionedField.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::ExplicitSetValue<Type>::setFieldData(const dictionary& dict)
{
Type data = value;
fieldNames_.setSize(dict.toc().size());
fieldData_.setSize(fieldNames_.size());
applied_.setSize(fieldNames_.size(), false);
label i = 0;
forAllConstIter(dictionary, dict, iter)
{
fieldNames_[i] = iter().keyword();
dict.lookup(iter().keyword()) >> fieldData_[i];
i++;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::ExplicitSetValue<Type>::ExplicitSetValue
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
fieldData_()
{
read(dict);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::ExplicitSetValue<Type>::setValue
(
fvMatrix<Type>& eqn,
const label fieldI
)
{
if (debug)
{
Info<< "ExplicitSetValue<"<< pTraits<Type>::typeName
<< ">::setValue for source " << name_ << endl;
}
DimensionedField<Type, volMesh> rhs
(
IOobject
(
"rhs",
Eqn.psi().mesh().time().timeName(),
Eqn.psi().mesh(),
name_ + fieldNames_[fieldI] + "rhs",
eqn.psi().mesh().time().timeName(),
eqn.psi().mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
Eqn.psi().mesh(),
eqn.psi().mesh(),
dimensioned<Type>
(
"zero",
@ -52,53 +101,14 @@ void Foam::explicitSetValue::setFieldValue
)
);
List<Type> values(this->cells().size());
List<Type> values(cells_.size());
forAll (values, i)
forAll(values, i)
{
values[i] = data;
values[i] = fieldData_[fieldI];
}
Eqn.setValues(this->cells(), values);
}
template <class Type>
void Foam::explicitSetValue::addField
(
HashTable<Type>& fields,
const wordList& fieldTypes,
const wordList& fieldNames,
const dictionary& fieldDataDict
)
{
typedef GeometricField<Type, fvPatchField, volMesh> geometricField;
forAll (fieldTypes, fieldI)
{
word fieldName = fieldNames[fieldI];
word fieldType = fieldTypes[fieldI];
if
(
(
fieldType
== GeometricField<Type, fvPatchField, volMesh>::typeName
) &&
(
this->mesh().foundObject<geometricField>(fieldName)
)
)
{
Type fieldValue = fieldDataDict.lookupOrDefault<Type>
(
fieldName,
pTraits<Type>::zero
);
fields.insert(fieldName, fieldValue);
}
}
eqn.setValues(cells_, values);
}

View File

@ -29,27 +29,26 @@ Description
Sources described by:
explicitSetValueCoeffs
<Type>ExplicitSetValueCoeffs
{
fieldData // field data - usage for multiple fields
fieldData
{
k 30.7;
epsilon 1.5;
}
}
SourceFiles
explicitSetValue.C
\*---------------------------------------------------------------------------*/
#ifndef explicitSetValue_H
#define explicitSetValue_H
#ifndef ExplicitSetValue_H
#define ExplicitSetValue_H
#include "cellSet.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
#include "basicSource.H"
#include "Tuple2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -60,37 +59,18 @@ namespace Foam
Class explicitSetValue Declaration
\*---------------------------------------------------------------------------*/
class explicitSetValue
template<class Type>
class ExplicitSetValue
:
public basicSource
{
// Private data
//- List of field types
HashTable<scalar> scalarFields_;
HashTable<vector> vectorFields_;
//- Set value to field
template<class Type>
void setFieldValue(fvMatrix<Type>&, const Type&) const;
//- Add field names and values to field table for types.
template<class Type>
void addField
(
HashTable<Type>& fields,
const wordList& fieldTypes,
const wordList& fieldNames,
const dictionary& dict
);
protected:
// Protected data
//- Coefficients dictionary
dictionary coeffs_;
//- Source value per field
List<Type> fieldData_;
// Protected functions
@ -108,7 +88,7 @@ public:
// Constructors
//- Construct from components
explicitSetValue
ExplicitSetValue
(
const word& name,
const word& modelType,
@ -116,30 +96,13 @@ public:
const fvMesh& mesh
);
//- Return clone
autoPtr<explicitSetValue> clone() const
{
notImplemented("autoPtr<explicitSetValue> clone() const");
return autoPtr<explicitSetValue>(NULL);
}
// Member Functions
// Edit
//- Return points
inline const List<point>& points() const;
// Evaluation
//- Set value on vector field
virtual void setValue(fvMatrix<vector>& UEqn);
//- Set value on scalar field
virtual void setValue(fvMatrix<scalar>& UEqn);
virtual void setValue(fvMatrix<Type>& eqn, const label fieldI);
// I-O
@ -147,15 +110,8 @@ public:
//- Write the source properties
virtual void writeData(Ostream&) const;
//- Read fieldData in sub-dictionary
//- Read source dictionary
virtual bool read(const dictionary& dict);
//- Ostream operator
friend Ostream& operator<<
(
Ostream& os,
const explicitSetValue& source
);
};
@ -165,13 +121,9 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "explicitSetValueIO.C"
#include "explicitSetValueI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "explicitSetValueTemplates.C"
# include "ExplicitSetValue.C"
# include "ExplicitSetValueIO.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,22 +23,23 @@ License
\*---------------------------------------------------------------------------*/
#include "explicitSetValue.H"
#include "ExplicitSetValue.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::explicitSetValue::writeData(Ostream& os) const
template<class Type>
void Foam::ExplicitSetValue<Type>::writeData(Ostream& os) const
{
os << indent << name_ << endl;
dict_.write(os);
}
bool Foam::explicitSetValue::read(const dictionary& dict)
template<class Type>
bool Foam::ExplicitSetValue<Type>::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
coeffs_ = dict.subDict(typeName + "Coeffs");
setFieldData(coeffs_.subDict("fieldData"));
return true;
}
@ -49,13 +50,4 @@ bool Foam::explicitSetValue::read(const dictionary& dict)
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const explicitSetValue& source)
{
source.writeData(os);
return os;
}
// ************************************************************************* //

View File

@ -23,92 +23,18 @@ License
\*---------------------------------------------------------------------------*/
#include "explicitSetValue.H"
#include "fvMesh.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
#include "HashSet.H"
#include "makeBasicSource.H"
#include "ExplicitSetValue.H"
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(explicitSetValue, 0);
addToRunTimeSelectionTable
(
basicSource,
explicitSetValue,
dictionary
);
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::explicitSetValue::setFieldData(const dictionary& dict)
{
scalarFields_.clear();
vectorFields_.clear();
wordList fieldTypes(dict.toc().size());
wordList fieldNames(dict.toc().size());
forAll(dict.toc(), i)
{
const word& fieldName = dict.toc()[i];
IOobject io
(
fieldName,
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);
if (io.headerOk())
{
fieldTypes[i] = io.headerClassName();
fieldNames[i] = dict.toc()[i];
}
else
{
FatalErrorIn("explicitSetValue::setFieldData")
<< "header not OK for field " << io.name()
<< abort(FatalError);
}
}
addField(scalarFields_, fieldTypes, fieldNames, dict);
addField(vectorFields_, fieldTypes, fieldNames, dict);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::explicitSetValue::explicitSetValue
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
coeffs_(dict.subDict(modelType + "Coeffs"))
{
setFieldData(coeffs_.subDict("fieldData"));
}
void Foam::explicitSetValue::setValue(fvMatrix<scalar>& Eqn)
{
setFieldValue(Eqn, scalarFields_[Eqn.psi().name()]);
}
void Foam::explicitSetValue::setValue(fvMatrix<vector>& Eqn)
{
setFieldValue(Eqn, vectorFields_[Eqn.psi().name()]);
makeBasicSource(ExplicitSetValue, scalar);
makeBasicSource(ExplicitSetValue, vector);
makeBasicSource(ExplicitSetValue, sphericalTensor);
makeBasicSource(ExplicitSetValue, symmTensor);
makeBasicSource(ExplicitSetValue, tensor);
}

View File

@ -0,0 +1,175 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "ExplicitSource.H"
#include "fvMesh.H"
#include "fvMatrices.H"
#include "DimensionedField.H"
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
template<class Type>
const Foam::wordList Foam::ExplicitSource<Type>::
volumeModeTypeNames_
(
IStringStream("(absolute specific)")()
);
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type>
typename Foam::ExplicitSource<Type>::volumeModeType
Foam::ExplicitSource<Type>::wordToVolumeModeType
(
const word& vmtName
) const
{
forAll(volumeModeTypeNames_, i)
{
if (vmtName == volumeModeTypeNames_[i])
{
return volumeModeType(i);
}
}
FatalErrorIn
(
"ExplicitSource<Type>::volumeModeType"
"ExplicitSource<Type>::wordToVolumeModeType(const word&)"
) << "Unknown volumeMode type " << vmtName
<< ". Valid volumeMode types are:" << nl << volumeModeTypeNames_
<< exit(FatalError);
return volumeModeType(0);
}
template<class Type>
Foam::word Foam::ExplicitSource<Type>::volumeModeTypeToWord
(
const volumeModeType& vmtType
) const
{
if (vmtType > volumeModeTypeNames_.size())
{
return "UNKNOWN";
}
else
{
return volumeModeTypeNames_[vmtType];
}
}
template<class Type>
void Foam::ExplicitSource<Type>::setFieldData(const dictionary& dict)
{
fieldNames_.setSize(dict.toc().size());
fieldData_.setSize(fieldNames_.size());
applied_.setSize(fieldNames_.size(), false);
label i = 0;
forAllConstIter(dictionary, dict, iter)
{
fieldNames_[i] = iter().keyword();
dict.lookup(iter().keyword()) >> fieldData_[i];
i++;
}
// Set volume normalisation
if (volumeMode_ == vmAbsolute)
{
VDash_ = V_;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::ExplicitSource<Type>::ExplicitSource
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
volumeMode_(vmAbsolute),
VDash_(1.0),
fieldData_()
{
read(dict);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::ExplicitSource<Type>::addSup
(
fvMatrix<Type>& eqn,
const label fieldI
)
{
// if (debug)
{
Info<< "ExplicitSource<"<< pTraits<Type>::typeName
<< ">::addSup for source " << name_ << endl;
}
DimensionedField<Type, volMesh> Su
(
IOobject
(
name_ + fieldNames_[fieldI] + "Sup",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensioned<Type>
(
"zero",
eqn.dimensions()/dimVolume,
pTraits<Type>::zero
),
false
);
forAll(cells_, i)
{
Su[cells_[i]] = fieldData_[fieldI]/VDash_;
}
eqn -= Su;
}
// ************************************************************************* //

View File

@ -22,39 +22,37 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::explicitSource
Foam::ExplicitSource
Description
Explicit source.
Explicit source
Sources described by:
explicitSourceCoeffs
<Type>ExplicitSourceCoeffs
{
points // list of points when selectionMode = points
(
(-0.088 0.007 -0.02)
(-0.028 0.007 -0.02)
);
volumeMode specific; //absolute
fieldData // field data - usage for multiple fields
volumeMode absolute; // specific
fieldData
{
k 30.7;
epsilon 1.5;
}
}
If volumeMode =
- absolute: values are given as <quantity>
- specific: values are given as <quantity>/m3
SourceFiles
explicitSource.C
ExplicitSource.C
\*---------------------------------------------------------------------------*/
#ifndef explicitSource_H
#define explicitSource_H
#ifndef ExplicitSource_H
#define ExplicitSource_H
#include "cellSet.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
#include "Tuple2.H"
#include "basicSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -62,35 +60,31 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class fvMesh;
template<class Type>
class ExplicitSource;
// Forward declaration of friend functions
template<class Type>
Ostream& operator<<
(
Ostream&,
const ExplicitSource<Type>&
);
/*---------------------------------------------------------------------------*\
Class explicitSource Declaration
Class ExplicitSource Declaration
\*---------------------------------------------------------------------------*/
class explicitSource
template<class Type>
class ExplicitSource
:
public basicSource
{
// Private data
//- List of field types
HashTable<scalar> scalarFields_;
HashTable<vector> vectorFields_;
//- Add source to matrix
template<class Type>
void addSource(fvMatrix<Type>&, const Type&) const;
//- Add field names and values to field table for types.
template<class Type>
void addField
(
HashTable<Type>& fields,
const wordList& fieldTypes,
const wordList& fieldNames,
const dictionary& dict
);
public:
// Public data
@ -103,22 +97,31 @@ public:
};
//- Word list of volume mode type names
static const NamedEnum<volumeModeType, 2> volumeModeTypeNames_;
static const wordList volumeModeTypeNames_;
protected:
// Protected data
//- Coefficients dictionary
dictionary coeffs_;
//- Volume mode
volumeModeType volumeMode_;
//- Volume normalisation
scalar VDash_;
//- Source field values
List<Type> fieldData_;
// Protected functions
//- Helper function to convert from a word to a volumeModeType
volumeModeType wordToVolumeModeType(const word& vtName) const;
//- Helper function to convert from a volumeModeType to a word
word volumeModeTypeToWord(const volumeModeType& vtType) const;
//- Set the local field data
void setFieldData(const dictionary& dict);
@ -126,13 +129,13 @@ protected:
public:
//- Runtime type information
TypeName("explicitSource");
TypeName("ExplicitSource");
// Constructors
//- Construct from components
explicitSource
ExplicitSource
(
const word& name,
const word& modelType,
@ -140,17 +143,6 @@ public:
const fvMesh& mesh
);
//- Return clone
autoPtr<explicitSource> clone() const
{
notImplemented
(
"autoPtr<explicitSource> clone() const"
);
return autoPtr<explicitSource>(NULL);
}
// Member Functions
@ -159,23 +151,23 @@ public:
//- Return const access to the volume mode
inline const volumeModeType& volumeMode() const;
//- Return const access to the source field values
inline const List<Type>& fieldData() const;
// Edit
//- Return access to the volume mode
inline volumeModeType& volumeMode();
//- Return points
inline const List<point>& points() const;
//- Return access to the source field values
inline List<Type>& fieldData();
// Evaluation
//-Source term to fvMatrix<vector>
virtual void addSu(fvMatrix<vector>& UEqn);
//-Source term to fvMatrix<scalar>
virtual void addSu(fvMatrix<scalar>& UEqn);
//- Add explicit contribution to equation
virtual void addSup(fvMatrix<Type>& eqn, const label fieldI);
// I-O
@ -183,15 +175,8 @@ public:
//- Write the source properties
virtual void writeData(Ostream&) const;
//- Read fieldData in sub-dictionary
//- Read source dictionary
virtual bool read(const dictionary& dict);
//- Ostream operator
friend Ostream& operator<<
(
Ostream& os,
const explicitSource& source
);
};
@ -201,14 +186,14 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "explicitSourceIO.C"
#include "explicitSourceI.H"
#ifdef NoRepository
# include "ExplicitSource.C"
# include "ExplicitSourceIO.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "explicitSourceTemplates.C"
#endif
#include "ExplicitSourceI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,28 +23,37 @@ License
\*---------------------------------------------------------------------------*/
#include "explicitSource.H"
#include "ExplicitSource.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::explicitSource::volumeModeType&
Foam::explicitSource::volumeMode() const
template<class Type>
inline const typename Foam::ExplicitSource<Type>::volumeModeType&
Foam::ExplicitSource<Type>::volumeMode() const
{
return volumeMode_;
}
inline Foam::explicitSource::volumeModeType&
Foam::explicitSource::volumeMode()
template<class Type>
inline const Foam::List<Type>& Foam::ExplicitSource<Type>::fieldData() const
{
return fieldData_;
}
template<class Type>
inline typename Foam::ExplicitSource<Type>::volumeModeType&
Foam::ExplicitSource<Type>::volumeMode()
{
return volumeMode_;
}
inline const Foam::List<Foam::point>&
Foam::explicitSource::points() const
template<class Type>
inline Foam::List<Type>& Foam::ExplicitSource<Type>::fieldData()
{
return points_;
return fieldData_;
}

View File

@ -23,23 +23,26 @@ License
\*---------------------------------------------------------------------------*/
#include "explicitSource.H"
#include "ExplicitSource.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::explicitSource::writeData(Ostream& os) const
template<class Type>
void Foam::ExplicitSource<Type>::writeData(Ostream& os) const
{
os << indent << name_ << endl;
dict_.write(os);
}
bool Foam::explicitSource::read(const dictionary& dict)
template<class Type>
bool Foam::ExplicitSource<Type>::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
coeffs_ = dict.subDict(typeName + "Coeffs");
setFieldData(coeffs_.subDict("fieldData"));
volumeMode_ = wordToVolumeModeType(coeffs_.lookup("volumeMode"));
return true;
}
else
@ -49,13 +52,4 @@ bool Foam::explicitSource::read(const dictionary& dict)
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const explicitSource& source)
{
source.writeData(os);
return os;
}
// ************************************************************************* //

View File

@ -23,111 +23,18 @@ License
\*---------------------------------------------------------------------------*/
#include "explicitSource.H"
#include "fvMesh.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
#include "HashSet.H"
#include "makeBasicSource.H"
#include "ExplicitSource.H"
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(explicitSource, 0);
addToRunTimeSelectionTable
(
basicSource,
explicitSource,
dictionary
);
// * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
template<> const char* NamedEnum
<
explicitSource::volumeModeType,
2
>::names[] =
{
"absolute",
"specific"
};
const NamedEnum<explicitSource::volumeModeType, 2>
explicitSource::volumeModeTypeNames_;
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::explicitSource::setFieldData(const dictionary& dict)
{
scalarFields_.clear();
vectorFields_.clear();
wordList fieldTypes(dict.toc().size());
wordList fieldNames(dict.toc().size());
forAll(dict.toc(), i)
{
const word& fieldName = dict.toc()[i];
IOobject io
(
fieldName,
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);
if (io.headerOk())
{
fieldTypes[i] = io.headerClassName();
fieldNames[i] = dict.toc()[i];
}
else
{
FatalErrorIn
(
"explicitSource::setFieldData"
) << "header not OK " << io.name()
<< exit(FatalError);
}
}
addField(scalarFields_, fieldTypes, fieldNames, dict);
addField(vectorFields_, fieldTypes, fieldNames, dict);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::explicitSource::explicitSource
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
coeffs_(dict.subDict(modelType + "Coeffs")),
volumeMode_(volumeModeTypeNames_.read(coeffs_.lookup("volumeMode")))
{
setFieldData(dict_.subDict("fieldData"));
}
void Foam::explicitSource::addSu(fvMatrix<scalar>& Eqn)
{
addSource(Eqn, scalarFields_[Eqn.psi().name()]);
}
void Foam::explicitSource::addSu(fvMatrix<vector>& Eqn)
{
addSource(Eqn, vectorFields_[Eqn.psi().name()]);
makeBasicSource(ExplicitSource, scalar);
makeBasicSource(ExplicitSource, vector);
makeBasicSource(ExplicitSource, sphericalTensor);
makeBasicSource(ExplicitSource, symmTensor);
makeBasicSource(ExplicitSource, tensor);
}

View File

@ -1,104 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
\*---------------------------------------------------------------------------*/
template <class Type>
void Foam::explicitSource::addSource
(
fvMatrix<Type>& Eqn,
const Type& sourceData
) const
{
Type data = sourceData;
if (volumeMode_ == vmAbsolute)
{
// Convert to specific quantity
data /= V_;
}
DimensionedField<Type, volMesh> rhs
(
IOobject
(
"rhs",
Eqn.psi().mesh().time().timeName(),
Eqn.psi().mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
Eqn.psi().mesh(),
dimensioned<Type>
(
"zero",
Eqn.dimensions()/dimVolume,
pTraits<Type>::zero
)
);
UIndirectList<Type>(rhs, this->cells()) = data;
Eqn -= rhs;
}
template <class Type>
void Foam::explicitSource::addField
(
HashTable<Type>& fields,
const wordList& fieldTypes,
const wordList& fieldNames,
const dictionary& fieldDataDict
)
{
typedef GeometricField<Type, fvPatchField, volMesh> geometricField;
forAll (fieldTypes, fieldI)
{
word fieldName = fieldNames[fieldI];
word fieldType = fieldTypes[fieldI];
if
(
(
fieldType
== GeometricField<Type, fvPatchField, volMesh>::typeName
) &&
(
this->mesh().foundObject<geometricField>(fieldName)
)
)
{
Type fieldValue = fieldDataDict.lookupOrDefault<Type>
(
fieldName,
pTraits<Type>::zero
);
fields.insert(fieldName, fieldValue);
}
}
}
// ************************************************************************* //

View File

@ -24,8 +24,25 @@ License
\*---------------------------------------------------------------------------*/
#include "pressureGradientExplicitSource.H"
#include "volFields.H"
#include "fvMatrices.H"
#include "DimensionedField.H"
#include "IFstream.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(pressureGradientExplicitSource, 0);
addToRunTimeSelectionTable
(
basicSource,
pressureGradientExplicitSource,
dictionary
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -38,7 +55,7 @@ void Foam::pressureGradientExplicitSource::writeGradP() const
(
IOobject
(
sourceName_ + "Properties",
name_ + "Properties",
mesh_.time().timeName(),
"uniform",
mesh_,
@ -52,65 +69,76 @@ void Foam::pressureGradientExplicitSource::writeGradP() const
}
void Foam::pressureGradientExplicitSource::update(fvMatrix<vector>& eqn)
{
volVectorField& U = const_cast<volVectorField&>(eqn.psi());
const volScalarField& rAU =
mesh_.lookupObject<volScalarField>("(1|A(" + U.name() + "))");
// Integrate flow variables over cell set
scalar magUbarAve = 0.0;
scalar rAUave = 0.0;
const scalarField& cv = mesh_.V();
forAll(cells_, i)
{
label cellI = cells_[i];
scalar volCell = cv[cellI];
magUbarAve += (flowDir_ & U[cellI])*volCell;
rAUave += rAU[cellI]*volCell;
}
// Collect across all processors
reduce(magUbarAve, sumOp<scalar>());
// Volume averages
magUbarAve /= V_;
rAUave /= V_;
// Calculate the pressure gradient increment needed to adjust the average
// flow-rate to the desired value
scalar gradPplus = (mag(Ubar_) - magUbarAve)/rAUave;
// Apply correction to velocity field
forAll(cells_, i)
{
label cellI = cells_[i];
U[cellI] += flowDir_*rAU[cellI]*gradPplus;
}
// Update pressure gradient
gradP_.value() += gradPplus;
Info<< "Uncorrected Ubar = " << magUbarAve << tab
<< "Pressure gradient = " << gradP_.value() << endl;
writeGradP();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
(
const word& sourceName,
volVectorField& U
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
sourceName_(sourceName),
mesh_(U.mesh()),
U_(U),
dict_
(
IOobject
(
sourceName + "Properties",
mesh_.time().constant(),
mesh_,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
),
Ubar_(dict_.lookup("Ubar")),
gradPini_(dict_.lookup("gradPini")),
basicSource(sourceName, modelType, dict, mesh),
Ubar_(coeffs_.lookup("Ubar")),
gradPini_(coeffs_.lookup("gradPini")),
gradP_(gradPini_),
flowDir_(Ubar_/mag(Ubar_)),
cellSource_(dict_.lookup("cellSource")),
cellSelector_
(
topoSetSource::New
(
cellSource_,
mesh_,
dict_.subDict(cellSource_ + "Coeffs")
)
),
selectedCellSet_
(
mesh_,
sourceName_ + "CellSet",
mesh_.nCells()/10 + 1 // Reasonable size estimate.
)
flowDir_(Ubar_/mag(Ubar_))
{
// Create the cell set
cellSelector_->applyToSet
(
topoSetSource::NEW,
selectedCellSet_
);
// Give some feedback
Info<< " Selected "
<< returnReduce(selectedCellSet_.size(), sumOp<label>())
<< " cells" << endl;
coeffs_.lookup("fieldNames") >> fieldNames_;
applied_.setSize(fieldNames_.size(), false);
// Read the initial pressure gradient from file if it exists
IFstream propsFile
(
mesh_.time().timeName()/"uniform"/(sourceName_ + "Properties")
mesh_.time().timeName()/"uniform"/(name_ + "Properties")
);
if (propsFile.good())
@ -126,16 +154,19 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh> >
Foam::pressureGradientExplicitSource::Su() const
void Foam::pressureGradientExplicitSource::addSup
(
fvMatrix<vector>& eqn,
const label fieldI
)
{
tmp<DimensionedField<vector, volMesh> > tSource
(
new DimensionedField<vector, volMesh>
update(eqn);
DimensionedField<vector, volMesh> Su
(
IOobject
(
sourceName_,
name_ + fieldNames_[fieldI] + "Sup",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
@ -143,69 +174,11 @@ Foam::pressureGradientExplicitSource::Su() const
),
mesh_,
dimensionedVector("zero", gradP_.dimensions(), vector::zero)
)
);
DimensionedField<vector, volMesh>& sourceField = tSource();
UIndirectList<vector>(Su, cells_) = flowDir_*gradP_.value();
forAllConstIter(cellSet, selectedCellSet_, iter)
{
label cellI = iter.key();
sourceField[cellI] = flowDir_*gradP_.value();
}
return tSource;
}
void Foam::pressureGradientExplicitSource::update()
{
const volScalarField& rAU =
mesh_.lookupObject<volScalarField>("(1|A(" + U_.name() + "))");
// Integrate flow variables over cell set
scalar volTot = 0.0;
scalar magUbarAve = 0.0;
scalar rAUave = 0.0;
forAllConstIter(cellSet, selectedCellSet_, iter)
{
label cellI = iter.key();
scalar volCell = mesh_.V()[cellI];
volTot += volCell;
magUbarAve += (flowDir_ & U_[cellI])*volCell;
rAUave += rAU[cellI]*volCell;
}
// Collect across all processors
reduce(volTot, sumOp<scalar>());
reduce(magUbarAve, sumOp<scalar>());
reduce(rAUave, sumOp<scalar>());
// Volume averages
magUbarAve /= volTot;
rAUave /= volTot;
// Calculate the pressure gradient increment needed to adjust the average
// flow-rate to the desired value
scalar gradPplus = (mag(Ubar_) - magUbarAve)/rAUave;
// Apply correction to velocity field
forAllConstIter(cellSet, selectedCellSet_, iter)
{
label cellI = iter.key();
U_[cellI] += flowDir_*rAU[cellI]*gradPplus;
}
// Update pressure gradient
gradP_.value() += gradPplus;
Info<< "Uncorrected Ubar = " << magUbarAve << tab
<< "Pressure gradient = " << gradP_.value() << endl;
writeGradP();
eqn -= Su;
}

View File

@ -25,10 +25,21 @@ Class
Foam::pressureGradientExplicitSource
Description
Creates a cell set pressure gradient source
Creates a pressure gradient source
Note: Currently only handles kinematic pressure
Sources described by:
pressureGradientExplicitSourceCoeffs
{
UName U; // name of velocity field
Ubar (10.0 0 0); // desired average velocity
gradPini gradPini [0 2 -2 0 0] 0; // initial pressure gradient
flowDir (1 0 0); // flow direction
}
SourceFiles
pressureGradientExplicitSource.C
@ -42,6 +53,7 @@ SourceFiles
#include "cellSet.H"
#include "fvMesh.H"
#include "volFields.H"
#include "basicSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -53,21 +65,11 @@ namespace Foam
\*---------------------------------------------------------------------------*/
class pressureGradientExplicitSource
:
public basicSource
{
// Private data
//- Name of the source
const word sourceName_;
//- Reference to the mesh
const fvMesh& mesh_;
//- Reference to the velocity field
volVectorField& U_;
//- Properties dictionary
IOdictionary dict_;
//- Average velocity
vector Ubar_;
@ -80,21 +82,15 @@ class pressureGradientExplicitSource
//- Flow direction
vector flowDir_;
//- Name of cell source
word cellSource_;
//- The method by which the cells will be selected
autoPtr<topoSetSource> cellSelector_;
//- The set of selected cells
cellSet selectedCellSet_;
// Private Member Functions
//- Write the pressure gradient to file (for restarts etc)
void writeGradP() const;
//- Correct driving force for a constant mass flow rate
void update(fvMatrix<vector>& eqn);
//- Disallow default bitwise copy construct
pressureGradientExplicitSource(const pressureGradientExplicitSource&);
@ -104,13 +100,19 @@ class pressureGradientExplicitSource
public:
//- Runtime type information
TypeName("pressureGradientExplicitSource");
// Constructors
//- Construct from explicit source name and mesh
pressureGradientExplicitSource
(
const word& sourceName,
volVectorField& U
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
);
@ -118,12 +120,17 @@ public:
// Access
//- Return a tmp field of the source
tmp<DimensionedField<vector, volMesh> > Su() const;
//- Add explicit contribution to equation
virtual void addSup(fvMatrix<vector>& eqn, const label fieldI);
//- Correct driving force for a constant mass flow rate
void update();
// I-O
//- Write the source properties
virtual void writeData(Ostream&) const;
//- Read source dictionary
virtual bool read(const dictionary& dict);
};

View File

@ -23,22 +23,34 @@ License
\*---------------------------------------------------------------------------*/
#include "timeActivatedExplicitSource.H"
#include "pressureGradientExplicitSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
namespace Foam
void Foam::pressureGradientExplicitSource::writeData(Ostream& os) const
{
defineTemplateTypeNameAndDebug
notImplemented
(
IOPtrList<scalarTimeActivatedExplicitSource>,
0
);
defineTemplateTypeNameAndDebug
(
IOPtrList<vectorTimeActivatedExplicitSource>,
0
"void Foam::pressureGradientExplicitSource::writeData"
"("
"Ostream&"
") const"
);
}
bool Foam::pressureGradientExplicitSource::read(const dictionary& dict)
{
notImplemented
(
"bool Foam::pressureGradientExplicitSource::read"
"("
"const dictionary&"
") const"
);
return false;
}
// ************************************************************************* //

View File

@ -53,30 +53,31 @@ Foam::radialActuationDiskSource::radialActuationDiskSource
)
:
actuationDiskSource(name, modelType, dict, mesh),
coeffsDict_(dict.subDict(modelType + "Coeffs")),
coeffs_()
radialCoeffs_(coeffs_.lookup("coeffs"))
{
coeffsDict_.lookup("coeffs") >> coeffs_;
Info<< " - creating radial actuation disk zone: "
<< this->name() << endl;
Info<< " - creating radial actuation disk zone: " << name_ << endl;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::radialActuationDiskSource::addSu(fvMatrix<vector>& UEqn)
void Foam::radialActuationDiskSource::addSup
(
fvMatrix<vector>& eqn,
const label fieldI
)
{
bool compressible = false;
if (UEqn.dimensions() == dimensionSet(1, 1, -2, 0, 0))
if (eqn.dimensions() == dimForce)
{
compressible = true;
}
const scalarField& cellsV = this->mesh().V();
vectorField& Usource = UEqn.source();
const vectorField& U = UEqn.psi();
const scalarField& cellsV = mesh_.V();
vectorField& Usource = eqn.source();
const vectorField& U = eqn.psi();
if (V() > VSMALL)
if (V_ > VSMALL)
{
if (compressible)
{
@ -85,7 +86,7 @@ void Foam::radialActuationDiskSource::addSu(fvMatrix<vector>& UEqn)
Usource,
cells_,
cellsV,
this->mesh().lookupObject<volScalarField>("rho"),
mesh_.lookupObject<volScalarField>("rho"),
U
);
}
@ -114,12 +115,11 @@ bool Foam::radialActuationDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
const dictionary& coeffsDict_ = dict.subDict(typeName + "Coeffs");
coeffsDict_.readIfPresent("diskDir", diskDir_);
coeffsDict_.readIfPresent("Cp", Cp_);
coeffsDict_.readIfPresent("Ct", Ct_);
coeffsDict_.readIfPresent("diskArea", diskArea_);
coeffsDict_.lookup("coeffs") >> coeffs_;
coeffs_.readIfPresent("diskDir", diskDir_);
coeffs_.readIfPresent("Cp", Cp_);
coeffs_.readIfPresent("Ct", Ct_);
coeffs_.readIfPresent("diskArea", diskArea_);
coeffs_.lookup("coeffs") >> radialCoeffs_;
return true;
}
else

View File

@ -31,6 +31,7 @@ Description
T = 2*rho*A*sqr(Uo)*a*(1-a)
U1 = (1 -a)Uo
where:
A: disk area
Uo: upstream velocity
@ -39,8 +40,21 @@ Description
The thrust is distributed by a radial function:
thrust(r) = T*(C0 + C1*r^2 + C2*r^4)
Sources described by:
actuationDiskSourceCoeffs
{
fieldName U; // name of field to apply source
diskDir (-1 0 0); // disk direction
Cp 0.1; // power coefficient
Ct 0.5; // thrust coefficient
diskArea 5.0; // disk area
coeffs (0.1 0.5 0.01); // radial distribution coefficients
}
SourceFiles
radialActuationDiskSource.C
@ -51,10 +65,8 @@ SourceFiles
#ifndef radialActuationDiskSource_H
#define radialActuationDiskSource_H
#include "DimensionedField.H"
#include "volFieldsFwd.H"
#include "FixedList.H"
#include "actuationDiskSource.H"
#include "FixedList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -71,11 +83,8 @@ class radialActuationDiskSource
{
// Private data
//- Coefficients dictionary
dictionary coeffsDict_;
//- Coeffcients for the radial distribution
FixedList<scalar, 3> coeffs_;
FixedList<scalar, 3> radialCoeffs_;
// Private Member Functions
@ -124,7 +133,7 @@ public:
// Public Functions
//- Source term to fvMatrix<vector>
virtual void addSu(fvMatrix<vector>& UEqn);
virtual void addSup(fvMatrix<vector>& eqn, const label fieldI);
// I-O

View File

@ -61,24 +61,25 @@ addRadialActuationDiskAxialInertialResistance
const scalar maxR = gMax(mag(zoneCellCentres - avgCentre));
scalar intCoeffs =
coeffs_[0]
+ coeffs_[1]*sqr(maxR)/2.0
+ coeffs_[2]*pow4(maxR)/3.0;
radialCoeffs_[0]
+ radialCoeffs_[1]*sqr(maxR)/2.0
+ radialCoeffs_[2]*pow4(maxR)/3.0;
forAll(cells, i)
{
T[i] = 2.0*rho[cells[i]]*diskArea_*mag(U[cells[i]])*a/(1.0 - a);
scalar r = mag(mesh().cellCentres()[cells[i]] - avgCentre);
scalar r2 = magSqr(mesh().cellCentres()[cells[i]] - avgCentre);
Tr[i] =
T[i]*(coeffs_[0] + coeffs_[1]*sqr(r) + coeffs_[2]*pow4(r))
T[i]
*(radialCoeffs_[0] + radialCoeffs_[1]*r2 + radialCoeffs_[2]*sqr(r2))
/intCoeffs;
}
forAll(cells, i)
{
Usource[cells[i]] += ((Vcells[cells[i]]/V())*Tr[i]*E) & U[cells[i]];
Usource[cells[i]] += ((Vcells[cells[i]]/V_)*Tr[i]*E) & U[cells[i]];
}
if (debug)

View File

@ -28,7 +28,7 @@ Description
Base class for profile models
SourceFiles
profileModel.C
profileModelList.C
\*---------------------------------------------------------------------------*/

View File

@ -28,6 +28,7 @@ License
#include "mathematicalConstants.H"
#include "unitConversion.H"
#include "geometricOneField.H"
#include "fvMatrices.H"
using namespace Foam::constant;
@ -262,10 +263,8 @@ void Foam::rotorDiskSource::createCoordinateSystem()
}
default:
{
FatalErrorIn
(
"rotorDiskSource::createCoordinateSystem(const geometryMode&);"
) << "Unknown geometryMode " << geometryModeTypeNames_[gm]
FatalErrorIn("rotorDiskSource::createCoordinateSystem()")
<< "Unknown geometryMode " << geometryModeTypeNames_[gm]
<< ". Available geometry modes include "
<< geometryModeTypeNames_ << exit(FatalError);
}
@ -369,7 +368,6 @@ Foam::rotorDiskSource::rotorDiskSource
)
:
basicSource(name, modelType, dict, mesh),
coeffs_(dict_.subDict(type() + "Coeffs")),
rhoName_("none"),
omega_(0.0),
nBlades_(0),
@ -399,20 +397,20 @@ Foam::rotorDiskSource::~rotorDiskSource()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::rotorDiskSource::addSu(fvMatrix<vector>& UEqn)
void Foam::rotorDiskSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
{
// add source to lhs of eqn
const volVectorField& U = UEqn.psi();
const volVectorField& U = eqn.psi();
if (UEqn.dimensions() == dimForce)
if (eqn.dimensions() == dimForce)
{
coeffs_.lookup("rhoName") >> rhoName_;
const volScalarField& rho =
mesh_.lookupObject<volScalarField>(rhoName_);
UEqn += calculateForces
eqn += calculateForces
(
rho.internalField(),
inflowVelocity(U),
@ -421,7 +419,7 @@ void Foam::rotorDiskSource::addSu(fvMatrix<vector>& UEqn)
}
else
{
UEqn += calculateForces
eqn += calculateForces
(
oneField(),
inflowVelocity(U),
@ -431,12 +429,6 @@ void Foam::rotorDiskSource::addSu(fvMatrix<vector>& UEqn)
}
void Foam::rotorDiskSource::addSu(fvMatrix<scalar>& UEqn)
{
// do nothing
}
void Foam::rotorDiskSource::writeData(Ostream& os) const
{
os << indent << name_ << endl;
@ -448,7 +440,8 @@ bool Foam::rotorDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
coeffs_ = dict.subDict(type() + "Coeffs");
coeffs_.lookup("fieldNames") >> fieldNames_;
applied_.setSize(fieldNames_.size(), false);
scalar rpm(readScalar(coeffs_.lookup("rpm")));
omega_ = rpm/60.0*mathematical::twoPi;

View File

@ -25,11 +25,61 @@ Class
Foam::rotorDiskSource
Description
Cell-zone based momemtum source
Cell based momemtum source
Source approximates the mean effects of rotor forces on a cylindrical
region within the domain
Sources described by:
rotorDiskSourceCoeffs
{
fieldNames (U); // names of fields on which to apply source
rhoName rho; // density field if compressible case
nBlades 3; // number of blades
tip effect 0.96; // normalised radius above which lift = 0
inletFlowType local; // inlet flow type specification
geometryMode auto; // geometry specification
refDirection (-1 0 0); // reference direction
flapCoeffs
{
beta0 0; // coning angle [deg]
beta1 0; // lateral flapping coeff
beta2 0; // longitudinal flapping coeff
}
trimCoeffs
{
alphac 15; // collective pitch angle [deg]
A 0; // lateral cyclic coeff
B 0; // longitudinal cyclic coeff
}
blade
{
...
}
profiles
{
...
}
}
Where:
geometryMode =
auto : determine rototor co-ord system from cells
specified : specified co-ord system
inletFlowType =
fixed : specified velocity
surfaceNormal : specified normal velocity (positive towards rotor)
local : use local flow conditions
SourceFiles
rotorDiskSource.C
rotorDiskSourceTemplates.C
@ -44,6 +94,8 @@ SourceFiles
#include "NamedEnum.H"
#include "bladeModel.H"
#include "profileModelList.H"
#include "volFieldsFwd.H"
#include "dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -97,9 +149,6 @@ protected:
// Protected data
//- Coefficients dictionary
dictionary coeffs_;
//- Name of density field
word rhoName_;
@ -211,14 +260,10 @@ public:
// Member Functions
// Source term addition
//- Source term to fvMatrix<vector>
virtual void addSu(fvMatrix<vector>& UEqn);
//- Source term to fvMatrix<scalar>
virtual void addSu(fvMatrix<scalar>& UEqn);
virtual void addSup(fvMatrix<vector>& eqn, const label fieldI);
// I-O

View File

@ -27,6 +27,7 @@ License
#include "addToRunTimeSelectionTable.H"
#include "mathematicalConstants.H"
#include "unitConversion.H"
#include "volFields.H"
using namespace Foam::constant;
@ -175,9 +176,9 @@ Foam::tmp<Foam::volVectorField> Foam::rotorDiskSource::calculateForces
}
// calculate forces
scalar pDyn = 0.5*rho[cellI]*sqr(magUc);
scalar f = pDyn*chord*nBlades_*area_[i]/(mathematical::twoPi);
vector localForce = vector(0.0, f*Cd, tipFactor*f*Cl);
const scalar pDyn = 0.5*rho[cellI]*sqr(magUc);
const scalar f = pDyn*chord*nBlades_*area_[i]/(mathematical::twoPi);
const vector localForce(0.0, f*Cd, tipFactor*f*Cl);
// accumulate forces
dragEff += localForce.y();

View File

@ -1,393 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "TimeActivatedExplicitSource.H"
#include "fvMesh.H"
#include "volFields.H"
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
template<class Type>
const Foam::wordList Foam::TimeActivatedExplicitSource<Type>::
selectionModeTypeNames_
(
IStringStream("(points cellSet cellZone all)")()
);
template<class Type>
const Foam::wordList Foam::TimeActivatedExplicitSource<Type>::
volumeModeTypeNames_
(
IStringStream("(absolute specific)")()
);
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type>
typename Foam::TimeActivatedExplicitSource<Type>::selectionModeType
Foam::TimeActivatedExplicitSource<Type>::wordToSelectionModeType
(
const word& smtName
) const
{
forAll(selectionModeTypeNames_, i)
{
if (smtName == selectionModeTypeNames_[i])
{
return selectionModeType(i);
}
}
FatalErrorIn
(
"TimeActivatedExplicitSource<Type>::selectionModeType"
"TimeActivatedExplicitSource<Type>::wordToSelectionModeType"
"("
"const word&"
")"
) << "Unknown selectionMode type " << smtName
<< ". Valid selectionMode types are:" << nl << selectionModeTypeNames_
<< exit(FatalError);
return selectionModeType(0);
}
template<class Type>
typename Foam::TimeActivatedExplicitSource<Type>::volumeModeType
Foam::TimeActivatedExplicitSource<Type>::wordToVolumeModeType
(
const word& vmtName
) const
{
forAll(volumeModeTypeNames_, i)
{
if (vmtName == volumeModeTypeNames_[i])
{
return volumeModeType(i);
}
}
FatalErrorIn
(
"TimeActivatedExplicitSource<Type>::volumeModeType"
"TimeActivatedExplicitSource<Type>::wordToVolumeModeType(const word&)"
) << "Unknown volumeMode type " << vmtName
<< ". Valid volumeMode types are:" << nl << volumeModeTypeNames_
<< exit(FatalError);
return volumeModeType(0);
}
template<class Type>
Foam::word Foam::TimeActivatedExplicitSource<Type>::selectionModeTypeToWord
(
const selectionModeType& smtType
) const
{
if (smtType > selectionModeTypeNames_.size())
{
return "UNKNOWN";
}
else
{
return selectionModeTypeNames_[smtType];
}
}
template<class Type>
Foam::word Foam::TimeActivatedExplicitSource<Type>::volumeModeTypeToWord
(
const volumeModeType& vmtType
) const
{
if (vmtType > volumeModeTypeNames_.size())
{
return "UNKNOWN";
}
else
{
return volumeModeTypeNames_[vmtType];
}
}
template<class Type>
void Foam::TimeActivatedExplicitSource<Type>::setSelection
(
const dictionary& dict
)
{
switch (selectionMode_)
{
case smPoints:
{
dict.lookup("points") >> points_;
break;
}
case smCellSet:
{
dict.lookup("cellSet") >> cellSetName_;
break;
}
case smCellZone:
{
dict.lookup("cellZone") >> cellSetName_;
break;
}
case smAll:
{
break;
}
default:
{
FatalErrorIn
(
"TimeActivatedExplicitSource::setSelection(const dictionary&)"
) << "Unknown selectionMode "
<< selectionModeTypeNames_[selectionMode_]
<< ". Valid selectionMode types are" << selectionModeTypeNames_
<< exit(FatalError);
}
}
}
template<class Type>
void Foam::TimeActivatedExplicitSource<Type>::setFieldData
(
const dictionary& dict,
const wordList& fieldNames
)
{
dict.lookup("fieldData") >> fieldData_;
labelList localFieldIds(fieldData_.size(), -1);
forAll(fieldNames, i)
{
forAll(fieldData_, j)
{
const word& fdName = fieldData_[j].first();
if (fdName == fieldNames[i])
{
fieldIds_[i] = j;
localFieldIds[j] = i;
break;
}
}
}
forAll(localFieldIds, i)
{
if (localFieldIds[i] < 0)
{
FatalErrorIn
(
"TimeActivatedExplicitSource<Type>::setFieldData"
"("
"const dictionary&, "
"const wordList&"
")"
) << "Field " << fieldData_[i].first() << " not found in "
<< "field list. Available fields are: " << nl << fieldNames
<< exit(FatalError);
}
}
}
template<class Type>
void Foam::TimeActivatedExplicitSource<Type>::setCellSet()
{
Info<< incrIndent << indent << "Source: " << name_ << endl;
switch (selectionMode_)
{
case smPoints:
{
Info<< indent << "- selecting cells using points" << endl;
labelHashSet selectedCells;
forAll(points_, i)
{
label cellI = mesh_.findCell
(
points_[i],
polyMesh::FACEDIAGTETS
);
if (cellI >= 0)
{
selectedCells.insert(cellI);
}
label globalCellI = returnReduce(cellI, maxOp<label>());
if (globalCellI < 0)
{
WarningIn("TimeActivatedExplicitSource<Type>::setCellIds()")
<< "Unable to find owner cell for point " << points_[i]
<< endl;
}
}
cells_ = selectedCells.toc();
break;
}
case smCellSet:
{
Info<< indent << "- selecting cells using cellSet "
<< cellSetName_ << endl;
cellSet selectedCells(mesh_, cellSetName_);
cells_ = selectedCells.toc();
break;
}
case smCellZone:
{
Info<< indent << "- selecting cells using cellZone "
<< cellSetName_ << endl;
label zoneID = mesh_.cellZones().findZoneID(cellSetName_);
if (zoneID == -1)
{
FatalErrorIn("TimeActivatedExplicitSource<Type>::setCellIds()")
<< "Cannot find cellZone " << cellSetName_ << endl
<< "Valid cellZones are " << mesh_.cellZones().names()
<< exit(FatalError);
}
cells_ = mesh_.cellZones()[zoneID];
break;
}
case smAll:
{
Info<< indent << "- selecting all cells" << endl;
cells_ = identity(mesh_.nCells());
break;
}
default:
{
FatalErrorIn("TimeActivatedExplicitSource<Type>::setCellIds()")
<< "Unknown selectionMode "
<< selectionModeTypeNames_[selectionMode_]
<< ". Valid selectionMode types are" << selectionModeTypeNames_
<< exit(FatalError);
}
}
// Set volume normalisation
if (volumeMode_ == vmAbsolute)
{
V_ = 0.0;
forAll(cells_, i)
{
V_ += mesh_.V()[cells_[i]];
}
reduce(V_, sumOp<scalar>());
}
Info<< indent << "- selected "
<< returnReduce(cells_.size(), sumOp<label>())
<< " cell(s) with volume " << V_ << nl << decrIndent << endl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::TimeActivatedExplicitSource<Type>::TimeActivatedExplicitSource
(
const word& name,
const dictionary& dict,
const fvMesh& mesh,
const wordList& fieldNames
)
:
name_(name),
mesh_(mesh),
active_(readBool(dict.lookup("active"))),
timeStart_(readScalar(dict.lookup("timeStart"))),
duration_(readScalar(dict.lookup("duration"))),
volumeMode_(wordToVolumeModeType(dict.lookup("volumeMode"))),
selectionMode_(wordToSelectionModeType(dict.lookup("selectionMode"))),
points_(),
cellSetName_("none"),
V_(1.0),
fieldData_(),
fieldIds_(fieldNames.size(), -1)
{
setSelection(dict);
if (fieldNames.size() == 1)
{
fieldData_.setSize(1);
fieldData_[0].first() = fieldNames[0];
dict.lookup("fieldData") >> fieldData_[0].second();
fieldIds_[0] = 0;
}
else
{
setFieldData(dict, fieldNames);
}
setCellSet();
}
template<class Type>
void Foam::TimeActivatedExplicitSource<Type>::addToField
(
DimensionedField<Type, volMesh>& Su,
const label fieldI
)
{
const label fid = fieldIds_[fieldI];
if
(
active_
&& (fid >= 0)
&& (mesh_.time().value() >= timeStart_)
&& (mesh_.time().value() <= timeEnd())
)
{
// Update the cell set if the mesh is changing
if (mesh_.changing())
{
setCellSet();
}
forAll(cells_, i)
{
Su[cells_[i]] = fieldData_[fid].second()/V_;
}
}
}
// ************************************************************************* //

View File

@ -1,392 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
Class
Foam::TimeActivatedExplicitSource
Description
Time activated explicit source.
Sources described by:
{
active true; // on/off switch
timeStart 0.2; // start time
duration 2.0; // duration
selectionMode points; // cellSet/cellZone/all
volumeMode absolute; // specific
fieldData // field data - usage for multiple fields
(
(H2O 0.005)
);
fieldData 0.005; // field data - usage for single field
points // list of points when selectionMode = points
(
(2.75 0.5 0)
);
cellSet c0; // cellSet name when selectionMode=cellSet
cellZone c0; // cellZone name when selectionMode=cellZone
}
SourceFiles
TimeActivatedExplicitSource.C
\*---------------------------------------------------------------------------*/
#ifndef TimeActivatedExplicitSource_H
#define TimeActivatedExplicitSource_H
#include "Tuple2.H"
#include "cellSet.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class fvMesh;
template<class Type>
class TimeActivatedExplicitSource;
// Forward declaration of friend functions
template<class Type>
Ostream& operator<<
(
Ostream&,
const TimeActivatedExplicitSource<Type>&
);
/*---------------------------------------------------------------------------*\
Class TimeActivatedExplicitSource Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class TimeActivatedExplicitSource
{
public:
// Public data
//- Enumeration for selection mode types
enum selectionModeType
{
smPoints,
smCellSet,
smCellZone,
smAll
};
//- Word list of selection mode type names
static const wordList selectionModeTypeNames_;
//- Enumeration for volume types
enum volumeModeType
{
vmAbsolute,
vmSpecific
};
//- Word list of volume mode type names
static const wordList volumeModeTypeNames_;
protected:
// Protected data
typedef Tuple2<word, Type> fieldNameValuePair;
//- Source name
word name_;
//- Reference to the mesh database
const fvMesh& mesh_;
//- Source active flag
bool active_;
//- Time start
scalar timeStart_;
//- Duration
scalar duration_;
//- Volume mode
volumeModeType volumeMode_;
//- Cell selection mode
selectionModeType selectionMode_;
//- List of points for "points" selectionMode
List<point> points_;
//- Name of cell set for "cellSet" and "cellZone" selectionMode
word cellSetName_;
//- Set of cells to apply source to
labelList cells_;
//- Sum of cell volumes
scalar V_;
//- List of source field name vs value pairs
List<fieldNameValuePair> fieldData_;
//- Map of fields ids from supplied fields to local field source ids
labelList fieldIds_;
// Protected functions
//- Helper function to convert from a word to a selectionModeType
selectionModeType wordToSelectionModeType(const word& smtName) const;
//- Helper function to convert from a word to a volumeModeType
volumeModeType wordToVolumeModeType(const word& vtName) const;
//- Helper function to convert from a selectionModeType to a word
word selectionModeTypeToWord(const selectionModeType& smtType) const;
//- Helper function to convert from a volumeModeType to a word
word volumeModeTypeToWord(const volumeModeType& vtType) const;
//- Set the cellSet or points selection
void setSelection(const dictionary& dict);
//- Set the local field data
void setFieldData(const dictionary& dict, const wordList& fieldNames);
//- Set the cell set based on the user input selection mode
void setCellSet();
public:
// Constructors
//- Construct from components
TimeActivatedExplicitSource
(
const word& name,
const dictionary& dict,
const fvMesh& mesh,
const wordList& fieldNames
);
//- Return clone
autoPtr<TimeActivatedExplicitSource> clone() const
{
notImplemented
(
"autoPtr<TimeActivatedExplicitSource> clone() const"
);
return autoPtr<TimeActivatedExplicitSource>(NULL);
}
//- Return pointer to new TimeActivatedExplicitSource object created
// on the freestore from an Istream
class iNew
{
//- Reference to the mesh database
const fvMesh& mesh_;
//- List of field names
const wordList& fieldNames_;
public:
iNew
(
const fvMesh& mesh,
const wordList& fieldNames
)
:
mesh_(mesh),
fieldNames_(fieldNames)
{}
autoPtr<TimeActivatedExplicitSource> operator()(Istream& is) const
{
const word name(is);
const dictionary dict(is);
return autoPtr<TimeActivatedExplicitSource>
(
new TimeActivatedExplicitSource
(
name,
dict,
mesh_,
fieldNames_
)
);
}
};
// Member Functions
// Access
//- Return const access to the source name
inline const word& name() const;
//- Return const access to the mesh database
inline const fvMesh& mesh() const;
//- Return const access to the source active flag
inline bool active() const;
//- Return const access to the time start
inline scalar timeStart() const;
//- Return const access to the duration
inline scalar duration() const;
//- Return const access to the time end
inline scalar timeEnd() const;
//- Return const access to the volume mode
inline const volumeModeType& volumeMode() const;
//- Return const access to the cell selection mode
inline const selectionModeType& selectionMode() const;
//- Return const access to the list of points for "points"
// selectionMode
inline const List<point>& points() const;
//- Return const access to the name of cell set for "cellSet"
// selectionMode
inline const word& cellSetName() const;
//- Return const access to the total cell volume
inline scalar V() const;
//- Return const access to the cell set
inline const labelList& cells() const;
//- Return const access to the source field name vs value pairs
inline const List<fieldNameValuePair>& fieldData() const;
//- Return const access to the the map of fields ids from supplied
// fields to local field source ids
inline const labelList& fieldIds() const;
// Edit
//- Return access to the source name
inline word& name();
//- Return access to the source active flag
inline bool& active();
//- Return access to the time start
inline scalar& timeStart();
//- Return access to the duration
inline scalar& duration();
//- Return access to the volume mode
inline volumeModeType& volumeMode();
//- Return access to the cell selection mode
inline selectionModeType& selectionMode();
//- Return access to the list of points for "points" selectionMode
inline List<point>& points();
//- Return access to the name of cell set for "cellSet"
// selectionMode
inline word& cellSetName();
//- Return access to the total cell volume
inline scalar& V();
//- Return access to the cell set
inline labelList& cells();
//- Return access to the source field name vs value pairs
inline List<fieldNameValuePair>& fieldData();
//- Return access to the the map of fields ids from supplied
// fields to local field source ids
inline labelList& fieldIds();
// Evaluation
//- Add the source contribution to field Su
void addToField
(
DimensionedField<Type, volMesh>& Su,
const label fieldI
);
// I-O
//- Write the source properties
void writeData(Ostream&) const;
//- Ostream operator
friend Ostream& operator<< <Type>
(
Ostream& os,
const TimeActivatedExplicitSource& source
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "TimeActivatedExplicitSource.C"
# include "TimeActivatedExplicitSourceIO.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "TimeActivatedExplicitSourceI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,228 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "TimeActivatedExplicitSource.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
inline const Foam::word& Foam::TimeActivatedExplicitSource<Type>::name() const
{
return name_;
}
template<class Type>
inline const Foam::fvMesh& Foam::TimeActivatedExplicitSource<Type>::mesh() const
{
return mesh_;
}
template<class Type>
inline bool Foam::TimeActivatedExplicitSource<Type>::active() const
{
return active_;
}
template<class Type>
inline Foam::scalar Foam::TimeActivatedExplicitSource<Type>::timeStart() const
{
return timeStart_;
}
template<class Type>
inline Foam::scalar Foam::TimeActivatedExplicitSource<Type>::duration() const
{
return duration_;
}
template<class Type>
inline Foam::scalar Foam::TimeActivatedExplicitSource<Type>::timeEnd() const
{
return timeStart_ + duration_;
}
template<class Type>
inline const typename Foam::TimeActivatedExplicitSource<Type>::volumeModeType&
Foam::TimeActivatedExplicitSource<Type>::volumeMode() const
{
return volumeMode_;
}
template<class Type>
inline const typename Foam::TimeActivatedExplicitSource<Type>::
selectionModeType&
Foam::TimeActivatedExplicitSource<Type>::selectionMode() const
{
return selectionMode_;
}
template<class Type>
inline const Foam::List<Foam::point>&
Foam::TimeActivatedExplicitSource<Type>::points() const
{
return points_;
}
template<class Type>
inline const Foam::word&
Foam::TimeActivatedExplicitSource<Type>::cellSetName() const
{
return cellSetName_;
}
template<class Type>
inline Foam::scalar Foam::TimeActivatedExplicitSource<Type>::V() const
{
return V_;
}
template<class Type>
inline const Foam::labelList&
Foam::TimeActivatedExplicitSource<Type>::cells() const
{
return cells_;
}
template<class Type>
inline const Foam::List<typename Foam::TimeActivatedExplicitSource<Type>::
fieldNameValuePair>&
Foam::TimeActivatedExplicitSource<Type>::fieldData() const
{
return fieldData_;
}
template<class Type>
inline const Foam::labelList&
Foam::TimeActivatedExplicitSource<Type>::fieldIds() const
{
return fieldIds_;
}
template<class Type>
inline Foam::word& Foam::TimeActivatedExplicitSource<Type>::name()
{
return name_;
}
template<class Type>
inline bool& Foam::TimeActivatedExplicitSource<Type>::active()
{
return active_;
}
template<class Type>
inline Foam::scalar& Foam::TimeActivatedExplicitSource<Type>::timeStart()
{
return timeStart_;
}
template<class Type>
inline Foam::scalar& Foam::TimeActivatedExplicitSource<Type>::duration()
{
return duration_;
}
template<class Type>
inline typename Foam::TimeActivatedExplicitSource<Type>::volumeModeType&
Foam::TimeActivatedExplicitSource<Type>::volumeMode()
{
return volumeMode_;
}
template<class Type>
inline typename Foam::TimeActivatedExplicitSource<Type>::selectionModeType&
Foam::TimeActivatedExplicitSource<Type>::selectionMode()
{
return selectionMode_;
}
template<class Type>
inline Foam::List<Foam::point>&
Foam::TimeActivatedExplicitSource<Type>::points()
{
return points_;
}
template<class Type>
inline Foam::word& Foam::TimeActivatedExplicitSource<Type>::cellSetName()
{
return cellSetName_;
}
template<class Type>
inline Foam::scalar& Foam::TimeActivatedExplicitSource<Type>::V()
{
return V_;
}
template<class Type>
inline Foam::labelList& Foam::TimeActivatedExplicitSource<Type>::cells()
{
return cells_;
}
template<class Type>
inline Foam::List
<
typename Foam::TimeActivatedExplicitSource<Type>::fieldNameValuePair
>&
Foam::TimeActivatedExplicitSource<Type>::fieldData()
{
return fieldData_;
}
template<class Type>
inline Foam::labelList& Foam::TimeActivatedExplicitSource<Type>::fieldIds()
{
return fieldIds_;
}
// ************************************************************************* //

View File

@ -1,101 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "TimeActivatedExplicitSource.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::TimeActivatedExplicitSource<Type>::writeData(Ostream& os) const
{
os << indent << name_ << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
os.writeKeyword("active") << active_ << token::END_STATEMENT << nl;
os.writeKeyword("timeStart") << timeStart_ << token::END_STATEMENT << nl;
os.writeKeyword("duration") << duration_ << token::END_STATEMENT << nl;
os.writeKeyword("selectionMode") << selectionModeTypeToWord(selectionMode_)
<< token::END_STATEMENT << nl;
os.writeKeyword("volumeMode") << volumeModeTypeToWord(volumeMode_)
<< token::END_STATEMENT << nl;
if (fieldIds_.size() == 1)
{
os.writeKeyword("fieldData") << fieldData_[0].second()
<< token::END_STATEMENT << nl;
}
else
{
os.writeKeyword("fieldData") << fieldData_ << nl;
}
switch (selectionMode_)
{
case smPoints:
{
os.writeKeyword("points") << nl << indent << points_
<< token::END_STATEMENT << nl;
break;
}
case smCellSet:
{
os.writeKeyword("cellSet") << cellSetName_
<< token::END_STATEMENT << nl;
break;
}
default:
{
FatalErrorIn
(
"TimeActivatedExplicitSource<Type>::writeData"
"("
"Ostream&, "
"bool"
") const"
) << "Unknown selectionMode "
<< selectionModeTypeToWord(selectionMode_)
<< abort(FatalError);
}
}
os << decrIndent << indent << token::END_BLOCK << endl;
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const TimeActivatedExplicitSource<Type>& source
)
{
source.writeData(os);
return os;
}
// ************************************************************************* //

View File

@ -1,222 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "TimeActivatedExplicitSourceList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::TimeActivatedExplicitSourceList<Type>::TimeActivatedExplicitSourceList
(
const word& name,
const fvMesh& mesh,
const dimensionSet& dimensions,
const wordList& fieldNames
)
:
IOPtrList<TimeActivatedExplicitSource<Type> >
(
IOobject
(
name + "SourceProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
typename TimeActivatedExplicitSource<Type>::iNew(mesh, fieldNames)
),
name_(name),
mesh_(mesh),
dimensions_(dimensions),
fieldNames_(fieldNames)
{}
template<class Type>
Foam::TimeActivatedExplicitSourceList<Type>::TimeActivatedExplicitSourceList
(
const word& name,
const fvMesh& mesh,
const dimensionSet& dimensions,
const word& fieldName
)
:
IOPtrList<TimeActivatedExplicitSource<Type> >
(
IOobject
(
name + "SourceProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
typename TimeActivatedExplicitSource<Type>::iNew
(
mesh,
IStringStream('(' + fieldName + ')')()
)
),
name_(name),
mesh_(mesh),
dimensions_(dimensions),
fieldNames_(1, fieldName)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh> >
Foam::TimeActivatedExplicitSourceList<Type>::Su(const label fieldI)
{
tmp<DimensionedField<Type, volMesh> > tSu
(
new DimensionedField<Type, volMesh>
(
IOobject
(
name_ + "Source_" + fieldNames_[fieldI],
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensioned<Type>("zero", dimensions_, pTraits<Type>::zero)
)
);
DimensionedField<Type, volMesh>& Su = tSu();
forAll(*this, i)
{
this->operator[](i).addToField(Su, fieldI);
}
return tSu;
}
template<class Type>
Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh> >
Foam::TimeActivatedExplicitSourceList<Type>::SuTot()
{
tmp<DimensionedField<Type, volMesh> > tSuTot
(
new DimensionedField<Type, volMesh>
(
IOobject
(
name_ + "TotalSource",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensioned<Type>("zero", dimensions_, pTraits<Type>::zero)
)
);
DimensionedField<Type, volMesh>& SuTot = tSuTot();
forAll(fieldNames_, fieldI)
{
forAll(*this, sourceI)
{
this->operator[](sourceI).addToField(SuTot, fieldI);
}
}
return tSuTot;
}
template<class Type>
bool Foam::TimeActivatedExplicitSourceList<Type>::readData(Istream& is)
{
this->clear();
IOPtrList<TimeActivatedExplicitSource<Type> > newSources
(
IOobject
(
name_ + "TimeActivatedExplicitSource",
mesh_.time().constant(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
),
typename TimeActivatedExplicitSource<Type>::iNew(mesh_, fieldNames_)
);
this->transfer(newSources);
return is.good();
}
template<class Type>
bool Foam::TimeActivatedExplicitSourceList<Type>::writeData(Ostream& os) const
{
// Write size of list
os << nl << this->size();
// Write beginning of contents
os << nl << token::BEGIN_LIST;
// Write list contents
forAll(*this, i)
{
os << nl;
this->operator[](i).writeData(os);
}
// Write end of contents
os << token::END_LIST << token::END_STATEMENT << nl;
// Check state of IOstream
return os.good();
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const TimeActivatedExplicitSourceList<Type>& sources
)
{
sources.writeData(os);
return os;
}
// ************************************************************************* //

View File

@ -1,171 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
Class
Foam::TimeActivatedExplicitSourceList
Description
List of time activeted explict sources
SourceFiles
TimeActivatedExplicitSourceList.C
\*---------------------------------------------------------------------------*/
#ifndef TimeActivatedExplicitSourceList_H
#define TimeActivatedExplicitSourceList_H
#include "IOPtrList.H"
#include "TimeActivatedExplicitSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class fvMesh;
template<class Type>
class TimeActivatedExplicitSource;
template<class Type>
class TimeActivatedExplicitSourceList;
// Forward declaration of friend functions
template<class Type>
Ostream& operator<<
(
Ostream&,
const TimeActivatedExplicitSourceList<Type>&
);
/*---------------------------------------------------------------------------*\
Class TimeActivatedExplicitSourceList Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class TimeActivatedExplicitSourceList
:
public IOPtrList<TimeActivatedExplicitSource<Type> >
{
private:
// Private data
//- Name of source properties list
word name_;
//- Reference to the mesh database
const fvMesh& mesh_;
//- Dimensions of source properties
dimensionSet dimensions_;
//- List of field names the source is working on
wordList fieldNames_;
// Private Member Functions
//- Disallow default bitwise copy construct
TimeActivatedExplicitSourceList
(
const TimeActivatedExplicitSourceList<Type>&
);
//- Disallow default bitwise assignment
void operator=(const TimeActivatedExplicitSourceList<Type>&);
public:
// Constructors
//- Construct from components with list of field names
TimeActivatedExplicitSourceList
(
const word& name,
const fvMesh& mesh,
const dimensionSet& dimensions,
const wordList& fieldNames
);
//- Construct from components with single field name
TimeActivatedExplicitSourceList
(
const word& name,
const fvMesh& mesh,
const dimensionSet& dimensions,
const word& fieldName
);
// Member Functions
// Evaluation
//- Return the source for field, fieldI
tmp<DimensionedField<Type, volMesh> > Su
(
const label fieldI = 0
);
//- Return the total source for all fields
tmp<DimensionedField<Type, volMesh> > SuTot();
// I-O
//- Read data from Istream
bool readData(Istream& is);
//- Write data to Istream
bool writeData(Ostream& os) const;
//- Ostream operator
friend Ostream& operator<< <Type>
(
Ostream& os,
const TimeActivatedExplicitSourceList& sources
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "TimeActivatedExplicitSourceList.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,66 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
Typedef
Foam::timeActivatedExplicitSource
\*---------------------------------------------------------------------------*/
#ifndef timeActivatedExplicitSource_H
#define timeActivatedExplicitSource_H
#include "TimeActivatedExplicitSource.H"
#include "TimeActivatedExplicitSourceList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef TimeActivatedExplicitSource<scalar>
scalarTimeActivatedExplicitSource;
typedef TimeActivatedExplicitSource<vector>
vectorTimeActivatedExplicitSource;
typedef TimeActivatedExplicitSource<sphericalTensor>
sphericalTensorTimeActivatedExplicitSource;
typedef TimeActivatedExplicitSource<symmTensor>
symmTensorTimeActivatedExplicitSource;
typedef TimeActivatedExplicitSource<tensor>
tensorTimeActivatedExplicitSource;
typedef TimeActivatedExplicitSourceList<scalar>
scalarTimeActivatedExplicitSourceList;
typedef TimeActivatedExplicitSourceList<vector>
vectorTimeActivatedExplicitSourceList;
typedef TimeActivatedExplicitSourceList<sphericalTensor>
sphericalTensorTimeActivatedExplicitSourceList;
typedef TimeActivatedExplicitSourceList<symmTensor>
symmTensorTimeActivatedExplicitSourceList;
typedef TimeActivatedExplicitSourceList<tensor>
tensorTimeActivatedExplicitSourceList;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -30,7 +30,7 @@ Description
cells are potentially in range of each other.
Builds referred interaction list, specifying which cells are
required to provide interactions across coupled patched (cyclic or
required to provide interactions across coupled patches (cyclic or
processor). Generates referred cells, and refers particles to the
correct processor, applying the appropriate transform.

View File

@ -339,7 +339,7 @@ void Foam::KinematicParcel<ParcelType>::hitFace(TrackData& td)
typename TrackData::cloudType::parcelType& p =
static_cast<typename TrackData::cloudType::parcelType&>(*this);
td.cloud().functions().postFace(p);
td.cloud().functions().postFace(p, p.face());
}
@ -363,7 +363,7 @@ bool Foam::KinematicParcel<ParcelType>::hitPatch
static_cast<typename TrackData::cloudType::parcelType&>(*this);
// Invoke post-processing model
td.cloud().functions().postPatch(p, patchI);
td.cloud().functions().postPatch(p, patchI, pp.whichFace(p.face()));
// Invoke surface film model
if (td.cloud().surfaceFilm().transferParcel(p, pp, td.keepParticle))

View File

@ -29,6 +29,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "FacePostProcessing.H"
#include "ParticleErosion.H"
#include "ParticleTracks.H"
#include "PatchPostProcessing.H"
#include "VoidFraction.H"
@ -40,6 +41,7 @@ License
makeCloudFunctionObject(CloudType); \
\
makeCloudFunctionObjectType(FacePostProcessing, CloudType); \
makeCloudFunctionObjectType(ParticleErosion, CloudType); \
makeCloudFunctionObjectType(ParticleTracks, CloudType); \
makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \
makeCloudFunctionObjectType(VoidFraction, CloudType);

View File

@ -107,6 +107,7 @@ template<class CloudType>
void Foam::CloudFunctionObject<CloudType>::postPatch
(
const typename CloudType::parcelType&,
const label,
const label
)
{
@ -117,7 +118,8 @@ void Foam::CloudFunctionObject<CloudType>::postPatch
template<class CloudType>
void Foam::CloudFunctionObject<CloudType>::postFace
(
const typename CloudType::parcelType&
const typename CloudType::parcelType&,
const label
)
{
// do nothing

Some files were not shown because too many files have changed in this diff Show More