Skip to content
Snippets Groups Projects
Commit 936d8977 authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: ConeNozzleInjection - added ability for the injector to move

The set of injectionMethods has been extended to include a new option:

    injectionMethod movingPoint;

The position is then read as a TimeFunction1 entry, e.g. for a 'table'
type:

    position        table
    (
        (0 (-0.009 0.0995 0))
        (1e-3 (0.009 0.0995 0))
    );

where the list corresponds to the tuples (time (position)), and the time
is relative to the start of injection (SOI)
parent a0a039ad
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -30,35 +30,57 @@ License ...@@ -30,35 +30,57 @@ License
using namespace Foam::constant; using namespace Foam::constant;
template<class CloudType>
const Foam::Enum
<
typename Foam::ConeNozzleInjection<CloudType>::injectionMethod
>
Foam::ConeNozzleInjection<CloudType>::injectionMethodNames
{
{ injectionMethod::imPoint, "point" },
{ injectionMethod::imDisc, "disc" },
{ injectionMethod::imMovingPoint, "movingPoint" }
};
template<class CloudType>
const Foam::Enum
<
typename Foam::ConeNozzleInjection<CloudType>::flowType
>
Foam::ConeNozzleInjection<CloudType>::flowTypeNames
{
{ flowType::ftConstantVelocity, "constantVelocity" },
{ flowType::ftPressureDrivenVelocity, "pressureDrivenVelocity" },
{ flowType::ftFlowRateAndDischarge, "flowRateAndDischarge" }
};
// * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
template<class CloudType> template<class CloudType>
void Foam::ConeNozzleInjection<CloudType>::setInjectionMethod() void Foam::ConeNozzleInjection<CloudType>::setInjectionMethod()
{ {
word injectionMethodType = this->coeffDict().lookup("injectionMethod"); switch (injectionMethod_)
if (injectionMethodType == "disc")
{
injectionMethod_ = imDisc;
}
else if (injectionMethodType == "point")
{
injectionMethod_ = imPoint;
// Set/cache the injector cell
this->findCellAtPosition
(
injectorCell_,
tetFacei_,
tetPti_,
position_,
false
);
}
else
{ {
FatalErrorInFunction case injectionMethod::imPoint:
<< "injectionMethod must be either 'point' or 'disc'" case injectionMethod::imDisc:
<< exit(FatalError); {
position_ = this->coeffDict().lookup("position");
break;
}
case injectionMethod::imMovingPoint:
{
positionVsTime_.reset(this->coeffDict());
break;
}
default:
{
FatalErrorInFunction
<< "Unhandled injection method "
<< injectionMethodNames[injectionMethod_]
<< exit(FatalError);
}
} }
} }
...@@ -66,28 +88,30 @@ void Foam::ConeNozzleInjection<CloudType>::setInjectionMethod() ...@@ -66,28 +88,30 @@ void Foam::ConeNozzleInjection<CloudType>::setInjectionMethod()
template<class CloudType> template<class CloudType>
void Foam::ConeNozzleInjection<CloudType>::setFlowType() void Foam::ConeNozzleInjection<CloudType>::setFlowType()
{ {
word flowType = this->coeffDict().lookup("flowType"); switch (flowType_)
if (flowType == "constantVelocity")
{
this->coeffDict().lookup("UMag") >> UMag_;
flowType_ = ftConstantVelocity;
}
else if (flowType == "pressureDrivenVelocity")
{
Pinj_.reset(this->coeffDict());
flowType_ = ftPressureDrivenVelocity;
}
else if (flowType == "flowRateAndDischarge")
{
Cd_.reset(this->coeffDict());
flowType_ = ftFlowRateAndDischarge;
}
else
{ {
FatalErrorInFunction case flowType::ftConstantVelocity:
<< "flowType must be either 'constantVelocity', " {
<<"'pressureDrivenVelocity' or 'flowRateAndDischarge'" this->coeffDict().lookup("UMag") >> UMag_;
<< exit(FatalError); break;
}
case flowType::ftPressureDrivenVelocity:
{
Pinj_.reset(this->coeffDict());
break;
}
case flowType::ftFlowRateAndDischarge:
{
Cd_.reset(this->coeffDict());
break;
}
default:
{
FatalErrorInFunction
<< "Unhandled flow type "
<< flowTypeNames[flowType_]
<< exit(FatalError);
}
} }
} }
...@@ -103,12 +127,16 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection ...@@ -103,12 +127,16 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
) )
: :
InjectionModel<CloudType>(dict, owner, modelName, typeName), InjectionModel<CloudType>(dict, owner, modelName, typeName),
injectionMethod_(imPoint), injectionMethod_
flowType_(ftConstantVelocity), (
injectionMethodNames.lookup("injectionMethod", this->coeffDict())
),
flowType_(flowTypeNames.lookup("flowType", this->coeffDict())),
outerDiameter_(readScalar(this->coeffDict().lookup("outerDiameter"))), outerDiameter_(readScalar(this->coeffDict().lookup("outerDiameter"))),
innerDiameter_(readScalar(this->coeffDict().lookup("innerDiameter"))), innerDiameter_(readScalar(this->coeffDict().lookup("innerDiameter"))),
duration_(readScalar(this->coeffDict().lookup("duration"))), duration_(readScalar(this->coeffDict().lookup("duration"))),
position_(this->coeffDict().lookup("position")), positionVsTime_(owner.db().time(), "position"),
position_(vector::zero),
injectorCell_(-1), injectorCell_(-1),
tetFacei_(-1), tetFacei_(-1),
tetPti_(-1), tetPti_(-1),
...@@ -214,6 +242,7 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection ...@@ -214,6 +242,7 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
outerDiameter_(im.outerDiameter_), outerDiameter_(im.outerDiameter_),
innerDiameter_(im.innerDiameter_), innerDiameter_(im.innerDiameter_),
duration_(im.duration_), duration_(im.duration_),
positionVsTime_(im.positionVsTime_),
position_(im.position_), position_(im.position_),
injectorCell_(im.injectorCell_), injectorCell_(im.injectorCell_),
tetFacei_(im.tetFacei_), tetFacei_(im.tetFacei_),
...@@ -245,10 +274,11 @@ Foam::ConeNozzleInjection<CloudType>::~ConeNozzleInjection() ...@@ -245,10 +274,11 @@ Foam::ConeNozzleInjection<CloudType>::~ConeNozzleInjection()
template<class CloudType> template<class CloudType>
void Foam::ConeNozzleInjection<CloudType>::updateMesh() void Foam::ConeNozzleInjection<CloudType>::updateMesh()
{ {
// Set/cache the injector cells // Set/cache the injector cell info for static methods
switch (injectionMethod_) switch (injectionMethod_)
{ {
case imPoint: case injectionMethod::imPoint:
{ {
this->findCellAtPosition this->findCellAtPosition
( (
...@@ -257,10 +287,11 @@ void Foam::ConeNozzleInjection<CloudType>::updateMesh() ...@@ -257,10 +287,11 @@ void Foam::ConeNozzleInjection<CloudType>::updateMesh()
tetPti_, tetPti_,
position_ position_
); );
break;
} }
default: default:
{ {
// Do nothing // Do nothing for the other methods
} }
} }
} }
...@@ -314,7 +345,7 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell ...@@ -314,7 +345,7 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell
( (
const label, const label,
const label, const label,
const scalar, const scalar time,
vector& position, vector& position,
label& cellOwner, label& cellOwner,
label& tetFacei, label& tetFacei,
...@@ -328,7 +359,7 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell ...@@ -328,7 +359,7 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell
switch (injectionMethod_) switch (injectionMethod_)
{ {
case imPoint: case injectionMethod::imPoint:
{ {
position = position_; position = position_;
cellOwner = injectorCell_; cellOwner = injectorCell_;
...@@ -337,7 +368,21 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell ...@@ -337,7 +368,21 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell
break; break;
} }
case imDisc: case injectionMethod::imMovingPoint:
{
position = positionVsTime_.value(time - this->SOI_);
this->findCellAtPosition
(
cellOwner,
tetFacei,
tetPti,
position
);
break;
}
case injectionMethod::imDisc:
{ {
scalar frac = rndGen.globalSample01<scalar>(); scalar frac = rndGen.globalSample01<scalar>();
scalar dr = outerDiameter_ - innerDiameter_; scalar dr = outerDiameter_ - innerDiameter_;
...@@ -357,8 +402,9 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell ...@@ -357,8 +402,9 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell
default: default:
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown injectionMethod type" << nl << "Unhandled injection method "
<< exit(FatalError); << injectionMethodNames[injectionMethod_]
<< exit(FatalError);
} }
} }
} }
...@@ -394,12 +440,12 @@ void Foam::ConeNozzleInjection<CloudType>::setProperties ...@@ -394,12 +440,12 @@ void Foam::ConeNozzleInjection<CloudType>::setProperties
switch (flowType_) switch (flowType_)
{ {
case ftConstantVelocity: case flowType::ftConstantVelocity:
{ {
parcel.U() = UMag_*dirVec; parcel.U() = UMag_*dirVec;
break; break;
} }
case ftPressureDrivenVelocity: case flowType::ftPressureDrivenVelocity:
{ {
scalar pAmbient = this->owner().pAmbient(); scalar pAmbient = this->owner().pAmbient();
scalar rho = parcel.rho(); scalar rho = parcel.rho();
...@@ -407,7 +453,7 @@ void Foam::ConeNozzleInjection<CloudType>::setProperties ...@@ -407,7 +453,7 @@ void Foam::ConeNozzleInjection<CloudType>::setProperties
parcel.U() = UMag*dirVec; parcel.U() = UMag*dirVec;
break; break;
} }
case ftFlowRateAndDischarge: case flowType::ftFlowRateAndDischarge:
{ {
scalar Ao = 0.25*mathematical::pi*outerDiameter_*outerDiameter_; scalar Ao = 0.25*mathematical::pi*outerDiameter_*outerDiameter_;
scalar Ai = 0.25*mathematical::pi*innerDiameter_*innerDiameter_; scalar Ai = 0.25*mathematical::pi*innerDiameter_*innerDiameter_;
...@@ -422,6 +468,10 @@ void Foam::ConeNozzleInjection<CloudType>::setProperties ...@@ -422,6 +468,10 @@ void Foam::ConeNozzleInjection<CloudType>::setProperties
} }
default: default:
{ {
FatalErrorInFunction
<< "Unhandled injection method "
<< flowTypeNames[flowType_]
<< exit(FatalError);
} }
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -65,6 +65,7 @@ SourceFiles ...@@ -65,6 +65,7 @@ SourceFiles
#define ConeNozzleInjection_H #define ConeNozzleInjection_H
#include "InjectionModel.H" #include "InjectionModel.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...@@ -90,20 +91,25 @@ class ConeNozzleInjection ...@@ -90,20 +91,25 @@ class ConeNozzleInjection
public: public:
//- Injection method enumeration //- Injection method enumeration
enum injectionMethod enum class injectionMethod
{ {
imPoint, imPoint,
imDisc imDisc,
imMovingPoint
}; };
static const Enum<injectionMethod> injectionMethodNames;
//- Flow type enumeration //- Flow type enumeration
enum flowType enum class flowType
{ {
ftConstantVelocity, ftConstantVelocity,
ftPressureDrivenVelocity, ftPressureDrivenVelocity,
ftFlowRateAndDischarge ftFlowRateAndDischarge
}; };
static const Enum<flowType> flowTypeNames;
private: private:
...@@ -124,6 +130,9 @@ private: ...@@ -124,6 +130,9 @@ private:
//- Injection duration [s] //- Injection duration [s]
scalar duration_; scalar duration_;
//- Position relative to SOI []
TimeFunction1<vector> positionVsTime_;
//- Injector position [m] //- Injector position [m]
vector position_; vector position_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment