Commit c754c1cc authored by Andrew Heather's avatar Andrew Heather Committed by Andrew Heather
Browse files

ENH: ConeNozzleInjection - enabled direction to change as f(time)

- Now only has the options 'point' and 'disk' (deprecated movingPoint)
  - moving state is based on the type of Function1

- The position and direction entries are Function1-types, e.g. for the 'table'
  type the entries could be:

        position        table
        (
            (  0 (0.1 0.5 0.5))
            (0.2 (0.5 0.9 0.5))
            (0.4 (0.9 0.5 0.5))
            (0.6 (0.5 0.1 0.5))

            (0.8 (0.5 0.5 0.9))
            (1.0 (0.5 0.9 0.5))
            (1.2 (0.5 0.5 0.1))
            (1.4 (0.5 0.1 0.5))

            (1.6 (0.1 0.5 0.5))
            (1.8 (0.5 0.5 0.9))
            (2.0 (0.9 0.5 0.5))
            (2.2 (0.5 0.5 0.1))
        );

        direction       table
        (
            (  0 ( 1  0  0))
            (0.2 ( 0 -1  0))
            (0.4 (-1  0  0))
            (0.6 ( 0  1  0))

            (0.8 ( 0  0 -1))
            (1.0 ( 0 -1  0))
            (1.2 ( 0  0  1))
            (1.4 ( 0  1  0))

            (1.6 ( 1  0  0))
            (1.8 ( 0  0 -1))
            (2.0 (-1  0  0))
            (2.2 ( 0  0  1))
        );
