Merge remote branch 'OpenCFD/master' into olesenm

This commit is contained in:
Mark Olesen
2010-11-08 08:07:29 +01:00
674 changed files with 19530 additions and 5336 deletions

View File

@ -61,7 +61,8 @@ sha1 = primitives/hashes/SHA1
$(sha1)/SHA1.C
$(sha1)/SHA1Digest.C
primitives/random/Random.C
primitives/random/Random/Random.C
primitives/random/cachedRandom/cachedRandom.H
containers/HashTables/HashTable/HashTableCore.C
containers/HashTables/StaticHashTable/StaticHashTableCore.C

View File

@ -64,9 +64,7 @@ bool Foam::IOobject::IOobject::fileNameComponents
return false;
}
string::size_type first = path.find('/');
if (first == 0)
if (path.isAbsolute())
{
// called with absolute path
WarningIn("IOobject::fileNameComponents(const fileName&, ...)")
@ -74,6 +72,8 @@ bool Foam::IOobject::IOobject::fileNameComponents
return false;
}
string::size_type first = path.find('/');
if (first == string::npos)
{
// no '/' found - no instance or local

View File

@ -72,7 +72,7 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName
fName.expand();
// relative name
if (fName.size() && fName[0] != '/')
if (fName.size() && !fName.isAbsolute())
{
fName = fileName(is.name()).path()/fName;
}

View File

@ -81,14 +81,20 @@ DimensionedField<Type, GeoMesh>::DimensionedField
(
const IOobject& io,
const Mesh& mesh,
const dimensionSet& dims
const dimensionSet& dims,
const bool checkIOFlags
)
:
regIOobject(io),
Field<Type>(GeoMesh::size(mesh)),
mesh_(mesh),
dimensions_(dims)
{}
{
if (checkIOFlags)
{
readIfPresent();
}
}
template<class Type, class GeoMesh>
@ -96,14 +102,20 @@ DimensionedField<Type, GeoMesh>::DimensionedField
(
const IOobject& io,
const Mesh& mesh,
const dimensioned<Type>& dt
const dimensioned<Type>& dt,
const bool checkIOFlags
)
:
regIOobject(io),
Field<Type>(GeoMesh::size(mesh), dt.value()),
mesh_(mesh),
dimensions_(dt.dimensions())
{}
{
if (checkIOFlags)
{
readIfPresent();
}
}
template<class Type, class GeoMesh>

View File

@ -94,6 +94,11 @@ private:
dimensionSet dimensions_;
// Private Member Functions
void readIfPresent(const word& fieldDictEntry = "value");
public:
//- Runtime type information
@ -122,7 +127,8 @@ public:
(
const IOobject&,
const Mesh& mesh,
const dimensionSet&
const dimensionSet&,
const bool checkIOFlags = true
);
//- Construct from components
@ -130,7 +136,8 @@ public:
(
const IOobject&,
const Mesh& mesh,
const dimensioned<Type>&
const dimensioned<Type>&,
const bool checkIOFlags = true
);
//- Construct from Istream
@ -141,12 +148,6 @@ public:
const word& fieldDictEntry="value"
);
void readField
(
const dictionary& fieldDict,
const word& fieldDictEntry="value"
);
//- Construct as copy
DimensionedField
(
@ -222,6 +223,12 @@ public:
// Member Functions
void readField
(
const dictionary& fieldDict,
const word& fieldDictEntry = "value"
);
//- Return mesh
inline const Mesh& mesh() const;

View File

@ -47,6 +47,21 @@ void DimensionedField<Type, GeoMesh>::readField
}
template<class Type, class GeoMesh>
void DimensionedField<Type, GeoMesh>::readIfPresent(const word& fieldDictEntry)
{
if
(
(this->headerOk() && this->readOpt() == IOobject::READ_IF_PRESENT)
|| this->readOpt() == IOobject::MUST_READ
|| this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
{
readField(dictionary(readStream(typeName)), fieldDictEntry);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type, class GeoMesh>

View File

@ -209,7 +209,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const word& patchFieldType
)
:
DimensionedField<Type, GeoMesh>(io, mesh, ds),
DimensionedField<Type, GeoMesh>(io, mesh, ds, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
@ -240,7 +240,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const wordList& actualPatchTypes
)
:
DimensionedField<Type, GeoMesh>(io, mesh, ds),
DimensionedField<Type, GeoMesh>(io, mesh, ds, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
@ -267,7 +267,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const word& patchFieldType
)
:
DimensionedField<Type, GeoMesh>(io, mesh, dt),
DimensionedField<Type, GeoMesh>(io, mesh, dt, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
@ -297,7 +297,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const wordList& actualPatchTypes
)
:
DimensionedField<Type, GeoMesh>(io, mesh, dt),
DimensionedField<Type, GeoMesh>(io, mesh, dt, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
@ -351,7 +351,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const Mesh& mesh
)
:
DimensionedField<Type, GeoMesh>(io, mesh, dimless),
DimensionedField<Type, GeoMesh>(io, mesh, dimless, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
@ -392,7 +392,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
Istream& is
)
:
DimensionedField<Type, GeoMesh>(io, mesh, dimless),
DimensionedField<Type, GeoMesh>(io, mesh, dimless, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
@ -431,7 +431,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
const dictionary& dict
)
:
DimensionedField<Type, GeoMesh>(io, mesh, dimless),
DimensionedField<Type, GeoMesh>(io, mesh, dimless, false),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),

View File

@ -315,7 +315,7 @@ void Foam::argList::getRootCase()
casePath = cwd();
options_.erase("case");
}
else if (casePath[0] != '/' && casePath.name() == "..")
else if (!casePath.isAbsolute() && casePath.name() == "..")
{
// avoid relative cases ending in '..' - makes for very ugly names
casePath = cwd()/casePath;
@ -334,7 +334,7 @@ void Foam::argList::getRootCase()
// Set the case and case-name as an environment variable
if (rootPath_[0] == '/')
if (rootPath_.isAbsolute())
{
// absolute path - use as-is
setEnv("FOAM_CASE", rootPath_/globalCase_, true);

View File

@ -202,9 +202,12 @@ void Foam::lduMatrix::operator+=(const lduMatrix& A)
}
else
{
FatalErrorIn("lduMatrix::operator+=(const lduMatrix& A)")
<< "Unknown matrix type combination"
<< abort(FatalError);
if (debug > 1)
{
WarningIn("lduMatrix::operator+=(const lduMatrix& A)")
<< "Unknown matrix type combination"
<< endl;
}
}
}
@ -270,9 +273,12 @@ void Foam::lduMatrix::operator-=(const lduMatrix& A)
}
else
{
FatalErrorIn("lduMatrix::operator-=(const lduMatrix& A)")
<< "Unknown matrix type combination"
<< abort(FatalError);
if (debug > 1)
{
WarningIn("lduMatrix::operator-=(const lduMatrix& A)")
<< "Unknown matrix type combination"
<< endl;
}
}
}

View File

@ -237,7 +237,7 @@ scalar tetrahedron<Point, PointRef>::barycentric
"const point& pt"
") const"
)
<< "Degenerate triangle - returning 1/4 barycentric coordinates."
<< "Degenerate tetrahedron - returning 1/4 barycentric coordinates."
<< endl;
bary = List<scalar>(4, 0.25);

View File

