Renamed U_ and T_ to boundaryU_ and boundaryT_.

Moved all fields and field reading into the DsmcCloud, all calculation and
resetting to single functions for all fields.

Changed constructors so that no fields are supplied to the solver called from
dsmcFoam and an initialisation dictionary is supplied by dsmcInitialise.
This commit is contained in:
graham
2009-07-17 18:17:26 +01:00
parent 103cd27ef5
commit 85d7852fc3
11 changed files with 433 additions and 575 deletions

View File

@ -1,162 +0,0 @@
Info<< nl << "Reading field boundaryT" << endl;
volScalarField boundaryT
(
IOobject
(
"boundaryT",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field boundaryU" << endl;
volVectorField boundaryU
(
IOobject
(
"boundaryU",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field rhoN (number density)" << endl;
volScalarField rhoN
(
IOobject
(
"rhoN",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field rhoM (mass density)" << endl;
volScalarField rhoM
(
IOobject
(
"rhoM",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field rhoNdsmc (dsmc particle density)" << endl;
volScalarField dsmcRhoN
(
IOobject
(
"dsmcRhoN",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field momentum (momentum density)" << endl;
volVectorField momentum
(
IOobject
(
"momentum",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field linearKE (linear kinetic energy density)"
<< endl;
volScalarField linearKE
(
IOobject
(
"linearKE",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field internalE (internal energy density)" << endl;
volScalarField internalE
(
IOobject
(
"internalE",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field iDof (internal degree of freedom density)"
<< endl;
volScalarField iDof
(
IOobject
(
"iDof",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field q (surface heat transfer)" << endl;
volScalarField q
(
IOobject
(
"q",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field fD (surface force density)" << endl;
volVectorField fD
(
IOobject
(
"fD",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Constructing dsmcCloud " << endl;
dsmcCloud dsmc("dsmc", boundaryT, boundaryU);

View File

@ -40,53 +40,21 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
#include "createMesh.H" #include "createMesh.H"
#include "createFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< nl << "Constructing dsmcCloud " << endl;
dsmcCloud dsmc("dsmc", mesh);
Info<< "\nStarting time loop\n" << endl; Info<< "\nStarting time loop\n" << endl;
while (runTime.run()) while (runTime.loop())
{ {
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
// Carry out dsmcCloud timestep
dsmc.evolve(); dsmc.evolve();
// Retrieve flow field data from dsmcCloud
rhoN = dsmc.rhoN();
rhoN.correctBoundaryConditions();
rhoM = dsmc.rhoM();
rhoM.correctBoundaryConditions();
dsmcRhoN = dsmc.dsmcRhoN();
dsmcRhoN.correctBoundaryConditions();
momentum = dsmc.momentum();
momentum.correctBoundaryConditions();
linearKE = dsmc.linearKE();
linearKE.correctBoundaryConditions();
internalE = dsmc.internalE();
internalE.correctBoundaryConditions();
iDof = dsmc.iDof();
iDof.correctBoundaryConditions();
// Retrieve surface field data from dsmcCloud
q = dsmc.q();
fD = dsmc.fD();
// Print status of dsmcCloud
dsmc.info(); dsmc.info();
runTime.write(); runTime.write();

View File

@ -44,9 +44,21 @@ int main(int argc, char *argv[])
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
IOdictionary dsmcInitialiseDict
(
IOobject
(
"dsmcInitialiseDict",
mesh.time().system(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
Info<< "Initialising dsmc for Time = " << runTime.timeName() << nl << endl; Info<< "Initialising dsmc for Time = " << runTime.timeName() << nl << endl;
dsmcCloud dsmc("dsmc", mesh); dsmcCloud dsmc("dsmc", mesh, dsmcInitialiseDict);
label totalMolecules = dsmc.size(); label totalMolecules = dsmc.size();

View File

@ -475,38 +475,99 @@ void Foam::DsmcCloud<ParcelType>::collisions()
template<class ParcelType> template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::resetSurfaceDataFields() void Foam::DsmcCloud<ParcelType>::resetFields()
{ {
volScalarField::GeometricBoundaryField& qBF(q_.boundaryField()); q_ = dimensionedScalar("zero", dimensionSet(1, 0, -3, 0, 0), 0.0);
forAll(qBF, p) fD_ = dimensionedVector
{
qBF[p] = 0.0;
}
volVectorField::GeometricBoundaryField& fDBF(fD_.boundaryField());
forAll(fDBF, p)
{
fDBF[p] = vector::zero;
}
volVectorField::GeometricBoundaryField& momentumBF
( (
momentum_.boundaryField() "zero",
dimensionSet(1, -1, -2, 0, 0),
vector::zero
); );
forAll(momentumBF, p) rhoN_ = dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL);
rhoM_ = dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0), VSMALL);
dsmcRhoN_ = dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), 0.0);
linearKE_ = dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0);
internalE_ = dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0);
iDof_ = dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL);
momentum_ = dimensionedVector
(
"zero",
dimensionSet(1, -2, -1, 0, 0),
vector::zero
);
}
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::calculateFields()
{
scalarField& rhoN = rhoN_.internalField();
rhoN = VSMALL;
scalarField& rhoM = rhoM_.internalField();
rhoM = VSMALL;
scalarField& dsmcRhoN = dsmcRhoN_.internalField();
dsmcRhoN = 0.0;
scalarField& linearKE = linearKE_.internalField();
linearKE = 0.0;
scalarField& internalE = internalE_.internalField();
internalE = 0.0;
scalarField& iDof = iDof_.internalField();
iDof = VSMALL;
vectorField& momentum = momentum_.internalField();
momentum = vector::zero;
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{ {
momentumBF[p] = vector::zero; const ParcelType& p = iter();
const label cellI = p.cell();
rhoN[cellI]++;
rhoM[cellI] += constProps(p.typeId()).mass();
dsmcRhoN[cellI]++;
linearKE[cellI] += 0.5*constProps(p.typeId()).mass()*(p.U() & p.U());
internalE[cellI] += p.Ei();
iDof[cellI] += constProps(p.typeId()).internalDegreesOfFreedom();
momentum[cellI] += constProps(p.typeId()).mass()*p.U();
} }
volScalarField::GeometricBoundaryField& rhoMBF(rhoM_.boundaryField()); rhoN *= nParticle_/mesh().cellVolumes();
rhoN_.correctBoundaryConditions();
forAll(rhoMBF, p) rhoM *= nParticle_/mesh().cellVolumes();
{ rhoM_.correctBoundaryConditions();
rhoMBF[p] = VSMALL;
} linearKE *= nParticle_/mesh().cellVolumes();
linearKE_.correctBoundaryConditions();
internalE *= nParticle_/mesh().cellVolumes();
internalE_.correctBoundaryConditions();
iDof *= nParticle_/mesh().cellVolumes();
iDof_.correctBoundaryConditions();
momentum *= nParticle_/mesh().cellVolumes();
momentum_.correctBoundaryConditions();
} }
@ -542,14 +603,13 @@ template<class ParcelType>
Foam::DsmcCloud<ParcelType>::DsmcCloud Foam::DsmcCloud<ParcelType>::DsmcCloud
( (
const word& cloudName, const word& cloudName,
const volScalarField& T, const fvMesh& mesh
const volVectorField& U
) )
: :
Cloud<ParcelType>(T.mesh(), cloudName, false), Cloud<ParcelType>(mesh, cloudName, false),
DsmcBaseCloud(), DsmcBaseCloud(),
cloudName_(cloudName), cloudName_(cloudName),
mesh_(T.mesh()), mesh_(mesh),
particleProperties_ particleProperties_
( (
IOobject IOobject
@ -581,68 +641,142 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
( (
IOobject IOobject
( (
this->name() + "q_", "q",
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::AUTO_WRITE
), ),
mesh_, mesh_
dimensionedScalar("zero", dimensionSet(1, 0, -3, 0, 0), 0.0)
), ),
fD_ fD_
( (
IOobject IOobject
( (
this->name() + "fD_", "fD",
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::AUTO_WRITE
), ),
mesh_, mesh_
dimensionedVector
(
"zero",
dimensionSet(1, -1, -2, 0, 0),
vector::zero
)
), ),
momentum_ rhoN_
( (
IOobject IOobject
( (
this->name() + "momentum_", "rhoN",
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::AUTO_WRITE
), ),
mesh_, mesh_
dimensionedVector
(
"zero",
dimensionSet(1, -2, -1, 0, 0),
vector::zero
)
), ),
rhoM_ rhoM_
( (
IOobject IOobject
( (
this->name() + "rhoM_", "rhoM",
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::AUTO_WRITE
), ),
mesh_
),
dsmcRhoN_
(
IOobject
(
"dsmcRhoN",
mesh_.time().timeName(),
mesh_, mesh_,
dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0), 0.0) IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
linearKE_
(
IOobject
(
"linearKE",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
internalE_
(
IOobject
(
"internalE",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
iDof_
(
IOobject
(
"iDof",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
momentum_
(
IOobject
(
"momentum",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
), ),
constProps_(), constProps_(),
rndGen_(label(149382906) + 7183*Pstream::myProcNo()), rndGen_(label(149382906) + 7183*Pstream::myProcNo()),
T_(T), boundaryT_
U_(U), (
volScalarField
(
IOobject
(
"boundaryT",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
)
),
boundaryU_
(
volVectorField
(
IOobject
(
"boundaryU",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
)
),
binaryCollisionModel_ binaryCollisionModel_
( (
BinaryCollisionModel<DsmcCloud<ParcelType> >::New BinaryCollisionModel<DsmcCloud<ParcelType> >::New
@ -685,7 +819,8 @@ template<class ParcelType>
Foam::DsmcCloud<ParcelType>::DsmcCloud Foam::DsmcCloud<ParcelType>::DsmcCloud
( (
const word& cloudName, const word& cloudName,
const fvMesh& mesh const fvMesh& mesh,
const IOdictionary& dsmcInitialiseDict
) )
: :
Cloud<ParcelType>(mesh, cloudName, false), Cloud<ParcelType>(mesh, cloudName, false),
@ -751,6 +886,84 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
vector::zero vector::zero
) )
), ),
rhoN_
(
IOobject
(
this->name() + "rhoN_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL)
),
rhoM_
(
IOobject
(
this->name() + "rhoM_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0), VSMALL)
),
dsmcRhoN_
(
IOobject
(
this->name() + "dsmcRhoN_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), 0.0)
),
linearKE_
(
IOobject
(
this->name() + "linearKE_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0)
),
internalE_
(
IOobject
(
this->name() + "internalE_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0)
),
iDof_
(
IOobject
(
this->name() + "iDof_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL)
),
momentum_ momentum_
( (
IOobject IOobject
@ -769,28 +982,15 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
vector::zero vector::zero
) )
), ),
rhoM_
(
IOobject
(
this->name() + "rhoM_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0), 0.0)
),
constProps_(), constProps_(),
rndGen_(label(971501) + 1526*Pstream::myProcNo()), rndGen_(label(971501) + 1526*Pstream::myProcNo()),
T_ boundaryT_
( (
volScalarField volScalarField
( (
IOobject IOobject
( (
"T", "boundaryT",
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
@ -800,13 +1000,13 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
dimensionedScalar("zero", dimensionSet(0, 0, 0, 1, 0), 0.0) dimensionedScalar("zero", dimensionSet(0, 0, 0, 1, 0), 0.0)
) )
), ),
U_ boundaryU_
( (
volVectorField volVectorField
( (
IOobject IOobject
( (
"U", "boundaryU",
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
@ -829,18 +1029,6 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
buildConstProps(); buildConstProps();
IOdictionary dsmcInitialiseDict
(
IOobject
(
"dsmcInitialiseDict",
mesh_.time().system(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
initialise(dsmcInitialiseDict); initialise(dsmcInitialiseDict);
} }
@ -862,8 +1050,8 @@ void Foam::DsmcCloud<ParcelType>::evolve()
typename ParcelType::trackData td(*this); typename ParcelType::trackData td(*this);
// Reset the surface data collection fields // Reset the data collection fields
resetSurfaceDataFields(); resetFields();
if (debug) if (debug)
{ {
@ -878,6 +1066,9 @@ void Foam::DsmcCloud<ParcelType>::evolve()
// Calculate new velocities via stochastic collisions // Calculate new velocities via stochastic collisions
collisions(); collisions();
// Calculate the volume field data
calculateFields();
} }

View File

@ -110,12 +110,27 @@ class DsmcCloud
//- Force density at surface field //- Force density at surface field
volVectorField fD_; volVectorField fD_;
//- Momentum density field //- number density field
volVectorField momentum_; volScalarField rhoN_;
//- Mass density field //- Mass density field
volScalarField rhoM_; volScalarField rhoM_;
//- dsmc particle density field
volScalarField dsmcRhoN_;
//- linear kinetic energy density field
volScalarField linearKE_;
//- Internal energy density field
volScalarField internalE_;
// Internal degree of freedom density field
volScalarField iDof_;
//- Momentum density field
volVectorField momentum_;
//- Parcel constant properties - one for each type //- Parcel constant properties - one for each type
List<typename ParcelType::constantProperties> constProps_; List<typename ParcelType::constantProperties> constProps_;
@ -127,13 +142,13 @@ class DsmcCloud
scalar cachedDeltaT_; scalar cachedDeltaT_;
// References to the macroscopic fields // boundary value fields
//- Temperature //- boundary temperature
const volScalarField& T_; volScalarField boundaryT_;
//- Velocity //- boundary velocity
const volVectorField& U_; volVectorField boundaryU_;
// References to the cloud sub-models // References to the cloud sub-models
@ -165,8 +180,11 @@ class DsmcCloud
//- Calculate collisions between molecules //- Calculate collisions between molecules
void collisions(); void collisions();
//- Reset the surface data accumulation field values //- Reset the data accumulation field values to zero
void resetSurfaceDataFields(); void resetFields();
//- Calculate the volume field data
void calculateFields();
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
DsmcCloud(const DsmcCloud&); DsmcCloud(const DsmcCloud&);
@ -185,21 +203,22 @@ public:
// Constructors // Constructors
//- Construct given name and mesh, will read Parcels from file //- Construct given name and mesh, will read Parcels and fields from
DsmcCloud // file
(
const word& cloudName,
const volScalarField& T,
const volVectorField& U
);
//- Construct given name and mesh. Used to initialise.
DsmcCloud DsmcCloud
( (
const word& cloudName, const word& cloudName,
const fvMesh& mesh const fvMesh& mesh
); );
//- Construct given name, mesh and initialisation dictionary.
DsmcCloud
(
const word& cloudName,
const fvMesh& mesh,
const IOdictionary& dsmcInitialiseDict
);
//- Destructor //- Destructor
virtual ~DsmcCloud(); virtual ~DsmcCloud();
@ -268,20 +287,48 @@ public:
//- Return non-const force density at boundary field reference //- Return non-const force density at boundary field reference
inline volVectorField::GeometricBoundaryField& fDBF(); inline volVectorField::GeometricBoundaryField& fDBF();
//- Return non-const momentum density boundary field reference
inline volVectorField::GeometricBoundaryField& momentumBF();
//- Return non-const mass density boundary field reference //- Return non-const mass density boundary field reference
inline volScalarField::GeometricBoundaryField& rhoMBF(); inline volScalarField::GeometricBoundaryField& rhoMBF();
//- Return non-const momentum density boundary field reference
inline volVectorField::GeometricBoundaryField& momentumBF();
// References to the macroscopic fields // References to the macroscopic fields
//- Return macroscopic temperature //- Return macroscopic temperature
inline const volScalarField& T() const; inline const volScalarField& boundaryT() const;
//- Return macroscopic velocity //- Return macroscopic velocity
inline const volVectorField& U() const; inline const volVectorField& boundaryU() const;
//- Return heat flux at surface field
inline const volScalarField& q() const;
//- Return force density at surface field
inline const volVectorField& fD() const;
//- Return the real particle number density field
inline const volScalarField& rhoN() const;
//- Return the particle mass density field
inline const volScalarField& rhoM() const;
//- Return the field of number of DSMC particles
inline const volScalarField& dsmcRhoN() const;
//- Return the total linear kinetic energy (translational and
// thermal density field
inline const volScalarField& linearKE() const;
//- Return the internal energy density field
inline const volScalarField& internalE() const;
//- Return the average internal degrees of freedom field
inline const volScalarField& iDof() const;
//- Return the momentum density field
inline const volVectorField& momentum() const;
// Kinetic theory helper functions // Kinetic theory helper functions
@ -395,35 +442,6 @@ public:
void dumpParticlePositions() const; void dumpParticlePositions() const;
// Fields
//- Return heat flux at surface field
inline const volScalarField& q() const;
//- Return force density at surface field
inline const volVectorField& fD() const;
//- Return the real particle number density field
inline const tmp<volScalarField> rhoN() const;
//- Return the particle mass density field
inline const volScalarField& rhoM();
//- Return the momentum density field
inline const volVectorField& momentum();
//- Return the total linear kinetic energy (translational and
// thermal density field
inline const tmp<volScalarField> linearKE() const;
//- Return the internal energy density field
inline const tmp<volScalarField> internalE() const;
//- Return the average internal degrees of freedom field
inline const tmp<volScalarField> iDof() const;
//- Return the field of number of DSMC particles
inline const tmp<volScalarField> dsmcRhoN() const;
// Cloud evolution functions // Cloud evolution functions
@ -441,7 +459,6 @@ public:
//- Evolve the cloud (move, collide) //- Evolve the cloud (move, collide)
void evolve(); void evolve();
//- Clear the Cloud //- Clear the Cloud
inline void clear(); inline void clear();

View File

@ -167,16 +167,18 @@ Foam::DsmcCloud<ParcelType>::rhoMBF()
template<class ParcelType> template<class ParcelType>
inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::T() const inline const Foam::volScalarField&
Foam::DsmcCloud<ParcelType>::boundaryT() const
{ {
return T_; return boundaryT_;
} }
template<class ParcelType> template<class ParcelType>
inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::U() const inline const Foam::volVectorField&
Foam::DsmcCloud<ParcelType>::boundaryU() const
{ {
return U_; return boundaryU_;
} }
@ -392,228 +394,56 @@ inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::fD() const
template<class ParcelType> template<class ParcelType>
inline const Foam::tmp<Foam::volScalarField> inline const Foam::volScalarField&
Foam::DsmcCloud<ParcelType>::rhoN() const Foam::DsmcCloud<ParcelType>::rhoN() const
{ {
tmp<volScalarField> trhoN return rhoN_;
(
new volScalarField
(
IOobject
(
this->name() + "rhoN",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL)
)
);
scalarField& rhoN = trhoN().internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
rhoN[cellI]++;
}
rhoN *= nParticle_/mesh().cellVolumes();
return trhoN;
} }
template<class ParcelType> template<class ParcelType>
inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::rhoM() inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::rhoM() const
{ {
scalarField& rM = rhoM_.internalField();
rM = VSMALL;
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
rM[cellI] += constProps(p.typeId()).mass();
}
rM *= nParticle_/mesh().cellVolumes();
return rhoM_; return rhoM_;
} }
template<class ParcelType> template<class ParcelType>
inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::momentum() inline const Foam::volScalarField&
{
vectorField& mom = momentum_.internalField();
mom = vector::zero;
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
mom[cellI] += constProps(p.typeId()).mass()*p.U();
}
mom *= nParticle_/mesh().cellVolumes();
return momentum_;
}
template<class ParcelType>
inline const Foam::tmp<Foam::volScalarField>
Foam::DsmcCloud<ParcelType>::linearKE() const
{
tmp<volScalarField> tlinearKE
(
new volScalarField
(
IOobject
(
this->name() + "linearKE",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0)
)
);
scalarField& linearKE = tlinearKE().internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
linearKE[cellI] += 0.5*constProps(p.typeId()).mass()*(p.U() & p.U());
}
linearKE *= nParticle_/mesh().cellVolumes();
return tlinearKE;
}
template<class ParcelType>
inline const Foam::tmp<Foam::volScalarField>
Foam::DsmcCloud<ParcelType>::internalE() const
{
tmp<volScalarField> tinternalE
(
new volScalarField
(
IOobject
(
this->name() + "internalE",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0)
)
);
scalarField& internalE = tinternalE().internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
internalE[cellI] += p.Ei();
}
internalE *= nParticle_/mesh().cellVolumes();
return tinternalE;
}
template<class ParcelType>
inline const Foam::tmp<Foam::volScalarField>
Foam::DsmcCloud<ParcelType>::iDof() const
{
tmp<volScalarField> tiDof
(
new volScalarField
(
IOobject
(
this->name() + "iDof",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL)
)
);
scalarField& iDof = tiDof().internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
iDof[cellI] += constProps(p.typeId()).internalDegreesOfFreedom();
}
iDof *= nParticle_/mesh().cellVolumes();
return tiDof;
}
template<class ParcelType>
inline const Foam::tmp<Foam::volScalarField>
Foam::DsmcCloud<ParcelType>::dsmcRhoN() const Foam::DsmcCloud<ParcelType>::dsmcRhoN() const
{ {
tmp<volScalarField> tdsmcRhoN return dsmcRhoN_;
( }
new volScalarField
(
IOobject
(
this->name() + "dsmcRhoN",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), 0.0)
)
);
scalarField& dsmcRhoN = tdsmcRhoN().internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
dsmcRhoN[cellI]++; template<class ParcelType>
} inline const Foam::volScalarField&
Foam::DsmcCloud<ParcelType>::linearKE() const
{
return linearKE_;
}
return tdsmcRhoN;
template<class ParcelType>
inline const Foam::volScalarField&
Foam::DsmcCloud<ParcelType>::internalE() const
{
return internalE_;
}
template<class ParcelType>
inline const Foam::volScalarField&
Foam::DsmcCloud<ParcelType>::iDof() const
{
return iDof_;
}
template<class ParcelType>
inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::momentum() const
{
return momentum_;
} }

View File

@ -39,11 +39,10 @@ namespace Foam
Foam::dsmcCloud::dsmcCloud Foam::dsmcCloud::dsmcCloud
( (
const word& cloudName, const word& cloudName,
const volScalarField& T, const fvMesh& mesh
const volVectorField& U
) )
: :
DsmcCloud<dsmcParcel>(cloudName, T, U) DsmcCloud<dsmcParcel>(cloudName, mesh)
{ {
dsmcParcel::readFields(*this); dsmcParcel::readFields(*this);
} }
@ -52,10 +51,11 @@ Foam::dsmcCloud::dsmcCloud
Foam::dsmcCloud::dsmcCloud Foam::dsmcCloud::dsmcCloud
( (
const word& cloudName, const word& cloudName,
const fvMesh& mesh const fvMesh& mesh,
const IOdictionary& dsmcInitialiseDict
) )
: :
DsmcCloud<dsmcParcel>(cloudName, mesh) DsmcCloud<dsmcParcel>(cloudName, mesh, dsmcInitialiseDict)
{} {}

View File

@ -69,21 +69,22 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct given name and mesh, will read Parcels and fields from
dsmcCloud // file
(
const word& cloudName,
const volScalarField& T,
const volVectorField& U
);
//- Construct from name and mesh, used to initialise.
dsmcCloud dsmcCloud
( (
const word& cloudName, const word& cloudName,
const fvMesh& mesh const fvMesh& mesh
); );
//- Construct given name, mesh and initialisation dictionary.
dsmcCloud
(
const word& cloudName,
const fvMesh& mesh,
const IOdictionary& dsmcInitialiseDict
);
//- Destructor //- Destructor
~dsmcCloud(); ~dsmcCloud();

View File

@ -136,12 +136,12 @@ void Foam::FreeStream<CloudType>::inflow()
const volScalarField::GeometricBoundaryField& boundaryT const volScalarField::GeometricBoundaryField& boundaryT
( (
cloud.T().boundaryField() cloud.boundaryT().boundaryField()
); );
const volVectorField::GeometricBoundaryField& boundaryU const volVectorField::GeometricBoundaryField& boundaryU
( (
cloud.U().boundaryField() cloud.boundaryU().boundaryField()
); );
forAll(patches_, p) forAll(patches_, p)
@ -165,7 +165,8 @@ void Foam::FreeStream<CloudType>::inflow()
if (min(boundaryT[patchI]) < SMALL) if (min(boundaryT[patchI]) < SMALL)
{ {
FatalErrorIn ("Foam::FreeStream<CloudType>::inflow()") FatalErrorIn ("Foam::FreeStream<CloudType>::inflow()")
<< "Zero boundary temperature detected, check boundaryT condition." << nl << "Zero boundary temperature detected, check boundaryT "
<< "condition." << nl
<< nl << abort(FatalError); << nl << abort(FatalError);
} }

View File

@ -101,7 +101,7 @@ void Foam::MaxwellianThermal<CloudType>::correct
// Other tangential unit vector // Other tangential unit vector
vector tw2 = nw^tw1; vector tw2 = nw^tw1;
scalar T = cloud.T().boundaryField()[wppIndex][wppLocalFace]; scalar T = cloud.boundaryT().boundaryField()[wppIndex][wppLocalFace];
scalar mass = cloud.constProps(typeId).mass(); scalar mass = cloud.constProps(typeId).mass();
@ -115,7 +115,7 @@ void Foam::MaxwellianThermal<CloudType>::correct
- sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw - sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
); );
U += cloud.U().boundaryField()[wppIndex][wppLocalFace]; U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace];
Ei = cloud.equipartitionInternalEnergy(T, iDof); Ei = cloud.equipartitionInternalEnergy(T, iDof);
} }

View File

@ -106,7 +106,7 @@ void Foam::MixedDiffuseSpecular<CloudType>::correct
// Other tangential unit vector // Other tangential unit vector
vector tw2 = nw^tw1; vector tw2 = nw^tw1;
scalar T = cloud.T().boundaryField()[wppIndex][wppLocalFace]; scalar T = cloud.boundaryT().boundaryField()[wppIndex][wppLocalFace];
scalar mass = cloud.constProps(typeId).mass(); scalar mass = cloud.constProps(typeId).mass();
@ -120,7 +120,7 @@ void Foam::MixedDiffuseSpecular<CloudType>::correct
- sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw - sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
); );
U += cloud.U().boundaryField()[wppIndex][wppLocalFace]; U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace];
Ei = cloud.equipartitionInternalEnergy(T, iDof); Ei = cloud.equipartitionInternalEnergy(T, iDof);
} }