ENH: Update injector positions when mesh is updated

This commit is contained in:
andy
2012-08-03 10:40:34 +01:00
parent 362d2fdac8
commit fc1bc5c5e2
33 changed files with 350 additions and 165 deletions

View File

@ -816,6 +816,13 @@ void Foam::KinematicCloud<CloudType>::patchData
}
template<class CloudType>
void Foam::KinematicCloud<CloudType>::updateMesh()
{
injectors_.updateMesh();
}
template<class CloudType>
void Foam::KinematicCloud<CloudType>::autoMap(const mapPolyMesh& mapper)
{
@ -824,6 +831,8 @@ void Foam::KinematicCloud<CloudType>::autoMap(const mapPolyMesh& mapper)
tdType td(*this);
Cloud<parcelType>::template autoMap<tdType>(td, mapper);
updateMesh();
}

View File

@ -566,8 +566,12 @@ public:
vector& Up
) const;
// Mapping
//- Update mesh
void updateMesh();
//- Remap the cells of particles corresponding to the
// mesh topology change with a default tracking data object
virtual void autoMap(const mapPolyMesh&);

View File

@ -345,6 +345,8 @@ void Foam::ReactingCloud<CloudType>::autoMap(const mapPolyMesh& mapper)
tdType td(*this);
Cloud<parcelType>::template autoMap<tdType>(td, mapper);
this->updateMesh();
}

View File

@ -264,6 +264,8 @@ void Foam::ReactingMultiphaseCloud<CloudType>::autoMap
tdType td(*this);
Cloud<parcelType>::template autoMap<tdType>(td, mapper);
this->updateMesh();
}

View File

@ -487,6 +487,8 @@ void Foam::ThermoCloud<CloudType>::autoMap(const mapPolyMesh& mapper)
tdType td(*this);
Cloud<parcelType>::template autoMap<tdType>(td, mapper);
this->updateMesh();
}

View File