parent 0260643c
......@@ -43,7 +43,6 @@ Foam::ConeNozzleInjection<CloudType>::injectionMethodNames
({
{ injectionMethod::imPoint, "point" },
{ injectionMethod::imDisc, "disc" },
{ injectionMethod::imMovingPoint, "movingPoint" },
});
template<class CloudType>
......@@ -62,37 +61,52 @@ Foam::ConeNozzleInjection<CloudType>::flowTypeNames
// * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::ConeNozzleInjection<CloudType>::setInjectionMethod()
void Foam::ConeNozzleInjection<CloudType>::setInjectionGeometry()
{
switch (injectionMethod_)
const auto& mesh = this->owner().mesh();
// Position
positionVsTime_.reset
(
Function1<vector>::New("position", this->coeffDict(), &mesh)
);
positionVsTime_->userTimeToTime(this->owner().time());
if (positionVsTime_->constant())
{
case injectionMethod::imPoint:
case injectionMethod::imDisc:
{
this->coeffDict().readEntry("position", position_);
break;
}
case injectionMethod::imMovingPoint:
{
positionVsTime_.reset
(
Function1<vector>::New
(
"position",
this->coeffDict(),
&this->owner().mesh()
)
);
positionVsTime_->userTimeToTime(this->owner().time());
break;
}
default:
position_ = positionVsTime_->value(0);
}
// Direction
directionVsTime_.reset
(
Function1<vector>::New("direction", this->coeffDict(), &mesh)
);
directionVsTime_->userTimeToTime(this->owner().time());
if (directionVsTime_->constant())
{
direction_ = directionVsTime_->value(0);
direction_.normalise();
Random& rndGen = this->owner().rndGen();
// Determine direction vectors tangential to direction
vector tangent = Zero;
scalar magTangent = 0.0;
while(magTangent < SMALL)
{
FatalErrorInFunction
<< "Unhandled injection method "
<< injectionMethodNames[injectionMethod_]
<< exit(FatalError);
vector v = rndGen.globalSample01<vector>();
tangent = v - (v & direction_)*direction_;
magTangent = mag(tangent);
}
tanVec1_ = tangent/magTangent;
tanVec2_ = direction_^tanVec1_;
}
}
......@@ -170,7 +184,8 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
injectorCell_(-1),
tetFacei_(-1),
tetPti_(-1),
direction_(this->coeffDict().lookup("direction")),
directionVsTime_(nullptr),
direction_(Zero),
parcelsPerSecond_(this->coeffDict().getScalar("parcelsPerSecond")),
flowRateProfile_
(
......@@ -231,29 +246,10 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
thetaInner_->userTimeToTime(time);
thetaOuter_->userTimeToTime(time);
setInjectionMethod();
setInjectionGeometry();
setFlowType();
Random& rndGen = this->owner().rndGen();
// Normalise direction vector
direction_.normalise();
// Determine direction vectors tangential to direction
vector tangent = Zero;
scalar magTangent = 0.0;
while(magTangent < SMALL)
{
vector v = rndGen.globalSample01<vector>();
tangent = v - (v & direction_)*direction_;
magTangent = mag(tangent);
}
tanVec1_ = tangent/magTangent;
tanVec2_ = direction_^tanVec1_;
// Set total volume to inject
this->volumeTotal_ = flowRateProfile_->integrate(0.0, duration_);
......@@ -279,6 +275,7 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
injectorCell_(im.injectorCell_),
tetFacei_(im.tetFacei_),
tetPti_(im.tetPti_),
directionVsTime_(im.directionVsTime_.clone()),
direction_(im.direction_),
parcelsPerSecond_(im.parcelsPerSecond_),
flowRateProfile_(im.flowRateProfile_.clone()),
......@@ -294,37 +291,23 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::ConeNozzleInjection<CloudType>::~ConeNozzleInjection()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::ConeNozzleInjection<CloudType>::updateMesh()
{
// Set/cache the injector cell info for static methods
switch (injectionMethod_)
if (positionVsTime_->constant())
{
case injectionMethod::imPoint:
{
this->findCellAtPosition
(
injectorCell_,
tetFacei_,
tetPti_,
position_
);
break;
}
default:
{
// Do nothing for the other methods
}
position_ = positionVsTime_->value(0);
this->findCellAtPosition
(
injectorCell_,
tetFacei_,
tetPti_,
position_
);
}
}
......@@ -381,6 +364,28 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell
)
{
Random& rndGen = this->owner().rndGen();
const scalar t = time - this->SOI_;
if (!directionVsTime_->constant())
{
direction_ = directionVsTime_->value(t);
direction_.normalise();
// Determine direction vectors tangential to direction
vector tangent = Zero;
scalar magTangent = 0.0;
while(magTangent < SMALL)
{
vector v = rndGen.globalSample01<vector>();
tangent = v - (v & direction_)*direction_;
magTangent = mag(tangent);
}
tanVec1_ = tangent/magTangent;
tanVec2_ = direction_^tanVec1_;
}
scalar beta = mathematical::twoPi*rndGen.globalSample01<scalar>();
normal_ = tanVec1_*cos(beta) + tanVec2_*sin(beta);
......@@ -389,25 +394,25 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell
{
case injectionMethod::imPoint:
{
position = position_;
cellOwner = injectorCell_;
tetFacei = tetFacei_;
tetPti = tetPti_;
break;
}
case injectionMethod::imMovingPoint:
{
position = positionVsTime_->value(time - this->SOI_);
this->findCellAtPosition
(
cellOwner,
tetFacei,
tetPti,
position
);
if (positionVsTime_->constant())
{
position = position_;
cellOwner = injectorCell_;
tetFacei = tetFacei_;
tetPti = tetPti_;
}
else
{
position = positionVsTime_->value(t);
this->findCellAtPosition
(
cellOwner,
tetFacei,
tetPti,
position
);
}
break;
}
case injectionMethod::imDisc:
......@@ -416,7 +421,7 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell
scalar dr = outerDiameter_ - innerDiameter_;
scalar r = 0.5*(innerDiameter_ + frac*dr);
position = position_ + r*normal_;
position = positionVsTime_->value(t) + r*normal_;
this->findCellAtPosition
(
......
......@@ -97,8 +97,7 @@ public:
enum class injectionMethod
{
imPoint,
imDisc,
imMovingPoint
imDisc
};
static const Enum<injectionMethod> injectionMethodNames;
......@@ -136,19 +135,22 @@ private:
//- Position relative to SOI []
autoPtr<Function1<vector>> positionVsTime_;
//- Injector position [m]
//- Static injector - position [m]
vector position_;
//- Cell containing injector position []
//- Static injector - cell containing injector position []
label injectorCell_;
//- Index of tet face for injector cell
//- Static injector - index of tet face for injector cell
label tetFacei_;
//- Index of tet point for injector cell
//- Static injector - index of tet point for injector cell
label tetPti_;
//- Injector direction []
autoPtr<Function1<vector>> directionVsTime_;
//- Cached direction vector
vector direction_;
//- Number of parcels to introduce per second []
......@@ -193,8 +195,8 @@ private:
// Private Member Functions
//- Set the injection type
void setInjectionMethod();
//- Set the injection position and direction
void setInjectionGeometry();
//- Set the injection flow type
void setFlowType();
......@@ -230,7 +232,7 @@ public:
//- Destructor
virtual ~ConeNozzleInjection();
virtual ~ConeNozzleInjection() = default;
// Member Functions
......
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