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

This commit is contained in:
mattijs
2011-11-04 09:30:09 +00:00
37 changed files with 265 additions and 105 deletions

View File

@ -5,12 +5,14 @@ tmp<fvVectorMatrix> UEqn
fvm::ddt(U)
+ fvm::div(phi, U)
+ turbulence->divDevReff(U)
==
sources(U)
);
sources.apply(UEqn());
UEqn().relax();
sources.constrain(UEqn());
volScalarField rAU(1.0/UEqn().A());
if (pimple.momentumPredictor())

View File

@ -4,11 +4,13 @@
(
fvm::div(phi, U)
+ turbulence->divDevReff(U)
==
sources(U)
);
mrfZones.addCoriolis(UEqn());
sources.apply(UEqn());
sources.constrain(UEqn());
UEqn().relax();

View File

@ -5,10 +5,12 @@
fvm::div(phi, Urel)
+ turbulence->divDevReff(Urel)
+ SRF->Su()
==
sources(Urel)
);
sources.apply(UrelEqn());
UrelEqn().relax();
sources.constrain(UrelEqn());
solve(UrelEqn() == -fvc::grad(p));

View File

@ -4,10 +4,12 @@
(
fvm::div(phi, U)
+ turbulence->divDevReff(U)
==
sources(U)
);
sources.apply(UEqn());
UEqn().relax();
sources.constrain(UEqn());
solve(UEqn() == -fvc::grad(p));

View File

@ -4,12 +4,14 @@
(
fvm::div(phi, U)
+ turbulence->divDevReff(U)
==
sources(U)
);
sources.apply(UEqn());
UEqn().relax();
sources.constrain(UEqn());
// Include the porous media resistance and solve the momentum equation
// either implicit in the tensorial resistance or transport using by
// including the spherical part of the resistance in the momentum diagonal

View File

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

View File

@ -31,9 +31,10 @@ if (solveSpecies)
==
parcels.SYi(i, Yi)
+ combustion->R(Yi)
+ sources(Yi)
);
sources.apply(YEqn);
sources.constrain(YEqn);
YEqn.solve(mesh.solver("Yi"));

View File

@ -9,9 +9,10 @@
+ parcels.Sh(hs)
+ radiation->Shs(thermo)
+ combustion->Sh()
+ sources(rho, hs)
);
sources.apply(hsEqn);
sources.constrain(hsEqn);
hsEqn.solve();

View File

@ -29,10 +29,9 @@
+ fvc::div(phi)
==
parcels.Srho()
+ sources(psi, p, rho.name())
);
sources.apply(pDDtEqn);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix pEqn
@ -41,6 +40,8 @@
- fvm::laplacian(rho*rAU, p)
);
sources.constrain(pDDtEqn, rho.name());
pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter())));
if (pimple.finalNonOrthogonalIter())

View File

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

View File

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

View File

@ -7,12 +7,13 @@
rho.dimensionedInternalField()*g
+ coalParcels.SU(U)
+ limestoneParcels.SU(U)
+ sources(rho, U)
);
sources.apply(UEqn);
UEqn.relax();
sources.constrain(UEqn);
if (pimple.momentumPredictor())
{
solve(UEqn == -fvc::grad(p));

View File

@ -30,11 +30,13 @@ tmp<fv::convectionScheme<scalar> > mvConvection
==
coalParcels.SYi(i, Yi)
+ combustion->R(Yi)
+ sources(rho, Yi)
);
sources.apply(YiEqn);
YiEqn.relax();
sources.constrain(YiEqn);
YiEqn.solve(mesh.solver("Yi"));
Yi.max(0.0);

View File

@ -6,15 +6,17 @@
- fvm::laplacian(turbulence->alphaEff(), hs)
==
DpDt
+ combustion->Sh()
+ coalParcels.Sh(hs)
+ limestoneParcels.Sh(hs)
+ radiation->Shs(thermo)
+ combustion->Sh()
+ coalParcels.Sh(hs)
+ limestoneParcels.Sh(hs)
+ radiation->Shs(thermo)
+ sources(rho, hs)
);
sources.apply(hsEqn);
hsEqn.relax();
sources.constrain(hsEqn);
hsEqn.solve();
thermo.correct();

View File

