Commit f5da7edf authored by andy's avatar andy
Browse files

ENH: Re-worked lagrangian/dsmc

parent 4fbde908
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -501,7 +501,7 @@ void Foam::DsmcCloud<ParcelType>::addNewParcel
{
ParcelType* pPtr = new ParcelType
(
*this,
mesh_,
position,
U,
Ei,
......@@ -970,7 +970,7 @@ Foam::DsmcCloud<ParcelType>::~DsmcCloud()
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::evolve()
{
typename ParcelType::trackData td(*this);
typename ParcelType::trackingData td(*this);
// Reset the data collection fields
resetFields();
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -30,13 +30,10 @@ License
template<class ParcelType>
template<class TrackData>
bool Foam::DsmcParcel<ParcelType>::move
(
TrackData& td,
const scalar trackTime
)
bool Foam::DsmcParcel<ParcelType>::move(TrackData& td, const scalar trackTime)
{
ParcelType& p = static_cast<ParcelType&>(*this);
typename TrackData::cloudType::parcelType& p =
static_cast<typename TrackData::cloudType::parcelType&>(*this);
td.switchProcessor = false;
td.keepParticle = true;
......@@ -113,15 +110,6 @@ void Foam::DsmcParcel<ParcelType>::hitProcessorPatch
}
template<class ParcelType>
void Foam::DsmcParcel<ParcelType>::hitProcessorPatch
(
const processorPolyPatch&,
int&
)
{}
template<class ParcelType>
template<class TrackData>
void Foam::DsmcParcel<ParcelType>::hitWallPatch
......@@ -174,7 +162,7 @@ void Foam::DsmcParcel<ParcelType>::hitWallPatch
td.cloud().wallInteraction().correct
(
static_cast<ParcelType&>(*this),
static_cast<DsmcParcel<ParcelType> &>(*this),
wpp
);
......@@ -215,44 +203,18 @@ void Foam::DsmcParcel<ParcelType>::hitWallPatch
}
template<class ParcelType>
void Foam::DsmcParcel<ParcelType>::hitWallPatch
(
const wallPolyPatch&,
int&,
const tetIndices&
)
{}
template<class ParcelType>
template<class TrackData>
void Foam::DsmcParcel<ParcelType>::hitPatch
(
const polyPatch&,
TrackData& td
)
void Foam::DsmcParcel<ParcelType>::hitPatch(const polyPatch&, TrackData& td)
{
td.keepParticle = false;
}
template<class ParcelType>
void Foam::DsmcParcel<ParcelType>::hitPatch
(
const polyPatch&,
int&
)
{}
template<class ParcelType>
void Foam::DsmcParcel<ParcelType>::transformProperties
(
const tensor& T
)
void Foam::DsmcParcel<ParcelType>::transformProperties(const tensor& T)
{
Particle<ParcelType>::transformProperties(T);
ParcelType::transformProperties(T);
U_ = transform(T, U_);
}
......@@ -263,7 +225,7 @@ void Foam::DsmcParcel<ParcelType>::transformProperties
const vector& separation
)
{
Particle<ParcelType>::transformProperties(separation);
ParcelType::transformProperties(separation);
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -37,7 +37,7 @@ SourceFiles
#ifndef DsmcParcel_H
#define DsmcParcel_H
#include "Particle.H"
#include "particle.H"
#include "IOstream.H"
#include "autoPtr.H"
#include "contiguous.H"
......@@ -68,7 +68,7 @@ Ostream& operator<<
template<class ParcelType>
class DsmcParcel
:
public Particle<ParcelType>
public ParcelType
{
public:
......@@ -123,31 +123,22 @@ public:
//- Class used to pass kinematic tracking data to the trackToFace function
class trackData
class trackingData
:
public Particle<ParcelType>::trackData
public particle::TrackingData<DsmcCloud<DsmcParcel<ParcelType> > >
{
// Private data
//- Reference to the cloud containing this particle
DsmcCloud<ParcelType>& cloud_;
public:
// Constructors
//- Construct from components
inline trackData
(
DsmcCloud<ParcelType>& cloud
);
// Member functions
//- Return access to the owner cloud
inline DsmcCloud<ParcelType>& cloud();
trackingData(DsmcCloud<DsmcParcel<ParcelType> >& cloud)
:
particle::TrackingData<DsmcCloud<DsmcParcel<ParcelType> > >
(
cloud
)
{}
};
......@@ -181,7 +172,7 @@ public:
//- Construct from components
inline DsmcParcel
(
DsmcCloud<ParcelType>& owner,
const polyMesh& mesh,
const vector& position,
const vector& U,
const scalar Ei,
......@@ -194,21 +185,41 @@ public:
//- Construct from Istream
DsmcParcel
(
const Cloud<ParcelType>& c,
const polyMesh& mesh,
Istream& is,
bool readFields = true
);
//- Construct and return a clone
virtual autoPtr<Particle<ParcelType> > clone() const
virtual autoPtr<particle> clone() const
{
return autoPtr<Particle<ParcelType> >
(
new DsmcParcel<ParcelType>(*this)
);
return autoPtr<particle>(new DsmcParcel<ParcelType>(*this));
}
//- Factory class to read-construct particles used for
// parallel transfer
class iNew
{
const polyMesh& mesh_;
public:
iNew(const polyMesh& mesh)
:
mesh_(mesh)
{}
autoPtr<DsmcParcel<ParcelType> > operator()(Istream& is) const
{
return autoPtr<DsmcParcel<ParcelType> >
(
new DsmcParcel<ParcelType>(mesh_, is, true)
);
}
};
// Member Functions
// Access
......@@ -263,14 +274,6 @@ public:
TrackData& td
);
//- Overridable function to handle the particle hitting a
// processorPatch without trackData
void hitProcessorPatch
(
const processorPolyPatch&,
int&
);
//- Overridable function to handle the particle hitting a wallPatch
template<class TrackData>
void hitWallPatch
......@@ -280,15 +283,6 @@ public:
const tetIndices&
);
//- Overridable function to handle the particle hitting a wallPatch
// without trackData
void hitWallPatch
(
const wallPolyPatch&,
int&,
const tetIndices&
);
//- Overridable function to handle the particle hitting a polyPatch
template<class TrackData>
void hitPatch
......@@ -297,14 +291,6 @@ public:
TrackData& td
);
//- Overridable function to handle the particle hitting a polyPatch
//- without trackData
void hitPatch
(
const polyPatch&,
int&
);
//- Transform the physical properties of the particle
// according to the given transformation tensor
void transformProperties(const tensor& T);
......@@ -316,9 +302,9 @@ public:
// I-O
static void readFields(Cloud<ParcelType>& c);
static void readFields(Cloud<DsmcParcel<ParcelType> >& c);
static void writeFields(const Cloud<ParcelType>& c);
static void writeFields(const Cloud<DsmcParcel<ParcelType> >& c);
// Ostream Operator
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -27,7 +27,7 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template <class ParcelType>
template<class ParcelType>
inline Foam::DsmcParcel<ParcelType>::constantProperties::constantProperties()
:
mass_(0),
......@@ -35,7 +35,7 @@ inline Foam::DsmcParcel<ParcelType>::constantProperties::constantProperties()
{}
template <class ParcelType>
template<class ParcelType>
inline Foam::DsmcParcel<ParcelType>::constantProperties::constantProperties
(
const dictionary& dict
......@@ -51,21 +51,10 @@ inline Foam::DsmcParcel<ParcelType>::constantProperties::constantProperties
{}
template <class ParcelType>
inline Foam::DsmcParcel<ParcelType>::trackData::trackData
(
DsmcCloud<ParcelType>& cloud
)
:
Particle<ParcelType>::trackData(cloud),
cloud_(cloud)
{}
template <class ParcelType>
template<class ParcelType>
inline Foam::DsmcParcel<ParcelType>::DsmcParcel
(
DsmcCloud<ParcelType>& owner,
const polyMesh& mesh,
const vector& position,
const vector& U,
const scalar Ei,
......@@ -75,7 +64,7 @@ inline Foam::DsmcParcel<ParcelType>::DsmcParcel
const label typeId
)
:
Particle<ParcelType>(owner, position, cellI, tetFaceI, tetPtI),
ParcelType(mesh, position, cellI, tetFaceI, tetPtI),
U_(U),
Ei_(Ei),
typeId_(typeId)
......@@ -84,7 +73,7 @@ inline Foam::DsmcParcel<ParcelType>::DsmcParcel
// * * * * * * * * * constantProperties Member Functions * * * * * * * * * * //
template <class ParcelType>
template<class ParcelType>
inline Foam::scalar
Foam::DsmcParcel<ParcelType>::constantProperties::mass() const
{
......@@ -92,15 +81,14 @@ Foam::DsmcParcel<ParcelType>::constantProperties::mass() const
}
template <class ParcelType>
inline Foam::scalar
Foam::DsmcParcel<ParcelType>::constantProperties::d() const
template<class ParcelType>
inline Foam::scalar Foam::DsmcParcel<ParcelType>::constantProperties::d() const
{
return d_;
}
template <class ParcelType>
template<class ParcelType>
inline Foam::scalar
Foam::DsmcParcel<ParcelType>::constantProperties::sigmaT() const
{
......@@ -108,7 +96,7 @@ Foam::DsmcParcel<ParcelType>::constantProperties::sigmaT() const
}
template <class ParcelType>
template<class ParcelType>
inline Foam::scalar
Foam::DsmcParcel<ParcelType>::constantProperties::internalDegreesOfFreedom()
const
......@@ -117,7 +105,7 @@ const
}
template <class ParcelType>
template<class ParcelType>
inline Foam::scalar
Foam::DsmcParcel<ParcelType>::constantProperties::omega() const
{
......@@ -125,47 +113,37 @@ Foam::DsmcParcel<ParcelType>::constantProperties::omega() const
}
// * * * * * * * * * * * trackData Member Functions * * * * * * * * * * * * //
template <class ParcelType>
inline Foam::DsmcCloud<ParcelType>&
Foam::DsmcParcel<ParcelType>::trackData::cloud()
{
return cloud_;
}
// * * * * * * * * * * DsmcParcel Member Functions * * * * * * * * * * //
template <class ParcelType>
template<class ParcelType>
inline Foam::label Foam::DsmcParcel<ParcelType>::typeId() const
{
return typeId_;
}
template <class ParcelType>
template<class ParcelType>
inline const Foam::vector& Foam::DsmcParcel<ParcelType>::U() const
{
return U_;
}
template <class ParcelType>
template<class ParcelType>
inline Foam::scalar Foam::DsmcParcel<ParcelType>::Ei() const
{
return Ei_;
}
template <class ParcelType>
template<class ParcelType>
inline Foam::vector& Foam::DsmcParcel<ParcelType>::U()
{
return U_;
}
template <class ParcelType>
template<class ParcelType>
inline Foam::scalar& Foam::DsmcParcel<ParcelType>::Ei()
{
return Ei_;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -33,12 +33,12 @@ License
template <class ParcelType>
Foam::DsmcParcel<ParcelType>::DsmcParcel
(
const Cloud<ParcelType>& cloud,
const polyMesh& mesh,
Istream& is,
bool readFields
)
:
Particle<ParcelType>(cloud, is, readFields),
ParcelType(mesh, is, readFields),
U_(vector::zero),
Ei_(0.0),
typeId_(-1)
......@@ -73,14 +73,14 @@ Foam::DsmcParcel<ParcelType>::DsmcParcel
template<class ParcelType>
void Foam::DsmcParcel<ParcelType>::readFields(Cloud<ParcelType>& c)
void Foam::DsmcParcel<ParcelType>::readFields(Cloud<DsmcParcel<ParcelType> >& c)
{
if (!c.size())
{
return;
}
Particle<ParcelType>::readFields(c);
ParcelType::readFields(c);
IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ));
c.checkFieldIOobject(c, U);
......@@ -92,9 +92,9 @@ void Foam::DsmcParcel<ParcelType>::readFields(Cloud<ParcelType>& c)
c.checkFieldIOobject(c, typeId);
label i = 0;
forAllIter(typename Cloud<ParcelType>, c, iter)
forAllIter(typename Cloud<DsmcParcel<ParcelType> >, c, iter)
{
ParcelType& p = iter();
DsmcParcel<ParcelType>& p = iter();
p.U_ = U[i];
p.Ei_ = Ei[i];
......@@ -105,9 +105,12 @@ void Foam::DsmcParcel<ParcelType>::readFields(Cloud<ParcelType>& c)
template<class ParcelType>
void Foam::DsmcParcel<ParcelType>::writeFields(const Cloud<ParcelType>& c)
void Foam::DsmcParcel<ParcelType>::writeFields
(
const Cloud<DsmcParcel<ParcelType> >& c
)
{
Particle<ParcelType>::writeFields(c);
ParcelType::writeFields(c);
label np = c.size();
......@@ -116,7 +119,7 @@ void Foam::DsmcParcel<ParcelType>::writeFields(const Cloud<ParcelType>& c)
IOField<label> typeId(c.fieldIOobject("typeId", IOobject::NO_READ), np);
label i = 0;
forAllConstIter(typename Cloud<ParcelType>, c, iter)
forAllConstIter(typename Cloud<DsmcParcel<ParcelType> >, c, iter)
{
const DsmcParcel<ParcelType>& p = iter();
......@@ -143,14 +146,14 @@ Foam::Ostream& Foam::operator<<
{
if (os.format() == IOstream::ASCII)
{
os << static_cast<const Particle<ParcelType>& >(p)
os << static_cast<const ParcelType& >(p)
<< token::SPACE << p.U()
<< token::SPACE << p.Ei()
<< token::SPACE << p.typeId();
}
else
{
os << static_cast<const Particle<ParcelType>& >(p);
os << static_cast<const ParcelType& >(p);
os.write
(
reinterpret_cast<const char*>(&p.U_),
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,13 +24,13 @@ License
\*---------------------------------------------------------------------------*/
#include "dsmcParcel.H"
#include "DsmcParcel.H"
#include "DsmcCloud.H"
namespace Foam
{
defineTemplateTypeNameAndDebug(DsmcParcel<particle>, 0);
defineTemplateTypeNameAndDebug(Cloud<dsmcParcel>, 0);
defineParcelTypeNameAndDebug(DsmcCloud<dsmcParcel>, 0);
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,14 +24,14 @@ License
\*---------------------------------------------------------------------------*/
#include "dsmcParcel.H"
/*
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(dsmcParcel, 0);
defineParticleTypeNameAndDebug(dsmcParcel, 0);
defineParcelTypeNameAndDebug(dsmcParcel, 0);
// defineTypeNameAndDebug(dsmcParcel, 0);
// defineParticleTypeNameAndDebug(dsmcParcel, 0);
// defineParcelTypeNameAndDebug(dsmcParcel, 0);
}