Skip to content
Permalink
Browse files

ConeInjection: Added support for time-varying position and direction

The position and direction of cone injection sites can now be specified
using Function1 to make them change in time, relative to the start of
injection.

An example specification of the relevant entries is shown below.

    injectionModels
    {
        injection1
        {
            type            coneInjection;
            position        table
            (
                (0 (-0.1 -0.1 0))
                (0.25 (0.1 -0.1 0))
                (0.5 (0.1 0.1 0))
                (0.75 (-0.1 0.1 0))
                (1 (-0.1 -0.1 0))
            );
            direction       table
            (
                (0 (-1 -1 0))
                (0.25 (1 -1 0))
                (0.5 (1 1 0))
                (0.75 (-1 1 0))
                (1 (-1 -1 0))
            );
            outOfBounds     repeat;

            // etc ...
        }
    }

Sub-dictionaries can also be used if the keywords of parameters of the
two functions collide:

    injectionModels
    {
        injection1
        {
            type            coneInjection;
            position        tableFile;
            positionCoeffs
            {
                file            "constant/injection1.positions";
                outOfBounds     clamp;
            }
            direction       tableFile;
            directionCoeffs
            {
                file            "constant/injection1.directions";
                outOfBounds     repeat;
            }

            // etc ...
        }
    }

A check is also done to determine whether a constant function is in use
on a stationary mesh, in order to prevent repeated searching for the
same position, and therefore retain approximately the efficiency of the
previous implementation in simple cases.
  • Loading branch information...
Will Bainbridge
Will Bainbridge committed Nov 30, 2018
1 parent f31a675 commit b785c988c6abc1580da24b2ed39d482791ab0c0c
@@ -25,6 +25,7 @@ License

#include "ConeInjection.H"
#include "TimeFunction1.H"
#include "Constant.H"
#include "mathematicalConstants.H"
#include "unitConversion.H"

@@ -118,8 +119,25 @@ Foam::ConeInjection<CloudType>::ConeInjection
InjectionModel<CloudType>(dict, owner, modelName, typeName),
injectionMethod_(imPoint),
flowType_(ftConstantVelocity),
position_(this->coeffDict().lookup("position")),
direction_(this->coeffDict().lookup("direction")),
position_
(
TimeFunction1<vector>
(
owner.db().time(),
"position",
this->coeffDict()
)
),
positionIsConstant_(isA<Function1Types::Constant<vector>>(position_)),
direction_
(
TimeFunction1<vector>
(
owner.db().time(),
"direction",
this->coeffDict()
)
),
injectorCell_(-1),
injectorTetFace_(-1),
injectorTetPt_(-1),
@@ -162,8 +180,6 @@ Foam::ConeInjection<CloudType>::ConeInjection
this->coeffDict().subDict("sizeDistribution"), owner.rndGen()
)
),
tanVec1_(vector::max),
tanVec2_(vector::max),
dInner_(vGreat),
dOuter_(vGreat),
Umag_(owner.db().time(), "Umag"),
@@ -176,12 +192,6 @@ Foam::ConeInjection<CloudType>::ConeInjection

setFlowType();

// Normalise direction vector and determine direction vectors
// tangential to injector direction
direction_ /= mag(direction_);
tanVec1_ = normalised(perpendicular(direction_));
tanVec2_ = normalised(direction_^tanVec1_);

// Set total volume to inject
this->volumeTotal_ = flowRateProfile_.integrate(0, duration_);

@@ -199,6 +209,7 @@ Foam::ConeInjection<CloudType>::ConeInjection
injectionMethod_(im.injectionMethod_),
flowType_(im.flowType_),
position_(im.position_),
positionIsConstant_(im.positionIsConstant_),
direction_(im.direction_),
injectorCell_(im.injectorCell_),
injectorTetFace_(im.injectorTetFace_),
@@ -209,8 +220,6 @@ Foam::ConeInjection<CloudType>::ConeInjection
thetaInner_(im.thetaInner_),
thetaOuter_(im.thetaOuter_),
sizeDistribution_(im.sizeDistribution_().clone().ptr()),
tanVec1_(im.tanVec1_),
tanVec2_(im.tanVec2_),
dInner_(im.dInner_),
dOuter_(im.dOuter_),
Umag_(im.Umag_),
@@ -231,24 +240,16 @@ Foam::ConeInjection<CloudType>::~ConeInjection()
template<class CloudType>
void Foam::ConeInjection<CloudType>::updateMesh()
{
// Set/cache the injector cells
switch (injectionMethod_)
if (injectionMethod_ == imPoint && positionIsConstant_)
{
case imPoint:
{
this->findCellAtPosition
(
injectorCell_,
injectorTetFace_,
injectorTetPt_,
position_
);
break;
}
default:
{
break;
}
vector position = position_.value(0);
this->findCellAtPosition
(
injectorCell_,
injectorTetFace_,
injectorTetPt_,
position
);
}
}

