Commit 34888963 authored by andy's avatar andy
Browse files

ENH: Abstracted out collisions for parcels and clouds and restructured

parent 4650948a
......@@ -19,6 +19,10 @@ KINEMATICPARCEL=$(DERIVEDPARCELS)/basicKinematicParcel
$(KINEMATICPARCEL)/defineBasicKinematicParcel.C
$(KINEMATICPARCEL)/makeBasicKinematicParcelSubmodels.C
KINEMATICCOLLIDINGPARCEL=$(DERIVEDPARCELS)/basicKinematicCollidingParcel
$(KINEMATICCOLLIDINGPARCEL)/defineBasicKinematicCollidingParcel.C
$(KINEMATICCOLLIDINGPARCEL)/makeBasicKinematicCollidingParcelSubmodels.C
/* thermo parcel sub-models */
THERMOPARCEL=$(DERIVEDPARCELS)/basicThermoParcel
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "CollidingCloud.H"
#include "CollisionModel.H"
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
template<class CloudType>
void Foam::CollidingCloud<CloudType>::setModels()
{
collisionModel_.reset
(
CollisionModel<CollidingCloud<CloudType> >::New
(
this->subModelProperties(),
*this
).ptr()
);
}
template<class CloudType>
template<class TrackData>
void Foam::CollidingCloud<CloudType>::moveCollide(TrackData& td)
{
td.part() = TrackData::tpVelocityHalfStep;
CloudType::move(td, this->solution().deltaT());
td.part() = TrackData::tpLinearTrack;
CloudType::move(td, this->solution().deltaT());
// td.part() = TrackData::tpRotationalTrack;
// CloudType::move(td);
this->updateCellOccupancy();
this->collision().collide();
td.part() = TrackData::tpVelocityHalfStep;
CloudType::move(td, this->solution().deltaT());
}
template<class CloudType>
void Foam::CollidingCloud<CloudType>::cloudReset(CollidingCloud<CloudType>& c)
{
CloudType::cloudReset(c);
collisionModel_.reset(c.collisionModel_.ptr());
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::CollidingCloud<CloudType>::CollidingCloud
(
const word& cloudName,
const volScalarField& rho,
const volVectorField& U,
const volScalarField& mu,
const dimensionedVector& g,
bool readFields
)
:
CloudType(cloudName, rho, U, mu, g, false),
collisionModel_(NULL)
{
if (this->solution().active())
{
setModels();
}
if (readFields)
{
parcelType::readFields(*this);
}
}
template<class CloudType>
Foam::CollidingCloud<CloudType>::CollidingCloud
(
CollidingCloud<CloudType>& c,
const word& name
)
:
CloudType(c, name),
collisionModel_(c.collisionModel_->clone())
{}
template<class CloudType>
Foam::CollidingCloud<CloudType>::CollidingCloud
(
const fvMesh& mesh,
const word& name,
const CollidingCloud<CloudType>& c
)
:
CloudType(mesh, name, c),
collisionModel_(NULL)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::CollidingCloud<CloudType>::~CollidingCloud()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::CollidingCloud<CloudType>::storeState()
{
cloudCopyPtr_.reset
(
static_cast<CollidingCloud<CloudType>*>
(
clone(this->name() + "Copy").ptr()
)
);
}
template<class CloudType>
void Foam::CollidingCloud<CloudType>::restoreState()
{
cloudReset(cloudCopyPtr_());
cloudCopyPtr_.clear();
}
template<class CloudType>
void Foam::CollidingCloud<CloudType>::evolve()
{
if (this->solution().canEvolve())
{
typename parcelType::template
TrackingData<CollidingCloud<CloudType> > td(*this);
this->solve(td);
}
}
template<class CloudType>
template<class TrackData>
void Foam::CollidingCloud<CloudType>::motion(TrackData& td)
{
// Sympletic leapfrog integration of particle forces:
// + apply half deltaV with stored force
// + move positions with new velocity
// + calculate forces in new position
// + apply half deltaV with new force
label nSubCycles = collision().nSubCycles();
if (nSubCycles > 1)
{
Info<< " " << nSubCycles << " move-collide subCycles" << endl;
subCycleTime moveCollideSubCycle
(
const_cast<Time&>(this->db().time()),
nSubCycles
);
while(!(++moveCollideSubCycle).end())
{
moveCollide(td);
}
moveCollideSubCycle.endSubCycle();
}
else
{
moveCollide(td);
}
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::CollidingCloud
Description
Adds coolisions to kinematic clouds
SourceFiles
CollidingCloudI.H
CollidingCloud.C
\*---------------------------------------------------------------------------*/
#ifndef CollidingCloud_H
#define CollidingCloud_H
#include "particle.H"
#include "Cloud.H"
#include "IOdictionary.H"
#include "autoPtr.H"
#include "fvMesh.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
template<class CloudType>
class CollisionModel;
/*---------------------------------------------------------------------------*\
Class CollidingCloud Declaration
\*---------------------------------------------------------------------------*/
template<class CloudType>
class CollidingCloud
:
public CloudType
{
public:
// Public typedefs
//- Redefine particle type as parcel type
typedef typename CloudType::particleType parcelType;
private:
// Private data
//- Cloud copy pointer
autoPtr<CollidingCloud<CloudType> > cloudCopyPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
CollidingCloud(const CollidingCloud&);
//- Disallow default bitwise assignment
void operator=(const CollidingCloud&);
protected:
// Protected data
// References to the cloud sub-models
//- Collision model
autoPtr<CollisionModel<CollidingCloud<CloudType> > >
collisionModel_;
// Initialisation
//- Set cloud sub-models
void setModels();
// Cloud evolution functions
//- Move-collide particles
template<class TrackData>
void moveCollide(TrackData& td);
//- Reset state of cloud
void cloudReset(CollidingCloud<CloudType>& c);
public:
typedef CloudType cloudType;
// Constructors
//- Construct given carrier gas fields
CollidingCloud
(
const word& cloudName,
const volScalarField& rho,
const volVectorField& U,
const volScalarField& mu,
const dimensionedVector& g,
bool readFields = true
);
//- Copy constructor with new name
CollidingCloud
(
CollidingCloud<CloudType>& c,
const word& name
);
//- Copy constructor with new name - creates bare cloud
CollidingCloud
(
const fvMesh& mesh,
const word& name,
const CollidingCloud<CloudType>& c
);
//- Construct and return clone based on (this) with new name
virtual autoPtr<Cloud<parcelType> > clone(const word& name)
{
return autoPtr<Cloud<parcelType> >
(
new CollidingCloud(*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 CollidingCloud(this->mesh(), name, *this)
);
}
//- Destructor
virtual ~CollidingCloud();
// Member Functions
// Access
//- Return a reference to the cloud copy
inline const CollidingCloud& 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
// the Parcel.
inline bool hasWallImpactDistance() const;
// Sub-models
//- Return const access to the collision model
inline const CollisionModel<CollidingCloud<CloudType> >&
collision() const;
//- Return reference to the collision model
inline CollisionModel<CollidingCloud<CloudType> >&
collision();
// Evolution
//- Store the current cloud state
void storeState();
//- Reset the current cloud to the previously stored state
void restoreState();
//- Evolve the cloud
void evolve();
//- Particle motion
template<class TrackData>
void motion(TrackData& td);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "CollidingCloudI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "CollidingCloud.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008-2011 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 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
inline const Foam::CollidingCloud<CloudType>&
Foam::CollidingCloud<CloudType>::cloudCopy() const
{
return cloudCopyPtr_();
}
template<class CloudType>
inline bool Foam::CollidingCloud<CloudType>::hasWallImpactDistance() const
{
return !collision().controlsWallInteraction();
}
template<class CloudType>
inline const Foam::CollisionModel<Foam::CollidingCloud<CloudType> >&
Foam::CollidingCloud<CloudType>::collision() const
{
return collisionModel_();
}
template<class CloudType>
inline Foam::CollisionModel<Foam::CollidingCloud<CloudType> >&
Foam::CollidingCloud<CloudType>::collision()
{
return collisionModel_();
}
// ************************************************************************* //
......@@ -28,7 +28,6 @@ License
#include "interpolation.H"
#include "subCycleTime.H"
#include "CollisionModel.H"
#include "DispersionModel.H"
#include "InjectionModel.H"
#include "PatchInteractionModel.H"
......@@ -190,15 +189,6 @@ bool Foam::KinematicCloud<CloudType>::cloudSolution::output() const
template<class CloudType>
void Foam::KinematicCloud<CloudType>::setModels()
{
collisionModel_.reset
(
CollisionModel<KinematicCloud<CloudType> >::New
(
subModelProperties_,
*this
).ptr()
);
dispersionModel_.reset
(
DispersionModel<KinematicCloud<CloudType> >::New
......@@ -372,7 +362,7 @@ void Foam::KinematicCloud<CloudType>::evolveCloud(TrackData& td)
// Assume that motion will update the cellOccupancy as necessary
// before it is required.
motion(td);
td.cloud().motion(td);
}
else
{
......@@ -386,64 +376,6 @@ void Foam::KinematicCloud<CloudType>::evolveCloud(TrackData& td)
}
template<class CloudType>
template<class TrackData>
void Foam::KinematicCloud<CloudType>::motion(TrackData& td)
{
// Sympletic leapfrog integration of particle forces:
// + apply half deltaV with stored force
// + move positions with new velocity
// + calculate forces in new position
// + apply half deltaV with new force
label nSubCycles = collision().nSubCycles();
if (nSubCycles > 1)
{
Info<< " " << nSubCycles << " move-collide subCycles" << endl;
subCycleTime moveCollideSubCycle
(
const_cast<Time&>(this->db().time()),
nSubCycles
);
while(!(++moveCollideSubCycle).end())
{
moveCollide(td);
}
moveCollideSubCycle.endSubCycle();
}
else
{
moveCollide(td);
}
}
template<class CloudType>
template<class TrackData>
void Foam::KinematicCloud<CloudType>::moveCollide(TrackData& td)
{
td.part() = TrackData::tpVelocityHalfStep;
CloudType::move(td, solution_.deltaT());
td.part() = TrackData::tpLinearTrack;
CloudType