@ -185,60 +185,7 @@ Foam::CellZoneInjection<CloudType>::CellZoneInjection
)
)
{
const fvMesh& mesh = owner.mesh();
const label zoneI = mesh.cellZones().findZoneID(cellZoneName_);
if (zoneI < 0)
{
FatalErrorIn
(
"Foam::CellZoneInjection<CloudType>::CellZoneInjection"
"("
"const dictionary&, "
"CloudType&"
")"
) << "Unknown cell zone name: " << cellZoneName_
<< ". Valid cell zones are: " << mesh.cellZones().names()
<< nl << exit(FatalError);
}
const labelList& cellZoneCells = mesh.cellZones()[zoneI];
const label nCells = cellZoneCells.size();
const scalar nCellsTotal = returnReduce(nCells, sumOp<label>());
const scalar VCells = sum(scalarField(mesh.V(), cellZoneCells));
const scalar VCellsTotal = returnReduce(VCells, sumOp<scalar>());
Info<< " cell zone size = " << nCellsTotal << endl;
Info<< " cell zone volume = " << VCellsTotal << endl;
if ((nCells == 0) || (VCellsTotal*numberDensity_ < 1))
{
WarningIn
(
"Foam::CellZoneInjection<CloudType>::CellZoneInjection"
"("
"const dictionary&, "
"CloudType&"
")"
) << "Number of particles to be added to cellZone " << cellZoneName_
<< " is zero" << endl;
}
else
{
setPositions(cellZoneCells);
Info<< " number density = " << numberDensity_ << nl
<< " number of particles = " << positions_.size() << endl;
// Construct parcel diameters
diameters_.setSize(positions_.size());
forAll(diameters_, i)
{
diameters_[i] = sizeDistribution_->sample();
}
}
// Determine volume of particles to inject
this->volumeTotal_ = sum(pow3(diameters_))*constant::mathematical::pi/6.0;
updateMesh();
}
@ -270,6 +217,55 @@ Foam::CellZoneInjection<CloudType>::~CellZoneInjection()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::CellZoneInjection<CloudType>::updateMesh()
{
// Set/cache the injector cells
const fvMesh& mesh = this->owner().mesh();
const label zoneI = mesh.cellZones().findZoneID(cellZoneName_);
if (zoneI < 0)
{
FatalErrorIn("Foam::CellZoneInjection<CloudType>::updateMesh()")
<< "Unknown cell zone name: " << cellZoneName_
<< ". Valid cell zones are: " << mesh.cellZones().names()
<< nl << exit(FatalError);
}
const labelList& cellZoneCells = mesh.cellZones()[zoneI];
const label nCells = cellZoneCells.size();
const scalar nCellsTotal = returnReduce(nCells, sumOp<label>());
const scalar VCells = sum(scalarField(mesh.V(), cellZoneCells));
const scalar VCellsTotal = returnReduce(VCells, sumOp<scalar>());
Info<< " cell zone size = " << nCellsTotal << endl;
Info<< " cell zone volume = " << VCellsTotal << endl;
if ((nCells == 0) || (VCellsTotal*numberDensity_ < 1))
{
WarningIn("Foam::CellZoneInjection<CloudType>::updateMesh()")
<< "Number of particles to be added to cellZone " << cellZoneName_
<< " is zero" << endl;
}
else
{
setPositions(cellZoneCells);
Info<< " number density = " << numberDensity_ << nl
<< " number of particles = " << positions_.size() << endl;
// Construct parcel diameters
diameters_.setSize(positions_.size());
forAll(diameters_, i)
{
diameters_[i] = sizeDistribution_->sample();
}
}
// Determine volume of particles to inject
this->volumeTotal_ = sum(pow3(diameters_))*constant::mathematical::pi/6.0;
}
template<class CloudType>
Foam::scalar Foam::CellZoneInjection<CloudType>::timeEnd() const
{

View File

@ -130,6 +130,9 @@ public:
// Member Functions
//- Set injector locations when mesh is updated
virtual void updateMesh();
//- Return the end-of-injection time
scalar timeEnd() const;

View File

@ -126,17 +126,7 @@ Foam::ConeInjection<CloudType>::ConeInjection
// Set total volume to inject
this->volumeTotal_ = flowRateProfile_.integrate(0.0, duration_);
// Set/cache the injector cells
forAll(positionAxis_, i)
{
this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
positionAxis_[i].first()
);
}
updateMesh();
}
@ -173,6 +163,23 @@ Foam::ConeInjection<CloudType>::~ConeInjection()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::ConeInjection<CloudType>::updateMesh()
{
// Set/cache the injector cells
forAll(positionAxis_, i)
{
this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
positionAxis_[i].first()
);
}
}
template<class CloudType>
Foam::scalar Foam::ConeInjection<CloudType>::timeEnd() const
{

View File

@ -144,6 +144,9 @@ public:
// Member Functions
//- Set injector locations when mesh is updated
virtual void updateMesh();
//- Return the end-of-injection time
scalar timeEnd() const;

View File

@ -201,6 +201,8 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
// Set total volume to inject
this->volumeTotal_ = flowRateProfile_.integrate(0.0, duration_);
updateMesh();
}
@ -244,6 +246,30 @@ Foam::ConeNozzleInjection<CloudType>::~ConeNozzleInjection()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::ConeNozzleInjection<CloudType>::updateMesh()
{
// Set/cache the injector cells
switch (injectionMethod_)
{
case imPoint:
{
this->findCellAtPosition
(
injectorCell_,
tetFaceI_,
tetPtI_,
position_
);
}
default:
{
// do nothing
}
}
}
template<class CloudType>
Foam::scalar Foam::ConeNozzleInjection<CloudType>::timeEnd() const
{
@ -342,6 +368,7 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell
"const label, "
"const scalar, "
"vector&, "
"label&, "
"label&"
")"
)<< "Unknown injectionMethod type" << nl

View File

@ -212,6 +212,9 @@ public:
// Member Functions
//- Set injector locations when mesh is updated
virtual void updateMesh();
//- Return the end-of-injection time
scalar timeEnd() const;

View File

