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