@@ -305,7 +306,7 @@ void Foam::ConeInjection<CloudType>::setPositionAndCell
(
const label parcelI,
const label,
const scalar,
const scalar time,
vector& position,
label& cellOwner,
label& tetFacei,
@@ -314,23 +315,42 @@ void Foam::ConeInjection<CloudType>::setPositionAndCell
{
Random& rndGen = this->owner().rndGen();

const scalar t = time - this->SOI_;

switch (injectionMethod_)
{
case imPoint:
{
position = position_;
cellOwner = injectorCell_;
tetFacei = injectorTetFace_;
tetPti = injectorTetPt_;
position = position_.value(t);
if (positionIsConstant_)
{
cellOwner = injectorCell_;
tetFacei = injectorTetFace_;
tetPti = injectorTetPt_;
}
else
{
this->findCellAtPosition
(
cellOwner,
tetFacei,
tetPti,
position,
false
);
}
break;
}
case imDisc:
{
const scalar beta = twoPi*rndGen.globalScalar01();
const scalar frac = rndGen.globalScalar01();
const vector tanVec = tanVec1_*cos(beta) + tanVec2_*sin(beta);
const vector n = normalised(direction_.value(t));
const vector t1 = normalised(perpendicular(n));
const vector t2 = normalised(n ^ t1);
const vector tanVec = t1*cos(beta) + t2*sin(beta);
const scalar d = sqrt((1 - frac)*sqr(dInner_) + frac*sqr(dOuter_));
position = position_ + d/2*tanVec;
position = position_.value(t) + d/2*tanVec;
this->findCellAtPosition
(
cellOwner,
@@ -375,7 +395,10 @@ void Foam::ConeInjection<CloudType>::setProperties
{
const scalar beta = twoPi*rndGen.scalar01();
const scalar frac = rndGen.scalar01();
tanVec = tanVec1_*cos(beta) + tanVec2_*sin(beta);
const vector n = normalised(direction_.value(t));
const vector t1 = normalised(perpendicular(n));
const vector t2 = normalised(n ^ t1);
tanVec = t1*cos(beta) + t2*sin(beta);
theta =
degToRad
(
@@ -389,9 +412,9 @@ void Foam::ConeInjection<CloudType>::setProperties
}
case imDisc:
{
const scalar r = mag(parcel.position() - position_);
const scalar r = mag(parcel.position() - position_.value(t));
const scalar frac = (2*r - dInner_)/(dOuter_ - dInner_);
tanVec = normalised(parcel.position() - position_);
tanVec = normalised(parcel.position() - position_.value(t));
theta =
degToRad
(
@@ -408,7 +431,11 @@ void Foam::ConeInjection<CloudType>::setProperties

// The direction of injection
const vector dirVec =
normalised(cos(theta)*direction_ + sin(theta)*tanVec);
normalised
(
cos(theta)*normalised(direction_.value(t))
+ sin(theta)*tanVec
);

// Set the velocity
switch (flowType_)
@@ -187,10 +187,13 @@ private:
flowType flowType_;

//- Position of the injector
vector position_;
const TimeFunction1<vector> position_;

//- Is the position constant?
const bool positionIsConstant_;

//- Centreline direction in which to inject
vector direction_;
const TimeFunction1<vector> direction_;

//- Cell label corresponding to the injector position
label injectorCell_;
@@ -220,15 +223,6 @@ private:
const autoPtr<distributionModel> sizeDistribution_;


// Tangential vectors to the direction vector

//- First tangential vector
vector tanVec1_;

//- Second tangential vector
vector tanVec2_;


// Disc geometry

//- The inner disc diameter [m]

0 comments on commit b785c98

Please sign in to comment.
You can’t perform that action at this time.