re-vamped patch interaction - generalised into reflect, stick and escape

This commit is contained in:
andy
2009-10-23 17:54:15 +01:00
parent e12acd7010
commit 7bce90d19e
18 changed files with 562 additions and 122 deletions

View File

@ -47,6 +47,7 @@ $(REACTINGMPPARCEL)/makeBasicReactingMultiphaseParcelSubmodels.C
/* bolt-on models */
submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C
submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C
submodels/Kinematic/PatchInteractionModel/LocalInteraction/patchInteractionData.C
/* data entries */

View File

@ -286,7 +286,13 @@ bool Foam::KinematicParcel<ParcelType>::hitPatch
ParcelType& p = static_cast<ParcelType&>(*this);
td.cloud().postProcessing().postPatch(p, patchI);
return td.cloud().patchInteraction().correct(pp, this->face(), U_);
return td.cloud().patchInteraction().correct
(
pp,
this->face(),
td.keepParticle,
U_
);
}

View File

@ -26,7 +26,7 @@ License
#include "LocalInteraction.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
template <class CloudType>
Foam::label Foam::LocalInteraction<CloudType>::applyToPatch
@ -46,7 +46,7 @@ Foam::label Foam::LocalInteraction<CloudType>::applyToPatch
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
template <class CloudType>
Foam::LocalInteraction<CloudType>::LocalInteraction
@ -62,6 +62,7 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
const polyMesh& mesh = cloud.mesh();
const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
// check that user patches are valid region patches
forAll(patchData_, patchI)
{
const word& patchName = patchData_[patchI].patchName();
@ -70,7 +71,7 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
{
FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)")
<< "Patch " << patchName << " not found. Available patches "
<< "are: " << bMesh.names() << exit(FatalError);
<< "are: " << bMesh.names() << nl << exit(FatalError);
}
}
@ -95,6 +96,26 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
<< "interaction. Please specify data for patches:" << nl
<< badWalls << nl << exit(FatalError);
}
// check that interactions are valid/specified
forAll(patchData_, patchI)
{
const word& interactionTypeName =
patchData_[patchI].interactionTypeName();
const typename PatchInteractionModel<CloudType>::interactionType& it =
this->wordToInteractionType(interactionTypeName);
if (it == PatchInteractionModel<CloudType>::itOther)
{
const word& patchName = patchData_[patchI].patchName();
FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)")
<< "Unknown patch interaction type "
<< interactionTypeName << " for patch " << patchName
<< ". Valid selections are:"
<< this->PatchInteractionModel<CloudType>::interactionTypeNames_
<< nl << exit(FatalError);
}
}
}
@ -105,7 +126,7 @@ Foam::LocalInteraction<CloudType>::~LocalInteraction()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class CloudType>
bool Foam::LocalInteraction<CloudType>::active() const
@ -119,6 +140,7 @@ bool Foam::LocalInteraction<CloudType>::correct
(
const polyPatch& pp,
const label faceId,
bool& keepParticle,
vector& U
) const
{
@ -126,6 +148,30 @@ bool Foam::LocalInteraction<CloudType>::correct
if (patchI >= 0)
{
typename PatchInteractionModel<CloudType>::interactionType it =
this->wordToInteractionType
(
patchData_[patchI].interactionTypeName()
);
switch (it)
{
case PatchInteractionModel<CloudType>::itEscape:
{
keepParticle = false;
U = vector::zero;
break;
}
case PatchInteractionModel<CloudType>::itStick:
{
keepParticle = true;
U = vector::zero;
break;
}
case PatchInteractionModel<CloudType>::itRebound:
{
keepParticle = true;
vector nw = pp.faceAreas()[pp.whichFace(faceId)];
nw /= mag(nw);
@ -139,6 +185,28 @@ bool Foam::LocalInteraction<CloudType>::correct
U -= patchData_[patchI].mu()*Ut;
break;
}
default:
{
FatalErrorIn
(
"bool LocalInteraction<CloudType>::correct"
"("
"const polyPatch&, "
"const label, "
"bool&, "
"vector&"
") const"
) << "Unknown interaction type "
<< patchData_[patchI].interactionTypeName()
<< "(" << it << ") for patch "
<< patchData_[patchI].patchName()
<< ". Valid selections are:" << this->interactionTypeNames_
<< endl << abort(FatalError);
}
}
return true;
}

View File

@ -34,7 +34,7 @@ Description
#define LocalInteraction_H
#include "PatchInteractionModel.H"
#include "dictionaryEntry.H"
#include "patchInteractionData.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,78 +49,6 @@ class LocalInteraction
:
public PatchInteractionModel<CloudType>
{
class patchInteractionData
{
// Private data
//- Patch name
word patchName_;
//- Elasticity coefficient
scalar e_;
//- Restitution coefficient
scalar mu_;
public:
//- Construct null
patchInteractionData()
:
patchName_("unknownPatch"),
e_(0.0),
mu_(0.0)
{}
//- Construct from dictionary
patchInteractionData(const dictionary& dict);
// Member functions
// Access
//- Return const access to the patch name
const word& patchName() const
{
return patchName_;
}
//- Return const access to the elasticity coefficient
scalar e() const
{
return e_;
}
//- Return const access to the restitution coefficient
scalar mu() const
{
return mu_;
}
// I-O
//- Istream operator
friend Istream& operator>>(Istream& is, patchInteractionData& pid)
{
is.check
(
"Istream& operator>>"
"(Istream&, patchInteractionData&)"
);
const dictionaryEntry entry(dictionary::null, is);
pid.patchName_ = entry.keyword();
entry.lookup("e") >> pid.e_;
entry.lookup("mu") >> pid.mu_;
return is;
}
};
// Private data
//- List of participating patches
@ -164,6 +92,7 @@ public:
(
const polyPatch& pp,
const label faceId,
bool& keepParticle,
vector& U
) const;
};

View File

@ -0,0 +1,89 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "patchInteractionData.H"
#include "dictionaryEntry.H"
#include "PatchInteractionModel.H"
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
Foam::patchInteractionData::patchInteractionData()
:
interactionTypeName_("unknownInteractionTypeName"),
patchName_("unknownPatch"),
e_(0.0),
mu_(0.0)
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::word& Foam::patchInteractionData::interactionTypeName() const
{
return interactionTypeName_;
}
const Foam::word& Foam::patchInteractionData::patchName() const
{
return patchName_;
}
Foam::scalar Foam::patchInteractionData::e() const
{
return e_;
}
Foam::scalar Foam::patchInteractionData::mu() const
{
return mu_;
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>
(
Istream& is,
patchInteractionData& pid
)
{
is.check("Istream& operator>>(Istream&, patchInteractionData&)");
const dictionaryEntry entry(dictionary::null, is);
pid.patchName_ = entry.keyword();
entry.lookup("type") >> pid.interactionTypeName_;
pid.e_ = entry.lookupOrDefault<scalar>("e", 1.0);
pid.mu_ = entry.lookupOrDefault<scalar>("mu", 0.0);
return is;
}
// ************************************************************************* //

View File

@ -0,0 +1,157 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::patchInteractionData
Description
Helper class for the LocalInteraction patch interaction model
\*---------------------------------------------------------------------------*/
#ifndef patchInteractionData_H
#define patchInteractionData_H
#include "Istream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class patchInteractionData Declaration
\*---------------------------------------------------------------------------*/
// Forward declaration of classes
class patchInteractionData;
// Forward declaration of friend functions
Istream& operator>>
(
Istream& is,
patchInteractionData& pid
);
class patchInteractionData
{
// Private data
//- Interaction type name
word interactionTypeName_;
//- Patch name
word patchName_;
//- Elasticity coefficient
scalar e_;
//- Restitution coefficient
scalar mu_;
public:
// Constructor
//- Construct null
patchInteractionData();
// Member functions
// Access
//- Return const access to the interaction type name
const word& interactionTypeName() const;
//- Return const access to the patch name
const word& patchName() const;
//- Return const access to the elasticity coefficient
scalar e() const;
//- Return const access to the restitution coefficient
scalar mu() const;
// I-O
//- Istream operator
friend Istream& operator>>
(
Istream& is,
patchInteractionData& pid
);
/* {
is.check
(
"Istream& operator>>"
"(Istream&, patchInteractionData&)"
);
const dictionaryEntry entry(dictionary::null, is);
pid.patchName_ = entry.keyword();
entry.lookup("type") >> pid.interactionTypeName_;
pid.e_ = entry.lookupOrDefault<scalar>("e", 1.0);
pid.mu_ = entry.lookupOrDefault<scalar>("mu", 0.0);
if
(
PatchInteractionModel<CloudType>::wordToInteractionType
(
pid.interactionTypeName_
)
== PatchInteractionModel<CloudType>::itOther)
{
FatalErrorIn
(
"friend Istream& operator>>"
"("
"Istream&, "
"patchInteractionData&"
")"
) << "Unknown patch interaction type "
<< pid.interactionTypeName_
<< ". Valid selections are:"
<< PatchInteractionModel<CloudType>::
interactionTypeNames_
<< endl << abort(FatalError);
}
return is;
}
*/};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -26,6 +26,76 @@ License
#include "PatchInteractionModel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class CloudType>
Foam::wordList Foam::PatchInteractionModel<CloudType>::interactionTypeNames_
(
IStringStream
(
"(rebound stick escape)"
)()
);
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
Foam::word Foam::PatchInteractionModel<CloudType>::interactionTypeToWord
(
const interactionType& itEnum
)
{
switch (itEnum)
{
case itRebound:
{
return "rebound";
break;
}
case itStick:
{
return "stick";
break;
}
case itEscape:
{
return "escape";
break;
}
default:
{
return "other";
}
}
}
template<class CloudType>
typename Foam::PatchInteractionModel<CloudType>::interactionType
Foam::PatchInteractionModel<CloudType>::wordToInteractionType
(
const word& itWord
)
{
if (itWord == "rebound")
{
return itRebound;
}
else if (itWord == "stick")
{
return itStick;
}
else if (itWord == "escape")
{
return itEscape;
}
else
{
return itOther;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>

View File

@ -40,6 +40,7 @@ SourceFiles
#include "IOdictionary.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "polyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -53,6 +54,24 @@ namespace Foam
template<class CloudType>
class PatchInteractionModel
{
public:
// Public enumerations
// Interaction types
enum interactionType
{
itRebound,
itStick,
itEscape,
itOther
};
static wordList interactionTypeNames_;
private:
// Private data
//- The cloud dictionary
@ -121,6 +140,12 @@ public:
// Member Functions
//- Convert interaction result to word
static word interactionTypeToWord(const interactionType& itEnum);
//- Convert word to interaction result
static interactionType wordToInteractionType(const word& itWord);
//- Flag to indicate whether model activates patch interaction model
virtual bool active() const = 0;
@ -130,6 +155,7 @@ public:
(
const polyPatch& pp,
const label faceId,
bool& keepParticle,
vector& U
) const = 0;
};

View File

@ -61,9 +61,12 @@ bool Foam::Rebound<CloudType>::correct
(
const polyPatch& pp,
const label faceId,
bool& keepParticle,
vector& U
) const
{
keepParticle = true;
vector nw = pp.faceAreas()[pp.whichFace(faceId)];
nw /= mag(nw);

View File

@ -82,6 +82,7 @@ public:
(
const polyPatch& pp,
const label faceId,
bool& keepParticle,
vector& U
) const;
};

View File

@ -36,9 +36,45 @@ Foam::StandardWallInteraction<CloudType>::StandardWallInteraction
)
:
PatchInteractionModel<CloudType>(dict, cloud, typeName),
e_(dimensionedScalar(this->coeffDict().lookup("e")).value()),
mu_(dimensionedScalar(this->coeffDict().lookup("mu")).value())
{}
interactionType_
(
this->wordToInteractionType(this->coeffDict().lookup("type"))
),
e_(0.0),
mu_(0.0)
{
switch (interactionType_)
{
case PatchInteractionModel<CloudType>::itOther:
{
word interactionTypeName(this->coeffDict().lookup("type"));
FatalErrorIn
(
"StandardWallInteraction<CloudType>::StandardWallInteraction"
"("
"const dictionary&, "
"CloudType& cloud"
")"
) << "Unknown interaction result type "
<< interactionTypeName
<< ". Valid selections are:" << this->interactionTypeNames_
<< endl << exit(FatalError);
break;
}
case PatchInteractionModel<CloudType>::itRebound:
{
e_ = this->coeffDict().lookupOrDefault("e", 1.0);
mu_ = this->coeffDict().lookupOrDefault("mu", 0.0);
break;
}
default:
{
// do nothing
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -62,11 +98,30 @@ bool Foam::StandardWallInteraction<CloudType>::correct
(
const polyPatch& pp,
const label faceId,
bool& keepParticle,
vector& U
) const
{
if (isA<wallPolyPatch>(pp))
{
switch (interactionType_)
{
case PatchInteractionModel<CloudType>::itEscape:
{
keepParticle = false;
U = vector::zero;
break;
}
case PatchInteractionModel<CloudType>::itStick:
{
keepParticle = true;
U = vector::zero;
break;
}
case PatchInteractionModel<CloudType>::itRebound:
{
keepParticle = true;
vector nw = pp.faceAreas()[pp.whichFace(faceId)];
nw /= mag(nw);
@ -80,6 +135,26 @@ bool Foam::StandardWallInteraction<CloudType>::correct
U -= mu_*Ut;
break;
}
default:
{
FatalErrorIn
(
"bool StandardWallInteraction<CloudType>::correct"
"("
"const polyPatch&, "
"const label, "
"bool&, "
"vector&"
") const"
) << "Unknown interaction type "
<< this->interactionTypeToWord(interactionType_)
<< "(" << interactionType_ << ")" << endl
<< abort(FatalError);
}
}
return true;
}

View File

@ -26,7 +26,19 @@ Class
Foam::StandardWallInteraction
Description
Wall interaction based on restitution and elasticity coefficients
Wall interaction model. Three choices:
- rebound - optionally specify elasticity and resitution coefficients
- stick - particles assigined zero velocity
- escape - remove particle from the domain
Example usage:
StandardWallInteractionCoeffs
{
type rebound; // stick, escape
e 1; // optional - elasticity coeff
mu 0; // optional - restitution coeff
}
\*---------------------------------------------------------------------------*/
@ -48,13 +60,19 @@ class StandardWallInteraction
:
public PatchInteractionModel<CloudType>
{
// Private data
protected:
//- Elasticity
const scalar e_;
// Protected data
//- Interaction type
typename PatchInteractionModel<CloudType>::interactionType
interactionType_;
//- Elasticity coefficient
scalar e_;
//- Restitution coefficient
const scalar mu_;
scalar mu_;
public:
@ -84,6 +102,7 @@ public:
(
const polyPatch& pp,
const label faceId,
bool& keepParticle,
vector& U
) const;
};

View File

@ -107,8 +107,9 @@ ManualInjectionCoeffs
StandardWallInteractionCoeffs
{
e e [ 0 0 0 0 0 ] 1;
mu mu [ 0 0 0 0 0 ] 0;
type rebound;
e 1;
mu 0;
}
RanzMarshallCoeffs

View File

@ -92,8 +92,9 @@ ManualInjectionCoeffs
StandardWallInteractionCoeffs
{
e e [ 0 0 0 0 0 ] 1;
mu mu [ 0 0 0 0 0 ] 0;
type rebound;
e 1;
mu 0;
}
RanzMarshallCoeffs

View File

@ -110,8 +110,7 @@ ReactingLookupTableInjectionCoeffs
StandardWallInteractionCoeffs
{
e e [ 0 0 0 0 0 ] 1;
mu mu [ 0 0 0 0 0 ] 0;
type rebound;
}
LocalInteractionCoeffs
@ -120,13 +119,11 @@ LocalInteractionCoeffs
(
walls
{
e 1;
mu 0;
type rebound;
}
cycLeft
{
e 1;
mu 0;
type rebound;
}
);
}

View File

@ -99,8 +99,7 @@ ManualInjectionCoeffs
StandardWallInteractionCoeffs
{
e e [ 0 0 0 0 0 ] 1;
mu mu [ 0 0 0 0 0 ] 0;
type rebound;
}
RanzMarshallCoeffs

View File

@ -104,8 +104,7 @@ ConeInjectionCoeffs
StandardWallInteractionCoeffs
{
e e [ 0 0 0 0 0 ] 1;
mu mu [ 0 0 0 0 0 ] 0;
type rebound;
}

View File

@ -92,8 +92,7 @@ ManualInjectionCoeffs
StandardWallInteractionCoeffs
{
e e [ 0 0 0 0 0 ] 1;
mu mu [ 0 0 0 0 0 ] 0;
type rebound;
}
RanzMarshallCoeffs