@ -96,17 +96,7 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
this->volumeTotal_ =
nParcelsPerInjector_*sum(pow3(diameters_))*pi/6.0;
// Set/cache the injector cells
forAll(positions_, i)
{
this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
positions_[i]
);
}
updateMesh();
}
@ -142,6 +132,23 @@ Foam::FieldActivatedInjection<CloudType>::~FieldActivatedInjection()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::FieldActivatedInjection<CloudType>::updateMesh()
{
// Set/cache the injector cells
forAll(positions_, i)
{
this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
positions_[i]
);
}
}
template<class CloudType>
Foam::scalar Foam::FieldActivatedInjection<CloudType>::timeEnd() const
{

View File

@ -150,6 +150,9 @@ public:
// Member Functions
//- Set injector locations when mesh is updated
virtual void updateMesh();
//- Return the end-of-injection time
scalar timeEnd() const;

View File

@ -153,6 +153,13 @@ Foam::InflationInjection<CloudType>::~InflationInjection()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::InflationInjection<CloudType>::updateMesh()
{
// do nothing
}
template<class CloudType>
Foam::scalar Foam::InflationInjection<CloudType>::timeEnd() const
{
@ -234,8 +241,8 @@ Foam::label Foam::InflationInjection<CloudType>::parcelsToInject
"Foam::label "
"Foam::InflationInjection<CloudType>::parcelsToInject"
"("
"const scalar time0, "
"const scalar time1"
"const scalar, "
"const scalar"
")"
)
<< "Maximum particle split iterations ("

View File

@ -146,6 +146,9 @@ public:
// Member Functions
//- Set injector locations when mesh is updated
virtual void updateMesh();
//- Return the end-of-injection time
scalar timeEnd() const;

View File

@ -407,6 +407,13 @@ Foam::InjectionModel<CloudType>::~InjectionModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::InjectionModel<CloudType>::updateMesh()
{
// do nothing
}
template<class CloudType>
Foam::scalar Foam::InjectionModel<CloudType>::timeEnd() const
{

View File

@ -250,6 +250,12 @@ public:
// Member Functions
// Mapping
//- Update mesh
virtual void updateMesh();
// Global information
//- Return the start-of-injection time

View File

@ -168,6 +168,16 @@ Foam::scalar Foam::InjectionModelList<CloudType>::averageParcelMass()
}
template<class CloudType>
void Foam::InjectionModelList<CloudType>::updateMesh()
{
forAll(*this, i)
{
this->operator[](i).updateMesh();
}
}
template<class CloudType>
template<class TrackData>
void Foam::InjectionModelList<CloudType>::inject(TrackData& td)

View File

@ -97,6 +97,12 @@ public:
scalar averageParcelMass();
// Edit
//- Set injector locations when mesh is updated
void updateMesh();
// Per-injection event functions
//- Main injection loop

View File

@ -65,16 +65,7 @@ Foam::KinematicLookupTableInjection<CloudType>::KinematicLookupTableInjection
injectorTetFaces_.setSize(injectors_.size());
injectorTetPts_.setSize(injectors_.size());
forAll(injectors_, i)
{
this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
injectors_[i].x()
);
}
updateMesh();
// Determine volume of particles to inject
this->volumeTotal_ = 0.0;
@ -112,6 +103,23 @@ Foam::KinematicLookupTableInjection<CloudType>::~KinematicLookupTableInjection()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::KinematicLookupTableInjection<CloudType>::updateMesh()
{
// Set/cache the injector cells
forAll(injectors_, i)
{
this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
injectors_[i].x()
);
}
}
template<class CloudType>
Foam::scalar Foam::KinematicLookupTableInjection<CloudType>::timeEnd() const
{

View File

@ -129,6 +129,9 @@ public:
// Member Functions
//- Set injector locations when mesh is updated
virtual void updateMesh();
//- Return the end-of-injection time
scalar timeEnd() const;

View File

@ -26,7 +26,6 @@ License
#include "ManualInjection.H"
#include "mathematicalConstants.H"
#include "PackedBoolList.H"
#include "Switch.H"
using namespace Foam::constant::mathematical;
@ -65,48 +64,13 @@ Foam::ManualInjection<CloudType>::ManualInjection
this->coeffDict().subDict("sizeDistribution"),
owner.rndGen()
)
)
{
Switch ignoreOutOfBounds
),
ignoreOutOfBounds_
(
this->coeffDict().lookupOrDefault("ignoreOutOfBounds", false)
);
label nRejected = 0;
PackedBoolList keep(positions_.size(), true);
forAll(positions_, pI)
{
if
(
!this->findCellAtPosition
(
injectorCells_[pI],
injectorTetFaces_[pI],
injectorTetPts_[pI],
positions_[pI],
!ignoreOutOfBounds
)
)
{
keep[pI] = false;
nRejected++;
}
}
if (nRejected > 0)
{
inplaceSubset(keep, positions_);
inplaceSubset(keep, diameters_);
inplaceSubset(keep, injectorCells_);
inplaceSubset(keep, injectorTetFaces_);
inplaceSubset(keep, injectorTetPts_);
Info<< " " << nRejected
<< " particles ignored, out of bounds." << endl;
}
updateMesh();
// Construct parcel diameters
forAll(diameters_, i)
@ -133,7 +97,8 @@ Foam::ManualInjection<CloudType>::ManualInjection
injectorTetFaces_(im.injectorTetFaces_),
injectorTetPts_(im.injectorTetPts_),
U0_(im.U0_),
sizeDistribution_(im.sizeDistribution_().clone().ptr())
sizeDistribution_(im.sizeDistribution_().clone().ptr()),
ignoreOutOfBounds_(im.ignoreOutOfBounds_)
{}
@ -146,6 +111,46 @@ Foam::ManualInjection<CloudType>::~ManualInjection()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::ManualInjection<CloudType>::updateMesh()
{
label nRejected = 0;
PackedBoolList keep(positions_.size(), true);
forAll(positions_, pI)
{
if
(
!this->findCellAtPosition
(
injectorCells_[pI],
injectorTetFaces_[pI],
injectorTetPts_[pI],
positions_[pI],
!ignoreOutOfBounds_
)
)
{
keep[pI] = false;
nRejected++;
}
}
if (nRejected > 0)
{
inplaceSubset(keep, positions_);
inplaceSubset(keep, diameters_);
inplaceSubset(keep, injectorCells_);
inplaceSubset(keep, injectorTetFaces_);
inplaceSubset(keep, injectorTetPts_);
Info<< " " << nRejected
<< " particles ignored, out of bounds" << endl;
}
}
template<class CloudType>
Foam::scalar Foam::ManualInjection<CloudType>::timeEnd() const
{

View File

@ -43,6 +43,7 @@ SourceFiles
#include "InjectionModel.H"
#include "distributionModel.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -84,6 +85,9 @@ class ManualInjection
//- Parcel size distribution model
const autoPtr<distributionModels::distributionModel> sizeDistribution_;
//- Flag to suppress errors if particle injection site is out-of-bounds
Switch ignoreOutOfBounds_;
public:
@ -120,6 +124,9 @@ public:
// Member Functions
//- Set injector locations when mesh is updated
virtual void updateMesh();
//- Return the end-of-injection time
scalar timeEnd() const;

View File

@ -82,7 +82,7 @@ Foam::PatchFlowRateInjection<CloudType>::PatchFlowRateInjection
duration_ = owner.db().time().userTimeToTime(duration_);
cellOwners_ = patch.faceCells();
updateMesh();
// TODO: retrieve mean diameter from distrution model
scalar pMeanDiameter =
@ -139,6 +139,15 @@ Foam::PatchFlowRateInjection<CloudType>::~PatchFlowRateInjection()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::PatchFlowRateInjection<CloudType>::updateMesh()
{
// Set/cache the injector cells
const polyPatch& patch = this->owner().mesh().boundaryMesh()[patchId_];
cellOwners_ = patch.faceCells();
}
template<class CloudType>
Foam::scalar Foam::PatchFlowRateInjection<CloudType>::timeEnd() const
{

View File

@ -146,6 +146,9 @@ public:
// Member Functions
//- Set injector locations when mesh is updated
virtual void updateMesh();
//- Return the end-of-injection time
scalar timeEnd() const;

View File

@ -80,11 +80,9 @@ Foam::PatchInjection<CloudType>::PatchInjection
<< nl << exit(FatalError);
}
const polyPatch& patch = owner.mesh().boundaryMesh()[patchId_];
duration_ = owner.db().time().userTimeToTime(duration_);
cellOwners_ = patch.faceCells();
updateMesh();
label patchSize = cellOwners_.size();
label totalPatchSize = patchSize;
@ -125,6 +123,15 @@ Foam::PatchInjection<CloudType>::~PatchInjection()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::PatchInjection<CloudType>::updateMesh()
{
// Set/cache the injector cells
const polyPatch& patch = this->owner().mesh().boundaryMesh()[patchId_];
cellOwners_ = patch.faceCells();
}
template<class CloudType>
Foam::scalar Foam::PatchInjection<CloudType>::timeEnd() const
{

View File

@ -129,6 +129,9 @@ public:
// Member Functions
//- Set injector locations when mesh is updated
virtual void updateMesh();
//- Return the end-of-injection time
scalar timeEnd() const;

View File

@ -64,16 +64,7 @@ Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection
injectorTetFaces_.setSize(injectors_.size());
injectorTetPts_.setSize(injectors_.size());
forAll(injectors_, i)
{
this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
injectors_[i].x()
);
}
updateMesh();
// Determine volume of particles to inject
this->volumeTotal_ = 0.0;
@ -111,6 +102,23 @@ Foam::ReactingLookupTableInjection<CloudType>::~ReactingLookupTableInjection()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::ReactingLookupTableInjection<CloudType>::updateMesh()
{
// Set/cache the injector cells
forAll(injectors_, i)
{
this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
injectors_[i].x()
);
}
}
template<class CloudType>
Foam::scalar Foam::ReactingLookupTableInjection<CloudType>::timeEnd() const
{

View File

@ -132,6 +132,9 @@ public:
// Member Functions
//- Set injector locations when mesh is updated
virtual void updateMesh();
//- Return the end-of-injection time
scalar timeEnd() const;

View File

@ -65,16 +65,7 @@ ReactingMultiphaseLookupTableInjection
injectorTetFaces_.setSize(injectors_.size());
injectorTetPts_.setSize(injectors_.size());
forAll(injectors_, i)
{
this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
injectors_[i].x()
);
}
updateMesh();
// Determine volume of particles to inject
this->volumeTotal_ = 0.0;
@ -114,6 +105,23 @@ Foam::ReactingMultiphaseLookupTableInjection<CloudType>::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::ReactingMultiphaseLookupTableInjection<CloudType>::updateMesh()
{
// Set/cache the injector cells
forAll(injectors_, i)
{
this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
injectors_[i].x()
);
}
}
template<class CloudType>
Foam::scalar
Foam::ReactingMultiphaseLookupTableInjection<CloudType>::timeEnd() const

