Commit 72037bc9 authored by Andrew Heather's avatar Andrew Heather Committed by Andrew Heather
Browse files

ENH: Injection models - added entry to ignore injection positions outside of the mesh

Example in the injection model input dictionary:

    // New entry to ignore injections out of bounds
    ignoreOutOfBounds yes;
parent 4d9c7ca8
......@@ -97,9 +97,14 @@ Foam::ConeInjection<CloudType>::ConeInjection
)
),
nInjected_(this->parcelsAddedTotal()),
tanVec1_(positionAxis_.size()),
tanVec2_(positionAxis_.size())
tanVec1_(),
tanVec2_()
{
updateMesh();
tanVec1_.setSize(positionAxis_.size());
tanVec2_.setSize(positionAxis_.size());
duration_ = owner.db().time().userTimeToTime(duration_);
// Normalise direction vector and determine direction vectors
......@@ -127,8 +132,6 @@ Foam::ConeInjection<CloudType>::ConeInjection
// Set total volume to inject
this->volumeTotal_ = flowRateProfile_.integrate(0.0, duration_);
updateMesh();
}
......@@ -156,28 +159,45 @@ Foam::ConeInjection<CloudType>::ConeInjection
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::ConeInjection<CloudType>::~ConeInjection()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::ConeInjection<CloudType>::updateMesh()
{
bitSet reject(positionAxis_.size());
// Set/cache the injector cells
forAll(positionAxis_, i)
{
this->findCellAtPosition
if
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
positionAxis_[i].first()
);
!this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
positionAxis_[i].first(),
!this->ignoreOutOfBounds_
)
)
{
reject.set(i);
}
}
const label nRejected = reject.count();
if (nRejected)
{
reject.flip();
inplaceSubset(reject, injectorCells_);
inplaceSubset(reject, injectorTetFaces_);
inplaceSubset(reject, injectorTetPts_);
inplaceSubset(reject, positionAxis_);
Info<< " " << nRejected
<< " positions rejected, out of bounds" << endl;
}
}
......
......@@ -147,7 +147,7 @@ public:
//- Destructor
virtual ~ConeInjection();
virtual ~ConeInjection() = default;
// Member Functions
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -77,12 +77,12 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
(
this->coeffDict().getLabel("parcelsPerInjector")
),
nParcelsInjected_(positions_.size(), Zero),
nParcelsInjected_(),
U0_
(
this->coeffDict().template get<vector>("U0")
),
diameters_(positions_.size()),
diameters_(),
sizeDistribution_
(
distributionModel::New
......@@ -92,7 +92,12 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
)
)
{
updateMesh();
nParcelsInjected_.setSize(positions_.size(), Zero);
// Construct parcel diameters - one per injector cell
diameters_.setSize(positions_.size());
forAll(diameters_, i)
{
diameters_[i] = sizeDistribution_->sample();
......@@ -101,8 +106,6 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
// Determine total volume of particles to inject
this->volumeTotal_ =
nParcelsPerInjector_*sum(pow3(diameters_))*pi/6.0;
updateMesh();
}
......@@ -129,28 +132,45 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::FieldActivatedInjection<CloudType>::~FieldActivatedInjection()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::FieldActivatedInjection<CloudType>::updateMesh()
{
bitSet reject(positions_.size());
// Set/cache the injector cells
forAll(positions_, i)
{
this->findCellAtPosition
if
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
positions_[i]
);
!this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
positions_[i],
!this->ignoreOutOfBounds_
)
)
{
reject.set(i);
}
}
const label nRejected = reject.count();
if (nRejected)
{
reject.flip();
inplaceSubset(reject, injectorCells_);
inplaceSubset(reject, injectorTetFaces_);
inplaceSubset(reject, injectorTetPts_);
inplaceSubset(reject, positions_);
Info<< " " << nRejected
<< " positions rejected, out of bounds" << endl;
}
}
......
......@@ -151,7 +151,7 @@ public:
//- Destructor
virtual ~FieldActivatedInjection();
virtual ~FieldActivatedInjection() = default;
// Member Functions
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -254,7 +254,7 @@ void Foam::InjectionModel<CloudType>::postInjectCheck
time0_ = this->owner().db().time().value();
// Increment number of injections
nInjections_++;
++nInjections_;
}
......@@ -280,7 +280,8 @@ Foam::InjectionModel<CloudType>::InjectionModel(CloudType& owner)
timeStep0_(this->template getModelProperty<scalar>("timeStep0")),
minParticlesPerParcel_(1),
delayedVolume_(0.0),
injectorID_(-1)
injectorID_(-1),
ignoreOutOfBounds_(false)
{}
......@@ -313,7 +314,11 @@ Foam::InjectionModel<CloudType>::InjectionModel
this->coeffDict().lookupOrDefault("minParticlesPerParcel", scalar(1))
),
delayedVolume_(0.0),
injectorID_(this->coeffDict().lookupOrDefault("injectorID", -1))
injectorID_(this->coeffDict().lookupOrDefault("injectorID", -1)),
ignoreOutOfBounds_
(
this->coeffDict().lookupOrDefault("ignoreOutOfBounds", false)
)
{
// Provide some info
// - also serves to initialise mesh dimensions - needed for parallel runs
......@@ -391,14 +396,8 @@ Foam::InjectionModel<CloudType>::InjectionModel
timeStep0_(im.timeStep0_),
minParticlesPerParcel_(im.minParticlesPerParcel_),
delayedVolume_(im.delayedVolume_),
injectorID_(im.injectorID_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::InjectionModel<CloudType>::~InjectionModel()
injectorID_(im.injectorID_),
ignoreOutOfBounds_(im.ignoreOutOfBounds_)
{}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -151,6 +151,10 @@ protected:
//- Optional injector ID
label injectorID_;
//- Optional flag to indicate that injections attempted outside
//- the mesh should be ignored
bool ignoreOutOfBounds_;
// Protected Member Functions
......@@ -237,7 +241,7 @@ public:
//- Destructor
virtual ~InjectionModel();
virtual ~InjectionModel() = default;
// Selectors
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -55,19 +55,14 @@ Foam::KinematicLookupTableInjection<CloudType>::KinematicLookupTableInjection
IOobject::NO_WRITE
)
),
injectorCells_(0),
injectorTetFaces_(0),
injectorTetPts_(0)
injectorCells_(injectors_.size()),
injectorTetFaces_(injectors_.size()),
injectorTetPts_(injectors_.size())
{
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells
injectorCells_.setSize(injectors_.size());
injectorTetFaces_.setSize(injectors_.size());
injectorTetPts_.setSize(injectors_.size());
updateMesh();
duration_ = owner.db().time().userTimeToTime(duration_);
// Determine volume of particles to inject
this->volumeTotal_ = 0.0;
forAll(injectors_, i)
......@@ -96,28 +91,45 @@ Foam::KinematicLookupTableInjection<CloudType>::KinematicLookupTableInjection
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::KinematicLookupTableInjection<CloudType>::~KinematicLookupTableInjection()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::KinematicLookupTableInjection<CloudType>::updateMesh()
{
bitSet reject(injectors_.size());
// Set/cache the injector cells
forAll(injectors_, i)
{
this->findCellAtPosition
if
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
injectors_[i].x()
);
!this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
injectors_[i].x(),
!this->ignoreOutOfBounds_
)
)
{
reject.set(i);
}
}
const label nRejected = reject.count();
if (nRejected)
{
reject.flip();
inplaceSubset(reject, injectorCells_);
inplaceSubset(reject, injectorTetFaces_);
inplaceSubset(reject, injectorTetPts_);
inplaceSubset(reject, injectors_);
Info<< " " << nRejected
<< " positions rejected, out of bounds" << endl;
}
}
......
......@@ -136,7 +136,7 @@ public:
//- Destructor
virtual ~KinematicLookupTableInjection();
virtual ~KinematicLookupTableInjection() = default;
// Member Functions
......@@ -181,7 +181,7 @@ public:
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
//- permitted
virtual bool validInjection(const label parcelI);
};
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -54,19 +54,14 @@ Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection
IOobject::NO_WRITE
)
),
injectorCells_(0),
injectorTetFaces_(0),
injectorTetPts_(0)
injectorCells_(injectors_.size()),
injectorTetFaces_(injectors_.size()),
injectorTetPts_(injectors_.size())
{
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells
injectorCells_.setSize(injectors_.size());
injectorTetFaces_.setSize(injectors_.size());
injectorTetPts_.setSize(injectors_.size());
updateMesh();
duration_ = owner.db().time().userTimeToTime(duration_);
// Determine volume of particles to inject
this->volumeTotal_ = 0.0;
forAll(injectors_, i)
......@@ -95,28 +90,46 @@ Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::ReactingLookupTableInjection<CloudType>::~ReactingLookupTableInjection()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::ReactingLookupTableInjection<CloudType>::updateMesh()
{
// Set/cache the injector cells
bitSet reject(injectors_.size());
// Set/cache the injector cells
forAll(injectors_, i)
{
this->findCellAtPosition
if
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
injectors_[i].x()
);
!this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
injectors_[i].x(),
!this->ignoreOutOfBounds_
)
)
{
reject.set(i);
}
}
const label nRejected = reject.count();
if (nRejected)
{
reject.flip();
inplaceSubset(reject, injectorCells_);
inplaceSubset(reject, injectorTetFaces_);
inplaceSubset(reject, injectorTetPts_);
inplaceSubset(reject, injectors_);
Info<< " " << nRejected
<< " positions rejected, out of bounds" << endl;
}
}
......
......@@ -135,7 +135,7 @@ public:
//- Destructor
virtual ~ReactingLookupTableInjection();
virtual ~ReactingLookupTableInjection() = default;
// Member Functions
......@@ -153,7 +153,6 @@ public:
virtual scalar volumeToInject(const scalar time0, const scalar time1);
// Injection geometry
//- Set the injection position and owner cell, tetFace and tetPt
......@@ -181,7 +180,7 @@ public:
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
//- permitted
virtual bool validInjection(const label parcelI);
};
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -55,19 +55,14 @@ ReactingMultiphaseLookupTableInjection
IOobject::NO_WRITE
)
),
injectorCells_(0),
injectorTetFaces_(0),
injectorTetPts_(0)
injectorCells_(injectors_.size()),
injectorTetFaces_(injectors_.size()),
injectorTetPts_(injectors_.size())
{
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells
injectorCells_.setSize(injectors_.size());
injectorTetFaces_.setSize(injectors_.size());
injectorTetPts_.setSize(injectors_.size());
updateMesh();
duration_ = owner.db().time().userTimeToTime(duration_);
// Determine volume of particles to inject
this->volumeTotal_ = 0.0;
forAll(injectors_, i)
......@@ -97,29 +92,46 @@ ReactingMultiphaseLookupTableInjection
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::ReactingMultiphaseLookupTableInjection<CloudType>::
~ReactingMultiphaseLookupTableInjection()
{}