Commit b8a89af0 authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: Multiple updates to lagrangian/intermediate library

sub-models:
- now derived from a common base class
- copy/clone functionality added

cloud:
- makes use of cachedRandom class (instead of Random)
parent 75fabe36
......@@ -293,7 +293,11 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
(
particleProperties_.lookup("cellValueSourceCorrection")
),
rndGen_(label(0)),
rndGen_
(
label(0),
readLabel(particleProperties_.lookup("randomSampleSize"))
),
cellOccupancyPtr_(),
rho_(rho),
U_(U),
......
......@@ -49,7 +49,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"
......@@ -206,7 +206,7 @@ protected:
const Switch cellValueSourceCorrection_;
//- 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_;
......@@ -358,7 +358,7 @@ public:
// Cloud data
//- 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
......
......@@ -334,7 +334,7 @@ rotationalKineticEnergyOfSystem() const
template<class ParcelType>
inline Foam::Random& Foam::KinematicCloud<ParcelType>::rndGen()
inline Foam::cachedRandom& Foam::KinematicCloud<ParcelType>::rndGen()
{
return rndGen_;
}
......
......@@ -30,9 +30,7 @@ License
template<class CloudType>
Foam::CollisionModel<CloudType>::CollisionModel(CloudType& owner)
:
dict_(dictionary::null),
owner_(owner),
coeffDict_(dictionary::null)
SubModelBase<CloudType>(owner)
{}
......@@ -44,9 +42,14 @@ Foam::CollisionModel<CloudType>::CollisionModel
const word& type
)
:
dict_(dict),
owner_(owner),
coeffDict_(dict.subDict(type + "Coeffs"))
SubModelBase<CloudType>(owner, dict, type)
{}
template<class CloudType>
Foam::CollisionModel<CloudType>::CollisionModel(CollisionModel<CloudType>& cm)
:
SubModelBase<CloudType>(cm)
{}
......@@ -57,6 +60,36 @@ Foam::CollisionModel<CloudType>::~CollisionModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
Foam::label Foam::CollisionModel<CloudType>::nSubCycles() const
{
notImplemented
(
"Foam::label Foam::CollisionModel<CloudType>::nSubCycles() const"
);
return 0;
}
template<class CloudType>
bool Foam::CollisionModel<CloudType>::controlsWallInteraction() const
{
notImplemented
(
"bool Foam::CollisionModel<CloudType>::controlsWallInteraction()"
);
return false;
}
template<class CloudType>
void Foam::CollisionModel<CloudType>::collide()
{
notImplemented("void Foam::CollisionModel<CloudType>::collide()");
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "CollisionModelNew.C"
......
......@@ -51,21 +51,9 @@ namespace Foam
template<class CloudType>
class CollisionModel
:
public SubModelBase<CloudType>
{
// Private data
//- The cloud dictionary
const dictionary& dict_;
//- Reference to the owner cloud class
CloudType& owner_;
//- The coefficients dictionary
const dictionary coeffDict_;
protected:
// Protected data
//- Convenience typedef for parcel type
......@@ -96,7 +84,7 @@ public:
//- Construct null from owner
CollisionModel(CloudType& owner);
//- Construct from dictionary
//- Construct from components
CollisionModel
(
const dictionary& dict,
......@@ -104,6 +92,18 @@ public:
const word& type
);
//- Construct copy
CollisionModel(CollisionModel<CloudType>& cm);
//- Construct and return a clone
virtual autoPtr<CollisionModel<CloudType> > clone()
{
return autoPtr<CollisionModel<CloudType> >
(
new CollisionModel<CloudType>(*this)
);
}
//- Destructor
virtual ~CollisionModel();
......@@ -117,36 +117,18 @@ public:
);
// Access
//- Return the owner cloud dictionary
inline const dictionary& dict() const;
//- Return const access the owner cloud object
inline const CloudType& owner() const;
//- Return non-const access the owner cloud object for manipulation
inline CloudType& owner();
//- Return the coefficients dictionary
inline const dictionary& coeffDict() const;
// Member Functions
//- Return the number of times to subcycle the current
// timestep to meet the criteria of the collision model
virtual label nSubCycles() const = 0;
//- Flag to indicate whether model activates injection model
virtual bool active() const = 0;
virtual label nSubCycles() const;
//- Indicates whether model determines wall collisions or not,
// used to determine what value to use for wallImpactDistance
virtual bool controlsWallInteraction() const = 0;
virtual bool controlsWallInteraction() const;
// Collision function
virtual void collide() = 0;
virtual void collide();
};
......@@ -172,10 +154,6 @@ public:
add##SS##CloudType##ParcelType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "CollisionModelI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
......
......@@ -35,12 +35,12 @@ Foam::CollisionModel<CloudType>::New
CloudType& owner
)
{
word CollisionModelType(dict.lookup("CollisionModel"));
word modelType(dict.lookup("CollisionModel"));
Info<< "Selecting CollisionModel " << CollisionModelType << endl;
Info<< "Selecting CollisionModel " << modelType << endl;
typename dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(CollisionModelType);
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
......@@ -51,8 +51,7 @@ Foam::CollisionModel<CloudType>::New
"const dictionary&, "
"CloudType&"
")"
) << "Unknown CollisionModelType type "
<< CollisionModelType
) << "Unknown CollisionModelType type " << modelType
<< ", constructor not in hash table" << nl << nl
<< " Valid CollisionModel types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError);
......
......@@ -38,6 +38,16 @@ Foam::NoCollision<CloudType>::NoCollision
{}
template<class CloudType>
Foam::NoCollision<CloudType>::NoCollision
(
NoCollision<CloudType>& cm
)
:
CollisionModel<CloudType>(cm)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
......
......@@ -60,12 +60,20 @@ public:
// Constructors
//- Construct from dictionary
NoCollision
(
const dictionary& dict,
CloudType& owner
);
//- Construct from components
NoCollision(const dictionary& dict, CloudType& owner);
//- Construct copy
NoCollision(NoCollision<CloudType>& cm);
//- Construct and return a clone
virtual autoPtr<CollisionModel<CloudType> > clone()
{
return autoPtr<CollisionModel<CloudType> >
(
new NoCollision<CloudType>(*this)
);
}
//- Destructor
......
......@@ -564,6 +564,24 @@ Foam::PairCollision<CloudType>::PairCollision
{}
template<class CloudType>
Foam::PairCollision<CloudType>::PairCollision(PairCollision<CloudType>& cm)
:
CollisionModel<CloudType>(cm),
pairModel_(NULL),
wallModel_(NULL),
il_(cm.owner().mesh())
{
notImplemented
(
"Foam::PairCollision<CloudType>::PairCollision"
"("
"PairCollision<CloudType>& cm"
")"
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
......@@ -602,13 +620,6 @@ Foam::label Foam::PairCollision<CloudType>::nSubCycles() const
}
template<class CloudType>
bool Foam::PairCollision<CloudType>::active() const
{
return true;
}
template<class CloudType>
bool Foam::PairCollision<CloudType>::controlsWallInteraction() const
{
......
......@@ -147,12 +147,20 @@ public:
// Constructors
//- Construct from dictionary
PairCollision
(
const dictionary& dict,
CloudType& owner
);
//- Construct from components
PairCollision(const dictionary& dict, CloudType& owner);
//- Construct copy
PairCollision(PairCollision<CloudType>& cm);
//- Construct and return a clone
virtual autoPtr<CollisionModel<CloudType> > clone()
{
return autoPtr<CollisionModel<CloudType> >
(
new PairCollision<CloudType>(*this)
);
}
//- Destructor
......@@ -165,9 +173,6 @@ public:
// timestep to meet the criteria of the collision model.
virtual label nSubCycles() const;
//- Flag to indicate whether model activates injection model
virtual bool active() const;
//- Indicates whether model determines wall collisions or not,
// used to determine what value to use for wallImpactDistance
virtual bool controlsWallInteraction() const;
......
......@@ -30,8 +30,7 @@ License
template<class CloudType>
Foam::DispersionModel<CloudType>::DispersionModel(CloudType& owner)
:
dict_(dictionary::null),
owner_(owner)
SubModelBase<CloudType>(owner)
{}
......@@ -39,41 +38,58 @@ template<class CloudType>
Foam::DispersionModel<CloudType>::DispersionModel
(
const dictionary& dict,
CloudType& owner
CloudType& owner,
const word& type
)
:
dict_(dict),
owner_(owner)
SubModelBase<CloudType>(dict, owner, type)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::DispersionModel<CloudType>::~DispersionModel()
Foam::DispersionModel<CloudType>::DispersionModel
(
DispersionModel<CloudType>& dm
)
:
SubModelBase<CloudType>(dm)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
const CloudType& Foam::DispersionModel<CloudType>::owner() const
{
return owner_;
}
Foam::DispersionModel<CloudType>::~DispersionModel()
{}
template<class CloudType>
CloudType& Foam::DispersionModel<CloudType>::owner()
{
return owner_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
const Foam::dictionary& Foam::DispersionModel<CloudType>::dict() const
Foam::vector Foam::DispersionModel<CloudType>::update
(
const scalar,
const label,
const vector&,
const vector& Uc,
vector&,
scalar&
)
{
return dict_;
notImplemented
(
"Foam::vector Foam::DispersionModel<CloudType>::update"
"("
"const scalar, "
"const label, "
"const vector&, "
"const vector&, "
"vector&, "
"scalar&"
")"
);
return Uc;
}
......
......@@ -34,6 +34,7 @@ Description
#include "IOdictionary.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "SubModelBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -46,17 +47,9 @@ namespace Foam
template<class CloudType>
class DispersionModel
:
public SubModelBase<CloudType>
{
// Private data
//- Cloud dictionary
const dictionary& dict_;
//- Reference to the owner cloud class
CloudType& owner_;
public:
//- Runtime type information
......@@ -90,6 +83,26 @@ public:
CloudType& owner
);
//- Construct from components
DispersionModel
(
const dictionary& dict,
CloudType& owner,
const word& type
);
//- Construct copy
DispersionModel(DispersionModel<CloudType>& dm);
//- Construct and return a clone
virtual autoPtr<DispersionModel<CloudType> > clone()
{
return autoPtr<DispersionModel<CloudType> >
(
new DispersionModel<CloudType>(*this)
);
}
//- Destructor
virtual ~DispersionModel();
......@@ -103,26 +116,8 @@ public:
);
// Access
//- Return the owner cloud object
const CloudType& owner() const;
//- Return the owner cloud object
CloudType& owner();
//- Return the dictionary
const dictionary& dict() const;
// Member Functions
//- Flag to indicate whether model activates injection model
virtual bool active() const = 0;
//- Cache carrier fields
virtual void cacheFields(const bool store) = 0;
//- Update (disperse particles)
virtual vector update
(
......@@ -132,7 +127,7 @@ public:
const vector& Uc,
vector& UTurb,
scalar& tTurb
) = 0;
);
};
......
......@@ -24,17 +24,18 @@ License
\*---------------------------------------------------------------------------*/
#include "DispersionRASModel.H"
#include "demandDrivenData.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::DispersionRASModel<CloudType>::DispersionRASModel
(
const dictionary& dict,
const dictionary&,
CloudType& owner
)
:
DispersionModel<CloudType>(dict, owner),
DispersionModel<CloudType>(owner),
turbulence_
(
owner.mesh().objectRegistry::lookupObject<compressible::RASModel>
......@@ -49,6 +50,24 @@ Foam::DispersionRASModel<CloudType>::DispersionRASModel
{}
template<class CloudType>
Foam::DispersionRASModel<CloudType>::DispersionRASModel
(
DispersionRASModel<CloudType>& dm
)
:
DispersionModel<CloudType>(dm),
turbulence_(dm.turbulence_),
kPtr_(dm.kPtr_),
ownK_(dm.ownK_),
epsilonPtr_(dm.epsilonPtr_),
ownEpsilon_(dm.ownEpsilon_)
{
dm.ownK_ = false;
dm.ownEpsilon_ = false;