Commit 218875bf authored by Henry's avatar Henry
Browse files

DSMC: Rationalization and addition of mapping support

parent 5cd0083d
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/lagrangian/dsmc/lnInclude \
-I$(LIB_SRC)/lagrangian/DSMC/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lmeshTools \
-lfiniteVolume \
-llagrangian \
-ldsmc
-lDSMC
......@@ -12,7 +12,7 @@ EXE_LIBS = \
-ldecompositionMethods \
-ldistributed \
-ldistributionModels \
-ldsmc \
-lDSMC \
-ldynamicFvMesh \
-ldynamicMesh \
-ledgeMesh \
......
......@@ -3,7 +3,7 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/postProcessing/functionObjects/utilities/lnInclude \
-I$(LIB_SRC)/lagrangian/dsmc/lnInclude \
-I$(LIB_SRC)/lagrangian/DSMC/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
......@@ -12,5 +12,4 @@ EXE_LIBS = \
-lfiniteVolume \
-lutilityFunctionObjects \
-llagrangian \
-ldsmc
-lDSMC
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/lagrangian/dsmc/lnInclude \
-I$(LIB_SRC)/lagrangian/DSMC/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lmeshTools \
-lfiniteVolume \
-llagrangian \
-ldsmc
-lDSMC
......@@ -12,7 +12,7 @@ wmake $targetType solidParticle
wmake $targetType intermediate
wmake $targetType turbulence
wmake $targetType spray
wmake $targetType dsmc
wmake $targetType DSMC
wmake $targetType coalCombustion
molecularDynamics/Allwmake $targetType $*
......
/* Parcels */
parcels/derived/dsmcParcel/dsmcParcel.C
/* Cloud base classes */
clouds/baseClasses/DSMCBaseCloud/DSMCBaseCloud.C
/* Sub-models */
parcels/derived/dsmcParcel/defineDSMCParcel.C
parcels/derived/dsmcParcel/makeDSMCParcelBinaryCollisionModels.C
parcels/derived/dsmcParcel/makeDSMCParcelWallInteractionModels.C
parcels/derived/dsmcParcel/makeDSMCParcelInflowBoundaryModels.C
LIB = $(FOAM_LIBBIN)/libDSMC
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "DsmcCloud.H"
#include "DSMCCloud.H"
#include "BinaryCollisionModel.H"
#include "WallInteractionModel.H"
#include "InflowBoundaryModel.H"
......@@ -33,11 +33,10 @@ License
using namespace Foam::constant;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::buildConstProps()
void Foam::DSMCCloud<ParcelType>::buildConstProps()
{
Info<< nl << "Constructing constant properties for" << endl;
constProps_.setSize(typeIdList_.size());
......@@ -62,14 +61,14 @@ void Foam::DsmcCloud<ParcelType>::buildConstProps()
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::buildCellOccupancy()
void Foam::DSMCCloud<ParcelType>::buildCellOccupancy()
{
forAll(cellOccupancy_, cO)
{
cellOccupancy_[cO].clear();
}
forAllIter(typename DsmcCloud<ParcelType>, *this, iter)
forAllIter(typename DSMCCloud<ParcelType>, *this, iter)
{
cellOccupancy_[iter().cell()].append(&iter());
}
......@@ -77,7 +76,7 @@ void Foam::DsmcCloud<ParcelType>::buildCellOccupancy()
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::initialise
void Foam::DSMCCloud<ParcelType>::initialise
(
const IOdictionary& dsmcInitialiseDict
)
......@@ -134,7 +133,7 @@ void Foam::DsmcCloud<ParcelType>::initialise
if (typeId == -1)
{
FatalErrorIn("Foam::DsmcCloud<ParcelType>::initialise")
FatalErrorIn("Foam::DSMCCloud<ParcelType>::initialise")
<< "typeId " << moleculeName << "not defined." << nl
<< abort(FatalError);
}
......@@ -216,7 +215,7 @@ void Foam::DsmcCloud<ParcelType>::initialise
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::collisions()
void Foam::DSMCCloud<ParcelType>::collisions()
{
if (!binaryCollision().active())
{
......@@ -395,7 +394,7 @@ void Foam::DsmcCloud<ParcelType>::collisions()
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::resetFields()
void Foam::DSMCCloud<ParcelType>::resetFields()
{
q_ = dimensionedScalar("zero", dimensionSet(1, 0, -3, 0, 0), 0.0);
......@@ -428,7 +427,7 @@ void Foam::DsmcCloud<ParcelType>::resetFields()
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::calculateFields()
void Foam::DSMCCloud<ParcelType>::calculateFields()
{
scalarField& rhoN = rhoN_.internalField();
......@@ -444,7 +443,7 @@ void Foam::DsmcCloud<ParcelType>::calculateFields()
vectorField& momentum = momentum_.internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
forAllConstIter(typename DSMCCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
......@@ -489,7 +488,7 @@ void Foam::DsmcCloud<ParcelType>::calculateFields()
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::addNewParcel
void Foam::DSMCCloud<ParcelType>::addNewParcel
(
const vector& position,
const vector& U,
......@@ -519,7 +518,7 @@ void Foam::DsmcCloud<ParcelType>::addNewParcel
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ParcelType>
Foam::DsmcCloud<ParcelType>::DsmcCloud
Foam::DSMCCloud<ParcelType>::DSMCCloud
(
const word& cloudName,
const fvMesh& mesh,
......@@ -527,7 +526,7 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
)
:
Cloud<ParcelType>(mesh, cloudName, false),
DsmcBaseCloud(),
DSMCBaseCloud(),
cloudName_(cloudName),
mesh_(mesh),
particleProperties_
......@@ -556,7 +555,17 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
),
mesh_
),
collisionSelectionRemainder_(mesh_.nCells(), 0),
collisionSelectionRemainder_
(
IOobject
(
this->name() + ":collisionSelectionRemainder",
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar("collisionSelectionRemainder", dimless, 0)
),
q_
(
IOobject
......@@ -699,7 +708,7 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
),
binaryCollisionModel_
(
BinaryCollisionModel<DsmcCloud<ParcelType> >::New
BinaryCollisionModel<DSMCCloud<ParcelType> >::New
(
particleProperties_,
*this
......@@ -707,7 +716,7 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
),
wallInteractionModel_
(
WallInteractionModel<DsmcCloud<ParcelType> >::New
WallInteractionModel<DSMCCloud<ParcelType> >::New
(
particleProperties_,
*this
......@@ -715,7 +724,7 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
),
inflowBoundaryModel_
(
InflowBoundaryModel<DsmcCloud<ParcelType> >::New
InflowBoundaryModel<DSMCCloud<ParcelType> >::New
(
particleProperties_,
*this
......@@ -741,7 +750,7 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
template<class ParcelType>
Foam::DsmcCloud<ParcelType>::DsmcCloud
Foam::DSMCCloud<ParcelType>::DSMCCloud
(
const word& cloudName,
const fvMesh& mesh,
......@@ -749,7 +758,7 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
)
:
Cloud<ParcelType>(mesh, cloudName, false),
DsmcBaseCloud(),
DSMCBaseCloud(),
cloudName_(cloudName),
mesh_(mesh),
particleProperties_
......@@ -780,7 +789,17 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
dimensionedScalar("zero", dimensionSet(0, 3, -1, 0, 0), 0.0),
zeroGradientFvPatchScalarField::typeName
),
collisionSelectionRemainder_(),
collisionSelectionRemainder_
(
IOobject
(
this->name() + ":collisionSelectionRemainder",
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar("collisionSelectionRemainder", dimless, 0)
),
q_
(
IOobject
......@@ -962,14 +981,14 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ParcelType>
Foam::DsmcCloud<ParcelType>::~DsmcCloud()
Foam::DSMCCloud<ParcelType>::~DSMCCloud()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::evolve()
void Foam::DSMCCloud<ParcelType>::evolve()
{
typename ParcelType::trackingData td(*this);
......@@ -999,12 +1018,12 @@ void Foam::DsmcCloud<ParcelType>::evolve()
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::info() const
void Foam::DSMCCloud<ParcelType>::info() const
{
label nDsmcParticles = this->size();
reduce(nDsmcParticles, sumOp<label>());
label nDSMCParticles = this->size();
reduce(nDSMCParticles, sumOp<label>());
scalar nMol = nDsmcParticles*nParticle_;
scalar nMol = nDSMCParticles*nParticle_;
vector linearMomentum = linearMomentumOfSystem();
reduce(linearMomentum, sumOp<vector>());
......@@ -1017,10 +1036,10 @@ void Foam::DsmcCloud<ParcelType>::info() const
Info<< "Cloud name: " << this->name() << nl
<< " Number of dsmc particles = "
<< nDsmcParticles
<< nDSMCParticles
<< endl;
if (nDsmcParticles)
if (nDSMCParticles)
{
Info<< " Number of molecules = "
<< nMol << nl
......@@ -1042,7 +1061,7 @@ void Foam::DsmcCloud<ParcelType>::info() const
template<class ParcelType>
Foam::vector Foam::DsmcCloud<ParcelType>::equipartitionLinearVelocity
Foam::vector Foam::DSMCCloud<ParcelType>::equipartitionLinearVelocity
(
scalar temperature,
scalar mass
......@@ -1060,7 +1079,7 @@ Foam::vector Foam::DsmcCloud<ParcelType>::equipartitionLinearVelocity
template<class ParcelType>
Foam::scalar Foam::DsmcCloud<ParcelType>::equipartitionInternalEnergy
Foam::scalar Foam::DSMCCloud<ParcelType>::equipartitionInternalEnergy
(
scalar temperature,
scalar iDof
......@@ -1101,7 +1120,7 @@ Foam::scalar Foam::DsmcCloud<ParcelType>::equipartitionInternalEnergy
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::dumpParticlePositions() const
void Foam::DSMCCloud<ParcelType>::dumpParticlePositions() const
{
OFstream pObj
(
......@@ -1110,7 +1129,7 @@ void Foam::DsmcCloud<ParcelType>::dumpParticlePositions() const
+ this->db().time().timeName() + ".obj"
);
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
forAllConstIter(typename DSMCCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
......@@ -1124,4 +1143,20 @@ void Foam::DsmcCloud<ParcelType>::dumpParticlePositions() const
}
template<class ParcelType>
void Foam::DSMCCloud<ParcelType>::autoMap(const mapPolyMesh& mapper)
{
typedef typename ParcelType::trackingData tdType;
tdType td(*this);
Cloud<ParcelType>::template autoMap<tdType>(td, mapper);
// Update the cell occupancy field
cellOccupancy_.setSize(mesh_.nCells());
buildCellOccupancy();
// Update the inflow BCs
this->inflowBoundary().autoMap(mapper);
}
// ************************************************************************* //
......@@ -22,22 +22,22 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::DsmcCloud
Foam::DSMCCloud
Description
Templated base class for dsmc cloud
SourceFiles
DsmcCloudI.H
DsmcCloud.C
DSMCCloudI.H
DSMCCloud.C
\*---------------------------------------------------------------------------*/
#ifndef DsmcCloud_H
#define DsmcCloud_H
#ifndef DSMCCloud_H
#define DSMCCloud_H
#include "Cloud.H"
#include "DsmcBaseCloud.H"
#include "DSMCBaseCloud.H"
#include "IOdictionary.H"
#include "autoPtr.H"
#include "Random.H"
......@@ -62,14 +62,14 @@ template<class CloudType>
class InflowBoundaryModel;
/*---------------------------------------------------------------------------*\
Class DsmcCloud Declaration
Class DSMCCloud Declaration
\*---------------------------------------------------------------------------*/
template<class ParcelType>
class DsmcCloud
class DSMCCloud
:
public Cloud<ParcelType>,
public DsmcBaseCloud
public DSMCBaseCloud
{
// Private data
......@@ -101,7 +101,7 @@ class DsmcCloud
volScalarField sigmaTcRMax_;
//- A field holding the remainder from the previous collision selections
scalarField collisionSelectionRemainder_;
DimensionedField<scalar, volMesh> collisionSelectionRemainder_;
//- Heat flux at surface field
volScalarField q_;
......@@ -149,15 +149,15 @@ class DsmcCloud
// References to the cloud sub-models
//- Binary collision model
autoPtr<BinaryCollisionModel<DsmcCloud<ParcelType> > >
autoPtr<BinaryCollisionModel<DSMCCloud<ParcelType> > >
binaryCollisionModel_;
//- Wall interaction model
autoPtr<WallInteractionModel<DsmcCloud<ParcelType> > >
autoPtr<WallInteractionModel<DSMCCloud<ParcelType> > >
wallInteractionModel_;
//- Inflow boundary model
autoPtr<InflowBoundaryModel<DsmcCloud<ParcelType> > >
autoPtr<InflowBoundaryModel<DSMCCloud<ParcelType> > >
inflowBoundaryModel_;
......@@ -182,10 +182,10 @@ class DsmcCloud
void calculateFields();
//- Disallow default bitwise copy construct
DsmcCloud(const DsmcCloud&);
DSMCCloud(const DSMCCloud&);
//- Disallow default bitwise assignment
void operator=(const DsmcCloud&);
void operator=(const DSMCCloud&);
public:
......@@ -194,7 +194,7 @@ public:
//- Construct given name and mesh, will read Parcels and fields from
// file
DsmcCloud
DSMCCloud
(
const word& cloudName,
const fvMesh& mesh,
......@@ -202,7 +202,7 @@ public:
);
//- Construct given name, mesh and initialisation dictionary.
DsmcCloud
DSMCCloud
(
const word& cloudName,
const fvMesh& mesh,
......@@ -211,7 +211,7 @@ public:
//- Destructor
virtual ~DsmcCloud();
virtual ~DSMCCloud();
//- Type of parcel the cloud was instantiated for
......@@ -398,27 +398,27 @@ public:
// Sub-models
//- Return reference to binary elastic collision model
inline const BinaryCollisionModel<DsmcCloud<ParcelType> >&
inline const BinaryCollisionModel<DSMCCloud<ParcelType> >&
binaryCollision() const;
//- Return non-const reference to binary elastic collision model
inline BinaryCollisionModel<DsmcCloud<ParcelType> >&
inline BinaryCollisionModel<DSMCCloud<ParcelType> >&
binaryCollision();
//- Return reference to wall interaction model
inline const WallInteractionModel<DsmcCloud<ParcelType> >&
inline const WallInteractionModel<DSMCCloud<ParcelType> >&
wallInteraction() const;
//- Return non-const reference to wall interaction model
inline WallInteractionModel<DsmcCloud<ParcelType> >&
inline WallInteractionModel<DSMCCloud<ParcelType> >&
wallInteraction();
//- Return reference to wall interaction model
inline const InflowBoundaryModel<DsmcCloud<ParcelType> >&
inline const InflowBoundaryModel<DSMCCloud<ParcelType> >&
inflowBoundary() const;
//- Return non-const reference to wall interaction model
inline InflowBoundaryModel<DsmcCloud<ParcelType> >&
inline InflowBoundaryModel<DSMCCloud<ParcelType> >&
inflowBoundary();
......@@ -464,6 +464,12 @@ public:
//- Clear the Cloud
inline void clear();
// Mapping
//- Remap the particles to the correct cells following mesh change
virtual void autoMap(const mapPolyMesh&);
};
......@@ -473,12 +479,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "DsmcCloudI.H"
#include "DSMCCloudI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "DsmcCloud.C"
# include "DSMCCloud.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -31,14 +31,14 @@ using namespace Foam::constant::mathematical;
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ParcelType>
inline const Foam::word& Foam::DsmcCloud<ParcelType>::cloudName() const
inline const Foam::word& Foam::DSMCCloud<ParcelType>::cloudName() const
{
return cloudName_;
}
template<class ParcelType>
inline const Foam::fvMesh& Foam::DsmcCloud<ParcelType>::mesh() const
inline const Foam::fvMesh& Foam::DSMCCloud<ParcelType>::mesh() const
{
return mesh_;
}
......@@ -46,7 +46,7 @@ inline const Foam::fvMesh& Foam::DsmcCloud<ParcelType>::mesh() const
template<class ParcelType>
inline const Foam::IOdictionary&
Foam::DsmcCloud<ParcelType>::particleProperties() const
Foam::DSMCCloud<ParcelType>::particleProperties() const
{
return particleProperties_;
}
......@@ -54,14 +54,14 @@ Foam::DsmcCloud<ParcelType>::particleProperties() const
template<class ParcelType>
inline const Foam::List<Foam::word>&
Foam::DsmcCloud<ParcelType>::typeIdList() const
Foam::DSMCCloud<ParcelType>::typeIdList() const
{
return typeIdList_;
}
template<class ParcelType>
inline Foam::scalar Foam::DsmcCloud<ParcelType>::nParticle() const
inline Foam::scalar Foam::DSMCCloud<ParcelType>::nParticle() const
{
return nParticle_;
}
......@@ -69,14 +69,14 @@ inline Foam::scalar Foam::DsmcCloud<ParcelType>::nParticle() const
template<class ParcelType>
inline const Foam::List<Foam::DynamicList<ParcelType*> >&
Foam::DsmcCloud<ParcelType>::cellOccupancy() const
Foam::DSMCCloud<ParcelType>::cellOccupancy() const
{