@ -0,0 +1,159 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "cachedRandom.H"
#include <cstdlib>
#if INT_MAX != 2147483647
# error "INT_MAX != 2147483647"
# error "The random number generator may not work!"
#endif
// * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * //
Foam::scalar Foam::cachedRandom::scalar01()
{
if (sampleI_ < 0)
{
return drand48();
}
if (sampleI_ == samples_.size() - 1)
{
scalar s = samples_[sampleI_];
sampleI_ = 0;
return s;
}
else
{
scalar s = samples_[sampleI_];
sampleI_++;
return s;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cachedRandom::cachedRandom(const label seed, const label count)
:
seed_(1),
samples_(0),
sampleI_(-1)
{
if (seed > 1)
{
seed_ = seed;
}
// Samples will be cached if count > 0
if (count > 0)
{
samples_.setSize(count);
sampleI_ = 0;
}
// Initialise samples
srand48(seed_);
forAll(samples_, i)
{
samples_[i] = drand48();
}
}
Foam::cachedRandom::cachedRandom(const cachedRandom& cr, const bool reset)
:
seed_(cr.seed_),
samples_(cr.samples_),
sampleI_(cr.sampleI_)
{
if (sampleI_ == -1)
{
WarningIn
(
"Foam::cachedRandom::cachedRandom(const cachedRandom& cr)"
) << "Copy constructor called, but samples not being cached. "
<< "This may lead to non-repeatable behaviour" << endl;
srand48(seed_);
}
else if (reset)
{
sampleI_ = 0;
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cachedRandom::~cachedRandom()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<>
Foam::label Foam::cachedRandom::sample01()
{
return round(scalar01());
}
template<>
Foam::scalar Foam::cachedRandom::sample01()
{
return scalar01();
}
template<>
Foam::label Foam::cachedRandom::position(const label& start, const label& end)
{
return start + round(scalar01()*(end - start));
}
template<>
Foam::scalar Foam::cachedRandom::position
(
const scalar& start,
const scalar& end
)
{
return start + scalar01()*(end - start);
}
void Foam::cachedRandom::operator=(const cachedRandom& cr)
{
seed_ = cr.seed_;
samples_ = cr.samples_;
sampleI_ = cr.sampleI_;
}
// ************************************************************************* //

View File

@ -0,0 +1,182 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::cachedRandom
Description
Random number generator.
Pre-computes and caches samples on construction, so that when sample01()
is called, the function simply returns the next (pre-computed) sample. On
reaching the last sample, the sample sequence is repeated.
Constructed using a seed and sample count. If the supplied count is
negative, no caching is performed, and a new sample is generated on each
call to sample01().
Note: the copy constructor cannot be used if count = -1.
SourceFiles
cachedRandomI.H
cachedRandom.C
cachedRandomTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef cachedRandom_H
#define cachedRandom_H
#include "scalarList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class cachedRandom;
/*---------------------------------------------------------------------------*\
Class cachedRandom Declaration
\*---------------------------------------------------------------------------*/
class cachedRandom
{
private:
// Private data
//- Initial random number seed
label seed_;
//- List of scalar samples
scalarList samples_;
//- Current sample marker
label sampleI_;
// Private Member Functions
//- Returns the current sample
scalar scalar01();
public:
// Constructors
//- Construct given seed and sample count
cachedRandom(const label seed, const label count);
//- Copy constructor with optional reset of sampleI
cachedRandom(const cachedRandom& cr, const bool reset = false);
// Destructor
~cachedRandom();
// Member functions
// Access
//- Return const access to the initial random number seed
inline label seed() const;
//- Return const access to the list of samples
inline const scalarList& samples() const;
//- Return the current sample marker
inline label sampleI() const;
// Manipulation
//- Return non-const access to the sample marker
inline label& sampleI();
// Evaluation
//- Return a sample whose components lie in the range 0-1
template<class Type>
Type sample01();
//- Return a sample between start and end
template<class Type>
Type position(const Type& start, const Type& end);
//- Randomise value in the range 0-1
template<class Type>
void randomise01(Type& value);
// Operators
//- Assignment operator
void operator=(const cachedRandom& cr);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Template specialisations
template<>
label cachedRandom::sample01<label>();
template<>
scalar cachedRandom::sample01<scalar>();
template<>
label cachedRandom::position<label>(const label& start, const label& end);
template<>
scalar cachedRandom::position<scalar>
(
const scalar& start,
const scalar& end
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "cachedRandomI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "cachedRandomTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "cachedRandom.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline Foam::label Foam::cachedRandom::seed() const
{
return seed_;
}
inline const Foam::scalarList& Foam::cachedRandom::samples() const
{
return samples_;
}
inline Foam::label Foam::cachedRandom::sampleI() const
{
return sampleI_;
}
inline Foam::label& Foam::cachedRandom::sampleI()
{
return sampleI_;
}
// ************************************************************************* //

View File

@ -0,0 +1,65 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "cachedRandom.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Type Foam::cachedRandom::sample01()
{
Type value;
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{
value.component(cmpt) = scalar01();
}
return value;
}
template<class Type>
Type Foam::cachedRandom::position(const Type& start, const Type& end)
{
Type value(start);
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{
value.component(cmpt) +=
scalar01()*(end.component(cmpt) - start.component(cmpt));
}
return value;
}
template<class Type>
void Foam::cachedRandom::randomise01(Type& value)
{
value = sample01<Type>();
}
// ************************************************************************* //

View File

@ -54,6 +54,13 @@ Foam::fileName::Type Foam::fileName::type() const
}
bool Foam::fileName::isAbsolute() const
{
fileName fName(*this);
return fName.size() && fName.operator[](0) == '/';
}
//
// * remove repeated slashes
// /abc////def --> /abc/def

View File

@ -138,10 +138,15 @@ public:
// eg, remove repeated slashes, etc.
fileName clean() const;
// Interogation
//- Return the file type: FILE, DIRECTORY or UNDEFINED
Type type() const;
// Interrogation
//- Return the file type: FILE, DIRECTORY or UNDEFINED
Type type() const;
//- Return true if file name is absolute
bool isAbsolute() const;
// Decomposition
@ -163,6 +168,7 @@ public:
//- Return a single component of the path
word component(const size_type, const char delimiter='/') const;
// Member operators
// Assignment

View File

@ -384,9 +384,19 @@ void Foam::Cloud<ParticleType>::deleteParticle(ParticleType& p)
}
template<class ParticleType>
void Foam::Cloud<ParticleType>::cloudReset(const Cloud<ParticleType>& c)
{
// Reset particle cound and particles only
// - not changing the cloud object registry or reference to the polyMesh
particleCount_ = 0;
IDLList<ParticleType>::operator=(c);
}
template<class ParticleType>
template<class TrackingData>
void Foam::Cloud<ParticleType>::move(TrackingData& td)
void Foam::Cloud<ParticleType>::move(TrackingData& td, const scalar trackTime)
{
const polyBoundaryMesh& pbm = pMesh().boundaryMesh();
const globalMeshData& pData = polyMesh_.globalData();
@ -444,7 +454,7 @@ void Foam::Cloud<ParticleType>::move(TrackingData& td)
ParticleType& p = pIter();
// Move the particle
bool keepParticle = p.move(td);
bool keepParticle = p.move(td, trackTime);
// If the particle is to be kept
// (i.e. it hasn't passed through an inlet or outlet)

View File

@ -318,10 +318,13 @@ public:
//- Remove particle from cloud and delete
void deleteParticle(ParticleType&);
//- Reset the particles
void cloudReset(const Cloud<ParticleType>& c);
//- Move the particles
// passing the TrackingData to the track function
template<class TrackingData>
void move(TrackingData& td);
void move(TrackingData& td, const scalar trackTime);
//- Remap the cells of particles corresponding to the
// mesh topology change

View File

@ -979,7 +979,10 @@ void Foam::InteractionLists<ParticleType>::fillReferredParticleCloud()
forAllConstIter(typename IDLList<ParticleType>, refCell, iter)
{
cloud_.addParticle(iter().clone().ptr());
cloud_.addParticle
(
static_cast<ParticleType*>(iter().clone().ptr())
);
}
}
}
@ -1076,6 +1079,29 @@ void Foam::InteractionLists<ParticleType>::writeReferredWallFaces() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ParticleType>
Foam::InteractionLists<ParticleType>::InteractionLists(const polyMesh& mesh)
:
mesh_(mesh),
cloud_(mesh_, "NULL_Cloud", IDLList<ParticleType>()),
writeCloud_(false),
cellMapPtr_(),
wallFaceMapPtr_(),
globalTransforms_(mesh_),
maxDistance_(0.0),
dil_(),
dwfil_(),
ril_(),
rilInverse_(),
cellIndexAndTransformToDistribute_(),
wallFaceIndexAndTransformToDistribute_(),
referredWallFaces_(),
UName_("unknown_UName"),
referredWallData_(),
referredParticles_()
{}
template<class ParticleType>
Foam::InteractionLists<ParticleType>::InteractionLists
(
@ -1106,6 +1132,7 @@ Foam::InteractionLists<ParticleType>::InteractionLists
buildInteractionLists();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ParticleType>

View File

@ -216,6 +216,9 @@ public:
// Constructors
//- Construct null from mesh
InteractionLists(const polyMesh& mesh);
//- Construct and call function to create all information from
// the mesh
InteractionLists

View File

@ -198,6 +198,25 @@ Foam::Particle<ParticleType>::Particle(const Particle<ParticleType>& p)
{}
template<class ParticleType>
Foam::Particle<ParticleType>::Particle
(
const Particle<ParticleType>& p,
const Cloud<ParticleType>& c
)
:
cloud_(c),
position_(p.position_),
cellI_(p.cellI_),
faceI_(p.faceI_),
stepFraction_(p.stepFraction_),
tetFaceI_(p.tetFaceI_),
tetPtI_(p.tetPtI_),
origProc_(p.origProc_),
origId_(p.origId_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ParticleType>
@ -480,6 +499,9 @@ Foam::scalar Foam::Particle<ParticleType>::trackToFace
} while (faceI_ < 0);
ParticleType& p = static_cast<ParticleType&>(*this);
p.hitFace(td);
if (cloud_.internalFace(faceI_))
{
// Change tet ownership because a tri face has been crossed,
@ -508,8 +530,6 @@ Foam::scalar Foam::Particle<ParticleType>::trackToFace
}
else
{
ParticleType& p = static_cast<ParticleType&>(*this);
label origFaceI = faceI_;
label patchI = patch(faceI_);
@ -622,9 +642,7 @@ Foam::scalar Foam::Particle<ParticleType>::trackToFace
vector nHat = wallTri.normal();
nHat /= mag(nHat);
const ParticleType& p = static_cast<const ParticleType&>(*this);
scalar r = p.wallImpactDistance(nHat);
const scalar r = p.wallImpactDistance(nHat);
// Removing (approximately) the wallTri normal
// component of the existing correction, to avoid the
@ -675,6 +693,12 @@ void Foam::Particle<ParticleType>::transformProperties(const vector&)
{}
template<class ParticleType>
template<class TrackData>
void Foam::Particle<ParticleType>::hitFace(TrackData&)
{}
template<class ParticleType>
template<class TrackData>
bool Foam::Particle<ParticleType>::hitPatch

View File

@ -219,6 +219,10 @@ protected:
// Patch interactions
//- Overridable function to handle the particle hitting a face
template<class TrackData>
void hitFace(TrackData& td);
//- Overridable function to handle the particle hitting a
// patch. Executed before other patch-hitting functions.
// trackFraction is passed in to allow mesh motion to
@ -361,10 +365,28 @@ public:
//- Construct as a copy
Particle(const Particle& p);
//- Construct as a copy
Particle(const Particle& p, const Cloud<ParticleType>& c);
//- Construct a clone
autoPtr<ParticleType> clone() const
virtual autoPtr<Particle<ParticleType> > clone() const
{
return autoPtr<Particle>(new Particle(*this));
return autoPtr<Particle<ParticleType> >
(
new Particle<ParticleType>(*this)
);
}
//- Construct a clone
virtual autoPtr<Particle<ParticleType> > clone
(
const Cloud<ParticleType>& c
) const
{
return autoPtr<Particle<ParticleType> >
(
new Particle<ParticleType>(*this, c)
);
}

View File

@ -108,9 +108,12 @@ public:
{}
//- Construct and return a clone
autoPtr<indexedParticle> clone() const
virtual autoPtr<Particle<indexedParticle> > clone() const
{
return autoPtr<indexedParticle>(new indexedParticle(*this));
return autoPtr<Particle<indexedParticle> >
(
new indexedParticle(*this)
);
}

View File

@ -99,9 +99,12 @@ public:
{}
//- Construct and return a clone
autoPtr<passiveParticle> clone() const
virtual autoPtr<Particle<passiveParticle> > clone() const
{
return autoPtr<passiveParticle>(new passiveParticle(*this));
return autoPtr<Particle<passiveParticle> >
(
new passiveParticle(*this)
);
}
};

View File

@ -111,6 +111,16 @@ Foam::coalParcel::coalParcel(const coalParcel& p)
}
Foam::coalParcel::coalParcel
(
const coalParcel& p,
const ReactingMultiphaseCloud<coalParcel>& c
)
:
ReactingMultiphaseParcel<coalParcel>(p, c)
{}
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * //
Foam::coalParcel::~coalParcel()

View File

@ -103,10 +103,33 @@ public:
//- Construct as a copy
coalParcel(const coalParcel& p);
//- Construct and return a clone
autoPtr<coalParcel> clone() const
//- Construct as a copy
coalParcel
(
const coalParcel& p,
const ReactingMultiphaseCloud<coalParcel>& c
);
//- Construct and return a (basic particle) clone
virtual autoPtr<Particle<coalParcel> > clone() const
{
return autoPtr<coalParcel>(new coalParcel(*this));
return autoPtr<Particle<coalParcel> >(new coalParcel(*this));
}
//- Construct and return a (basic particle) clone
virtual autoPtr<Particle<coalParcel> > clone
(
const Cloud<coalParcel>& c
) const
{
return autoPtr<Particle<coalParcel> >
(
new coalParcel
(
*this,
static_cast<const ReactingMultiphaseCloud<coalParcel>&>(c)
)
);
}

View File

@ -26,6 +26,8 @@ License
#include "COxidationDiffusionLimitedRate.H"
#include "mathematicalConstants.H"
using namespace Foam::constant;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
@ -36,8 +38,8 @@ Foam::COxidationDiffusionLimitedRate<CloudType>::COxidationDiffusionLimitedRate
)
:
SurfaceReactionModel<CloudType>(dict, owner, typeName),
Sb_(dimensionedScalar(this->coeffDict().lookup("Sb")).value()),
D_(dimensionedScalar(this->coeffDict().lookup("D")).value()),
Sb_(readScalar(this->coeffDict().lookup("Sb"))),
D_(readScalar(this->coeffDict().lookup("D"))),
CsLocalId_(-1),
O2GlobalId_(owner.composition().globalCarrierId("O2")),
CO2GlobalId_(owner.composition().globalCarrierId("CO2")),
@ -67,9 +69,31 @@ Foam::COxidationDiffusionLimitedRate<CloudType>::COxidationDiffusionLimitedRate
) << "Stoichiometry of reaction, Sb, must be greater than zero" << nl
<< exit(FatalError);
}
const scalar YCloc = owner.composition().Y0(idSolid)[CsLocalId_];
const scalar YSolidTot = owner.composition().YMixture0()[idSolid];
Info<< " C(s): particle mass fraction = " << YCloc*YSolidTot << endl;
}
template<class CloudType>
Foam::COxidationDiffusionLimitedRate<CloudType>::COxidationDiffusionLimitedRate
(
const COxidationDiffusionLimitedRate<CloudType>& srm
)
:
SurfaceReactionModel<CloudType>(srm),
Sb_(srm.Sb_),
D_(srm.D_),
CsLocalId_(srm.CsLocalId_),
O2GlobalId_(srm.O2GlobalId_),
CO2GlobalId_(srm.CO2GlobalId_),
WC_(srm.WC_),
WO2_(srm.WO2_),
HcCO2_(srm.HcCO2_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
@ -80,13 +104,6 @@ Foam::COxidationDiffusionLimitedRate<CloudType>::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
bool Foam::COxidationDiffusionLimitedRate<CloudType>::active() const
{
return true;
}
template<class CloudType>
Foam::scalar Foam::COxidationDiffusionLimitedRate<CloudType>::calculate
(
@ -119,12 +136,13 @@ Foam::scalar Foam::COxidationDiffusionLimitedRate<CloudType>::calculate
return 0.0;
}
const SLGThermo& thermo = this->owner().thermo();
// Local mass fraction of O2 in the carrier phase
const scalar YO2 = this->owner().thermo().carrier().Y(O2GlobalId_)[cellI];
const scalar YO2 = thermo.carrier().Y(O2GlobalId_)[cellI];
// Change in C mass [kg]
scalar dmC =
4.0*constant::mathematical::pi*d*D_*YO2*Tc*rhoc/(Sb_*(T + Tc))*dt;
scalar dmC = 4.0*mathematical::pi*d*D_*YO2*Tc*rhoc/(Sb_*(T + Tc))*dt;
// Limit mass transfer by availability of C
dmC = min(mass*fComb, dmC);
@ -142,8 +160,12 @@ Foam::scalar Foam::COxidationDiffusionLimitedRate<CloudType>::calculate
dMassSRCarrier[O2GlobalId_] -= dmO2;
dMassSRCarrier[CO2GlobalId_] += dmCO2;
const scalar HC = thermo.solids().properties()[CsLocalId_].H(T);
const scalar HCO2 = thermo.carrier().H(CO2GlobalId_, T);
const scalar HO2 = thermo.carrier().H(O2GlobalId_, T);
// Heat of reaction [J]
return -HcCO2_*dmCO2;
return dmC*HC + dmO2*HO2 - dmCO2*HCO2;
}

View File

@ -105,6 +105,21 @@ public:
CloudType& owner
);
//- Construct copy
COxidationDiffusionLimitedRate
(
const COxidationDiffusionLimitedRate<CloudType>& srm
);
//- Construct and return a clone
virtual autoPtr<SurfaceReactionModel<CloudType> > clone() const
{
return autoPtr<SurfaceReactionModel<CloudType> >
(
new COxidationDiffusionLimitedRate<CloudType>(*this)
);
}
//- Destructor
virtual ~COxidationDiffusionLimitedRate();
@ -112,9 +127,6 @@ public:
// Member Functions
//- Flag to indicate whether model activates surface reaction model
virtual bool active() const;
//- Update surface reactions
virtual scalar calculate
(

View File

@ -42,10 +42,9 @@ COxidationKineticDiffusionLimitedRate
owner,
typeName
),
Sb_(dimensionedScalar(this->coeffDict().lookup("Sb")).value()),
C1_(dimensionedScalar(this->coeffDict().lookup("C1")).value()),
C2_(dimensionedScalar(this->coeffDict().lookup("C2")).value()),
E_(dimensionedScalar(this->coeffDict().lookup("E")).value()),
C1_(readScalar(this->coeffDict().lookup("C1"))),
C2_(readScalar(this->coeffDict().lookup("C2"))),
E_(readScalar(this->coeffDict().lookup("E"))),
CsLocalId_(-1),
O2GlobalId_(owner.composition().globalCarrierId("O2")),
CO2GlobalId_(owner.composition().globalCarrierId("CO2")),
@ -63,21 +62,31 @@ COxidationKineticDiffusionLimitedRate
WC_ = WCO2 - WO2_;
HcCO2_ = owner.thermo().carrier().Hc(CO2GlobalId_);
if (Sb_ < 0)
{
FatalErrorIn
(
"COxidationKineticDiffusionLimitedRate"
"("
"const dictionary&, "
"CloudType&"
")"
) << "Stoichiometry of reaction, Sb, must be greater than zero" << nl
<< exit(FatalError);
}
const scalar YCloc = owner.composition().Y0(idSolid)[CsLocalId_];
const scalar YSolidTot = owner.composition().YMixture0()[idSolid];
Info<< " C(s): particle mass fraction = " << YCloc*YSolidTot << endl;
}
template<class CloudType>
Foam::COxidationKineticDiffusionLimitedRate<CloudType>::
COxidationKineticDiffusionLimitedRate
(
const COxidationKineticDiffusionLimitedRate<CloudType>& srm
)
:
SurfaceReactionModel<CloudType>(srm),
C1_(srm.C1_),
C2_(srm.C2_),
E_(srm.E_),
CsLocalId_(srm.CsLocalId_),
O2GlobalId_(srm.O2GlobalId_),
CO2GlobalId_(srm.CO2GlobalId_),
WC_(srm.WC_),
WO2_(srm.WO2_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
@ -88,13 +97,6 @@ Foam::COxidationKineticDiffusionLimitedRate<CloudType>::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
bool Foam::COxidationKineticDiffusionLimitedRate<CloudType>::active() const
{
return true;
}
template<class CloudType>
Foam::scalar Foam::COxidationKineticDiffusionLimitedRate<CloudType>::calculate
(
@ -127,8 +129,10 @@ Foam::scalar Foam::COxidationKineticDiffusionLimitedRate<CloudType>::calculate
return 0.0;
}
const SLGThermo& thermo = this->owner().thermo();
// Local mass fraction of O2 in the carrier phase
const scalar YO2 = this->owner().thermo().carrier().Y(O2GlobalId_)[cellI];
const scalar YO2 = thermo.carrier().Y(O2GlobalId_)[cellI];
// Diffusion rate coefficient
const scalar D0 = C1_/d*pow(0.5*(T + Tc), 0.75);
@ -145,21 +149,28 @@ Foam::scalar Foam::COxidationKineticDiffusionLimitedRate<CloudType>::calculate
// Limit mass transfer by availability of C
dmC = min(mass*fComb, dmC);
// Molar consumption
const scalar dOmega = dmC/WC_;
// Change in O2 mass [kg]
const scalar dmO2 = dmC/WC_*Sb_*WO2_;
const scalar dmO2 = dOmega*WO2_;
// Mass of newly created CO2 [kg]
const scalar dmCO2 = dmC + dmO2;
const scalar dmCO2 = dOmega*(WC_ + WO2_);
// Update local particle C mass
dMassSolid[CsLocalId_] += dmC;
dMassSolid[CsLocalId_] += dOmega*WC_;
// Update carrier O2 and CO2 mass
dMassSRCarrier[O2GlobalId_] -= dmO2;
dMassSRCarrier[CO2GlobalId_] += dmCO2;
const scalar HC = thermo.solids().properties()[CsLocalId_].H(T);
const scalar HCO2 = thermo.carrier().H(CO2GlobalId_, T);
const scalar HO2 = thermo.carrier().H(O2GlobalId_, T);
// Heat of reaction [J]
return -HcCO2_*dmCO2;
return dOmega*(WC_*HC + WO2_*HO2 - (WC_ + WO2_)*HCO2);
}

