Commit 619d3e24 authored by graham's avatar graham
Browse files

Merge branch 'particleInteractions'

parents 1a2973c4 61978441
......@@ -291,7 +291,10 @@ void Foam::DsmcCloud<ParcelType>::initialise
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::collisions()
{
buildCellOccupancy();
if (!binaryCollision().active())
{
return;
}
// Temporary storage for subCells
List<DynamicList<label> > subCells(8);
......@@ -1057,6 +1060,9 @@ void Foam::DsmcCloud<ParcelType>::evolve()
// Move the particles ballistically with their current velocities
Cloud<ParcelType>::move(td);
// Update cell occupancy
buildCellOccupancy();
// Calculate new velocities via stochastic collisions
collisions();
......
......@@ -25,6 +25,7 @@ License
#include "dsmcParcel.H"
#include "DsmcCloud.H"
#include "NoBinaryCollision.H"
#include "VariableHardSphere.H"
#include "LarsenBorgnakkeVariableHardSphere.H"
......@@ -34,6 +35,12 @@ namespace Foam
// Add instances of collision model to the table
makeBinaryCollisionModelType
(
NoBinaryCollision,
DsmcCloud,
dsmcParcel
);
makeBinaryCollisionModelType
(
VariableHardSphere,
DsmcCloud,
......
......@@ -27,6 +27,15 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::BinaryCollisionModel<CloudType>::BinaryCollisionModel(CloudType& owner)
:
dict_(dictionary::null),
owner_(owner),
coeffDict_(dictionary::null)
{}
template<class CloudType>
Foam::BinaryCollisionModel<CloudType>::BinaryCollisionModel
(
......@@ -87,4 +96,3 @@ Foam::BinaryCollisionModel<CloudType>::coeffDict() const
#include "BinaryCollisionModelNew.C"
// ************************************************************************* //
......@@ -85,6 +85,9 @@ public:
// Constructors
//- Construct null from owner
BinaryCollisionModel(CloudType& owner);
//- Construct from components
BinaryCollisionModel
(
......@@ -123,6 +126,9 @@ public:
// Member Functions
//- Flag to indicate whether model activates collision model
virtual bool active() const = 0;
//- Return the collision cross section * relative velocity product
virtual scalar sigmaTcR
(
......
......@@ -117,6 +117,12 @@ Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
bool Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::active() const
{
return true;
}
template <class CloudType>
Foam::scalar Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::sigmaTcR
......
......@@ -89,6 +89,9 @@ public:
// Member Functions
//- Flag to indicate whether model activates collision model
virtual bool active() const;
//- Return the collision cross section * relative velocity product
virtual scalar sigmaTcR
(
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-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 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 "NoBinaryCollision.H"
#include "constants.H"
using namespace Foam::constant::mathematical;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template <class CloudType>
Foam::NoBinaryCollision<CloudType>::NoBinaryCollision
(
const dictionary& dict,
CloudType& cloud
)
:
BinaryCollisionModel<CloudType>(cloud)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template <class CloudType>
Foam::NoBinaryCollision<CloudType>::~NoBinaryCollision()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
bool Foam::NoBinaryCollision<CloudType>::active() const
{
return false;
}
template <class CloudType>
Foam::scalar Foam::NoBinaryCollision<CloudType>::sigmaTcR
(
label typeIdP,
label typeIdQ,
const vector& UP,
const vector& UQ
) const
{
FatalErrorIn
(
"Foam::scalar Foam::NoBinaryCollision<CloudType>::sigmaTcR"
"("
"label typeIdP,"
"label typeIdQ,"
"const vector& UP,"
"const vector& UQ"
") const"
)
<< "sigmaTcR called on NoBinaryCollision model, this should "
<< "not happen, this is not an actual model." << nl
<< "Enclose calls to sigmaTcR within a if(binaryCollision().active()) "
<< " check."
<< abort(FatalError);
return 0.0;
}
template <class CloudType>
void Foam::NoBinaryCollision<CloudType>::collide
(
label typeIdP,
label typeIdQ,
vector& UP,
vector& UQ,
scalar& EiP,
scalar& EiQ
)
{}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-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 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::NoBinaryCollision
Description
No collison BinaryCollision Model
\*---------------------------------------------------------------------------*/
#ifndef NoBinaryCollision_H
#define NoBinaryCollision_H
#include "BinaryCollisionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class NoBinaryCollision Declaration
\*---------------------------------------------------------------------------*/
template<class CloudType>
class NoBinaryCollision
:
public BinaryCollisionModel<CloudType>
{
public:
//- Runtime type information
TypeName("none");
// Constructors
//- Construct from dictionary
NoBinaryCollision
(
const dictionary& dict,
CloudType& cloud
);
//- Destructor
virtual ~NoBinaryCollision();
// Member Functions
//- Flag to indicate whether model activates collision model
virtual bool active() const;
//- Return the collision cross section * relative velocity product
virtual scalar sigmaTcR
(
label typeIdP,
label typeIdQ,
const vector& UP,
const vector& UQ
) const;
//- Apply collision
virtual void collide
(
label typeIdP,
label typeIdQ,
vector& UP,
vector& UQ,
scalar& EiP,
scalar& EiQ
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "NoBinaryCollision.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -51,6 +51,12 @@ Foam::VariableHardSphere<CloudType>::~VariableHardSphere()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
bool Foam::VariableHardSphere<CloudType>::active() const
{
return true;
}
template <class CloudType>
Foam::scalar Foam::VariableHardSphere<CloudType>::sigmaTcR
......
......@@ -74,6 +74,9 @@ public:
// Member Functions
//- Flag to indicate whether model activates collision model
virtual bool active() const;
//- Return the collision cross section * relative velocity product
virtual scalar sigmaTcR
(
......
......@@ -27,6 +27,15 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::InflowBoundaryModel<CloudType>::InflowBoundaryModel(CloudType& owner)
:
dict_(dictionary::null),
owner_(owner),
coeffDict_(dictionary::null)
{}
template<class CloudType>
Foam::InflowBoundaryModel<CloudType>::InflowBoundaryModel
(
......
......@@ -86,6 +86,9 @@ public:
// Constructors
//- Construct null from owner
InflowBoundaryModel(CloudType& owner);
//- Construct from dictionary
InflowBoundaryModel
(
......
......@@ -34,7 +34,7 @@ Foam::NoInflow<CloudType>::NoInflow
CloudType& cloud
)
:
InflowBoundaryModel<CloudType>(dict, cloud, typeName)
InflowBoundaryModel<CloudType>(cloud)
{}
......
......@@ -50,7 +50,7 @@ class NoInflow
public:
//- Runtime type information
TypeName("NoInflow");
TypeName("none");
// Constructors
......
......@@ -37,7 +37,7 @@ Foam::MaxwellianThermal<CloudType>::MaxwellianThermal
CloudType& cloud
)
:
WallInteractionModel<CloudType>(dict, cloud, typeName)
WallInteractionModel<CloudType>(cloud)
{}
......
......@@ -36,7 +36,7 @@ Foam::SpecularReflection<CloudType>::SpecularReflection
CloudType& cloud
)
:
WallInteractionModel<CloudType>(dict, cloud, typeName)
WallInteractionModel<CloudType>(cloud)
{}
......
......@@ -27,6 +27,15 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::WallInteractionModel<CloudType>::WallInteractionModel(CloudType& owner)
:
dict_(dictionary::null),
owner_(owner),
coeffDict_(dictionary::null)
{}
template<class CloudType>
Foam::WallInteractionModel<CloudType>::WallInteractionModel
(
......
......@@ -85,6 +85,9 @@ public:
// Constructors
//- Construct null from owner
WallInteractionModel(CloudType& owner);
//- Construct from components
WallInteractionModel
(
......
......@@ -28,37 +28,41 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::CollisionRecordList<Type>::CollisionRecordList()
template<class PairType, class WallType>
Foam::CollisionRecordList<PairType, WallType>::CollisionRecordList()
:
DynamicList<CollisionRecord<Type> >()
pairRecords_(),
wallRecords_()
{}
template<class Type>
Foam::CollisionRecordList<Type>::CollisionRecordList(Istream& is)
template<class PairType, class WallType>
Foam::CollisionRecordList<PairType, WallType>::CollisionRecordList(Istream& is)
:
DynamicList<CollisionRecord<Type> >(is)
pairRecords_(is),
wallRecords_(is)
{
// Check state of Istream
is.check
(
"Foam::CollisionRecordList<Type>::CollisionRecordList(Foam::Istream&)"
"Foam::CollisionRecordList<PairType, WallType>::"
"CollisionRecordList(Foam::Istream&)"
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * /
template<class Type>
Foam::CollisionRecordList<Type>::~CollisionRecordList()
template<class PairType, class WallType>
Foam::CollisionRecordList<PairType, WallType>::~CollisionRecordList()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class Type>
Foam::CollisionRecord<Type>& Foam::CollisionRecordList<Type>::matchRecord
template<class PairType, class WallType>
Foam::PairCollisionRecord<PairType>&
Foam::CollisionRecordList<PairType, WallType>::matchPairRecord
(
label origProcOfOther,
label origIdOfOther
......@@ -68,15 +72,15 @@ Foam::CollisionRecord<Type>& Foam::CollisionRecordList<Type>::matchRecord
// identifiers. Two records with the same identification is not
// supported.
forAll(*this, i)
forAll(pairRecords_, i)
{
CollisionRecord<Type>& cR = (*this)[i];
PairCollisionRecord<PairType>& pCR = pairRecords_[i];
if (cR.match(origProcOfOther, origIdOfOther))
if (pCR.match(origProcOfOther, origIdOfOther))
{
cR.setAccessed();
pCR.setAccessed();
return cR;
return pCR;
}
}
......@@ -84,28 +88,179 @@ Foam::CollisionRecord<Type>& Foam::CollisionRecordList<Type>::matchRecord
// member of the list. The status of the record will be accessed
// by construction.
append(CollisionRecord<Type>(origProcOfOther, origIdOfOther));
pairRecords_.append
(
PairCollisionRecord<PairType>(origProcOfOther, origIdOfOther)
);
return pairRecords_.last();
}
template<class PairType, class WallType>
Foam::WallCollisionRecord<WallType>&
Foam::CollisionRecordList<PairType, WallType>::matchWallRecord
(
const vector& pRel,
scalar radius
)
{
// Returning the first record that matches the relative position.
// Two records with the same relative position is not supported.
forAll(wallRecords_, i)
{
WallCollisionRecord<WallType>& wCR = wallRecords_[i];
if (wCR.match(pRel, radius))
{
wCR.setAccessed();
return wCR;
}
}
// Record not found, create a new one and return it as the last
// member of the list. The status of the record will be accessed
// by construction.
return (*this)[this->size() - 1];
wallRecords_.append(WallCollisionRecord<WallType>(pRel));
return wallRecords_.last();
}
template<class Type>
void Foam::CollisionRecordList<Type>::update()
template<class PairType, class WallType>
void Foam::CollisionRecordList<PairType, WallType>::update()
{
DynamicList<CollisionRecord<Type> > updatedRecords;
{
DynamicList<PairCollisionRecord<PairType> > updatedRecords;
forAll(pairRecords_, i)
{
if (pairRecords_[i].accessed())
{
pairRecords_[i].setUnaccessed();