View File

@ -135,6 +135,9 @@ public:
// Member Functions
//- Set injector locations when mesh is updated
virtual void updateMesh();
//- Return the end-of-injection time
scalar timeEnd() const;

View File

@ -65,16 +65,7 @@ Foam::ThermoLookupTableInjection<CloudType>::ThermoLookupTableInjection
injectorTetFaces_.setSize(injectors_.size());
injectorTetPts_.setSize(injectors_.size());
forAll(injectors_, i)
{
this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
injectors_[i].x()
);
}
updateMesh();
// Determine volume of particles to inject
this->volumeTotal_ = 0.0;
@ -112,6 +103,23 @@ Foam::ThermoLookupTableInjection<CloudType>::~ThermoLookupTableInjection()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::ThermoLookupTableInjection<CloudType>::updateMesh()
{
// Set/cache the injector cells
forAll(injectors_, i)
{
this->findCellAtPosition
(
injectorCells_[i],
injectorTetFaces_[i],
injectorTetPts_[i],
injectors_[i].x()
);
}
}
template<class CloudType>
Foam::scalar Foam::ThermoLookupTableInjection<CloudType>::timeEnd() const
{

View File

@ -132,6 +132,9 @@ public:
// Member Functions
//- Set injector locations when mesh is updated
virtual void updateMesh();
//- Return the end-of-injection time
scalar timeEnd() const;