View File

@ -61,9 +61,6 @@ class COxidationKineticDiffusionLimitedRate
// Model constants
//- Stoichiometry of reaction
const scalar Sb_;
//- Mass diffusion limited rate constant, C1
const scalar C1_;
@ -113,6 +110,21 @@ public:
CloudType& owner
);
//- Construct copy
COxidationKineticDiffusionLimitedRate
(
const COxidationKineticDiffusionLimitedRate<CloudType>& srm
);
//- Construct and return a clone
virtual autoPtr<SurfaceReactionModel<CloudType> > clone() const
{
return autoPtr<SurfaceReactionModel<CloudType> >
(
new COxidationKineticDiffusionLimitedRate<CloudType>(*this)
);
}
//- Destructor
virtual ~COxidationKineticDiffusionLimitedRate();
@ -120,9 +132,6 @@ public:
// Member Functions
//- Flag to indicate whether model activates surface reaction model
virtual bool active() const;
//- Update surface reactions
virtual scalar calculate
(

View File

@ -50,14 +50,14 @@ Foam::COxidationMurphyShaddix<CloudType>::COxidationMurphyShaddix
owner,
typeName
),
D0_(dimensionedScalar(this->coeffDict().lookup("D0")).value()),
rho0_(dimensionedScalar(this->coeffDict().lookup("rho0")).value()),
T0_(dimensionedScalar(this->coeffDict().lookup("T0")).value()),
Dn_(dimensionedScalar(this->coeffDict().lookup("Dn")).value()),
A_(dimensionedScalar(this->coeffDict().lookup("A")).value()),
E_(dimensionedScalar(this->coeffDict().lookup("E")).value()),
n_(dimensionedScalar(this->coeffDict().lookup("n")).value()),
WVol_(dimensionedScalar(this->coeffDict().lookup("WVol")).value()),
D0_(readScalar(this->coeffDict().lookup("D0"))),
rho0_(readScalar(this->coeffDict().lookup("rho0"))),
T0_(readScalar(this->coeffDict().lookup("T0"))),
Dn_(readScalar(this->coeffDict().lookup("Dn"))),
A_(readScalar(this->coeffDict().lookup("A"))),
E_(readScalar(this->coeffDict().lookup("E"))),
n_(readScalar(this->coeffDict().lookup("n"))),
WVol_(readScalar(this->coeffDict().lookup("WVol"))),
CsLocalId_(-1),
O2GlobalId_(owner.composition().globalCarrierId("O2")),
CO2GlobalId_(owner.composition().globalCarrierId("CO2")),
@ -72,9 +72,36 @@ Foam::COxidationMurphyShaddix<CloudType>::COxidationMurphyShaddix
WO2_ = owner.thermo().carrier().W(O2GlobalId_);
const scalar WCO2 = owner.thermo().carrier().W(CO2GlobalId_);
WC_ = WCO2 - WO2_;
const scalar YCloc = owner.composition().Y0(idSolid)[CsLocalId_];
const scalar YSolidTot = owner.composition().YMixture0()[idSolid];
Info<< " C(s): particle mass fraction = " << YCloc*YSolidTot << endl;
}
template<class CloudType>
Foam::COxidationMurphyShaddix<CloudType>::COxidationMurphyShaddix
(
const COxidationMurphyShaddix<CloudType>& srm
)
:
SurfaceReactionModel<CloudType>(srm),
D0_(srm.D0_),
rho0_(srm.rho0_),
T0_(srm.T0_),
Dn_(srm.Dn_),
A_(srm.A_),
E_(srm.E_),
n_(srm.n_),
WVol_(srm.WVol_),
CsLocalId_(srm.CsLocalId_),
O2GlobalId_(srm.O2GlobalId_),
CO2GlobalId_(srm.CO2GlobalId_),
WC_(srm.WC_),
WO2_(srm.WO2_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
@ -84,13 +111,6 @@ Foam::COxidationMurphyShaddix<CloudType>::~COxidationMurphyShaddix()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
bool Foam::COxidationMurphyShaddix<CloudType>::active() const
{
return true;
}
template<class CloudType>
Foam::scalar Foam::COxidationMurphyShaddix<CloudType>::calculate
(
@ -123,9 +143,10 @@ Foam::scalar Foam::COxidationMurphyShaddix<CloudType>::calculate
return 0.0;
}
const SLGThermo& thermo = this->owner().thermo();
// Cell carrier phase O2 species density [kg/m^3]
const scalar rhoO2 =
rhoc*this->owner().thermo().carrier().Y(O2GlobalId_)[cellI];
const scalar rhoO2 = rhoc*thermo.carrier().Y(O2GlobalId_)[cellI];
if (rhoO2 < SMALL)
{
@ -204,11 +225,9 @@ Foam::scalar Foam::COxidationMurphyShaddix<CloudType>::calculate
// Add to particle mass transfer
dMassSolid[CsLocalId_] += dOmega*WC_;
const scalar HC =
this->owner().composition().solids().properties()[CsLocalId_].Hf()
+ this->owner().composition().solids().properties()[CsLocalId_].cp()*T;
const scalar HCO2 = this->owner().thermo().carrier().H(CO2GlobalId_, T);
const scalar HO2 = this->owner().thermo().carrier().H(O2GlobalId_, T);
const scalar HC = thermo.solids().properties()[CsLocalId_].H(T);
const scalar HCO2 = thermo.carrier().H(CO2GlobalId_, T);
const scalar HO2 = thermo.carrier().H(O2GlobalId_, T);
// Heat of reaction
return dOmega*(WC_*HC + WO2_*HO2 - (WC_ + WO2_)*HCO2);

View File

@ -131,6 +131,21 @@ public:
CloudType& owner
);
//- Construct copy
COxidationMurphyShaddix
(
const COxidationMurphyShaddix<CloudType>& srm
);
//- Construct and return a clone
virtual autoPtr<SurfaceReactionModel<CloudType> > clone() const
{
return autoPtr<SurfaceReactionModel<CloudType> >
(
new COxidationMurphyShaddix<CloudType>(*this)
);
}
//- Destructor
virtual ~COxidationMurphyShaddix();
@ -138,9 +153,6 @@ public:
// Member Functions
//- Flag to indicate whether model activates surface reaction model
virtual bool active() const;
//- Update surface reactions
virtual scalar calculate
(

View File

@ -25,7 +25,6 @@ License
#include "commonRailInjector.H"
#include "addToRunTimeSelectionTable.H"
#include "Random.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -175,13 +174,13 @@ Foam::commonRailInjector::~commonRailInjector()
void Foam::commonRailInjector::setTangentialVectors()
{
Random rndGen(label(0));
cachedRandom rndGen(label(0), -1);
scalar magV = 0.0;
vector tangent;
while (magV < SMALL)
{
vector testThis = rndGen.vector01();
vector testThis = rndGen.sample01<vector>();
tangent = testThis - (testThis & direction_)*direction_;
magV = mag(tangent);
@ -223,7 +222,7 @@ Foam::vector Foam::commonRailInjector::position
const vector& axisOfSymmetry,
const vector& axisOfWedge,
const vector& axisOfWedgeNormal,
Random& rndGen
cachedRandom& rndGen
) const
{
if (twoD)
@ -241,8 +240,8 @@ Foam::vector Foam::commonRailInjector::position
else
{
// otherwise, disc injection
scalar iRadius = d_*rndGen.scalar01();
scalar iAngle = constant::mathematical::twoPi*rndGen.scalar01();
scalar iRadius = d_*rndGen.sample01<scalar>();
scalar iAngle = constant::mathematical::twoPi*rndGen.sample01<scalar>();
return
(

View File

@ -138,7 +138,7 @@ public:
const vector& axisOfSymmetry,
const vector& axisOfWedge,
const vector& axisOfWedgeNormal,
Random& rndGen
cachedRandom& rndGen
) const;
//- Return the number of holes

View File

@ -25,7 +25,6 @@ License
#include "definedInjector.H"
#include "addToRunTimeSelectionTable.H"
#include "Random.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -158,13 +157,13 @@ Foam::definedInjector::~definedInjector()
void Foam::definedInjector::setTangentialVectors()
{
Random rndGen(label(0));
cachedRandom rndGen(label(0), -1);
scalar magV = 0.0;
vector tangent;
while (magV < SMALL)
{
vector testThis = rndGen.vector01();
vector testThis = rndGen.sample01<vector>();
tangent = testThis - (testThis & direction_)*direction_;
magV = mag(tangent);
@ -204,7 +203,7 @@ Foam::vector Foam::definedInjector::position
const vector& axisOfSymmetry,
const vector& axisOfWedge,
const vector& axisOfWedgeNormal,
Random& rndGen
cachedRandom& rndGen
) const
{
if (twoD)
@ -222,8 +221,8 @@ Foam::vector Foam::definedInjector::position
else
{
// otherwise, disc injection
scalar iRadius = d_*rndGen.scalar01();
scalar iAngle = constant::mathematical::twoPi*rndGen.scalar01();
scalar iRadius = d_*rndGen.sample01<scalar>();
scalar iAngle = constant::mathematical::twoPi*rndGen.sample01<scalar>();
return
(

View File

@ -139,7 +139,7 @@ public:
const vector& axisOfSymmetry,
const vector& axisOfWedge,
const vector& axisOfWedgeNormal,
Random& rndGen
cachedRandom& rndGen
) const;
//- Return the number of holes

View File

@ -43,7 +43,7 @@ SourceFiles
#include "runTimeSelectionTables.H"
#include "vector.H"
#include "scalarField.H"
#include "Random.H"
#include "cachedRandom.H"
#include "liquidMixture.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -120,7 +120,7 @@ public:
const vector& axisOfSymmetry,
const vector& axisOfWedge,
const vector& axisOfWedgeNormal,
Random& rndGen
cachedRandom& rndGen
) const = 0;
//- Return the number of holes

View File

@ -25,7 +25,6 @@ License
#include "multiHoleInjector.H"
#include "addToRunTimeSelectionTable.H"
#include "Random.H"
#include "unitConversion.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -194,7 +193,7 @@ void Foam::multiHoleInjector::setTangentialVectors()
position_[i] = centerPosition_ + 0.5*nozzleTipDiameter_*dp;
}
Random rndGen(label(0));
cachedRandom rndGen(label(0), -1);
for (label i=0; i<nHoles_; i++)
{
@ -202,7 +201,7 @@ void Foam::multiHoleInjector::setTangentialVectors()
scalar magV = 0;
while (magV < SMALL)
{
vector testThis = rndGen.vector01();
vector testThis = rndGen.sample01<vector>();
tangent = testThis - (testThis & direction_[i])*direction_[i];
magV = mag(tangent);
@ -244,7 +243,7 @@ Foam::vector Foam::multiHoleInjector::position
const vector& axisOfSymmetry,
const vector& axisOfWedge,
const vector& axisOfWedgeNormal,
Random& rndGen
cachedRandom& rndGen
) const
{
if (twoD)
@ -262,8 +261,8 @@ Foam::vector Foam::multiHoleInjector::position
else
{
// otherwise, disc injection
scalar iRadius = d_*rndGen.scalar01();
scalar iAngle = constant::mathematical::twoPi*rndGen.scalar01();
scalar iRadius = d_*rndGen.sample01<scalar>();
scalar iAngle = constant::mathematical::twoPi*rndGen.sample01<scalar>();
return
(

View File

@ -148,7 +148,7 @@ public:
const vector& axisOfSymmetry,
const vector& axisOfWedge,
const vector& axisOfWedgeNormal,
Random& rndGen
cachedRandom& rndGen
) const;
//- Return the number of holes

View File

@ -25,7 +25,6 @@ License
#include "swirlInjector.H"
#include "addToRunTimeSelectionTable.H"
#include "Random.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -179,13 +178,13 @@ Foam::swirlInjector::~swirlInjector()
void Foam::swirlInjector::setTangentialVectors()
{
Random rndGen(label(0));
cachedRandom rndGen(label(0), -1);
scalar magV = 0.0;
vector tangent;
while (magV < SMALL)
{
vector testThis = rndGen.vector01();
vector testThis = rndGen.sample01<vector>();
tangent = testThis - (testThis & direction_)*direction_;
magV = mag(tangent);
@ -226,7 +225,7 @@ Foam::vector Foam::swirlInjector::position
const vector& axisOfSymmetry,
const vector& axisOfWedge,
const vector& axisOfWedgeNormal,
Random& rndGen
cachedRandom& rndGen
) const
{
if (twoD)
@ -244,8 +243,8 @@ Foam::vector Foam::swirlInjector::position
else
{
// otherwise, disc injection
scalar iRadius = d_*rndGen.scalar01();
scalar iAngle = constant::mathematical::twoPi*rndGen.scalar01();
scalar iRadius = d_*rndGen.sample01<scalar>();
scalar iAngle = constant::mathematical::twoPi*rndGen.sample01<scalar>();
return
(

View File

@ -157,7 +157,7 @@ public:
const vector& axisOfSymmetry,
const vector& axisOfWedge,
const vector& axisOfWedgeNormal,
Random& rndGen
cachedRandom& rndGen
) const;
//- Return the number of holes

View File

@ -25,7 +25,6 @@ License
#include "unitInjector.H"
#include "addToRunTimeSelectionTable.H"
#include "Random.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -154,13 +153,13 @@ Foam::unitInjector::~unitInjector()
void Foam::unitInjector::setTangentialVectors()
{
Random rndGen(label(0));
cachedRandom rndGen(label(0), -1);
scalar magV = 0.0;
vector tangent;
while (magV < SMALL)
{
vector testThis = rndGen.vector01();
vector testThis = rndGen.sample01<vector>();
tangent = testThis - (testThis & direction_)*direction_;
magV = mag(tangent);
@ -199,7 +198,7 @@ Foam::vector Foam::unitInjector::position
const vector& axisOfSymmetry,
const vector& axisOfWedge,
const vector& axisOfWedgeNormal,
Random& rndGen
cachedRandom& rndGen
) const
{
if (twoD)
@ -217,8 +216,8 @@ Foam::vector Foam::unitInjector::position
else
{
// otherwise, disc injection
scalar iRadius = d_*rndGen.scalar01();
scalar iAngle = constant::mathematical::twoPi*rndGen.scalar01();
scalar iRadius = d_*rndGen.sample01<scalar>();
scalar iAngle = constant::mathematical::twoPi*rndGen.sample01<scalar>();
return
(

View File

@ -137,7 +137,7 @@ public:
const vector& axisOfSymmetry,
const vector& axisOfWedge,
const vector& axisOfWedgeNormal,
Random& rndGen
cachedRandom& rndGen
) const;
//- Return the number of holes

View File

@ -94,14 +94,13 @@ Foam::parcel::parcel
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::parcel::move(spray& sDB)
bool Foam::parcel::move(spray& sDB, const scalar trackTime)
{
const polyMesh& mesh = cloud().pMesh();
const polyBoundaryMesh& pbMesh = mesh.boundaryMesh();
const liquidMixture& fuels = sDB.fuels();
scalar deltaT = sDB.runTime().deltaTValue();
label Nf = fuels.components().size();
label Ns = sDB.composition().Y().size();
@ -156,12 +155,12 @@ bool Foam::parcel::move(spray& sDB)
pg,
Yfg,
m()*fuels.Y(X()),
deltaT
trackTime
);
// set the end-time for the track
scalar tEnd = (1.0 - stepFraction())*deltaT;
scalar tEnd = (1.0 - stepFraction())*trackTime;
// set the maximum time step for this parcel
scalar dtMax = min
@ -215,7 +214,7 @@ bool Foam::parcel::move(spray& sDB)
tEnd -= dt;
// Set the current time-step fraction.
stepFraction() = 1.0 - tEnd/deltaT;
stepFraction() = 1.0 - tEnd/trackTime;
if (onBoundary()) // hit face
{
@ -521,7 +520,7 @@ void Foam::parcel::updateParcelProperties
scalar Taverage = TDroplet + (Tg - TDroplet)/3.0;
// for a liquid Cl \approx Cp
scalar liquidcL = sDB.fuels().cp(pg, TDroplet, X());
scalar liquidcL = sDB.fuels().Cp(pg, TDroplet, X());
cpMix = 0.0;
for (label i=0; i<Ns; i++)

View File

@ -349,7 +349,7 @@ public:
// Parcel operations
bool move(spray& sprayData);
bool move(spray& sprayData, const scalar trackTime);
//- Transform the position and physical properties of the particle
// according to the given transformation tensor

View File

@ -65,7 +65,7 @@ void Foam::parcel::setRelaxationTimes
// calculate mixture properties
scalar W = 0.0;
scalar kMixture = 0.0;
scalar cpMixture = 0.0;
scalar CpMixture = 0.0;
scalar muf = 0.0;
for (label i=0; i<Ns; i++)
@ -74,7 +74,7 @@ void Foam::parcel::setRelaxationTimes
W += Y/sDB.gasProperties()[i].W();
// Using mass-fractions to average...
kMixture += Y*sDB.gasProperties()[i].kappa(Tf);
cpMixture += Y*sDB.gasProperties()[i].Cp(Tf);
CpMixture += Y*sDB.gasProperties()[i].Cp(Tf);
muf += Y*sDB.gasProperties()[i].mu(Tf);
}
W = 1.0/W;
@ -98,7 +98,7 @@ void Foam::parcel::setRelaxationTimes
scalar nuf = muf/rho;
scalar liquidDensity = fuels.rho(pressure, T(), X());
scalar liquidcL = fuels.cp(pressure, T(), X());
scalar liquidcL = fuels.Cp(pressure, T(), X());
scalar heatOfVapour = fuels.hl(pressure, T(), X());
// calculate the partial rho of the fuel vapour
@ -130,7 +130,7 @@ void Foam::parcel::setRelaxationTimes
}
scalar Reynolds = Re(Up, nuf);
scalar Prandtl = Pr(cpMixture, muf, kMixture);
scalar Prandtl = Pr(CpMixture, muf, kMixture);
// calculate the characteritic times
@ -280,7 +280,7 @@ void Foam::parcel::setRelaxationTimes
tauBoiling[i] = sDB.evaporation().boilingTime
(
fuels.properties()[i].rho(pressure, Td),
fuels.properties()[i].cp(pressure, Td),
fuels.properties()[i].Cp(pressure, Td),
heatOfVapour,
kMixture,
Nusselt,
@ -292,7 +292,7 @@ void Foam::parcel::setRelaxationTimes
tBoilingSurface,
vapourSurfaceEnthalpy,
vapourFarEnthalpy,
cpMixture,
CpMixture,
temperature,
kLiquid
);

View File

@ -68,7 +68,7 @@ Foam::spray::spray
runTime_(U.time()),
time0_(runTime_.value()),
mesh_(U.mesh()),
rndGen_(label(0)),
rndGen_(label(0), -1),
g_(g.value()),
U_(U),

View File

@ -39,7 +39,7 @@ Description
#include "liquid.H"
#include "autoPtr.H"
#include "liquidMixture.H"
#include "Random.H"
#include "cachedRandom.H"
#include "thermoPhysicsTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -76,7 +76,7 @@ class spray
const fvMesh& mesh_;
//- Random number generator
Random rndGen_;
cachedRandom rndGen_;
//- Acceleration due to gravity
const vector& g_;
@ -250,7 +250,7 @@ public:
inline tmp<volScalarField> evaporationSource(const label i) const;
inline tmp<volScalarField> heatTransferSource() const;
inline Random& rndGen();
inline cachedRandom& rndGen();
inline label subCycles() const;
inline const vector& g() const;

View File

@ -221,7 +221,7 @@ inline tmp<volScalarField> spray::heatTransferSource() const
}
inline Random& spray::rndGen()
inline cachedRandom& spray::rndGen()
{
return rndGen_;
}

View File

@ -159,7 +159,8 @@ void Foam::spray::inject()
(runTime_.deltaTValue() - dt)
/runTime_.deltaTValue();
bool keepParcel = pPtr->move(*this);
bool keepParcel =
pPtr->move(*this, runTime_.deltaTValue());
if (keepParcel)
{

View File

@ -76,7 +76,7 @@ void Foam::spray::move()
srhos_[i] = 0.0;
}
Cloud<parcel>::move(*this);
Cloud<parcel>::move(*this, runTime_.deltaTValue());
}

View File

@ -54,7 +54,6 @@ Foam::LISA::LISA
:
atomizationModel(dict, sm),
coeffsDict_(dict.subDict(typeName + "Coeffs")),
rndGen_(sm.rndGen()),
Cl_(readScalar(coeffsDict_.lookup("Cl"))),
cTau_(readScalar(coeffsDict_.lookup("cTau"))),
Q_(readScalar(coeffsDict_.lookup("Q"))),
@ -361,8 +360,8 @@ void Foam::LISA::atomizeParcel
do
{
x = minValue + range*rndGen_.scalar01();
y = rndGen_.scalar01();
x = minValue + range*rndGen_.sample01<scalar>();
y = rndGen_.sample01<scalar>();
scalar xx = pow(x/dD, nExp);

View File

@ -68,7 +68,6 @@ private:
// Private data
dictionary coeffsDict_;
Random& rndGen_;
scalar Cl_;
scalar cTau_;
scalar Q_;

View File

@ -55,7 +55,7 @@ protected:
const dictionary& dict_;
spray& spray_;
Random& rndGen_;
cachedRandom& rndGen_;
public:

View File

@ -56,8 +56,7 @@ Foam::blobsSheetAtomization::blobsSheetAtomization
atomizationModel(dict, sm),
coeffsDict_(dict.subDict(typeName + "Coeffs")),
B_(readScalar(coeffsDict_.lookup("B"))),
angle_(readScalar(coeffsDict_.lookup("angle"))),
rndGen_(sm.rndGen())
angle_(readScalar(coeffsDict_.lookup("angle")))
{}

View File

@ -67,7 +67,6 @@ private:
dictionary coeffsDict_;
scalar B_;
scalar angle_;
Random& rndGen_;
public:

View File

@ -53,7 +53,6 @@ Foam::SHF::SHF
breakupModel(dict, sm),
coeffsDict_(dict.subDict(typeName + "Coeffs")),
g_(sm.g()),
rndGen_(sm.rndGen()),
weCorrCoeff_(readScalar(coeffsDict_.lookup("weCorrCoeff"))),
weBuCrit_(readScalar(coeffsDict_.lookup("weBuCrit"))),
weBuBag_(readScalar(coeffsDict_.lookup("weBuBag"))),
@ -186,9 +185,9 @@ void Foam::SHF::breakupParcel
do
{
x = cDmaxBM_*rndGen_.scalar01();
x = cDmaxBM_*rndGen_.sample01<scalar>();
d = sqr(x)*d05;
y = rndGen_.scalar01();
y = rndGen_.sample01<scalar>();
px =
x
@ -217,9 +216,9 @@ void Foam::SHF::breakupParcel
do
{
x = cDmaxS_*rndGen_.scalar01();
x = cDmaxS_*rndGen_.sample01<scalar>();
d = sqr(x)*d05;
y = rndGen_.scalar01();
y = rndGen_.sample01<scalar>();
px =
x

View File

@ -66,8 +66,6 @@ private:
// reference to gravity
const vector& g_;
Random& rndGen_;
// model constants
scalar weCorrCoeff_;

View File

@ -175,7 +175,7 @@ void Foam::TAB::breakupParcel
label n = 0;
bool found = false;
scalar random = rndGen_.scalar01();
scalar random = rndGen_.sample01<scalar>();
while (!found && (n<99))
{
if (rrd_[n] > random)

View File

@ -56,7 +56,7 @@ protected:
const dictionary& dict_;
spray& spray_;
Random& rndGen_;
cachedRandom& rndGen_;
Switch includeOscillation_;

View File

@ -48,7 +48,7 @@ Foam::ORourkeCollisionModel::ORourkeCollisionModel
(
const dictionary& dict,
spray& sm,
Random& rndGen
cachedRandom& rndGen
)
:
collisionModel(dict, sm, rndGen),

View File

@ -75,7 +75,7 @@ public:
(
const dictionary& dict,
spray& sm,
Random& rndGen
cachedRandom& rndGen
);

View File

@ -35,7 +35,7 @@ scalar mdMin = mMin/nMin;
scalar nu0 = 0.25*constant::mathematical::pi*sqr(sumD)*magVRel*dt/vols_[cell1];
scalar nu = nMin*nu0;
scalar collProb = exp(-nu);
scalar xx = rndGen_.scalar01();
scalar xx = rndGen_.sample01<scalar>();
if ((xx > collProb) && (mMin > VSMALL) && (mMax > VSMALL))
{
@ -62,7 +62,7 @@ if ((xx > collProb) && (mMin > VSMALL) && (mMax > VSMALL))
scalar WeColl = max(1.0e-12, 0.5*rho*magVRel*magVRel*dMin/sigma);
scalar coalesceProb = min(1.0, 2.4*f/WeColl);
scalar prob = rndGen_.scalar01();
scalar prob = rndGen_.sample01<scalar>();
// Coalescence
if (prob < coalesceProb && coalescence_)

View File

@ -41,7 +41,7 @@ Foam::collisionModel::collisionModel
(
const dictionary& dict,
spray& sm,
Random& rndGen
cachedRandom& rndGen
)
:
dict_(dict),

View File

@ -34,7 +34,7 @@ Description
#include "IOdictionary.H"
#include "spray.H"
#include "Random.H"
#include "cachedRandom.H"
#include "Switch.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
@ -56,7 +56,7 @@ protected:
// Protected data
const dictionary& dict_;
spray& spray_;
Random& rndGen_;
cachedRandom& rndGen_;
//dictionary coeffsDict_;
@ -76,7 +76,7 @@ public:
(
const dictionary& dict,
spray& sm,
Random& rndGen
cachedRandom& rndGen
),
(dict, sm, rndGen)
);
@ -89,7 +89,7 @@ public:
(
const dictionary& dict,
spray& sm,
Random& rndGen
cachedRandom& rndGen
);
@ -103,7 +103,7 @@ public:
(
const dictionary& dict,
spray& sm,
Random& rndGen
cachedRandom& rndGen
);

View File

@ -37,7 +37,7 @@ Foam::autoPtr<Foam::collisionModel> Foam::collisionModel::New
(
const dictionary& dict,
spray& sm,
Random& rndGen
cachedRandom& rndGen
)
{
const word modelType(dict.lookup("collisionModel"));

View File

@ -49,7 +49,7 @@ Foam::noCollision::noCollision
(
const dictionary& dict,
spray& sm,
Random& rndGen
cachedRandom& rndGen
)
:
collisionModel(dict, sm, rndGen)

View File

@ -62,7 +62,7 @@ public:
(
const dictionary& dict,
spray& sm,
Random& rndGen
cachedRandom& rndGen
);
//- Destructor

View File

@ -51,7 +51,7 @@ if (vAlign > 0)
pow(0.5*sumD/max(0.5*sumD, closestDist), cSpace_)
*exp(-cTime_*mag(alpha-beta));
scalar xx = rndGen_.scalar01();
scalar xx = rndGen_.sample01<scalar>();
spray::iterator pMin = p1;
spray::iterator pMax = p2;
@ -106,7 +106,7 @@ if (vAlign > 0)
scalar coalesceProb = min(1.0, 2.4*f/WeColl);
scalar prob = rndGen_.scalar01();
scalar prob = rndGen_.sample01<scalar>();
// Coalescence
if ( prob < coalesceProb && coalescence_)

View File

@ -48,7 +48,7 @@ Foam::trajectoryCollisionModel::trajectoryCollisionModel
(
const dictionary& dict,
spray& sm,
Random& rndGen
cachedRandom& rndGen
)
:
collisionModel(dict, sm, rndGen),

View File

@ -78,7 +78,7 @@ public:
(
const dictionary& dict,
spray& sm,
Random& rndGen
cachedRandom& rndGen
);

View File

@ -102,8 +102,8 @@ void Foam::gradientDispersionRAS::disperseParcels() const
scalar rsq = 10.0;
while ((rsq > 1.0) || (rsq == 0.0))
{
x1 = 2.0*spray_.rndGen().scalar01() - 1.0;
x2 = 2.0*spray_.rndGen().scalar01() - 1.0;
x1 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
x2 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
rsq = x1*x1 + x2*x2;
}

View File

@ -96,7 +96,7 @@ void Foam::stochasticDispersionRAS::disperseParcels() const
elmnt().tTurb() = 0.0;
scalar sigma = sqrt(2.0*k[cellI]/3.0);
vector dir = 2.0*spray_.rndGen().vector01() - one;
vector dir = 2.0*spray_.rndGen().sample01<vector>() - one;
dir /= mag(dir) + SMALL;
// numerical recipes... Ch. 7. Random Numbers...
@ -104,8 +104,8 @@ void Foam::stochasticDispersionRAS::disperseParcels() const
scalar rsq = 10.0;
while (rsq > 1.0 || rsq == 0.0)
{
x1 = 2.0*spray_.rndGen().scalar01() - 1.0;
x2 = 2.0*spray_.rndGen().scalar01() - 1.0;
x1 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
x2 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
rsq = x1*x1 + x2*x2;
}

View File

@ -123,7 +123,7 @@ Foam::vector Foam::ChomiakInjector::direction
scalar alpha = sin(angle);
scalar dcorr = cos(angle);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01();
scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector
vector normal = vector::zero;

View File

@ -105,7 +105,7 @@ Foam::scalar Foam::blobsSwirlInjector::d0
{
const injectorType& it = injectors_[n].properties();
scalar c = rndGen_.scalar01();
scalar c = rndGen_.sample01<scalar>();
angle_ = degToRad(coneAngle_[n]/2.0 + c*coneInterval_[n]);
@ -139,7 +139,7 @@ Foam::vector Foam::blobsSwirlInjector::direction
{
scalar alpha = sin(angle_);
scalar dcorr = cos(angle_);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01();
scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector
vector normal = vector::zero;

View File

@ -130,11 +130,12 @@ Foam::vector Foam::constInjector::direction
*/
scalar angle =
rndGen_.scalar01()*sprayAngle_[n]*constant::mathematical::pi/360.0;
rndGen_.sample01<scalar>()*sprayAngle_[n]
*constant::mathematical::pi/360.0;
scalar alpha = sin(angle);
scalar dcorr = cos(angle);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01();
scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector
vector normal = vector::zero;

View File

@ -157,11 +157,11 @@ Foam::vector Foam::definedHollowConeInjector::direction
scalar angleOuter = it.getTableValue(outerConeAngle_, t);
// use random number to generate angle between inner/outer cone angles
scalar angle = angleInner + rndGen_.scalar01()*(angleOuter - angleInner);
scalar angle = rndGen_.position<scalar>(angleInner, angleOuter);
scalar alpha = sin(angle*constant::mathematical::pi/360.0);
scalar dcorr = cos(angle*constant::mathematical::pi/360.0);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01();
scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector
vector normal = vector::zero;

View File

@ -90,7 +90,7 @@ Foam::scalar Foam::definedPressureSwirlInjector::d0
{
const injectorType& it = injectors_[n].properties();
scalar c = rndGen_.scalar01();
scalar c = rndGen_.sample01<scalar>();
scalar coneAngle = it.getTableValue(coneAngle_, t);
scalar coneInterval = it.getTableValue(coneInterval_, t);
angle_ = coneAngle ;
@ -212,7 +212,7 @@ Foam::vector Foam::definedPressureSwirlInjector::direction
{
scalar alpha = sin(angle_);
scalar dcorr = cos(angle_);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01();
scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector
vector normal = vector::zero;

View File

@ -124,11 +124,10 @@ Foam::vector Foam::hollowConeInjector::direction
const scalar d
) const
{
scalar angle =
innerAngle_[n] + rndGen_.scalar01()*(outerAngle_[n]-innerAngle_[n]);
scalar angle = rndGen_.position<scalar>(innerAngle_[n], outerAngle_[n]);
scalar alpha = sin(angle*constant::mathematical::pi/360.0);
scalar dcorr = cos(angle*constant::mathematical::pi/360.0);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01();
scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector
vector normal = vector::zero;

View File

@ -62,7 +62,7 @@ protected:
spray& sm_;
const PtrList<injector>& injectors_;
Random& rndGen_;
cachedRandom& rndGen_;
public:

View File

@ -100,7 +100,7 @@ Foam::scalar Foam::pressureSwirlInjector::d0
{
const injectorType& it = injectors_[n].properties();
scalar c = rndGen_.scalar01();
scalar c = rndGen_.sample01<scalar>();
angle_ = coneAngle_[n] + 2.0*coneInterval_[n]*(0.5 - c);
angle_ *= constant::mathematical::pi/360.0;
@ -134,7 +134,7 @@ Foam::vector Foam::pressureSwirlInjector::direction
{
scalar alpha = sin(angle_);
scalar dcorr = cos(angle_);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01();
scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector
vector normal = vector::zero;

View File

@ -984,7 +984,7 @@ void Foam::DsmcCloud<ParcelType>::evolve()
this->inflowBoundary().inflow();
// Move the particles ballistically with their current velocities
Cloud<ParcelType>::move(td);
Cloud<ParcelType>::move(td, mesh_.time().deltaTValue());
// Update cell occupancy
buildCellOccupancy();

View File

@ -32,7 +32,8 @@ template<class ParcelType>
template<class TrackData>
bool Foam::DsmcParcel<ParcelType>::move
(
TrackData& td
TrackData& td,
const scalar trackTime
)
{
ParcelType& p = static_cast<ParcelType&>(*this);
@ -43,8 +44,7 @@ bool Foam::DsmcParcel<ParcelType>::move
const polyMesh& mesh = td.cloud().pMesh();
const polyBoundaryMesh& pbMesh = mesh.boundaryMesh();
const scalar deltaT = mesh.time().deltaTValue();
scalar tEnd = (1.0 - p.stepFraction())*deltaT;
scalar tEnd = (1.0 - p.stepFraction())*trackTime;
const scalar dtMax = tEnd;
// For reduced-D cases, the velocity used to track needs to be
@ -71,7 +71,7 @@ bool Foam::DsmcParcel<ParcelType>::move
tEnd -= dt;
p.stepFraction() = 1.0 - tEnd/deltaT;
p.stepFraction() = 1.0 - tEnd/trackTime;
if (p.onBoundary() && td.keepParticle)
{

View File

@ -200,9 +200,12 @@ public:
);
//- Construct and return a clone
autoPtr<ParcelType> clone() const
virtual autoPtr<Particle<ParcelType> > clone() const
{
return autoPtr<ParcelType>(new DsmcParcel<ParcelType>(*this));
return autoPtr<Particle<ParcelType> >
(
new DsmcParcel<ParcelType>(*this)
);
}
@ -234,7 +237,7 @@ public:
//- Move the parcel
template<class TrackData>
bool move(TrackData& td);
bool move(TrackData& td, const scalar trackTime);
// Patch interactions

View File

@ -81,9 +81,9 @@ public:
);
//- Construct and return a clone
autoPtr<dsmcParcel> clone() const
autoPtr<Particle<dsmcParcel> > clone() const
{
return autoPtr<dsmcParcel>(new dsmcParcel(*this));
return autoPtr<Particle<dsmcParcel> >(new dsmcParcel(*this));
}

View File

@ -39,6 +39,13 @@ Foam::Analytical<Type>::Analytical
{}
template<class Type>
Foam::Analytical<Type>::Analytical(const Analytical& is)
:
IntegrationScheme<Type>(is)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
@ -59,8 +66,12 @@ Foam::Analytical<Type>::integrate
) const
{
typename IntegrationScheme<Type>::integrationResult retValue;
retValue.average() = alpha + (phi - alpha)*(1 - exp(-beta*dt))/(beta*dt);
retValue.value() = alpha + (phi - alpha)*exp(-beta*dt);
const scalar expTerm = exp(min(50, -beta*dt));
retValue.average() =
alpha + (phi - alpha)*(1 - expTerm)/(beta*dt + ROOTVSMALL);
retValue.value() = alpha + (phi - alpha)*expTerm;
return retValue;
}

View File

@ -59,6 +59,18 @@ public:
//- Construct from components
Analytical(const word& phiName, const dictionary& dict);
//- Copy constructor
Analytical(const Analytical& is);
//- Construct and return clone
virtual autoPtr<IntegrationScheme<Type> > clone() const
{
return autoPtr<IntegrationScheme<Type> >
(
new Analytical<Type>(*this)
);
}
//- Destructor
virtual ~Analytical();

View File

@ -39,6 +39,13 @@ Foam::Euler<Type>::Euler
{}
template<class Type>
Foam::Euler<Type>::Euler(const Euler& is)
:
IntegrationScheme<Type>(is)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>

View File

@ -59,6 +59,15 @@ public:
//- Construct from components
Euler(const word& phiName, const dictionary& dict);
//- Copy constructor
Euler(const Euler& is);
//- Construct and return clone
virtual autoPtr<IntegrationScheme<Type> > clone() const
{
return autoPtr<IntegrationScheme<Type> >(new Euler<Type>(*this));
}
//- Destructor
virtual ~Euler();

View File

@ -39,6 +39,14 @@ Foam::IntegrationScheme<Type>::IntegrationScheme
{}
template<class Type>
Foam::IntegrationScheme<Type>::IntegrationScheme(const IntegrationScheme& is)
:
phiName_(is.phiName_),
dict_(is.dict_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
template<class Type>
@ -48,6 +56,38 @@ Foam::IntegrationScheme<Type>::~IntegrationScheme()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
typename Foam::IntegrationScheme<Type>::integrationResult
Foam::IntegrationScheme<Type>::integrate
(
const Type phi,
const scalar dt,
const Type alpha,
const scalar beta
) const
{
notImplemented
(
"Foam::IntegrationScheme<Type>::integrationResult"
"Foam::IntegrationScheme<Type>::integrate"
"("
"const Type, "
"const scalar, "
"const Type, "
"const scalar"
") const"
);
typename IntegrationScheme<Type>::integrationResult retValue;
retValue.average() = pTraits<Type>::zero;
retValue.value() = pTraits<Type>::zero;
return retValue;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "IntegrationSchemeNew.C"
// ************************************************************************* //

View File

@ -121,9 +121,6 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
IntegrationScheme(const IntegrationScheme&);
//- Disallow default bitwise assignment
void operator=(const IntegrationScheme&);
@ -154,6 +151,18 @@ public:
//- Construct from components
IntegrationScheme(const word& phiName, const dictionary& dict);
//- Copy constructor
IntegrationScheme(const IntegrationScheme& is);
//- Construct and return clone
virtual autoPtr<IntegrationScheme<Type> > clone() const
{
return autoPtr<IntegrationScheme<Type> >
(
new IntegrationScheme<Type>(*this)
);
}
// Selectors
@ -178,7 +187,7 @@ public:
const scalar dt,
const Type alpha,
const scalar beta
) const = 0;
) const;
};

View File

@ -28,21 +28,203 @@ License
#include "interpolation.H"
#include "subCycleTime.H"
#include "CollisionModel.H"
#include "DispersionModel.H"
#include "DragModel.H"
#include "InjectionModel.H"
#include "CollisionModel.H"
#include "PatchInteractionModel.H"
#include "PostProcessingModel.H"
#include "SurfaceFilmModel.H"
// * * * * * * * * * * * * * * cloudSolution * * * * * * * * * * * * * * * * //
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::cloudSolution::read()
{
dict_.lookup("transient") >> transient_;
dict_.lookup("coupled") >> coupled_;
dict_.lookup("cellValueSourceCorrection") >> cellValueSourceCorrection_;
if (steadyState())
{
dict_.lookup("calcFrequency") >> calcFrequency_;
dict_.lookup("maxTrackTime") >> maxTrackTime_;
dict_.subDict("sourceTerms").lookup("resetOnStartup")
>> resetSourcesOnStartup_;
}
}
template<class ParcelType>
Foam::KinematicCloud<ParcelType>::cloudSolution::cloudSolution
(
const fvMesh& mesh,
const dictionary& dict
)
:
mesh_(mesh),
dict_(dict),
active_(dict.lookup("active")),
transient_(false),
calcFrequency_(1),
iter_(1),
deltaT_(0.0),
coupled_(false),
cellValueSourceCorrection_(false),
maxTrackTime_(0.0),
resetSourcesOnStartup_(false)
{
if (active_)
{
read();
}
}
template<class ParcelType>
Foam::KinematicCloud<ParcelType>::cloudSolution::cloudSolution
(
const cloudSolution& cs
)
:
mesh_(cs.mesh_),
dict_(cs.dict_),
active_(cs.active_),
transient_(cs.transient_),
calcFrequency_(cs.calcFrequency_),
iter_(cs.iter_),
deltaT_(cs.deltaT_),
coupled_(cs.coupled_),
cellValueSourceCorrection_(cs.cellValueSourceCorrection_),
maxTrackTime_(cs.maxTrackTime_),
resetSourcesOnStartup_(cs.resetSourcesOnStartup_)
{}
template<class ParcelType>
Foam::KinematicCloud<ParcelType>::cloudSolution::cloudSolution
(
const fvMesh& mesh
)
:
mesh_(mesh),
dict_(dictionary::null),
active_(false),
transient_(false),
calcFrequency_(0),
iter_(0),
deltaT_(0.0),
coupled_(false),
cellValueSourceCorrection_(false),
maxTrackTime_(0.0),
resetSourcesOnStartup_(false)
{}
template<class ParcelType>
Foam::KinematicCloud<ParcelType>::cloudSolution::~cloudSolution()
{}
template<class ParcelType>
Foam::scalar Foam::KinematicCloud<ParcelType>::cloudSolution::relaxCoeff
(
const word& fieldName
) const
{
return readScalar(sourceTermDict().subDict(fieldName).lookup("alpha"));
}
template<class ParcelType>
bool Foam::KinematicCloud<ParcelType>::cloudSolution::semiImplicit
(
const word& fieldName
) const
{
return readBool(sourceTermDict().subDict(fieldName).lookup("semiImplicit"));
}
template<class ParcelType>
bool Foam::KinematicCloud<ParcelType>::cloudSolution::solveThisStep() const
{
return
active_
&& (
mesh_.time().outputTime()
|| (mesh_.time().timeIndex() % calcFrequency_ == 0)
);
}
template<class ParcelType>
bool Foam::KinematicCloud<ParcelType>::cloudSolution::canEvolve()
{
// Set the calculation time step
if (transient_)
{
deltaT_ = mesh_.time().deltaTValue();
}
else
{
deltaT_ = maxTrackTime_;
}
return solveThisStep();
}
template<class ParcelType>
bool Foam::KinematicCloud<ParcelType>::cloudSolution::output() const
{
return active_ && mesh_.time().outputTime();
}
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::solve
(
typename ParcelType::trackData& td
)
{
if (solution_.transient())
{
td.cloud().preEvolve();
evolveCloud(td);
}
else
{
td.cloud().storeState();
td.cloud().preEvolve();
evolveCloud(td);
td.cloud().relaxSources(td.cloud().cloudCopy());
}
td.cloud().info();
td.cloud().postEvolve();
if (solution_.steadyState())
{
td.cloud().restoreState();
}
}
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::preEvolve()
{
Info<< "\nSolving cloud " << this->name() << endl;
this->dispersion().cacheFields(true);
forces_.cacheFields(true, interpolationSchemes_);
forces_.cacheFields(true, solution_.interpolationSchemes());
updateCellOccupancy();
}
@ -93,62 +275,46 @@ void Foam::KinematicCloud<ParcelType>::updateCellOccupancy()
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::evolveCloud()
void Foam::KinematicCloud<ParcelType>::evolveCloud
(
typename ParcelType::trackData& td
)
{
autoPtr<interpolation<scalar> > rhoInterpolator =
interpolation<scalar>::New
(
interpolationSchemes_,
rho_
);
autoPtr<interpolation<vector> > UInterpolator =
interpolation<vector>::New
(
interpolationSchemes_,
U_
);
autoPtr<interpolation<scalar> > muInterpolator =
interpolation<scalar>::New
(
interpolationSchemes_,
mu_
);
typename ParcelType::trackData td
(
*this,
constProps_,
rhoInterpolator(),
UInterpolator(),
muInterpolator(),
g_.value()
);
label preInjectionSize = this->size();
this->surfaceFilm().inject(td);
// Update the cellOccupancy if the size of the cloud has changed
// during the injection.
if (preInjectionSize != this->size())
if (solution_.coupled())
{
updateCellOccupancy();
preInjectionSize = this->size();
td.cloud().resetSourceTerms();
}
this->injection().inject(td);
if (coupled_)
if (solution_.transient())
{
resetSourceTerms();
}
label preInjectionSize = this->size();
// Assume that motion will update the cellOccupancy as necessary
// before it is required.
motion(td);
this->surfaceFilm().inject(td);
// Update the cellOccupancy if the size of the cloud has changed
// during the injection.
if (preInjectionSize != this->size())
{
updateCellOccupancy();
preInjectionSize = this->size();
}
this->injection().inject(td);
// Assume that motion will update the cellOccupancy as necessary
// before it is required.
motion(td);
}
else
{
// this->surfaceFilm().injectStreadyState(td);
this->injection().injectSteadyState(td, solution_.deltaT());
td.part() = ParcelType::trackData::tpLinearTrack;
Cloud<ParcelType>::move(td, solution_.deltaT());
}
}
@ -197,10 +363,10 @@ void Foam::KinematicCloud<ParcelType>::moveCollide
)
{
td.part() = ParcelType::trackData::tpVelocityHalfStep;
Cloud<ParcelType>::move(td);
Cloud<ParcelType>::move(td, solution_.deltaT());
td.part() = ParcelType::trackData::tpLinearTrack;
Cloud<ParcelType>::move(td);
Cloud<ParcelType>::move(td, solution_.deltaT());
// td.part() = ParcelType::trackData::tpRotationalTrack;
// Cloud<ParcelType>::move(td);
@ -210,22 +376,44 @@ void Foam::KinematicCloud<ParcelType>::moveCollide
this->collision().collide();
td.part() = ParcelType::trackData::tpVelocityHalfStep;
Cloud<ParcelType>::move(td);
Cloud<ParcelType>::move(td, solution_.deltaT());
}
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::postEvolve()
{
Info<< endl;
if (debug)
{
this->writePositions();
}
this->dispersion().cacheFields(false);
forces_.cacheFields(false, interpolationSchemes_);
forces_.cacheFields(false, solution_.interpolationSchemes());
this->postProcessing().post();
solution_.nextIter();
}
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::cloudReset(KinematicCloud<ParcelType>& c)
{
Cloud<ParcelType>::cloudReset(c);
rndGen_ = c.rndGen_;
collisionModel_ = c.collisionModel_->clone();
dispersionModel_= c.dispersionModel_->clone();
dragModel_ = c.dragModel_->clone();
injectionModel_ = c.injectionModel_->clone();
patchInteractionModel_ = c.patchInteractionModel_->clone();
postProcessingModel_ = c.postProcessingModel_->clone();
UIntegrator_ = c.UIntegrator_->clone();
}
@ -244,6 +432,7 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
:
Cloud<ParcelType>(rho.mesh(), cloudName, false),
kinematicCloud(),
cloudCopyPtr_(NULL),
mesh_(rho.mesh()),
particleProperties_
(
@ -256,27 +445,33 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
IOobject::NO_WRITE
)
),
solution_(mesh_, particleProperties_.subDict("solution")),
constProps_(particleProperties_),
active_(particleProperties_.lookup("active")),
parcelTypeId_(readLabel(particleProperties_.lookup("parcelTypeId"))),
coupled_(particleProperties_.lookup("coupled")),
cellValueSourceCorrection_
subModelProperties_(particleProperties_.subDict("subModels")),
rndGen_
(
particleProperties_.lookup("cellValueSourceCorrection")
label(0),
particleProperties_.lookupOrDefault<label>("randomSampleSize", 100000)
),
rndGen_(label(0)),
cellOccupancyPtr_(),
rho_(rho),
U_(U),
mu_(mu),
g_(g),
forces_(mesh_, particleProperties_, g_.value()),
interpolationSchemes_(particleProperties_.subDict("interpolationSchemes")),
collisionModel_
(
CollisionModel<KinematicCloud<ParcelType> >::New
(
subModelProperties_,
*this
)
),
dispersionModel_
(
DispersionModel<KinematicCloud<ParcelType> >::New
(
particleProperties_,
subModelProperties_,
*this
)
),
@ -284,7 +479,7 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
(
DragModel<KinematicCloud<ParcelType> >::New
(
particleProperties_,
subModelProperties_,
*this
)
),
@ -292,15 +487,7 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
(
InjectionModel<KinematicCloud<ParcelType> >::New
(
particleProperties_,
*this
)
),
collisionModel_
(
CollisionModel<KinematicCloud<ParcelType> >::New
(
particleProperties_,
subModelProperties_,
*this
)
),
@ -308,7 +495,7 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
(
PatchInteractionModel<KinematicCloud<ParcelType> >::New
(
particleProperties_,
subModelProperties_,
*this
)
),
@ -316,7 +503,7 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
(
PostProcessingModel<KinematicCloud<ParcelType> >::New
(
this->particleProperties_,
subModelProperties_,
*this
)
),
@ -324,7 +511,7 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
(
SurfaceFilmModel<KinematicCloud<ParcelType> >::New
(
this->particleProperties_,
subModelProperties_,
*this,
g
)
@ -334,31 +521,167 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
vectorIntegrationScheme::New
(
"U",
particleProperties_.subDict("integrationSchemes")
solution_.integrationSchemes()
)
),
UTrans_
(
IOobject
new DimensionedField<vector, volMesh>
(
this->name() + "UTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedVector("zero", dimMass*dimVelocity, vector::zero)
IOobject
(
this->name() + "UTrans",
this->db().time().timeName(),
this->db(),
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedVector("zero", dimMass*dimVelocity, vector::zero)
)
),
UCoeff_
(
new DimensionedField<scalar, volMesh>
(
IOobject
(
this->name() + "UCoeff",
this->db().time().timeName(),
this->db(),
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("zero", dimMass/dimTime, 0.0)
)
)
{
if (readFields)
{
ParcelType::readFields(*this);
}
if (solution_.resetSourcesOnStartup())
{
resetSourceTerms();
}
}
template<class ParcelType>
Foam::KinematicCloud<ParcelType>::KinematicCloud
(
KinematicCloud<ParcelType>& c,
const word& name
)
:
Cloud<ParcelType>(c.mesh(), name, c),
kinematicCloud(),
cloudCopyPtr_(NULL),
mesh_(c.mesh_),
particleProperties_(c.particleProperties_),
solution_(c.solution_),
constProps_(c.constProps_),
subModelProperties_(c.subModelProperties_),
rndGen_(c.rndGen_, true),
cellOccupancyPtr_(NULL),
rho_(c.rho_),
U_(c.U_),
mu_(c.mu_),
g_(c.g_),
forces_(c.forces_),
collisionModel_(c.collisionModel_->clone()),
dispersionModel_(c.dispersionModel_->clone()),
dragModel_(c.dragModel_->clone()),
injectionModel_(c.injectionModel_->clone()),
patchInteractionModel_(c.patchInteractionModel_->clone()),
postProcessingModel_(c.postProcessingModel_->clone()),
surfaceFilmModel_(c.surfaceFilmModel_->clone()),
UIntegrator_(c.UIntegrator_->clone()),
UTrans_
(
new DimensionedField<vector, volMesh>
(
IOobject
(
this->name() + "UTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
c.UTrans_()
)
),
UCoeff_
(
new DimensionedField<scalar, volMesh>
(
IOobject
(
name + "UCoeff",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
c.UCoeff_()
)
)
{}
template<class ParcelType>
Foam::KinematicCloud<ParcelType>::KinematicCloud
(
const fvMesh& mesh,
const word& name,
const KinematicCloud<ParcelType>& c
)
:
Cloud<ParcelType>(mesh, name, IDLList<ParcelType>()),
kinematicCloud(),
cloudCopyPtr_(NULL),
mesh_(mesh),
particleProperties_
(
IOobject
(
name + "Properties",
mesh.time().constant(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
)
),
solution_(mesh),
constProps_(),
subModelProperties_(dictionary::null),
rndGen_(0, 0),
cellOccupancyPtr_(NULL),
rho_(c.rho_),
U_(c.U_),
mu_(c.mu_),
g_(c.g_),
forces_(mesh),
collisionModel_(NULL),
dispersionModel_(NULL),
dragModel_(NULL),
injectionModel_(NULL),
patchInteractionModel_(NULL),
postProcessingModel_(NULL),
surfaceFilmModel_(NULL),
UIntegrator_(NULL),
UTrans_(NULL),
UCoeff_(NULL)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ParcelType>
@ -381,31 +704,73 @@ void Foam::KinematicCloud<ParcelType>::checkParcelProperties
parcel.rho() = constProps_.rho0();
}
scalar carrierDt = this->db().time().deltaTValue();
const scalar carrierDt = this->db().time().deltaTValue();
parcel.stepFraction() = (carrierDt - lagrangianDt)/carrierDt;
}
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::storeState()
{
cloudCopyPtr_.reset
(
static_cast<KinematicCloud<ParcelType>*>
(
clone(this->name() + "Copy").ptr()
)
);
}
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::restoreState()
{
cloudReset(cloudCopyPtr_());
cloudCopyPtr_.clear();
}
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::resetSourceTerms()
{
UTrans_.field() = vector::zero;
UTrans().field() = vector::zero;
UCoeff().field() = 0.0;
}
template<class ParcelType>
template<class Type>
void Foam::KinematicCloud<ParcelType>::relax
(
DimensionedField<Type, volMesh>& field,
const DimensionedField<Type, volMesh>& field0,
const word& name
) const
{
const scalar coeff = solution_.relaxCoeff(name);
field = field0 + coeff*(field - field0);
}
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::relaxSources
(
const KinematicCloud<ParcelType>& cloudOldTime
)
{
this->relax(UTrans_(), cloudOldTime.UTrans(), "U");
}
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::evolve()
{
if (active_)
if (solution_.canEvolve())
{
preEvolve();
typename ParcelType::trackData td(*this);
evolveCloud();
postEvolve();
info();
Info<< endl;
solve(td);
}
}

View File

@ -27,14 +27,16 @@ Class
Description
Templated base class for kinematic cloud
- Kinematic only
- holds a 'cloudSolution' class that stores all relevant solution info
- sub-models:
- Collision model
- Dispersion model
- Drag model
- Injection model
- Patch interaction model
- Post-processing model
- Surface film model
- Collision model
SourceFiles
KinematicCloudI.H
@ -49,7 +51,7 @@ SourceFiles
#include "kinematicCloud.H"
#include "IOdictionary.H"
#include "autoPtr.H"
#include "Random.H"
#include "cachedRandom.H"
#include "fvMesh.H"
#include "volFields.H"
#include "fvMatrices.H"
@ -64,6 +66,9 @@ namespace Foam
// Forward declaration of classes
template<class CloudType>
class CollisionModel;
template<class CloudType>
class DispersionModel;
@ -73,9 +78,6 @@ class DragModel;
template<class CloudType>
class InjectionModel;
template<class CloudType>
class CollisionModel;
template<class CloudType>
class PatchInteractionModel;
@ -96,6 +98,12 @@ class KinematicCloud
public Cloud<ParcelType>,
public kinematicCloud
{
// Private data
//- Cloud copy pointer
autoPtr<KinematicCloud<ParcelType> > cloudCopyPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
@ -105,6 +113,156 @@ class KinematicCloud
void operator=(const KinematicCloud&);
public:
// Cloud solution helper class
class cloudSolution
{
// Private Data
//- Reference to the mesh
const fvMesh& mesh_;
//- Dictionary used during construction
dictionary dict_;
//- Cloud active flag
const Switch active_;
//- Transient flag
Switch transient_;
//- Calculation frequency - carrier steps per cloud step
// NOTE: Steady operation only
label calcFrequency_;
//- Current cloud iteration
label iter_;
//- Cloud solution time step
scalar deltaT_;
// Run-time options
//- Flag to indicate whether parcels are coupled to the carrier
// phase, i.e. whether or not to generate source terms for
// carrier phase
Switch coupled_;
//- Flag to correct cell values with latest transfer information
// during the lagrangian timestep
Switch cellValueSourceCorrection_;
//- Maximum particle track time [s]
scalar maxTrackTime_;
//- Flag to indicate whether coupling source terms should be
// reset on start-up/first read
Switch resetSourcesOnStartup_;
// Private Member Functions
//- Disallow default bitwise assignment
void operator=(const cloudSolution&);
public:
// Constructors
//- Construct null from mesh reference
cloudSolution(const fvMesh& mesh);
//- Construct from mesh and dictionary
cloudSolution(const fvMesh& mesh, const dictionary& dict);
//- Construct copy
cloudSolution(const cloudSolution& cs);
//- Destructor
virtual ~cloudSolution();
// Member functions
//- Read properties from dictionary
void read();
// Access
//- Return relaxation coefficient for field
scalar relaxCoeff(const word& fieldName) const;
//- Return semi-implicit flag coefficient for field
bool semiImplicit(const word& fieldName) const;
//- Return reference to the mesh
inline const fvMesh& mesh() const;
//- Return const access to the dictionary
inline const dictionary& dict() const;
//- Return the active flag
inline const Switch active() const;
//- Return const access to the transient flag
inline const Switch transient() const;
//- Return const access to the steady flag
inline const Switch steadyState() const;
//- Return const access to the calculation frequency
inline label calcFrequency() const;
//- Return const access to the current cloud iteration
inline label iter() const;
//- Increment and return iter counter
inline label nextIter();
//- Return the time step
inline scalar deltaT() const;
//- Return const access to the coupled flag
inline const Switch coupled() const;
//- Return const access to the cell value correction flag
inline const Switch cellValueSourceCorrection() const;
//- Return const access to the particle track time
inline scalar maxTrackTime() const;
//- Return const access to the reset sources flag
inline const Switch resetSourcesOnStartup() const;
//- Source terms dictionary
inline const dictionary& sourceTermDict() const;
//- Interpolation schemes dictionary
inline const dictionary& interpolationSchemes() const;
//- Integration schemes dictionary
inline const dictionary& integrationSchemes() const;
// Helper functions
//- Returns true if performing a cloud iteration this calc step
bool solveThisStep() const;
//- Returns true if possible to evolve the cloud and sets timestep
// parameters
bool canEvolve();
//- Returns true if writing this step
bool output() const;
};
protected:
// Protected data
@ -115,26 +273,17 @@ protected:
//- Dictionary of particle properties
IOdictionary particleProperties_;
//- Solution properties
cloudSolution solution_;
//- Parcel constant properties
typename ParcelType::constantProperties constProps_;
//- Cloud active flag
const Switch active_;
//- Parcel type id - used to flag the type of parcels issued by this
// cloud
const label parcelTypeId_;
//- Flag to indicate whether parcels are coupled to the carrier phase
// i.e. whether or not to generate source terms for carrier phase
const Switch coupled_;
//- Flag to correct cell values with latest transfer information
// during the lagrangian timestep
const Switch cellValueSourceCorrection_;
//- Sub-models dictionary
const dictionary& subModelProperties_;
//- Random number generator - used by some injection routines
Random rndGen_;
cachedRandom rndGen_;
//- Cell occupancy information for each parcel, (demand driven)
autoPtr<List<DynamicList<ParcelType*> > > cellOccupancyPtr_;
@ -142,13 +291,13 @@ protected:
// References to the carrier gas fields
//- Density
//- Density [kg/m3]
const volScalarField& rho_;
//- Velocity
//- Velocity [m/s]
const volVectorField& U_;
//- Dynamic viscosity
//- Dynamic viscosity [Pa.s]
const volScalarField& mu_;
@ -161,12 +310,13 @@ protected:
//- Optional particle forces
particleForces forces_;
//- Interpolation schemes dictionary
dictionary interpolationSchemes_;
// References to the cloud sub-models
//- Collision model
autoPtr<CollisionModel<KinematicCloud<ParcelType> > >
collisionModel_;
//- Dispersion model
autoPtr<DispersionModel<KinematicCloud<ParcelType> > >
dispersionModel_;
@ -178,10 +328,6 @@ protected:
autoPtr<InjectionModel<KinematicCloud<ParcelType> > >
injectionModel_;
//- Collision model
autoPtr<CollisionModel<KinematicCloud<ParcelType> > >
collisionModel_;
//- Patch interaction model
autoPtr<PatchInteractionModel<KinematicCloud<ParcelType> > >
patchInteractionModel_;
@ -204,11 +350,17 @@ protected:
// Sources
//- Momentum
DimensionedField<vector, volMesh> UTrans_;
autoPtr<DimensionedField<vector, volMesh> > UTrans_;
//- Coefficient for carrier phase U equation
autoPtr<DimensionedField<scalar, volMesh> > UCoeff_;
// Cloud evolution functions
//- Solve the cloud - calls all evolution functions
void solve(typename ParcelType::trackData& td);
//- Pre-evolve
void preEvolve();
@ -220,7 +372,7 @@ protected:
void updateCellOccupancy();
//- Evolve the cloud
void evolveCloud();
void evolveCloud(typename ParcelType::trackData& td);
//- Particle motion
void motion(typename ParcelType::trackData& td);
@ -231,6 +383,9 @@ protected:
//- Post-evolve
void postEvolve();
//- Reset state of cloud
void cloudReset(KinematicCloud<ParcelType>& c);
public:
@ -247,6 +402,35 @@ public:
bool readFields = true
);
//- Copy constructor with new name
KinematicCloud(KinematicCloud<ParcelType>& c, const word& name);
//- Copy constructor with new name - creates bare cloud
KinematicCloud
(
const fvMesh& mesh,
const word& name,
const KinematicCloud<ParcelType>& c
);
//- Construct and return clone based on (this) with new name
virtual autoPtr<Cloud<ParcelType> > clone(const word& name)
{
return autoPtr<Cloud<ParcelType> >
(
new KinematicCloud(*this, name)
);
}
//- Construct and return bare clone based on (this) with new name
virtual autoPtr<Cloud<ParcelType> > cloneBare(const word& name) const
{
return autoPtr<Cloud<ParcelType> >
(
new KinematicCloud(this->mesh(), name, *this)
);
}
//- Destructor
virtual ~KinematicCloud();
@ -260,6 +444,9 @@ public:
// Access
//- Return a reference to the cloud copy
inline const KinematicCloud& cloudCopy() const;
//- If the collision model controls the wall interaction,
// then the wall impact distance should be zero.
// Otherwise, it should be allowed to be the value from
@ -275,27 +462,24 @@ public:
//- Return particle properties dictionary
inline const IOdictionary& particleProperties() const;
//- Return const access to the solution properties
inline const cloudSolution& solution() const;
//- Return access to the solution properties
inline cloudSolution& solution();
//- Return the constant properties
inline const typename ParcelType::constantProperties&
constProps() const;
//- Return reference to the sub-models dictionary
inline const dictionary& subModelProperties() const;
// Cloud data
//- Return the active flag
inline const Switch active() const;
//- Return the parcel type id
inline label parcelTypeId() const;
//- Return coupled flag
inline const Switch coupled() const;
//- Return cell value correction flag
inline const Switch cellValueSourceCorrection() const;
//- Return refernce to the random object
inline Random& rndGen();
inline cachedRandom& rndGen();
//- Return the cell occupancy information for each
// parcel, non-const access, the caller is
@ -326,14 +510,16 @@ public:
inline const particleForces& forces() const;
// Interpolations
//- Return reference to the interpolation dictionary
inline const dictionary& interpolationSchemes() const;
// Sub-models
//- Return const access to the collision model
inline const CollisionModel<KinematicCloud<ParcelType> >&
collision() const;
//- Return reference to the collision model
inline CollisionModel<KinematicCloud<ParcelType> >&
collision();
//- Return const-access to the dispersion model
inline const DispersionModel<KinematicCloud<ParcelType> >&
dispersion() const;
@ -354,15 +540,6 @@ public:
inline InjectionModel<KinematicCloud<ParcelType> >&
injection();
//- Return const access to the collision model
inline
const CollisionModel<KinematicCloud<ParcelType> >&
collision() const;
//- Return reference to the collision model
inline CollisionModel<KinematicCloud<ParcelType> >&
collision();
//- Return const-access to the patch interaction model
inline const PatchInteractionModel<KinematicCloud<ParcelType> >&
patchInteraction() const;
@ -393,8 +570,19 @@ public:
//- Return reference to momentum source
inline DimensionedField<vector, volMesh>& UTrans();
//- Return tmp momentum source term - fully explicit
inline tmp<DimensionedField<vector, volMesh> > SU() const;
//- Return const reference to momentum source
inline const DimensionedField<vector, volMesh>&
UTrans() const;
//- Return coefficient for carrier phase U equation
inline DimensionedField<scalar, volMesh>& UCoeff();
//- Return const coefficient for carrier phase U equation
inline const DimensionedField<scalar, volMesh>&
UCoeff() const;
//- Return tmp momentum source term
inline tmp<fvVectorMatrix> SU(volVectorField& U) const;
// Check
@ -414,9 +602,6 @@ public:
//- Total rotational kinetic energy in the system
inline scalar rotationalKineticEnergyOfSystem() const;
//- Print cloud information
void info() const;
// Fields
@ -443,11 +628,32 @@ public:
const bool fullyDescribed
);
//- Reset the spray source terms
//- Store the current cloud state
void storeState();
//- Reset the current cloud to the previously stored state
void restoreState();
//- Reset the cloud source terms
void resetSourceTerms();
//- Evolve the spray (inject, inject)
//- Relax field
template<class Type>
void relax
(
DimensionedField<Type, volMesh>& field,
const DimensionedField<Type, volMesh>& field0,
const word& name
) const;
//- Apply relaxation to (steady state) cloud sources
void relaxSources(const KinematicCloud<ParcelType>& cloudOldTime);
//- Evolve the cloud
void evolve();
//- Print cloud information
void info() const;
};

View File

@ -25,8 +25,145 @@ License
#include "fvmSup.H"
// * * * * * * * * * * * cloudSolution Member Functions * * * * * * * * * * //
template<class ParcelType>
inline const Foam::fvMesh&
Foam::KinematicCloud<ParcelType>::cloudSolution::mesh() const
{
return mesh_;
}
template<class ParcelType>
inline const Foam::dictionary&
Foam::KinematicCloud<ParcelType>::cloudSolution::dict() const
{
return dict_;
}
template<class ParcelType>
inline const Foam::Switch
Foam::KinematicCloud<ParcelType>::cloudSolution::active() const
{
return active_;
}
template<class ParcelType>
inline const Foam::dictionary&
Foam::KinematicCloud<ParcelType>::cloudSolution::sourceTermDict() const
{
return dict_.subDict("sourceTerms");
}
template<class ParcelType>
inline const Foam::dictionary&
Foam::KinematicCloud<ParcelType>::cloudSolution::interpolationSchemes() const
{
return dict_.subDict("interpolationSchemes");
}
template<class ParcelType>
inline const Foam::dictionary&
Foam::KinematicCloud<ParcelType>::cloudSolution::integrationSchemes() const
{
return dict_.subDict("integrationSchemes");
}
template<class ParcelType>
inline const Foam::Switch
Foam::KinematicCloud<ParcelType>::cloudSolution::transient() const
{
return transient_;
}
template<class ParcelType>
inline const Foam::Switch
Foam::KinematicCloud<ParcelType>::cloudSolution::steadyState() const
{
return !transient_;
}
template<class ParcelType>
inline Foam::label
Foam::KinematicCloud<ParcelType>::cloudSolution::calcFrequency() const
{
return calcFrequency_;
}
template<class ParcelType>
inline Foam::label Foam::KinematicCloud<ParcelType>::cloudSolution::iter() const
{
return iter_;
}
template<class ParcelType>
inline Foam::label Foam::KinematicCloud<ParcelType>::cloudSolution::nextIter()
{
return ++iter_;
}
template<class ParcelType>
inline Foam::scalar
Foam::KinematicCloud<ParcelType>::cloudSolution::deltaT() const
{
return deltaT_;
}
template<class ParcelType>
inline const Foam::Switch
Foam::KinematicCloud<ParcelType>::cloudSolution::coupled() const
{
return coupled_;
}
template<class ParcelType>
inline const Foam::Switch
Foam::KinematicCloud<ParcelType>::cloudSolution::cellValueSourceCorrection()
const
{
return cellValueSourceCorrection_;
}
template<class ParcelType>
inline Foam::scalar
Foam::KinematicCloud<ParcelType>::cloudSolution::maxTrackTime() const
{
return maxTrackTime_;
}
template<class ParcelType>
inline const Foam::Switch
Foam::KinematicCloud<ParcelType>::cloudSolution::resetSourcesOnStartup() const
{
return resetSourcesOnStartup_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ParcelType>
inline const Foam::KinematicCloud<ParcelType>&
Foam::KinematicCloud<ParcelType>::cloudCopy() const
{
return cloudCopyPtr_();
}
template<class ParcelType>
inline bool Foam::KinematicCloud<ParcelType>::hasWallImpactDistance() const
{
@ -34,13 +171,6 @@ inline bool Foam::KinematicCloud<ParcelType>::hasWallImpactDistance() const
}
template<class ParcelType>
inline Foam::label Foam::KinematicCloud<ParcelType>::parcelTypeId() const
{
return parcelTypeId_;
}
template<class ParcelType>
inline const Foam::fvMesh& Foam::KinematicCloud<ParcelType>::mesh() const
{
@ -56,6 +186,22 @@ Foam::KinematicCloud<ParcelType>::particleProperties() const
}
template<class ParcelType>
inline const typename Foam::KinematicCloud<ParcelType>::cloudSolution&
Foam::KinematicCloud<ParcelType>::solution() const
{
return solution_;
}
template<class ParcelType>
inline typename Foam::KinematicCloud<ParcelType>::cloudSolution&
Foam::KinematicCloud<ParcelType>::solution()
{
return solution_;
}
template<class ParcelType>
inline const typename ParcelType::constantProperties&
Foam::KinematicCloud<ParcelType>::constProps() const
@ -65,24 +211,10 @@ Foam::KinematicCloud<ParcelType>::constProps() const
template<class ParcelType>
inline const Foam::Switch Foam::KinematicCloud<ParcelType>::active() const
inline const Foam::dictionary&
Foam::KinematicCloud<ParcelType>::subModelProperties() const
{
return active_;
}
template<class ParcelType>
inline const Foam::Switch Foam::KinematicCloud<ParcelType>::coupled() const
{
return coupled_;
}
template <class ParcelType>
inline const Foam::Switch
Foam::KinematicCloud<ParcelType>::cellValueSourceCorrection() const
{
return cellValueSourceCorrection_;
return subModelProperties_;
}
@ -125,10 +257,18 @@ Foam::KinematicCloud<ParcelType>::forces() const
template<class ParcelType>
inline const Foam::dictionary&
Foam::KinematicCloud<ParcelType>::interpolationSchemes() const
inline const Foam::CollisionModel<Foam::KinematicCloud<ParcelType> >&
Foam::KinematicCloud<ParcelType>::collision() const
{
return interpolationSchemes_;
return collisionModel_();
}
template<class ParcelType>
inline Foam::CollisionModel<Foam::KinematicCloud<ParcelType> >&
Foam::KinematicCloud<ParcelType>::collision()
{
return collisionModel_();
}
@ -180,22 +320,6 @@ Foam::KinematicCloud<ParcelType>::injection()
}
template<class ParcelType>
inline const Foam::CollisionModel<Foam::KinematicCloud<ParcelType> >&
Foam::KinematicCloud<ParcelType>::collision() const
{
return collisionModel_();
}
template<class ParcelType>
inline Foam::CollisionModel<Foam::KinematicCloud<ParcelType> >&
Foam::KinematicCloud<ParcelType>::collision()
{
return collisionModel_();
}
template<class ParcelType>
inline Foam::PostProcessingModel<Foam::KinematicCloud<ParcelType> >&
Foam::KinematicCloud<ParcelType>::postProcessing()
@ -296,7 +420,7 @@ rotationalKineticEnergyOfSystem() const
template<class ParcelType>
inline Foam::Random& Foam::KinematicCloud<ParcelType>::rndGen()
inline Foam::cachedRandom& Foam::KinematicCloud<ParcelType>::rndGen()
{
return rndGen_;
}
@ -319,40 +443,67 @@ template<class ParcelType>
inline Foam::DimensionedField<Foam::vector, Foam::volMesh>&
Foam::KinematicCloud<ParcelType>::UTrans()
{
return UTrans_;
return UTrans_();
}
template<class ParcelType>
inline Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh> >
Foam::KinematicCloud<ParcelType>::SU() const
inline const Foam::DimensionedField<Foam::vector, Foam::volMesh>&
Foam::KinematicCloud<ParcelType>::UTrans() const
{
tmp<DimensionedField<vector, volMesh> > tSU
(
new DimensionedField<vector, volMesh>
(
IOobject
(
this->name() + "SU",
this->db().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
this->mesh(),
dimensionedVector
(
"zero",
dimDensity*dimVelocity/dimTime,
vector::zero
)
)
);
return UTrans_();
}
vectorField& SU = tSU().field();
SU = UTrans_/(mesh_.V()*this->db().time().deltaT());
return tSU;
template<class ParcelType>
inline Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
Foam::KinematicCloud<ParcelType>::UCoeff()
{
return UCoeff_();
}
template<class ParcelType>
inline const Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
Foam::KinematicCloud<ParcelType>::UCoeff() const
{
return UCoeff_();
}
template<class ParcelType>
inline Foam::tmp<Foam::fvVectorMatrix>
Foam::KinematicCloud<ParcelType>::SU(volVectorField& U) const
{
if (debug)
{
Info<< "UTrans min/max = " << min(UTrans()).value() << ", "
<< max(UTrans()).value() << nl
<< "UCoeff min/max = " << min(UCoeff()).value() << ", "
<< max(UCoeff()).value() << endl;
}
if (solution_.coupled())
{
if (solution_.semiImplicit("U"))
{
return
UTrans()/(mesh_.V()*this->db().time().deltaT())
+ fvm::SuSp(-UCoeff()/mesh_.V(), U)
+ UCoeff()/mesh_.V()*U;
}
else
{
tmp<fvVectorMatrix> tfvm(new fvVectorMatrix(U, dimForce));
fvVectorMatrix& fvm = tfvm();
fvm.source() = -UTrans()/(this->db().time().deltaT());
return tfvm;
}
}
return tmp<fvVectorMatrix>(new fvVectorMatrix(U, dimForce));
}

View File

@ -58,108 +58,14 @@ void Foam::ReactingCloud<ParcelType>::checkSuppliedComposition
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::preEvolve()
void Foam::ReactingCloud<ParcelType>::cloudReset(ReactingCloud<ParcelType>& c)
{
ThermoCloud<ParcelType>::preEvolve();
}
ThermoCloud<ParcelType>::cloudReset(c);
compositionModel_ = c.compositionModel_->clone();
phaseChangeModel_ = c.phaseChangeModel_->clone();
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::evolveCloud()
{
const volScalarField& T = this->thermo().thermo().T();
const volScalarField cp = this->thermo().thermo().Cp();
const volScalarField& p = this->thermo().thermo().p();
autoPtr<interpolation<scalar> > rhoInterp = interpolation<scalar>::New
(
this->interpolationSchemes(),
this->rho()
);
autoPtr<interpolation<vector> > UInterp = interpolation<vector>::New
(
this->interpolationSchemes(),
this->U()
);
autoPtr<interpolation<scalar> > muInterp = interpolation<scalar>::New
(
this->interpolationSchemes(),
this->mu()
);
autoPtr<interpolation<scalar> > TInterp = interpolation<scalar>::New
(
this->interpolationSchemes(),
T
);
autoPtr<interpolation<scalar> > cpInterp = interpolation<scalar>::New
(
this->interpolationSchemes(),
cp
);
autoPtr<interpolation<scalar> > pInterp = interpolation<scalar>::New
(
this->interpolationSchemes(),
p
);
typename ParcelType::trackData td
(
*this,
constProps_,
rhoInterp(),
UInterp(),
muInterp(),
TInterp(),
cpInterp(),
pInterp(),
this->g().value()
);
label preInjectionSize = this->size();
this->surfaceFilm().inject(td);
// Update the cellOccupancy if the size of the cloud has changed
// during the injection.
if (preInjectionSize != this->size())
{
this->updateCellOccupancy();
preInjectionSize = this->size();
}
this->injection().inject(td);
if (this->coupled())
{
resetSourceTerms();
}
// Assume that motion will update the cellOccupancy as necessary
// before it is required.
motion(td);
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::motion
(
typename ParcelType::trackData& td
)
{
ThermoCloud<ParcelType>::motion(td);
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::postEvolve()
{
ThermoCloud<ParcelType>::postEvolve();
dMassPhaseChange_ = c.dMassPhaseChange_;
}
@ -178,12 +84,13 @@ Foam::ReactingCloud<ParcelType>::ReactingCloud
:
ThermoCloud<ParcelType>(cloudName, rho, U, g, thermo, false),
reactingCloud(),
cloudCopyPtr_(NULL),
constProps_(this->particleProperties()),
compositionModel_
(
CompositionModel<ReactingCloud<ParcelType> >::New
(
this->particleProperties(),
this->subModelProperties(),
*this
)
),
@ -191,7 +98,7 @@ Foam::ReactingCloud<ParcelType>::ReactingCloud
(
PhaseChangeModel<ReactingCloud<ParcelType> >::New
(
this->particleProperties(),
this->subModelProperties(),
*this
)
),
@ -212,9 +119,8 @@ Foam::ReactingCloud<ParcelType>::ReactingCloud
this->name() + "rhoTrans_" + specieName,
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
this->mesh(),
dimensionedScalar("zero", dimMass, 0.0)
@ -226,9 +132,74 @@ Foam::ReactingCloud<ParcelType>::ReactingCloud
{
ParcelType::readFields(*this);
}
if (this->solution().resetSourcesOnStartup())
{
resetSourceTerms();
}
}
template<class ParcelType>
Foam::ReactingCloud<ParcelType>::ReactingCloud
(
ReactingCloud<ParcelType>& c,
const word& name
)
:
ThermoCloud<ParcelType>(c, name),
reactingCloud(),
cloudCopyPtr_(NULL),
constProps_(c.constProps_),
compositionModel_(c.compositionModel_->clone()),
phaseChangeModel_(c.phaseChangeModel_->clone()),
rhoTrans_(c.rhoTrans_.size()),
dMassPhaseChange_(c.dMassPhaseChange_)
{
forAll(c.rhoTrans_, i)
{
const word& specieName = this->thermo().carrier().species()[i];
rhoTrans_.set
(
i,
new DimensionedField<scalar, volMesh>
(
IOobject
(
this->name() + "rhoTrans_" + specieName,
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
c.rhoTrans_[i]
)
);
}
}
template<class ParcelType>
Foam::ReactingCloud<ParcelType>::ReactingCloud
(
const fvMesh& mesh,
const word& name,
const ReactingCloud<ParcelType>& c
)
:
ThermoCloud<ParcelType>(mesh, name, c),
reactingCloud(),
cloudCopyPtr_(NULL),
constProps_(),
compositionModel_(c.compositionModel_->clone()),
// compositionModel_(NULL),
phaseChangeModel_(NULL),
rhoTrans_(0),
dMassPhaseChange_(0.0)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ParcelType>
@ -272,6 +243,27 @@ void Foam::ReactingCloud<ParcelType>::checkParcelProperties
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::storeState()
{
cloudCopyPtr_.reset
(
static_cast<ReactingCloud<ParcelType>*>
(
clone(this->name() + "Copy").ptr()
)
);
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::restoreState()
{
cloudReset(cloudCopyPtr_());
cloudCopyPtr_.clear();
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::resetSourceTerms()
{
@ -283,23 +275,44 @@ void Foam::ReactingCloud<ParcelType>::resetSourceTerms()
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::relaxSources
(
const ReactingCloud<ParcelType>& cloudOldTime
)
{
typedef DimensionedField<scalar, volMesh> dsfType;
ThermoCloud<ParcelType>::relaxSources(cloudOldTime);
forAll(rhoTrans_, fieldI)
{
dsfType& rhoT = rhoTrans_[fieldI];
const dsfType& rhoT0 = cloudOldTime.rhoTrans()[fieldI];
this->relax(rhoT, rhoT0, "rho");
}
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::evolve()
{
if (this->active())
if (this->solution().canEvolve())
{
preEvolve();
typename ParcelType::trackData td(*this);
evolveCloud();
postEvolve();
info();
Info<< endl;
this->solve(td);
}
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::addToMassPhaseChange(const scalar dMass)
{
dMassPhaseChange_ += dMass;
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::info() const
{
@ -310,11 +323,4 @@ void Foam::ReactingCloud<ParcelType>::info() const
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::addToMassPhaseChange(const scalar dMass)
{
dMassPhaseChange_ += dMass;
}
// ************************************************************************* //

View File

@ -69,7 +69,13 @@ class ReactingCloud
private:
// Private Member Functions
// Private data
//- Cloud copy pointer
autoPtr<ReactingCloud<ParcelType> > cloudCopyPtr_;
// Private member functions
//- Disallow default bitwise copy construct
ReactingCloud(const ReactingCloud&);
@ -124,17 +130,8 @@ protected:
// Cloud evolution functions
//- Pre-evolve
void preEvolve();
//- Evolve the cloud
void evolveCloud();
//- Particle motion
void motion(typename ParcelType::trackData& td);
//- Post-evolve
void postEvolve();
//- Reset state of cloud
void cloudReset(ReactingCloud<ParcelType>& c);
public:
@ -152,6 +149,35 @@ public:
bool readFields = true
);
//- Copy constructor with new name
ReactingCloud(ReactingCloud<ParcelType>& c, const word& name);
//- Copy constructor with new name - creates bare cloud
ReactingCloud
(
const fvMesh& mesh,
const word& name,
const ReactingCloud<ParcelType>& c
);
//- Construct and return clone based on (this) with new name
virtual autoPtr<Cloud<ParcelType> > clone(const word& name)
{
return autoPtr<Cloud<ParcelType> >
(
new ReactingCloud(*this, name)
);
}
//- Construct and return bare clone based on (this) with new name
virtual autoPtr<Cloud<ParcelType> > cloneBare(const word& name) const
{
return autoPtr<Cloud<ParcelType> >
(
new ReactingCloud(this->mesh(), name, *this)
);
}
//- Destructor
virtual ~ReactingCloud();
@ -165,6 +191,9 @@ public:
// Access
//- Return a reference to the cloud copy
inline const ReactingCloud& cloudCopy() const;
//- Return the constant properties
inline const typename ParcelType::constantProperties&
constProps() const;
@ -189,10 +218,21 @@ public:
inline DimensionedField<scalar, volMesh>&
rhoTrans(const label i);
//- Return const access to mass source fields
inline const PtrList<DimensionedField<scalar, volMesh> >&
rhoTrans() const;
//- Return reference to mass source fields
inline PtrList<DimensionedField<scalar, volMesh> >&
rhoTrans();
//- Return mass source term for specie i - specie eqn
inline tmp<fvScalarMatrix> SYi
(
const label i,
volScalarField& Yi
) const;
//- Return tmp mass source for field i - fully explicit
inline tmp<DimensionedField<scalar, volMesh> >
Srho(const label i) const;
@ -201,12 +241,12 @@ public:
// - fully explicit
inline tmp<DimensionedField<scalar, volMesh> > Srho() const;
//- Return total mass source term [kg/m3/s]
inline tmp<fvScalarMatrix> Srho(volScalarField& rho) const;
// Check
//- Print cloud information
void info() const;
//- Add to cumulative phase change mass transfer
void addToMassPhaseChange(const scalar dMass);
@ -221,11 +261,23 @@ public:
const bool fullyDescribed
);
//- Reset the spray source terms
//- Store the current cloud state
void storeState();
//- Reset the current cloud to the previously stored state
void restoreState();
//- Reset the cloud source terms
void resetSourceTerms();
//- Evolve the spray (inject, move)
//- Apply relaxation to (steady state) cloud sources
void relaxSources(const ReactingCloud<ParcelType>& cloudOldTime);
//- Evolve the cloud
void evolve();
//- Print cloud information
void info() const;
};

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