@ -24,9 +24,10 @@ if (pimple.transonic())
- fvm::laplacian(rho*rAU, p)
==
coalParcels.Srho()
+ sources(psi, p, rho.name())
);
sources.apply(pEqn);
sources.constrain(pEqn, rho.name());
pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter())));
@ -39,8 +40,8 @@ if (pimple.transonic())
else
{
phi =
fvc::interpolate(rho)*
(
fvc::interpolate(rho)
*(
(fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rAU, rho, U, phi)
);
@ -54,9 +55,10 @@ else
- fvm::laplacian(rho*rAU, p)
==
coalParcels.Srho()
+ sources(psi, p, rho.name())
);
sources.apply(pEqn);
sources.constrain(pEqn, rho.name());
pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter())));

View File

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

View File

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

View File

@ -32,9 +32,10 @@ if (solveSpecies)
==
parcels.SYi(i, Yi)
+ combustion->R(Yi)
+ sources(rho, Yi)
);
sources.apply(YiEqn);
sources.constrain(YiEqn);
YiEqn.solve(mesh.solver("Yi"));

View File

@ -39,9 +39,10 @@
+ parcels.Sh(hs)
+ radiation->Shs(thermo)
+ combustion->Sh()
+ sources(rho, hs)
);
sources.apply(hsEqn);
sources.constrain(hsEqn);
hsEqn.solve();

View File

@ -29,9 +29,9 @@
+ fvc::div(phi)
==
parcels.Srho()
+ sources(psi, p, rho.name())
);
sources.apply(pDDtEqn);
while (pimple.correctNonOrthogonal())
{
@ -41,6 +41,8 @@
- fvm::laplacian(rho*rAU, p)
);
sources.constrain(pDDtEqn, rho.name());
pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter())));
if (pimple.finalNonOrthogonalIter())

View File

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

View File

@ -55,7 +55,7 @@ void Foam::actuationDiskSource::addActuationDiskAxialInertialResistance
}
forAll(cells, i)
{
Usource[cells[i]] += ((Vcells[cells[i]]/V())*T[i]*E) & U[cells[i]];
Usource[cells[i]] -= ((Vcells[cells[i]]/V())*T[i]*E) & U[cells[i]];
}
}

View File

@ -33,6 +33,8 @@ Description
duration 1000.0; // duration
selectionMode cellSet; // cellSet // points //cellZone
On evaluation, source expects to be added to the rhs of the equation
SourceFiles
basicSource.C

View File

@ -36,7 +36,7 @@ namespace Foam
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::basicSourceList::checkApplied() const
{

View File

@ -36,7 +36,8 @@ SourceFile
#define basicSourceList_H
#include "PtrList.H"
#include "DimensionedField.H"
#include "GeometricField.H"
#include "fvPatchField.H"
#include "basicSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -52,9 +53,9 @@ class basicSourceList
:
public PtrList<basicSource>
{
private:
protected:
// Private data
// Protected data
//- Reference to the mesh database
const fvMesh& mesh_;
@ -63,7 +64,7 @@ private:
label checkTimeIndex_;
// Private Member Functions
// Protected Member Functions
//- Check that all sources have been applied
void checkApplied() const;
@ -94,11 +95,50 @@ public:
// Member Functions
// Evaluation
// Sources
//- Apply sources to equation
//- Return source for equation
template<class Type>
void apply(fvMatrix<Type>& eqn);
tmp<fvMatrix<Type> > operator()
(
GeometricField<Type, fvPatchField, volMesh>& fld
);
//- Return source for equation with specified name
template<class Type>
tmp<fvMatrix<Type> > operator()
(
GeometricField<Type, fvPatchField, volMesh>& fld,
const word& fieldName
);
//- Return source for equation
template<class Type, class RhoType>
tmp<fvMatrix<Type> > operator()
(
const RhoType& rho,
GeometricField<Type, fvPatchField, volMesh>& fld
);
//- Return source for equation with specified name
template<class Type, class RhoType>
tmp<fvMatrix<Type> > operator()
(
const RhoType& rho,
GeometricField<Type, fvPatchField, volMesh>& fld,
const word& fieldName
);
// Constraints
//- Apply constraints to equation
template<class Type>
void constrain(fvMatrix<Type>& eqn);
//- Apply constraints to equation with specified name
template<class Type>
void constrain(fvMatrix<Type>& eqn, const word& fieldName);
// I-O

View File

@ -26,11 +26,30 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::basicSourceList::apply(fvMatrix<Type>& eqn)
Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
(
GeometricField<Type, fvPatchField, volMesh>& fld
)
{
return this->operator()(fld, fld.name());
}
template<class Type>
Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
(
GeometricField<Type, fvPatchField, volMesh>& fld,
const word& fieldName
)
{
checkApplied();
const word& fieldName = eqn.psi().name();
const dimensionSet ds = fld.dimensions()/dimTime*dimVolume;
tmp<fvMatrix<Type> > tmtx(new fvMatrix<Type>(fld, ds));
fvMatrix<Type>& mtx = tmtx();
forAll(*this, i)
{
@ -50,7 +69,104 @@ void Foam::basicSourceList::apply(fvMatrix<Type>& eqn)
<< fieldName << endl;
}
source.addSup(eqn, fieldI);
source.addSup(mtx, fieldI);
}
}
}
return tmtx;
}
template<class Type, class RhoType>
Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
(
const RhoType& rho,
GeometricField<Type, fvPatchField, volMesh>& fld
)
{
return this->operator()(rho, fld, fld.name());
}
template<class Type, class RhoType>
Foam::tmp<Foam::fvMatrix<Type> > Foam::basicSourceList::operator()
(
const RhoType& rho,
GeometricField<Type, fvPatchField, volMesh>& fld,
const word& fieldName
)
{
checkApplied();
const dimensionSet ds = rho.dimensions()*fld.dimensions()/dimTime*dimVolume;
tmp<fvMatrix<Type> > tmtx(new fvMatrix<Type>(fld, ds));
fvMatrix<Type>& mtx = tmtx();
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(mtx, fieldI);
}
}
}
return tmtx;
}
template<class Type>
void Foam::basicSourceList::constrain(fvMatrix<Type>& eqn)
{
constrain(eqn, eqn.psi().name());
}
template<class Type>
void Foam::basicSourceList::constrain
(
fvMatrix<Type>& eqn,
const word& fieldName
)
{
checkApplied();
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 constraint " << source.name()
<< " to field " << fieldName << endl;
}
source.setValue(eqn, fieldI);
}
}

