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