View File

@ -34,7 +34,7 @@ template<class Type>
void Foam::ExplicitSetValue<Type>::setFieldData(const dictionary& dict)
{
fieldNames_.setSize(dict.toc().size());
fieldData_.setSize(fieldNames_.size());
injectionRate_.setSize(fieldNames_.size());
applied_.setSize(fieldNames_.size(), false);
@ -42,7 +42,7 @@ void Foam::ExplicitSetValue<Type>::setFieldData(const dictionary& dict)
forAllConstIter(dictionary, dict, iter)
{
fieldNames_[i] = iter().keyword();
dict.lookup(iter().keyword()) >> fieldData_[i];
dict.lookup(iter().keyword()) >> injectionRate_[i];
i++;
}
}
@ -60,7 +60,7 @@ Foam::ExplicitSetValue<Type>::ExplicitSetValue
)
:
basicSource(name, modelType, dict, mesh),
fieldData_()
injectionRate_()
{
read(dict);
}
@ -81,32 +81,9 @@ void Foam::ExplicitSetValue<Type>::setValue
<< ">::setValue for source " << name_ << endl;
}
DimensionedField<Type, volMesh> rhs
(
IOobject
(
name_ + fieldNames_[fieldI] + "rhs",
eqn.psi().mesh().time().timeName(),
eqn.psi().mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
eqn.psi().mesh(),
dimensioned<Type>
(
"zero",
dimless,
pTraits<Type>::zero
)
);
List<Type> values(cells_.size());
forAll(values, i)
{
values[i] = fieldData_[fieldI];
}
UIndirectList<Type>(values, cells_) = injectionRate_[fieldI];
eqn.setValues(cells_, values);
}

View File

@ -31,7 +31,7 @@ Description
<Type>ExplicitSetValueCoeffs
{
fieldData
injectionRate
{
k 30.7;
epsilon 1.5;
@ -70,7 +70,7 @@ protected:
// Protected data
//- Source value per field
List<Type> fieldData_;
List<Type> injectionRate_;
// Protected functions

View File

@ -40,7 +40,7 @@ bool Foam::ExplicitSetValue<Type>::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
setFieldData(coeffs_.subDict("fieldData"));
setFieldData(coeffs_.subDict("injectionRate"));
return true;
}
else

View File

@ -88,7 +88,7 @@ template<class Type>
void Foam::ExplicitSource<Type>::setFieldData(const dictionary& dict)
{
fieldNames_.setSize(dict.toc().size());
fieldData_.setSize(fieldNames_.size());
injectionRate_.setSize(fieldNames_.size());
applied_.setSize(fieldNames_.size(), false);
@ -96,7 +96,7 @@ void Foam::ExplicitSource<Type>::setFieldData(const dictionary& dict)
forAllConstIter(dictionary, dict, iter)
{
fieldNames_[i] = iter().keyword();
dict.lookup(iter().keyword()) >> fieldData_[i];
dict.lookup(iter().keyword()) >> injectionRate_[i];
i++;
}
@ -122,7 +122,7 @@ Foam::ExplicitSource<Type>::ExplicitSource
basicSource(name, modelType, dict, mesh),
volumeMode_(vmAbsolute),
VDash_(1.0),
fieldData_()
injectionRate_()
{
read(dict);
}
@ -137,7 +137,7 @@ void Foam::ExplicitSource<Type>::addSup
const label fieldI
)
{
// if (debug)
if (debug)
{
Info<< "ExplicitSource<"<< pTraits<Type>::typeName
<< ">::addSup for source " << name_ << endl;
@ -163,12 +163,9 @@ void Foam::ExplicitSource<Type>::addSup
false
);
forAll(cells_, i)
{
Su[cells_[i]] = fieldData_[fieldI]/VDash_;
}
UIndirectList<Type>(Su, cells_) = injectionRate_[fieldI]/VDash_;
eqn -= Su;
eqn += Su;
}

View File

@ -32,7 +32,7 @@ Description
<Type>ExplicitSourceCoeffs
{
volumeMode absolute; // specific
fieldData
injectionRate
{
k 30.7;
epsilon 1.5;
@ -111,7 +111,7 @@ protected:
scalar VDash_;
//- Source field values
List<Type> fieldData_;
List<Type> injectionRate_;
// Protected functions
@ -152,7 +152,7 @@ public:
inline const volumeModeType& volumeMode() const;
//- Return const access to the source field values
inline const List<Type>& fieldData() const;
inline const List<Type>& injectionRate() const;
// Edit
@ -161,7 +161,7 @@ public:
inline volumeModeType& volumeMode();
//- Return access to the source field values
inline List<Type>& fieldData();
inline List<Type>& injectionRate();
// Evaluation

View File

@ -36,9 +36,9 @@ Foam::ExplicitSource<Type>::volumeMode() const
template<class Type>
inline const Foam::List<Type>& Foam::ExplicitSource<Type>::fieldData() const
inline const Foam::List<Type>& Foam::ExplicitSource<Type>::injectionRate() const
{
return fieldData_;
return injectionRate_;
}
@ -51,9 +51,9 @@ Foam::ExplicitSource<Type>::volumeMode()
template<class Type>
inline Foam::List<Type>& Foam::ExplicitSource<Type>::fieldData()
inline Foam::List<Type>& Foam::ExplicitSource<Type>::injectionRate()
{
return fieldData_;
return injectionRate_;
}

View File

@ -40,7 +40,7 @@ bool Foam::ExplicitSource<Type>::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
setFieldData(coeffs_.subDict("fieldData"));
setFieldData(coeffs_.subDict("injectionRate"));
volumeMode_ = wordToVolumeModeType(coeffs_.lookup("volumeMode"));
return true;

View File

@ -79,7 +79,7 @@ addRadialActuationDiskAxialInertialResistance
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

@ -399,7 +399,7 @@ Foam::rotorDiskSource::~rotorDiskSource()
void Foam::rotorDiskSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
{
// add source to lhs of eqn
// add source to rhs of eqn
const volVectorField& U = eqn.psi();
@ -410,7 +410,7 @@ void Foam::rotorDiskSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
const volScalarField& rho =
mesh_.lookupObject<volScalarField>(rhoName_);
eqn += calculateForces
eqn -= calculateForces
(
rho.internalField(),
inflowVelocity(U),
@ -419,7 +419,7 @@ void Foam::rotorDiskSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
}
else
{
eqn += calculateForces
eqn -= calculateForces
(
oneField(),
inflowVelocity(U),

View File

@ -27,7 +27,7 @@ source1
scalarExplicitSourceCoeffs
{
volumeMode absolute;
fieldData
injectionRate
{
hs 20000;
}

View File

@ -30,11 +30,10 @@ massSource1
scalarExplicitSourceCoeffs
{
volumeMode absolute;
fieldData
injectionRate
{
rho 1e-4; // kg/s
H2O 1e-4; // kg/s
p 1e-4; // kg/s
}
}
}
@ -55,7 +54,7 @@ momentumSource1
vectorExplicitSourceCoeffs
{
volumeMode absolute;
fieldData
injectionRate
{
U (0 0.005 0);
}
@ -78,7 +77,7 @@ energySource1
scalarExplicitSourceCoeffs
{
volumeMode absolute;
fieldData
injectionRate
{
hs 10;
}