lagrangian: InjectionModel: New uniformParcelSize control

Lagrangian injections now have a 'uniformParcelSize' control, which
specifies what size of the parcels is kept uniform during a given time
step. This control can be set to 'nParticles', 'surfaceArea' or
'volume'. The particle sizes, by contrast, are specified by the size
distribution.

For example, if 'uniformParcelSize nParticles;' is specified then all
parcels introduced at a given time will have the same number of
particles. Every particle in a parcel has the same properties, including
diameter. So, in this configuration, the larger diameter parcels contain
a much larger fraction of the total particulate volume than the smaller
diameter ones. This may be undesirable as the effect of a parcel on the
simulation might be more in proportion with its volume than with the
number of particles it represents. It might be preferable to create a
greater proportion of large diameter parcels so that their more
significant effect is represented by a finer Lagrangian discretisation.
This can be achieved by setting 'uniformParcelSize volume;'. A setting
of 'uniformParcelSize surfaceArea;' might be appropriate if the limiting
effect of a Lagrangian element scales with its surface area; interfacial
evaporation, for example.

Previously, this control was provided by 'parcelBasisType'. However,
this control also effectively specified the size exponent of the
supplied distribution. This interdependence was not documented and was
problematic in that it coupled physical and numerical controls.
'parcelBasisType' has been removed, and the size exponent of the
distribution is now specified independently of the new
'uniformParcelSize' control along with the rest of the distribution
coefficients or data. See the previous commit for details.

It is still possible to specify a fixed number of particles per parcel
using the 'nParticle' control. The presence of this control is used to
determine whether or not the number of particles per parcel is fixed, so
a 'fixed' basis type is no longer needed.

A number of bugs have been fixed with regards to lack of
interoperability between the various settings in the injection models.
'uniformParcelSize' can be changed freely and the number of parcels and
amount of mass that an injector introduces will not change (this was not
true of 'parcelBasisType'). Redundant settings are no longer read by the
injection models; e.g., mass is not read if the number of particles per
parcel is fixed, duration is not specified for steady tracking, etc...

The 'inflationInjection' model has been removed as there are no examples
of its usage, its purpose was not clearly documented, and it was not
obvious how it should be updated as a result of these changes.
This commit is contained in:
Will Bainbridge
2023-05-11 14:28:33 +01:00
parent cae41959dd
commit 0d2fd78864
129 changed files with 1179 additions and 4279 deletions

View File

@ -13,7 +13,6 @@ LIB_LIBS = \
-lmomentumTransportModels \
-lfilmCompressibleMomentumTransportModels \
-linterfaceProperties \
-ldistributionModels \
-lfiniteVolume \
-lmeshTools \
-lsampling \

View File

@ -38,7 +38,6 @@ dummyThirdParty/Allwmake $targetType $*
wmake $targetType finiteVolume
wmake $targetType lagrangian/basic
wmake $targetType lagrangian/distributionModels
wmake $targetType genericPatchFields
wmake $targetType mesh/extrudeModel

View File

@ -4,7 +4,6 @@ cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
wmake $targetType distributionModels
wmake $targetType basic
wmake $targetType solidParticle
wmake $targetType parcel

View File

@ -1,13 +0,0 @@
distributionModel/distributionModel.C
distributionModel/distributionModelNew.C
exponential/exponential.C
fixedValue/fixedValue.C
general/general.C
multiNormal/multiNormal.C
normal/normal.C
RosinRammler/RosinRammler.C
massRosinRammler/massRosinRammler.C
uniform/uniform.C
LIB = $(FOAM_LIBBIN)/libdistributionModels

View File

@ -1 +0,0 @@
EXE_INC =

View File

@ -1,104 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "RosinRammler.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
defineTypeNameAndDebug(RosinRammler, 0);
addToRunTimeSelectionTable(distributionModel, RosinRammler, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::distributionModels::RosinRammler::RosinRammler
(
const dictionary& dict,
Random& rndGen
)
:
distributionModel(typeName, dict, rndGen),
minValue_(distributionModelDict_.template lookup<scalar>("minValue")),
maxValue_(distributionModelDict_.template lookup<scalar>("maxValue")),
d_(distributionModelDict_.template lookup<scalar>("d")),
n_(distributionModelDict_.template lookup<scalar>("n"))
{
check();
info();
}
Foam::distributionModels::RosinRammler::RosinRammler(const RosinRammler& p)
:
distributionModel(p),
minValue_(p.minValue_),
maxValue_(p.maxValue_),
d_(p.d_),
n_(p.n_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::distributionModels::RosinRammler::~RosinRammler()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::distributionModels::RosinRammler::sample() const
{
const scalar minValueByDPowN = pow(minValue_/d_, n_);
const scalar K = 1 - exp(- pow(maxValue_/d_, n_) + minValueByDPowN);
const scalar y = rndGen_.sample01<scalar>();
return d_*pow(minValueByDPowN - log(1 - K*y), 1/n_);
}
Foam::scalar Foam::distributionModels::RosinRammler::minValue() const
{
return minValue_;
}
Foam::scalar Foam::distributionModels::RosinRammler::maxValue() const
{
return maxValue_;
}
Foam::scalar Foam::distributionModels::RosinRammler::meanValue() const
{
return d_;
}
// ************************************************************************* //

View File

@ -1,128 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::distributionModels::RosinRammler
Description
Rosin-Rammler distributionModel
\f[
CDF(x) =
(1 - exp(-(x/d)^n + (d_0/d)^n)
/(1 - exp(-(d_1/d)^n + (d_0/d)^n)
\f]
SourceFiles
RosinRammler.C
\*---------------------------------------------------------------------------*/
#ifndef RosinRammler_H
#define RosinRammler_H
#include "distributionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
/*---------------------------------------------------------------------------*\
Class RosinRammler Declaration
\*---------------------------------------------------------------------------*/
class RosinRammler
:
public distributionModel
{
// Private Data
//- Distribution minimum
scalar minValue_;
//- Distribution maximum
scalar maxValue_;
// Model coefficients
//- Scale parameter
scalar d_;
//- Shape parameter
scalar n_;
public:
//- Runtime type information
TypeName("RosinRammler");
// Constructors
//- Construct from components
RosinRammler(const dictionary& dict, Random& rndGen);
//- Construct copy
RosinRammler(const RosinRammler& p);
//- Construct and return a clone
virtual autoPtr<distributionModel> clone() const
{
return autoPtr<distributionModel>(new RosinRammler(*this));
}
//- Destructor
virtual ~RosinRammler();
// Member Functions
//- Sample the distributionModel
virtual scalar sample() const;
//- Return the minimum value
virtual scalar minValue() const;
//- Return the maximum value
virtual scalar maxValue() const;
//- Return the mean value
virtual scalar meanValue() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace distributionModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,97 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "distributionModel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(distributionModel, 0);
defineRunTimeSelectionTable(distributionModel, dictionary);
}
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::distributionModel::check() const
{
if (minValue() < 0)
{
FatalErrorInFunction
<< type() << "distribution: Minimum value must be greater than "
<< "zero." << nl << "Supplied minValue = " << minValue()
<< abort(FatalError);
}
if (maxValue() < minValue())
{
FatalErrorInFunction
<< type() << "distribution: Maximum value is smaller than the "
<< "minimum value:" << nl << " maxValue = " << maxValue()
<< ", minValue = " << minValue()
<< abort(FatalError);
}
}
void Foam::distributionModel::info() const
{
Info<< " Distribution min: " << minValue() << " max: " << maxValue()
<< " mean: " << meanValue() << endl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::distributionModel::distributionModel
(
const word& name,
const dictionary& dict,
Random& rndGen
)
:
distributionModelDict_(dict.subDict(name + "Distribution")),
rndGen_(rndGen)
{}
Foam::distributionModel::distributionModel
(
const distributionModel& p
)
:
distributionModelDict_(p.distributionModelDict_),
rndGen_(p.rndGen_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::distributionModel::~distributionModel()
{}
// ************************************************************************* //

View File

@ -1,160 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::distributionModel
Description
A library of runtime-selectable distribution models.
Returns a sampled value given the expectation (nu) and variance (sigma^2)
Current distribution models include:
- exponential
- fixedValue
- general
- multi-normal
- normal
- Rosin-Rammler
- Mass-based Rosin-Rammler
- uniform
SourceFiles
distributionModel.C
distributionModelNew.C
\*---------------------------------------------------------------------------*/
#ifndef distributionModel_H
#define distributionModel_H
#include "IOdictionary.H"
#include "autoPtr.H"
#include "Random.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class distributionModel Declaration
\*---------------------------------------------------------------------------*/
class distributionModel
{
protected:
// Protected data
//- Coefficients dictionary
const dictionary distributionModelDict_;
//- Reference to the random number generator
Random& rndGen_;
// Protected Member Functions
//- Check that the distribution model is valid
virtual void check() const;
//- Print information about the distribution
void info() const;
public:
//-Runtime type information
TypeName("distributionModel");
//- Declare runtime constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
distributionModel,
dictionary,
(
const dictionary& dict,
Random& rndGen
),
(dict, rndGen)
);
// Constructors
//- Construct from dictionary
distributionModel
(
const word& name,
const dictionary& dict,
Random& rndGen
);
//- Construct copy
distributionModel(const distributionModel& p);
//- Construct and return a clone
virtual autoPtr<distributionModel> clone() const = 0;
//- Selector
static autoPtr<distributionModel> New
(
const dictionary& dict,
Random& rndGen
);
//- Destructor
virtual ~distributionModel();
// Member Functions
//- Sample the distributionModel
virtual scalar sample() const = 0;
//- Return the minimum value
virtual scalar minValue() const = 0;
//- Return the maximum value
virtual scalar maxValue() const = 0;
//- Return the mean value
virtual scalar meanValue() const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,101 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "exponential.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
defineTypeNameAndDebug(exponential, 0);
addToRunTimeSelectionTable(distributionModel, exponential, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::distributionModels::exponential::exponential
(
const dictionary& dict,
Random& rndGen
)
:
distributionModel(typeName, dict, rndGen),
minValue_(distributionModelDict_.template lookup<scalar>("minValue")),
maxValue_(distributionModelDict_.template lookup<scalar>("maxValue")),
lambda_(distributionModelDict_.template lookup<scalar>("lambda"))
{
check();
info();
}
Foam::distributionModels::exponential::exponential(const exponential& p)
:
distributionModel(p),
minValue_(p.minValue_),
maxValue_(p.maxValue_),
lambda_(p.lambda_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::distributionModels::exponential::~exponential()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::distributionModels::exponential::sample() const
{
scalar y = rndGen_.sample01<scalar>();
scalar K = exp(-lambda_*maxValue_) - exp(-lambda_*minValue_);
return -(1.0/lambda_)*log(exp(-lambda_*minValue_) + y*K);
}
Foam::scalar Foam::distributionModels::exponential::minValue() const
{
return minValue_;
}
Foam::scalar Foam::distributionModels::exponential::maxValue() const
{
return maxValue_;
}
Foam::scalar Foam::distributionModels::exponential::meanValue() const
{
return 1.0/lambda_;
}
// ************************************************************************* //

View File

@ -1,119 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::distributionModels::exponential
Description
exponential distribution model
SourceFiles
exponential.C
\*---------------------------------------------------------------------------*/
#ifndef exponential_H
#define exponential_H
#include "distributionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
/*---------------------------------------------------------------------------*\
Class exponential Declaration
\*---------------------------------------------------------------------------*/
class exponential
:
public distributionModel
{
// Private Data
//- Distribution minimum
scalar minValue_;
//- Distribution maximum
scalar maxValue_;
// Model coefficients
scalar lambda_;
public:
//- Runtime type information
TypeName("exponential");
// Constructors
//- Construct from components
exponential(const dictionary& dict, Random& rndGen);
//- Construct copy
exponential(const exponential& p);
//- Construct and return a clone
virtual autoPtr<distributionModel> clone() const
{
return autoPtr<distributionModel>(new exponential(*this));
}
//- Destructor
virtual ~exponential();
// Member Functions
//- Sample the distributionModel
virtual scalar sample() const;
//- Return the minimum value
virtual scalar minValue() const;
//- Return the maximum value
virtual scalar maxValue() const;
//- Return the mean value
virtual scalar meanValue() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace distributionModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,94 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "fixedValue.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
defineTypeNameAndDebug(fixedValue, 0);
addToRunTimeSelectionTable(distributionModel, fixedValue, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::distributionModels::fixedValue::fixedValue
(
const dictionary& dict,
Random& rndGen
)
:
distributionModel(typeName, dict, rndGen),
value_(distributionModelDict_.template lookup<scalar>("value"))
{
info();
}
Foam::distributionModels::fixedValue::fixedValue(const fixedValue& p)
:
distributionModel(p),
value_(p.value_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::distributionModels::fixedValue::~fixedValue()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::distributionModels::fixedValue::fixedValue::sample() const
{
return value_;
}
Foam::scalar Foam::distributionModels::fixedValue::fixedValue::minValue() const
{
return value_;
}
Foam::scalar Foam::distributionModels::fixedValue::fixedValue::maxValue() const
{
return value_;
}
Foam::scalar Foam::distributionModels::fixedValue::fixedValue::meanValue() const
{
return value_;
}
// ************************************************************************* //

View File

@ -1,228 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "general.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
defineTypeNameAndDebug(general, 0);
addToRunTimeSelectionTable(distributionModel, general, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::distributionModels::general::general
(
const dictionary& dict,
Random& rndGen
)
:
distributionModel(typeName, dict, rndGen),
xy_(distributionModelDict_.lookup("distribution")),
nEntries_(xy_.size()),
minValue_(xy_[0][0]),
maxValue_(xy_[nEntries_-1][0]),
meanValue_(0.0),
integral_(nEntries_),
cumulative_(distributionModelDict_.lookupOrDefault("cumulative", false))
{
check();
// Additional sanity checks
if (cumulative_ && xy_[0][1] != 0)
{
FatalErrorInFunction
<< type() << "distribution: "
<< "The cumulative distribution must start from zero."
<< abort(FatalError);
}
for (label i=0; i<nEntries_; i++)
{
if (i > 0 && xy_[i][0] <= xy_[i-1][0])
{
FatalErrorInFunction
<< type() << "distribution: "
<< "The points must be specified in ascending order."
<< abort(FatalError);
}
if (xy_[i][1] < 0)
{
FatalErrorInFunction
<< type() << "distribution: "
<< "The distribution can't be negative."
<< abort(FatalError);
}
if (i > 0 && cumulative_ && xy_[i][1] < xy_[i-1][1])
{
FatalErrorInFunction
<< type() << "distribution: "
<< "Cumulative distribution must be non-decreasing."
<< abort(FatalError);
}
}
// Fill out the integral table (x, P(x<=0)) and calculate mean
// For density function: P(x<=0) = int f(x) and mean = int x*f(x)
// For cumulative function: mean = int 1-P(x<=0) = maxValue_ - int P(x<=0)
integral_[0] = 0.0;
for (label i=1; i<nEntries_; i++)
{
// Integrating k*x+d
scalar k = (xy_[i][1] - xy_[i-1][1])/(xy_[i][0] - xy_[i-1][0]);
scalar d = xy_[i-1][1] - k*xy_[i-1][0];
scalar y1 = xy_[i][0]*(0.5*k*xy_[i][0] + d);
scalar y0 = xy_[i-1][0]*(0.5*k*xy_[i-1][0] + d);
scalar area = y1 - y0;
if (cumulative_)
{
integral_[i] = xy_[i][1];
meanValue_ += area;
}
else
{
integral_[i] = area + integral_[i-1];
y1 = sqr(xy_[i][0])*(1.0/3.0*k*xy_[i][0] + 0.5*d);
y0 = sqr(xy_[i-1][0])*(1.0/3.0*k*xy_[i-1][0] + 0.5*d);
meanValue_ += y1 - y0;
}
}
// normalise the distribution
scalar sumArea = integral_.last();
for (label i=0; i<nEntries_; i++)
{
xy_[i][1] /= sumArea;
integral_[i] /= sumArea;
}
meanValue_ /= sumArea;
meanValue_ = cumulative_ ? (maxValue_ - meanValue_) : meanValue_;
info();
}
Foam::distributionModels::general::general(const general& p)
:
distributionModel(p),
xy_(p.xy_),
nEntries_(p.nEntries_),
minValue_(p.minValue_),
maxValue_(p.maxValue_),
meanValue_(p.meanValue_),
integral_(p.integral_),
cumulative_(p.cumulative_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::distributionModels::general::~general()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::distributionModels::general::sample() const
{
scalar y = rndGen_.sample01<scalar>();
// find the interval where y is in the table
label n=1;
while (integral_[n] <= y)
{
n++;
}
scalar k = (xy_[n][1] - xy_[n-1][1])/(xy_[n][0] - xy_[n-1][0]);
scalar d = xy_[n-1][1] - k*xy_[n-1][0];
if (cumulative_)
{
return (y - d)/k;
}
scalar alpha = y + xy_[n-1][0]*(0.5*k*xy_[n-1][0] + d) - integral_[n-1];
scalar x = 0.0;
// if k is small it is a linear equation, otherwise it is of second order
if (mag(k) > small)
{
scalar p = 2.0*d/k;
scalar q = -2.0*alpha/k;
scalar sqrtEr = sqrt(0.25*p*p - q);
scalar x1 = -0.5*p + sqrtEr;
scalar x2 = -0.5*p - sqrtEr;
if ((x1 >= xy_[n-1][0]) && (x1 <= xy_[n][0]))
{
x = x1;
}
else
{
x = x2;
}
}
else
{
x = alpha/d;
}
return x;
}
Foam::scalar Foam::distributionModels::general::minValue() const
{
return minValue_;
}
Foam::scalar Foam::distributionModels::general::maxValue() const
{
return maxValue_;
}
Foam::scalar Foam::distributionModels::general::meanValue() const
{
return meanValue_;
}
// ************************************************************************* //

View File

@ -1,139 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::distributionModels::general
Description
A general distribution model where the distribution is specified as
(point, value) pairs. By default the values are assumed to represent
a probability density function, but the model also supports specifying a
cumulative distribution function. In both cases it is assumed that the
function is linear between the specified points.
In both modes of operation the values are automatically normalised.
SourceFiles
general.C
\*---------------------------------------------------------------------------*/
#ifndef general_H
#define general_H
#include "distributionModel.H"
#include "Vector.H"
#include "VectorSpace.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
/*---------------------------------------------------------------------------*\
Class general Declaration
\*---------------------------------------------------------------------------*/
class general
:
public distributionModel
{
// Private Data
typedef VectorSpace<Vector<scalar>, scalar, 2> pair;
//- List of (x, y=f(x)) pairs
List<pair> xy_;
//- Amount of entries in the xy_ list
label nEntries_;
//- Distribution minimum
scalar minValue_;
//- Distribution maximum
scalar maxValue_;
//- Distribution mean
scalar meanValue_;
//- Values of cumulative distribution function
List<scalar> integral_;
//- Is the distribution specified as cumulative or as density
Switch cumulative_;
public:
//- Runtime type information
TypeName("general");
// Constructors
//- Construct from components
general(const dictionary& dict, Random& rndGen);
//- Construct copy
general(const general& p);
//- Construct and return a clone
virtual autoPtr<distributionModel> clone() const
{
return autoPtr<distributionModel>(new general(*this));
}
//- Destructor
virtual ~general();
// Member Functions
//- Sample the distributionModel
virtual scalar sample() const;
//- Return the minimum value
virtual scalar minValue() const;
//- Return the maximum value
virtual scalar maxValue() const;
//- Return the mean value
virtual scalar meanValue() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace distributionModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,115 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "massRosinRammler.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
defineTypeNameAndDebug(massRosinRammler, 0);
addToRunTimeSelectionTable(distributionModel, massRosinRammler, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::distributionModels::massRosinRammler::massRosinRammler
(
const dictionary& dict,
Random& rndGen
)
:
distributionModel(typeName, dict, rndGen),
minValue_(distributionModelDict_.template lookup<scalar>("minValue")),
maxValue_(distributionModelDict_.template lookup<scalar>("maxValue")),
d_(distributionModelDict_.template lookup<scalar>("d")),
n_(distributionModelDict_.template lookup<scalar>("n"))
{
check();
info();
}
Foam::distributionModels::massRosinRammler::massRosinRammler
(
const massRosinRammler& p
)
:
distributionModel(p),
minValue_(p.minValue_),
maxValue_(p.maxValue_),
d_(p.d_),
n_(p.n_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::distributionModels::massRosinRammler::~massRosinRammler()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::distributionModels::massRosinRammler::sample() const
{
scalar d;
// Re-sample if the calculated d is out of the physical range
do
{
const scalar a = 3/n_ + 1;
const scalar P = rndGen_.sample01<scalar>();
const scalar x = invIncGammaRatio_P(a, P);
d = d_*pow(x, 1/n_);
} while (d < minValue_ || d > maxValue_);
return d;
}
Foam::scalar Foam::distributionModels::massRosinRammler::minValue() const
{
return minValue_;
}
Foam::scalar Foam::distributionModels::massRosinRammler::maxValue() const
{
return maxValue_;
}
Foam::scalar Foam::distributionModels::massRosinRammler::meanValue() const
{
return d_;
}
// ************************************************************************* //

View File

@ -1,141 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::distributionModels::massRosinRammler
Description
Corrected form of the Rosin-Rammler distribution which applies
coefficients relating to a number (q0) distribution of particle
diameters to parcels of fixed mass.
Parcels of fixed mass are specified by the following setting:
\verbatim
parcelBasisType mass;
\endverbatim
If coefficients for a mass/volume (q3) distribution are given
instead, then the standard Rosin-Rammler distribution can be applied
to parcels of fixed mass.
See equation 10 in reference:
\verbatim
Yoon, S. S., Hewson, J. C., DesJardin, P. E., Glaze, D. J.,
Black, A. R., & Skaggs, R. R. (2004).
Numerical modeling and experimental measurements of a high speed
solid-cone water spray for use in fire suppression applications.
International Journal of Multiphase Flow, 30(11), 1369-1388.
\endverbatim
SourceFiles
massRosinRammler.C
\*---------------------------------------------------------------------------*/
#ifndef massRosinRammler_H
#define massRosinRammler_H
#include "distributionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
/*---------------------------------------------------------------------------*\
Class massRosinRammler Declaration
\*---------------------------------------------------------------------------*/
class massRosinRammler
:
public distributionModel
{
// Private Data
//- Distribution minimum
scalar minValue_;
//- Distribution maximum
scalar maxValue_;
//- Characteristic droplet size
scalar d_;
//- Empirical dimensionless constant to specify the distribution width,
// sometimes referred to as the dispersion coefficient
scalar n_;
public:
//- Runtime type information
TypeName("massRosinRammler");
// Constructors
//- Construct from components
massRosinRammler(const dictionary& dict, Random& rndGen);
//- Construct copy
massRosinRammler(const massRosinRammler& p);
//- Construct and return a clone
virtual autoPtr<distributionModel> clone() const
{
return autoPtr<distributionModel>(new massRosinRammler(*this));
}
//- Destructor
virtual ~massRosinRammler();
// Member Functions
//- Sample the distributionModel
virtual scalar sample() const;
//- Return the minimum value
virtual scalar minValue() const;
//- Return the maximum value
virtual scalar maxValue() const;
//- Return the mean value
virtual scalar meanValue() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace distributionModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,162 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "multiNormal.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
defineTypeNameAndDebug(multiNormal, 0);
addToRunTimeSelectionTable(distributionModel, multiNormal, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::distributionModels::multiNormal::multiNormal
(
const dictionary& dict,
Random& rndGen
)
:
distributionModel(typeName, dict, rndGen),
minValue_(distributionModelDict_.template lookup<scalar>("minValue")),
maxValue_(distributionModelDict_.template lookup<scalar>("maxValue")),
range_(maxValue_ - minValue_),
expectation_(distributionModelDict_.lookup("expectation")),
variance_(distributionModelDict_.lookup("variance")),
strength_(distributionModelDict_.lookup("strength"))
{
check();
scalar sMax = 0;
label n = strength_.size();
for (label i=0; i<n; i++)
{
scalar x = expectation_[i];
scalar s = strength_[i];
for (label j=0; j<n; j++)
{
if (i!=j)
{
scalar x2 = (x - expectation_[j])/variance_[j];
scalar y = exp(-0.5*x2*x2);
s += strength_[j]*y;
}
}
sMax = max(sMax, s);
}
for (label i=0; i<n; i++)
{
strength_[i] /= sMax;
}
info();
}
Foam::distributionModels::multiNormal::multiNormal(const multiNormal& p)
:
distributionModel(p),
minValue_(p.minValue_),
maxValue_(p.maxValue_),
range_(p.range_),
expectation_(p.expectation_),
variance_(p.variance_),
strength_(p.strength_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::distributionModels::multiNormal::~multiNormal()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::distributionModels::multiNormal::sample() const
{
scalar y = 0;
scalar x = 0;
label n = expectation_.size();
bool success = false;
while (!success)
{
x = minValue_ + range_*rndGen_.sample01<scalar>();
y = rndGen_.sample01<scalar>();
scalar p = 0.0;
for (label i=0; i<n; i++)
{
scalar nu = expectation_[i];
scalar sigma = variance_[i];
scalar s = strength_[i];
scalar v = (x - nu)/sigma;
p += s*exp(-0.5*v*v);
}
if (y<p)
{
success = true;
}
}
return x;
}
Foam::scalar Foam::distributionModels::multiNormal::minValue() const
{
return minValue_;
}
Foam::scalar Foam::distributionModels::multiNormal::maxValue() const
{
return maxValue_;
}
Foam::scalar Foam::distributionModels::multiNormal::meanValue() const
{
scalar mean = 0.0;
forAll(strength_, i)
{
mean += strength_[i]*expectation_[i];
}
return mean;
}
// ************************************************************************* //

View File

@ -1,129 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::distributionModels::multiNormal
Description
A multiNormal distribution model
\verbatim
model = sum_i strength_i * exp(-0.5*((x - expectation_i)/variance_i)^2 )
\endverbatim
SourceFiles
multiNormal.C
\*---------------------------------------------------------------------------*/
#ifndef multiNormal_H
#define multiNormal_H
#include "distributionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
/*---------------------------------------------------------------------------*\
Class multiNormal Declaration
\*---------------------------------------------------------------------------*/
class multiNormal
:
public distributionModel
{
// Private Data
//- Distribution minimum
scalar minValue_;
//- Distribution maximum
scalar maxValue_;
//- Distribution range
scalar range_;
// Model coefficients
List<scalar> expectation_;
List<scalar> variance_;
List<scalar> strength_;
public:
//- Runtime type information
TypeName("multiNormal");
// Constructors
//- Construct from components
multiNormal(const dictionary& dict, Random& rndGen);
//- Construct copy
multiNormal(const multiNormal& p);
//- Construct and return a clone
virtual autoPtr<distributionModel> clone() const
{
return autoPtr<distributionModel>(new multiNormal(*this));
}
//- Destructor
virtual ~multiNormal();
// Member Functions
//- Sample the distributionModel
virtual scalar sample() const;
//- Return the minimum value
virtual scalar minValue() const;
//- Return the maximum value
virtual scalar maxValue() const;
//- Return the mean value
virtual scalar meanValue() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace distributionModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,129 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "normal.H"
#include "addToRunTimeSelectionTable.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
defineTypeNameAndDebug(normal, 0);
addToRunTimeSelectionTable(distributionModel, normal, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::distributionModels::normal::normal
(
const dictionary& dict,
Random& rndGen
)
:
distributionModel(typeName, dict, rndGen),
minValue_(distributionModelDict_.template lookup<scalar>("minValue")),
maxValue_(distributionModelDict_.template lookup<scalar>("maxValue")),
expectation_(distributionModelDict_.template lookup<scalar>("expectation")),
variance_(distributionModelDict_.template lookup<scalar>("variance")),
a_(0.147)
{
check();
info();
}
Foam::distributionModels::normal::normal(const normal& p)
:
distributionModel(p),
minValue_(p.minValue_),
maxValue_(p.maxValue_),
expectation_(p.expectation_),
variance_(p.variance_),
a_(p.a_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::distributionModels::normal::~normal()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::distributionModels::normal::sample() const
{
scalar a = erf((minValue_ - expectation_)/variance_);
scalar b = erf((maxValue_ - expectation_)/variance_);
scalar y = rndGen_.sample01<scalar>();
scalar x = erfInv(y*(b - a) + a)*variance_ + expectation_;
// Note: numerical approximation of the inverse function yields slight
// inaccuracies
x = min(max(x, minValue_), maxValue_);
return x;
}
Foam::scalar Foam::distributionModels::normal::minValue() const
{
return minValue_;
}
Foam::scalar Foam::distributionModels::normal::maxValue() const
{
return maxValue_;
}
Foam::scalar Foam::distributionModels::normal::meanValue() const
{
return expectation_;
}
Foam::scalar Foam::distributionModels::normal::erfInv(const scalar y) const
{
scalar k = 2.0/(constant::mathematical::pi*a_) + 0.5*log(1.0 - y*y);
scalar h = log(1.0 - y*y)/a_;
scalar x = sqrt(-k + sqrt(k*k - h));
if (y < 0.0)
{
x *= -1.0;
}
return x;
}
// ************************************************************************* //

View File

@ -1,131 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::distributionModels::normal
Description
A normal distribution model
\verbatim
model = strength * exp(-0.5*((x - expectation)/variance)^2 )
\endverbatim
strength only has meaning if there's more than one distribution model
SourceFiles
normal.C
\*---------------------------------------------------------------------------*/
#ifndef normal_H
#define normal_H
#include "distributionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
/*---------------------------------------------------------------------------*\
Class normal Declaration
\*---------------------------------------------------------------------------*/
class normal
:
public distributionModel
{
// Private Data
//- Distribution minimum
scalar minValue_;
//- Distribution maximum
scalar maxValue_;
// Model coefficients
scalar expectation_;
scalar variance_;
scalar a_;
public:
//- Runtime type information
TypeName("normal");
// Constructors
//- Construct from components
normal(const dictionary& dict, Random& rndGen);
//- Construct copy
normal(const normal& p);
//- Construct and return a clone
virtual autoPtr<distributionModel> clone() const
{
return autoPtr<distributionModel>(new normal(*this));
}
//- Destructor
virtual ~normal();
// Member Functions
//- Sample the distributionModel
virtual scalar sample() const;
//- Return the minimum value
virtual scalar minValue() const;
//- Return the maximum value
virtual scalar maxValue() const;
//- Return the mean value
virtual scalar meanValue() const;
virtual scalar erfInv(const scalar y) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace distributionModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,97 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "uniform.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
defineTypeNameAndDebug(uniform, 0);
addToRunTimeSelectionTable(distributionModel, uniform, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::distributionModels::uniform::uniform
(
const dictionary& dict,
Random& rndGen
)
:
distributionModel(typeName, dict, rndGen),
minValue_(distributionModelDict_.template lookup<scalar>("minValue")),
maxValue_(distributionModelDict_.template lookup<scalar>("maxValue"))
{
check();
info();
}
Foam::distributionModels::uniform::uniform(const uniform& p)
:
distributionModel(p),
minValue_(p.minValue_),
maxValue_(p.maxValue_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::distributionModels::uniform::~uniform()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::distributionModels::uniform::sample() const
{
return rndGen_.scalarAB(minValue_, maxValue_);
}
Foam::scalar Foam::distributionModels::uniform::minValue() const
{
return minValue_;
}
Foam::scalar Foam::distributionModels::uniform::maxValue() const
{
return maxValue_;
}
Foam::scalar Foam::distributionModels::uniform::meanValue() const
{
return 0.5*(minValue_ + maxValue_);
}
// ************************************************************************* //

View File

@ -1,114 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::distributionModels::uniform
Description
Uniform/equally-weighted distribution model
SourceFiles
uniform.C
\*---------------------------------------------------------------------------*/
#ifndef uniform_H
#define uniform_H
#include "distributionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
/*---------------------------------------------------------------------------*\
Class uniform Declaration
\*---------------------------------------------------------------------------*/
class uniform
:
public distributionModel
{
// Private Data
//- Distribution minimum
scalar minValue_;
//- Distribution maximum
scalar maxValue_;
public:
//- Runtime type information
TypeName("uniform");
// Constructors
//- Construct from components
uniform(const dictionary& dict, Random& rndGen);
//- Construct copy
uniform(const uniform& p);
//- Construct and return a clone
virtual autoPtr<distributionModel> clone() const
{
return autoPtr<distributionModel>(new uniform(*this));
}
//- Destructor
virtual ~uniform();
// Member Functions
//- Sample the distributionModel
virtual scalar sample() const;
//- Return the minimum value
virtual scalar minValue() const;
//- Return the maximum value
virtual scalar maxValue() const;
//- Return the mean value
virtual scalar meanValue() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace distributionModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -96,6 +96,9 @@ $(MPPICTIMESCALE)/equilibrium/equilibrium.C
$(MPPICTIMESCALE)/nonEquilibrium/nonEquilibrium.C
$(MPPICTIMESCALE)/isotropic/isotropic.C
# injection model
submodels/Momentum/InjectionModel/InjectionModel/injectionModel.C
# integration schemes
integrationScheme/integrationScheme/integrationScheme.C
integrationScheme/integrationScheme/integrationSchemeNew.C

View File

@ -1,6 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
@ -13,7 +12,6 @@ EXE_INC = \
LIB_LIBS = \
-llagrangian \
-ldistributionModels \
-lspecie \
-lfluidThermophysicalModels \
-lthermophysicalProperties \

View File

@ -545,7 +545,7 @@ template<class CloudType>
void Foam::MomentumCloud<CloudType>::checkParcelProperties
(
parcelType& parcel,
const bool fullyDescribed
const label injectori
)
{
if (parcel.typeId() == -1)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -539,7 +539,7 @@ public:
void checkParcelProperties
(
parcelType& parcel,
const bool fullyDescribed
const label injectori
);
//- Store the current cloud state

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -208,12 +208,12 @@ template<class CloudType>
void Foam::ReactingCloud<CloudType>::checkParcelProperties
(
parcelType& parcel,
const bool fullyDescribed
const label injectori
)
{
CloudType::checkParcelProperties(parcel, fullyDescribed);
CloudType::checkParcelProperties(parcel, injectori);
if (fullyDescribed)
if (injectori != -1 && this->injectors()[injectori].fullyDescribed())
{
checkSuppliedComposition
(
@ -222,9 +222,6 @@ void Foam::ReactingCloud<CloudType>::checkParcelProperties
"YMixture"
);
}
// derived information - store initial mass
parcel.mass0() = parcel.mass();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -265,7 +265,7 @@ public:
void checkParcelProperties
(
parcelType& parcel,
const bool fullyDescribed
const label injectori
);
//- Store the current cloud state

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -171,12 +171,14 @@ template<class CloudType>
void Foam::ReactingMultiphaseCloud<CloudType>::checkParcelProperties
(
parcelType& parcel,
const bool fullyDescribed
const label injectori
)
{
CloudType::checkParcelProperties(parcel, fullyDescribed);
CloudType::checkParcelProperties(parcel, injectori);
if (fullyDescribed)
parcel.mass0() = parcel.mass();
if (injectori != -1 && this->injectors()[injectori].fullyDescribed())
{
label idGas = this->composition().idGas();
label idLiquid = this->composition().idLiquid();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -261,7 +261,7 @@ public:
void checkParcelProperties
(
parcelType& parcel,
const bool fullyDescribed
const label injectori
);
//- Store the current cloud state

View File

@ -26,6 +26,7 @@ License
#include "SprayCloud.H"
#include "AtomisationModel.H"
#include "BreakupModel.H"
#include "ConeInjection.H"
#include "parcelThermo.H"
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
@ -163,19 +164,22 @@ template<class CloudType>
void Foam::SprayCloud<CloudType>::checkParcelProperties
(
parcelType& parcel,
const bool fullyDescribed
const label injectori
)
{
CloudType::checkParcelProperties(parcel, fullyDescribed);
CloudType::checkParcelProperties(parcel, injectori);
// store the injection position and initial drop size
parcel.position0() = parcel.position(this->mesh());
// store the initial size and position
parcel.d0() = parcel.d();
parcel.mass0() = parcel.mass();
parcel.position0() = parcel.position(this->mesh());
parcel.y() = breakup().y0();
parcel.yDot() = breakup().yDot0();
parcel.liquidCore() = atomisation().initLiquidCore();
parcel.injector() = injectori;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -50,6 +50,7 @@ namespace Foam
{
// Forward declaration of classes
template<class CloudType>
class AtomisationModel;
@ -215,7 +216,7 @@ public:
void checkParcelProperties
(
parcelType& parcel,
const bool fullyDescribed
const label injectori
);
//- Store the current cloud state

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -373,10 +373,10 @@ template<class CloudType>
void Foam::ThermoCloud<CloudType>::checkParcelProperties
(
parcelType& parcel,
const bool fullyDescribed
const label injectori
)
{
CloudType::checkParcelProperties(parcel, fullyDescribed);
CloudType::checkParcelProperties(parcel, injectori);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -55,6 +55,9 @@ namespace Foam
class integrationScheme;
template<class CloudType>
class InjectionModel;
template<class CloudType>
class HeatTransferModel;
@ -354,7 +357,7 @@ public:
void checkParcelProperties
(
parcelType& parcel,
const bool fullyDescribed
const label injectori
);
//- Store the current cloud state

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -278,7 +278,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
d0,
T0,
mass0,
this->mass0_,
mass0_,
YMix[GAS]*YGas_,
YMix[LIQ]*YLiquid_,
YMix[SLD]*YSolid_,
@ -716,6 +716,7 @@ Foam::ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel
)
:
ParcelType(p),
mass0_(p.mass0_),
YGas_(p.YGas_),
YLiquid_(p.YLiquid_),
YSolid_(p.YSolid_),

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -198,6 +198,9 @@ protected:
// Parcel properties
//- Initial mass [kg]
scalar mass0_;
//- Mass fractions of gases []
scalarField YGas_;
@ -274,7 +277,8 @@ public:
AddToPropertyList
(
ParcelType,
" nGas(Y1..YN)"
" mass0"
+ " nGas(Y1..YN)"
+ " nLiquid(Y1..YN)"
+ " nSolid(Y1..YN)"
);
@ -330,6 +334,9 @@ public:
// Access
//- Return const access to initial mass [kg]
inline scalar mass0() const;
//- Return const access to mass fractions of gases
inline const scalarField& YGas() const;
@ -345,6 +352,9 @@ public:
// Edit
//- Return access to initial mass [kg]
inline scalar& mass0();
//- Return access to mass fractions of gases
inline scalarField& YGas();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -78,6 +78,7 @@ inline Foam::ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel
)
:
ParcelType(mesh, coordinates, celli, tetFacei, tetPti, facei),
mass0_(0),
YGas_(0),
YLiquid_(0),
YSolid_(0),
@ -94,6 +95,7 @@ inline Foam::ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel
)
:
ParcelType(mesh, position, celli),
mass0_(0),
YGas_(0),
YLiquid_(0),
YSolid_(0),
@ -137,7 +139,14 @@ hRetentionCoeff() const
}
// * * * * * * * * * * ThermoParcel Member Functions * * * * * * * * * * * * //
// * * * * * * * * ReactingMultiphaseParcel Member Functions * * * * * * * * //
template<class ParcelType>
inline Foam::scalar Foam::ReactingMultiphaseParcel<ParcelType>::mass0() const
{
return mass0_;
}
template<class ParcelType>
inline const Foam::scalarField& Foam::ReactingMultiphaseParcel<ParcelType>::
@ -171,6 +180,13 @@ Foam::ReactingMultiphaseParcel<ParcelType>::canCombust() const
}
template<class ParcelType>
inline Foam::scalar& Foam::ReactingMultiphaseParcel<ParcelType>::mass0()
{
return mass0_;
}
template<class ParcelType>
inline Foam::scalarField& Foam::ReactingMultiphaseParcel<ParcelType>::YGas()
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -35,7 +35,7 @@ Foam::string Foam::ReactingMultiphaseParcel<ParcelType>::propertyList_ =
template<class ParcelType>
const std::size_t Foam::ReactingMultiphaseParcel<ParcelType>::sizeofFields_
(
0
sizeof(scalar)
);
@ -49,6 +49,7 @@ Foam::ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel
)
:
ParcelType(is, readFields),
mass0_(0.0),
YGas_(0),
YLiquid_(0),
YSolid_(0),
@ -60,7 +61,15 @@ Foam::ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel
DynamicList<scalar> Yl;
DynamicList<scalar> Ys;
if (is.format() == IOstream::ASCII)
{
is >> mass0_ >> Yg >> Yl >> Ys;
}
else
{
is.read(reinterpret_cast<char*>(&mass0_), sizeofFields_);
is >> Yg >> Yl >> Ys;
}
YGas_.transfer(Yg);
YLiquid_.transfer(Yl);
@ -106,6 +115,20 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::readFields
ParcelType::readFields(c, compModel);
IOField<scalar> mass0
(
c.fieldIOobject("mass0", IOobject::MUST_READ),
valid
);
c.checkFieldIOobject(c, mass0);
label i = 0;
forAllIter(typename CloudType, c, iter)
{
ReactingMultiphaseParcel<ParcelType>& p = iter();
p.mass0_ = mass0[i++];
}
// Get names and sizes for each Y...
const label idGas = compModel.idGas();
const wordList& gasNames = compModel.componentNames(idGas);
@ -207,8 +230,18 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeFields
label np = c.size();
// Write the composition fractions
{
IOField<scalar> mass0(c.fieldIOobject("mass0", IOobject::NO_READ), np);
label i = 0;
forAllConstIter(typename CloudType, c, iter)
{
const ReactingMultiphaseParcel<ParcelType>& p = iter();
mass0[i++] = p.mass0_;
}
mass0.write(np > 0);
// Write the composition fractions
const wordList& stateLabels = compModel.stateLabels();
const label idGas = compModel.idGas();
@ -301,6 +334,7 @@ Foam::Ostream& Foam::operator<<
if (os.format() == IOstream::ASCII)
{
os << static_cast<const ParcelType&>(p)
<< token::SPACE << p.mass0()
<< token::SPACE << YGasLoc
<< token::SPACE << YLiquidLoc
<< token::SPACE << YSolidLoc;
@ -308,6 +342,11 @@ Foam::Ostream& Foam::operator<<
else
{
os << static_cast<const ParcelType&>(p);
os.write
(
reinterpret_cast<const char*>(&p.mass0_),
ReactingMultiphaseParcel<ParcelType>::sizeofFields_
);
os << YGasLoc << YLiquidLoc << YSolidLoc;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -184,7 +184,6 @@ Foam::ReactingParcel<ParcelType>::ReactingParcel
)
:
ParcelType(p),
mass0_(p.mass0_),
Y_(p.Y_)
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -132,9 +132,6 @@ protected:
// Parcel properties
//- Initial mass [kg]
scalar mass0_;
//- Mass fractions of mixture []
scalarField Y_;
@ -182,8 +179,7 @@ public:
AddToPropertyList
(
ParcelType,
" mass0"
+ " nPhases(Y1..YN)"
" nPhases(Y1..YN)"
);
@ -233,18 +229,12 @@ public:
// Access
//- Return const access to initial mass [kg]
inline scalar mass0() const;
//- Return const access to mass fractions of mixture []
inline const scalarField& Y() const;
// Edit
//- Return access to initial mass [kg]
inline scalar& mass0();
//- Return access to mass fractions of mixture []
inline scalarField& Y();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -73,7 +73,6 @@ inline Foam::ReactingParcel<ParcelType>::ReactingParcel
)
:
ParcelType(mesh, coordinates, celli, tetFacei, tetPti, facei),
mass0_(0.0),
Y_(0)
{}
@ -87,7 +86,6 @@ inline Foam::ReactingParcel<ParcelType>::ReactingParcel
)
:
ParcelType(mesh, position, celli),
mass0_(0.0),
Y_(0)
{}
@ -110,14 +108,7 @@ Foam::ReactingParcel<ParcelType>::constantProperties::constantVolume() const
}
// * * * * * * * * * * ThermoParcel Member Functions * * * * * * * * * * * * //
template<class ParcelType>
inline Foam::scalar Foam::ReactingParcel<ParcelType>::mass0() const
{
return mass0_;
}
// * * * * * * * * * * ReactingParcel Member Functions * * * * * * * * * * * //
template<class ParcelType>
inline const Foam::scalarField& Foam::ReactingParcel<ParcelType>::Y() const
@ -126,13 +117,6 @@ inline const Foam::scalarField& Foam::ReactingParcel<ParcelType>::Y() const
}
template<class ParcelType>
inline Foam::scalar& Foam::ReactingParcel<ParcelType>::mass0()
{
return mass0_;
}
template<class ParcelType>
inline Foam::scalarField& Foam::ReactingParcel<ParcelType>::Y()
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -35,7 +35,7 @@ Foam::string Foam::ReactingParcel<ParcelType>::propertyList_ =
template<class ParcelType>
const std::size_t Foam::ReactingParcel<ParcelType>::sizeofFields_
(
sizeof(scalar)
0
);
@ -45,22 +45,13 @@ template<class ParcelType>
Foam::ReactingParcel<ParcelType>::ReactingParcel(Istream& is, bool readFields)
:
ParcelType(is, readFields),
mass0_(0.0),
Y_(0)
{
if (readFields)
{
DynamicList<scalar> Ymix;
if (is.format() == IOstream::ASCII)
{
is >> mass0_ >> Ymix;
}
else
{
is.read(reinterpret_cast<char*>(&mass0_), sizeofFields_);
is >> Ymix;
}
Y_.transfer(Ymix);
}
@ -98,20 +89,6 @@ void Foam::ReactingParcel<ParcelType>::readFields
ParcelType::readFields(c);
IOField<scalar> mass0
(
c.fieldIOobject("mass0", IOobject::MUST_READ),
valid
);
c.checkFieldIOobject(c, mass0);
label i = 0;
forAllIter(typename CloudType, c, iter)
{
ReactingParcel<ParcelType>& p = iter();
p.mass0_ = mass0[i++];
}
// Get names and sizes for each Y...
const wordList& phaseTypes = compModel.phaseTypes();
const label nPhases = phaseTypes.size();
@ -121,7 +98,6 @@ void Foam::ReactingParcel<ParcelType>::readFields
stateLabels = compModel.stateLabels()[0];
}
// Set storage for each Y... for each parcel
forAllIter(typename CloudType, c, iter)
{
@ -173,16 +149,6 @@ void Foam::ReactingParcel<ParcelType>::writeFields
const label np = c.size();
{
IOField<scalar> mass0(c.fieldIOobject("mass0", IOobject::NO_READ), np);
label i = 0;
forAllConstIter(typename CloudType, c, iter)
{
const ReactingParcel<ParcelType>& p = iter();
mass0[i++] = p.mass0_;
}
mass0.write(np > 0);
// Write the composition fractions
const wordList& phaseTypes = compModel.phaseTypes();
wordList stateLabels(phaseTypes.size(), "");
@ -227,17 +193,11 @@ Foam::Ostream& Foam::operator<<
if (os.format() == IOstream::ASCII)
{
os << static_cast<const ParcelType&>(p)
<< token::SPACE << p.mass0()
<< token::SPACE << p.Y();
}
else
{
os << static_cast<const ParcelType&>(p);
os.write
(
reinterpret_cast<const char*>(&p.mass0_),
ReactingParcel<ParcelType>::sizeofFields_
);
os << p.Y();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -153,6 +153,8 @@ void Foam::SprayParcel<ParcelType>::calcAtomisation
const scalar dt
)
{
if (injector_ == -1) return;
typedef typename TrackCloudType::thermoCloudType thermoCloudType;
const CompositionModel<thermoCloudType>& composition =
cloud.composition();
@ -169,7 +171,7 @@ void Foam::SprayParcel<ParcelType>::calcAtomisation
// Calculate average gas density based on average temperature
scalar rhoAv = td.pc()/(R*Tav);
scalar soi = cloud.injectors().timeStart();
scalar soi = cloud.injectors()[injector_].timeStart();
scalar currentTime = cloud.db().time().value();
const vector& pos = this->position(td.mesh);
const vector& injectionPos = this->position0();
@ -179,10 +181,12 @@ void Foam::SprayParcel<ParcelType>::calcAtomisation
scalar Urel = mag(this->U());
scalar t0 = max(0.0, currentTime - this->age() - soi);
scalar t1 = min(t0 + dt, cloud.injectors().timeEnd() - soi);
scalar t1 = min(t0 + dt, cloud.injectors()[injector_].timeEnd() - soi);
scalar rho0 = mass0_/this->volume(d0_);
// This should be the vol flow rate from when the parcel was injected
scalar volFlowRate = cloud.injectors().volumeToInject(t0, t1)/dt;
scalar volFlowRate = cloud.injectors()[injector_].massToInject(t0, t1)/rho0;
scalar chi = 0.0;
if (atomisation.calcChi())
@ -276,6 +280,7 @@ void Foam::SprayParcel<ParcelType>::calcBreakup
Urel,
Urmag,
this->tMom(),
injector_,
dChild,
parcelMassChild
)
@ -306,7 +311,6 @@ void Foam::SprayParcel<ParcelType>::calcBreakup
child->ms() = -great;
child->injector() = this->injector();
child->tMom() = massChild/(Fcp.Sp() + Fncp.Sp());
child->user() = 0.0;
child->calcDispersion(cloud, td, dt);
cloud.addParticle(child);
@ -426,8 +430,7 @@ Foam::SprayParcel<ParcelType>::SprayParcel(const SprayParcel<ParcelType>& p)
tc_(p.tc_),
ms_(p.ms_),
injector_(p.injector_),
tMom_(p.tMom_),
user_(p.user_)
tMom_(p.tMom_)
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -146,9 +146,12 @@ protected:
// Spray parcel properties
//- Initial droplet diameter
//- Initial droplet diameter [m]
scalar d0_;
//- Initial mass [kg]
scalar mass0_;
//- Injection position
vector position0_;
@ -176,16 +179,12 @@ protected:
//- Stripped parcel mass due to breakup
scalar ms_;
//- Injected from injector (needed e.g. for calculating distance
// from injector)
scalar injector_;
//- Injector id
label injector_;
//- Momentum relaxation time (needed for calculating parcel acc.)
scalar tMom_;
//- Passive scalar (extra variable to be defined by user)
scalar user_;
public:
@ -238,6 +237,9 @@ public:
//- Return const access to initial droplet diameter
inline scalar d0() const;
//- Return const access to initial mass [kg]
inline scalar mass0() const;
//- Return const access to initial droplet position
inline const vector& position0() const;
@ -266,20 +268,20 @@ public:
inline scalar ms() const;
//- Return const access to injector id
inline scalar injector() const;
inline label injector() const;
//- Return const access to momentum relaxation time
inline scalar tMom() const;
//- Return const access to passive user scalar
inline scalar user() const;
// Edit
//- Return access to initial droplet diameter
inline scalar& d0();
//- Return access to initial mass [kg]
inline scalar& mass0();
//- Return access to initial droplet position
inline vector& position0();
@ -308,14 +310,11 @@ public:
inline scalar& ms();
//- Return access to injector id
inline scalar& injector();
inline label& injector();
//- Return access to momentum relaxation time
inline scalar& tMom();
//- Return access to passive user scalar
inline scalar& user();
// Main calculation loop

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -118,6 +118,7 @@ inline Foam::SprayParcel<ParcelType>::SprayParcel
:
ParcelType(mesh, coordinates, celli, tetFacei, tetPti, facei),
d0_(this->d()),
mass0_(this->mass()),
position0_(this->position(mesh)),
sigma_(0.0),
mu_(0.0),
@ -127,9 +128,8 @@ inline Foam::SprayParcel<ParcelType>::SprayParcel
yDot_(0.0),
tc_(0.0),
ms_(0.0),
injector_(1.0),
tMom_(great),
user_(0.0)
injector_(-1),
tMom_(great)
{}
@ -143,6 +143,7 @@ inline Foam::SprayParcel<ParcelType>::SprayParcel
:
ParcelType(mesh, position, celli),
d0_(this->d()),
mass0_(this->mass()),
position0_(this->position(mesh)),
sigma_(0.0),
mu_(0.0),
@ -152,9 +153,8 @@ inline Foam::SprayParcel<ParcelType>::SprayParcel
yDot_(0.0),
tc_(0.0),
ms_(0.0),
injector_(1.0),
tMom_(great),
user_(0.0)
injector_(-1),
tMom_(great)
{}
@ -185,6 +185,13 @@ inline Foam::scalar Foam::SprayParcel<ParcelType>::d0() const
}
template<class ParcelType>
inline Foam::scalar Foam::SprayParcel<ParcelType>::mass0() const
{
return mass0_;
}
template<class ParcelType>
inline const Foam::vector& Foam::SprayParcel<ParcelType>::position0() const
{
@ -249,7 +256,7 @@ inline Foam::scalar Foam::SprayParcel<ParcelType>::ms() const
template<class ParcelType>
inline Foam::scalar Foam::SprayParcel<ParcelType>::injector() const
inline Foam::label Foam::SprayParcel<ParcelType>::injector() const
{
return injector_;
}
@ -263,16 +270,16 @@ inline Foam::scalar Foam::SprayParcel<ParcelType>::tMom() const
template<class ParcelType>
inline Foam::scalar Foam::SprayParcel<ParcelType>::user() const
inline Foam::scalar& Foam::SprayParcel<ParcelType>::d0()
{
return user_;
return d0_;
}
template<class ParcelType>
inline Foam::scalar& Foam::SprayParcel<ParcelType>::d0()
inline Foam::scalar& Foam::SprayParcel<ParcelType>::mass0()
{
return d0_;
return mass0_;
}
@ -340,7 +347,7 @@ inline Foam::scalar& Foam::SprayParcel<ParcelType>::ms()
template<class ParcelType>
inline Foam::scalar& Foam::SprayParcel<ParcelType>::injector()
inline Foam::label& Foam::SprayParcel<ParcelType>::injector()
{
return injector_;
}
@ -353,11 +360,4 @@ inline Foam::scalar& Foam::SprayParcel<ParcelType>::tMom()
}
template<class ParcelType>
inline Foam::scalar& Foam::SprayParcel<ParcelType>::user()
{
return user_;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,6 +42,7 @@ Foam::SprayParcel<ParcelType>::SprayParcel(Istream& is, bool readFields)
:
ParcelType(is, readFields),
d0_(0.0),
mass0_(0.0),
position0_(Zero),
sigma_(0.0),
mu_(0.0),
@ -51,15 +52,15 @@ Foam::SprayParcel<ParcelType>::SprayParcel(Istream& is, bool readFields)
yDot_(0.0),
tc_(0.0),
ms_(0.0),
injector_(1.0),
tMom_(great),
user_(0.0)
injector_(-1),
tMom_(great)
{
if (readFields)
{
if (is.format() == IOstream::ASCII)
{
d0_ = readScalar(is);
mass0_ = readScalar(is);
is >> position0_;
sigma_ = readScalar(is);
mu_ = readScalar(is);
@ -69,9 +70,8 @@ Foam::SprayParcel<ParcelType>::SprayParcel(Istream& is, bool readFields)
yDot_ = readScalar(is);
tc_ = readScalar(is);
ms_ = readScalar(is);
injector_ = readScalar(is);
injector_ = readLabel(is);
tMom_ = readScalar(is);
user_ = readScalar(is);
}
else
{
@ -115,6 +115,9 @@ void Foam::SprayParcel<ParcelType>::readFields
IOField<scalar> d0(c.fieldIOobject("d0", IOobject::MUST_READ), write);
c.checkFieldIOobject(c, d0);
IOField<scalar> mass0(c.fieldIOobject("mass0", IOobject::MUST_READ), write);
c.checkFieldIOobject(c, mass0);
IOField<vector> position0
(
c.fieldIOobject("position0", IOobject::MUST_READ),
@ -170,7 +173,7 @@ void Foam::SprayParcel<ParcelType>::readFields
);
c.checkFieldIOobject(c, ms);
IOField<scalar> injector
IOField<label> injector
(
c.fieldIOobject("injector", IOobject::MUST_READ),
write
@ -184,18 +187,12 @@ void Foam::SprayParcel<ParcelType>::readFields
);
c.checkFieldIOobject(c, tMom);
IOField<scalar> user
(
c.fieldIOobject("user", IOobject::MUST_READ),
write
);
c.checkFieldIOobject(c, user);
label i = 0;
forAllIter(typename CloudType, c, iter)
{
SprayParcel<ParcelType>& p = iter();
p.d0_ = d0[i];
p.mass0_ = mass0[i];
p.position0_ = position0[i];
p.sigma_ = sigma[i];
p.mu_ = mu[i];
@ -207,7 +204,6 @@ void Foam::SprayParcel<ParcelType>::readFields
p.ms_ = ms[i];
p.injector_ = injector[i];
p.tMom_ = tMom[i];
p.user_ = user[i];
i++;
}
}
@ -234,6 +230,7 @@ void Foam::SprayParcel<ParcelType>::writeFields
label np = c.size();
IOField<scalar> d0(c.fieldIOobject("d0", IOobject::NO_READ), np);
IOField<scalar> mass0(c.fieldIOobject("mass0", IOobject::NO_READ), np);
IOField<vector> position0
(
c.fieldIOobject("position0", IOobject::NO_READ),
@ -251,19 +248,19 @@ void Foam::SprayParcel<ParcelType>::writeFields
IOField<scalar> yDot(c.fieldIOobject("yDot", IOobject::NO_READ), np);
IOField<scalar> tc(c.fieldIOobject("tc", IOobject::NO_READ), np);
IOField<scalar> ms(c.fieldIOobject("ms", IOobject::NO_READ), np);
IOField<scalar> injector
IOField<label> injector
(
c.fieldIOobject("injector", IOobject::NO_READ),
np
);
IOField<scalar> tMom(c.fieldIOobject("tMom", IOobject::NO_READ), np);
IOField<scalar> user(c.fieldIOobject("user", IOobject::NO_READ), np);
label i = 0;
forAllConstIter(typename CloudType, c, iter)
{
const SprayParcel<ParcelType>& p = iter();
d0[i] = p.d0_;
mass0[i] = p.mass0_;
position0[i] = p.position0_;
sigma[i] = p.sigma_;
mu[i] = p.mu_;
@ -275,13 +272,13 @@ void Foam::SprayParcel<ParcelType>::writeFields
ms[i] = p.ms_;
injector[i] = p.injector_;
tMom[i] = p.tMom_;
user[i] = p.user_;
i++;
}
const bool write = np > 0;
d0.write(write);
mass0.write(write);
position0.write(write);
sigma.write(write);
mu.write(write);
@ -293,7 +290,6 @@ void Foam::SprayParcel<ParcelType>::writeFields
ms.write(write);
injector.write(write);
tMom.write(write);
user.write(write);
}
@ -310,6 +306,7 @@ Foam::Ostream& Foam::operator<<
{
os << static_cast<const ParcelType&>(p)
<< token::SPACE << p.d0()
<< token::SPACE << p.mass0()
<< token::SPACE << p.position0()
<< token::SPACE << p.sigma()
<< token::SPACE << p.mu()
@ -320,8 +317,7 @@ Foam::Ostream& Foam::operator<<
<< token::SPACE << p.tc()
<< token::SPACE << p.ms()
<< token::SPACE << p.injector()
<< token::SPACE << p.tMom()
<< token::SPACE << p.user();
<< token::SPACE << p.tMom();
}
else
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,7 +31,6 @@ License
#include "CellZoneInjection.H"
#include "ConeInjection.H"
#include "FieldActivatedInjection.H"
#include "InflationInjection.H"
#include "MomentumLookupTableInjection.H"
#include "ManualInjection.H"
#include "NoInjection.H"
@ -47,7 +46,6 @@ License
makeInjectionModelType(CellZoneInjection, CloudType); \
makeInjectionModelType(ConeInjection, CloudType); \
makeInjectionModelType(FieldActivatedInjection, CloudType); \
makeInjectionModelType(InflationInjection, CloudType); \
makeInjectionModelType(MomentumLookupTableInjection, CloudType); \
makeInjectionModelType(ManualInjection, CloudType); \
makeInjectionModelType(NoInjection, CloudType); \

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,6 +42,7 @@ License
#define makeReactingMultiphaseParcelInjectionModels(CloudType) \
\
makeInjectionModel(CloudType); \
\
makeInjectionModelType(CellZoneInjection, CloudType); \
makeInjectionModelType(ConeInjection, CloudType); \
makeInjectionModelType(FieldActivatedInjection, CloudType); \

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,6 +42,7 @@ License
#define makeReactingParcelInjectionModels(CloudType) \
\
makeInjectionModel(CloudType); \
\
makeInjectionModelType(CellZoneInjection, CloudType); \
makeInjectionModelType(ConeInjection, CloudType); \
makeInjectionModelType(FieldActivatedInjection, CloudType); \

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,7 +31,6 @@ License
#include "CellZoneInjection.H"
#include "ConeInjection.H"
#include "FieldActivatedInjection.H"
#include "InflationInjection.H"
#include "ManualInjection.H"
#include "NoInjection.H"
#include "PatchInjection.H"
@ -46,7 +45,6 @@ License
makeInjectionModelType(CellZoneInjection, CloudType); \
makeInjectionModelType(ConeInjection, CloudType); \
makeInjectionModelType(FieldActivatedInjection, CloudType); \
makeInjectionModelType(InflationInjection, CloudType); \
makeInjectionModelType(ManualInjection, CloudType); \
makeInjectionModelType(NoInjection, CloudType); \
makeInjectionModelType(PatchFlowRateInjection, CloudType); \

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,6 +42,7 @@ License
#define makeThermoParcelInjectionModels(CloudType) \
\
makeInjectionModel(CloudType); \
\
makeInjectionModelType(CellZoneInjection, CloudType); \
makeInjectionModelType(ConeInjection, CloudType); \
makeInjectionModelType(FieldActivatedInjection, CloudType); \

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -161,6 +161,7 @@ Foam::CellZoneInjection<CloudType>::CellZoneInjection
:
InjectionModel<CloudType>(dict, owner, modelName, typeName),
cellZoneName_(this->coeffDict().lookup("cellZone")),
massTotal_(this->readMassTotal(dict, owner)),
numberDensity_(this->coeffDict().template lookup<scalar>("numberDensity")),
injectorCoordinates_(),
injectorCells_(),
@ -170,9 +171,11 @@ Foam::CellZoneInjection<CloudType>::CellZoneInjection
U0_(this->coeffDict().lookup("U0")),
sizeDistribution_
(
distributionModel::New
distribution::New
(
this->coeffDict().subDict("sizeDistribution"), owner.rndGen()
this->coeffDict().subDict("sizeDistribution"),
owner.rndGen(),
this->sizeSampleQ()
)
)
{
@ -188,6 +191,7 @@ Foam::CellZoneInjection<CloudType>::CellZoneInjection
:
InjectionModel<CloudType>(im),
cellZoneName_(im.cellZoneName_),
massTotal_(im.massTotal_),
numberDensity_(im.numberDensity_),
injectorCoordinates_(im.injectorCoordinates_),
injectorCells_(im.injectorCells_),
@ -252,9 +256,6 @@ void Foam::CellZoneInjection<CloudType>::topoChange()
diameters_[i] = sizeDistribution_->sample();
}
}
// Determine volume of particles to inject
this->volumeTotal_ = sum(pow3(diameters_))*constant::mathematical::pi/6.0;
}
@ -267,13 +268,14 @@ Foam::scalar Foam::CellZoneInjection<CloudType>::timeEnd() const
template<class CloudType>
Foam::label Foam::CellZoneInjection<CloudType>::parcelsToInject
Foam::label Foam::CellZoneInjection<CloudType>::nParcelsToInject
(
const scalar time0,
const scalar time1
)
{
if ((0.0 >= time0) && (0.0 < time1))
// All parcels introduced at SOI
if (0 >= time0 && 0 < time1)
{
return injectorCoordinates_.size();
}
@ -285,20 +287,20 @@ Foam::label Foam::CellZoneInjection<CloudType>::parcelsToInject
template<class CloudType>
Foam::scalar Foam::CellZoneInjection<CloudType>::volumeToInject
Foam::scalar Foam::CellZoneInjection<CloudType>::massToInject
(
const scalar time0,
const scalar time1
)
{
// All parcels introduced at SOI
if ((0.0 >= time0) && (0.0 < time1))
if (0 >= time0 && 0 < time1)
{
return this->volumeTotal_;
return massTotal_;
}
else
{
return 0.0;
return 0;
}
}
@ -347,11 +349,4 @@ bool Foam::CellZoneInjection<CloudType>::fullyDescribed() const
}
template<class CloudType>
bool Foam::CellZoneInjection<CloudType>::validInjection(const label)
{
return true;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -46,7 +46,7 @@ SourceFiles
#define CellZoneInjection_H
#include "InjectionModel.H"
#include "distributionModel.H"
#include "distribution.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -67,6 +67,9 @@ class CellZoneInjection
//- Name of cell zone
const word cellZoneName_;
//- Mass to inject
const scalar massTotal_;
//- Number density
const scalar numberDensity_;
@ -89,7 +92,7 @@ class CellZoneInjection
const vector U0_;
//- Parcel size distribution model
const autoPtr<distributionModel> sizeDistribution_;
const autoPtr<distribution> sizeDistribution_;
// Private Member Functions
@ -137,13 +140,13 @@ public:
virtual void topoChange();
//- Return the end-of-injection time
scalar timeEnd() const;
virtual scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
label parcelsToInject(const scalar time0, const scalar time1);
virtual label nParcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
scalar volumeToInject(const scalar time0, const scalar time1);
//- Parcel mass to introduce relative to SOI
virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry
@ -172,10 +175,6 @@ public:
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -142,20 +142,12 @@ Foam::ConeInjection<CloudType>::ConeInjection
injectorCell_(-1),
injectorTetFace_(-1),
injectorTetPt_(-1),
duration_(this->coeffDict().template lookup<scalar>("duration")),
duration_(this->readDuration(dict, owner)),
massFlowRate_(this->readMassFlowRate(dict, owner, duration_)),
parcelsPerSecond_
(
this->coeffDict().template lookup<scalar>("parcelsPerSecond")
),
flowRateProfile_
(
TimeFunction1<scalar>
(
owner.db().time(),
"flowRateProfile",
this->coeffDict()
)
),
thetaInner_
(
TimeFunction1<scalar>
@ -176,9 +168,11 @@ Foam::ConeInjection<CloudType>::ConeInjection
),
sizeDistribution_
(
distributionModel::New
distribution::New
(
this->coeffDict().subDict("sizeDistribution"), owner.rndGen()
this->coeffDict().subDict("sizeDistribution"),
owner.rndGen(),
this->sizeSampleQ()
)
),
dInner_(vGreat),
@ -187,15 +181,10 @@ Foam::ConeInjection<CloudType>::ConeInjection
Cd_(owner.db().time(), "Cd"),
Pinj_(owner.db().time(), "Pinj")
{
duration_ = owner.db().time().userTimeToTime(duration_);
setInjectionMethod();
setFlowType();
// Set total volume to inject
this->volumeTotal_ = flowRateProfile_.integral(0, duration_);
topoChange();
}
@ -217,8 +206,8 @@ Foam::ConeInjection<CloudType>::ConeInjection
injectorTetFace_(im.injectorTetFace_),
injectorTetPt_(im.injectorTetPt_),
duration_(im.duration_),
massFlowRate_(im.massFlowRate_),
parcelsPerSecond_(im.parcelsPerSecond_),
flowRateProfile_(im.flowRateProfile_),
thetaInner_(im.thetaInner_),
thetaOuter_(im.thetaOuter_),
sizeDistribution_(im.sizeDistribution_().clone().ptr()),
@ -265,7 +254,7 @@ Foam::scalar Foam::ConeInjection<CloudType>::timeEnd() const
template<class CloudType>
Foam::label Foam::ConeInjection<CloudType>::parcelsToInject
Foam::label Foam::ConeInjection<CloudType>::nParcelsToInject
(
const scalar time0,
const scalar time1
@ -287,7 +276,7 @@ Foam::label Foam::ConeInjection<CloudType>::parcelsToInject
template<class CloudType>
Foam::scalar Foam::ConeInjection<CloudType>::volumeToInject
Foam::scalar Foam::ConeInjection<CloudType>::massToInject
(
const scalar time0,
const scalar time1
@ -295,7 +284,7 @@ Foam::scalar Foam::ConeInjection<CloudType>::volumeToInject
{
if (time0 >= 0 && time0 < duration_)
{
return flowRateProfile_.integral(time0, time1);
return massFlowRate_.integral(time0, time1);
}
else
{
@ -465,10 +454,8 @@ void Foam::ConeInjection<CloudType>::setProperties
case ftFlowRateAndDischarge:
{
const scalar A = 0.25*pi*(sqr(dOuter_) - sqr(dInner_));
const scalar massFlowRate =
this->massTotal()*flowRateProfile_.value(t)/this->volumeTotal();
const scalar Umag =
massFlowRate/(parcel.rho()*Cd_.value(t)*A);
massFlowRate_.value(t)/(parcel.rho()*Cd_.value(t)*A);
parcel.U() = Umag*dirVec;
break;
}
@ -490,11 +477,4 @@ bool Foam::ConeInjection<CloudType>::fullyDescribed() const
}
template<class CloudType>
bool Foam::ConeInjection<CloudType>::validInjection(const label)
{
return true;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -141,7 +141,7 @@ SourceFiles
#define ConeInjection_H
#include "InjectionModel.H"
#include "distributionModel.H"
#include "distribution.H"
#include "TimeFunction1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -208,14 +208,14 @@ private:
label injectorTetPt_;
//- Injection duration [s]
scalar duration_;
const scalar duration_;
//- Mass flow rate relative to SOI []
const TimeFunction1<scalar> massFlowRate_;
//- Number of parcels to introduce per second
const label parcelsPerSecond_;
//- Flow rate profile relative to SOI []
const TimeFunction1<scalar> flowRateProfile_;
//- Inner half-cone angle relative to SOI [deg]
const TimeFunction1<scalar> thetaInner_;
@ -223,7 +223,7 @@ private:
const TimeFunction1<scalar> thetaOuter_;
//- Parcel size distribution model
const autoPtr<distributionModel> sizeDistribution_;
const autoPtr<distribution> sizeDistribution_;
// Disc geometry
@ -298,11 +298,10 @@ public:
scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
virtual label nParcelsToInject(const scalar time0, const scalar time1);
//- Parcel mass to introduce relative to SOI
virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry
@ -331,10 +330,6 @@ public:
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -71,6 +71,7 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
injectorCells_(positions_.size()),
injectorTetFaces_(positions_.size()),
injectorTetPts_(positions_.size()),
massTotal_(this->readMassTotal(dict, owner)),
nParcelsPerInjector_
(
this->coeffDict().template lookup<label>("parcelsPerInjector")
@ -80,10 +81,11 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
diameters_(positions_.size()),
sizeDistribution_
(
distributionModel::New
distribution::New
(
this->coeffDict().subDict("sizeDistribution"),
owner.rndGen()
owner.rndGen(),
this->sizeSampleQ()
)
)
{
@ -93,10 +95,6 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
diameters_[i] = sizeDistribution_->sample();
}
// Determine total volume of particles to inject
this->volumeTotal_ =
nParcelsPerInjector_*sum(pow3(diameters_))*pi/6.0;
topoChange();
}
@ -117,6 +115,7 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
injectorCells_(im.injectorCells_),
injectorTetFaces_(im.injectorTetFaces_),
injectorTetPts_(im.injectorTetPts_),
massTotal_(im.massTotal_),
nParcelsPerInjector_(im.nParcelsPerInjector_),
nParcelsInjected_(im.nParcelsInjected_),
U0_(im.U0_),
@ -160,7 +159,7 @@ Foam::scalar Foam::FieldActivatedInjection<CloudType>::timeEnd() const
template<class CloudType>
Foam::label Foam::FieldActivatedInjection<CloudType>::parcelsToInject
Foam::label Foam::FieldActivatedInjection<CloudType>::nParcelsToInject
(
const scalar time0,
const scalar time1
@ -178,7 +177,7 @@ Foam::label Foam::FieldActivatedInjection<CloudType>::parcelsToInject
template<class CloudType>
Foam::scalar Foam::FieldActivatedInjection<CloudType>::volumeToInject
Foam::scalar Foam::FieldActivatedInjection<CloudType>::massToInject
(
const scalar time0,
const scalar time1
@ -186,7 +185,7 @@ Foam::scalar Foam::FieldActivatedInjection<CloudType>::volumeToInject
{
if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
{
return this->volumeTotal_/nParcelsPerInjector_;
return massTotal_/nParcelsPerInjector_;
}
else
{
@ -198,7 +197,7 @@ Foam::scalar Foam::FieldActivatedInjection<CloudType>::volumeToInject
template<class CloudType>
void Foam::FieldActivatedInjection<CloudType>::setPositionAndCell
(
const label parcelI,
const label parceli,
const label,
const scalar,
barycentric& coordinates,
@ -208,17 +207,28 @@ void Foam::FieldActivatedInjection<CloudType>::setPositionAndCell
label& facei
)
{
coordinates = injectorCoordinates_[parcelI];
celli = injectorCells_[parcelI];
tetFacei = injectorTetFaces_[parcelI];
tetPti = injectorTetPts_[parcelI];
const label injectorCelli = injectorCells_[parceli];
if
(
nParcelsInjected_[parceli] < nParcelsPerInjector_
&& factor_*referenceField_[injectorCelli] > thresholdField_[injectorCelli]
)
{
coordinates = injectorCoordinates_[parceli];
celli = injectorCells_[parceli];
tetFacei = injectorTetFaces_[parceli];
tetPti = injectorTetPts_[parceli];
nParcelsInjected_[parceli]++;
}
}
template<class CloudType>
void Foam::FieldActivatedInjection<CloudType>::setProperties
(
const label parcelI,
const label parceli,
const label,
const scalar,
typename CloudType::parcelType& parcel
@ -228,7 +238,7 @@ void Foam::FieldActivatedInjection<CloudType>::setProperties
parcel.U() = U0_;
// set particle diameter
parcel.d() = diameters_[parcelI];
parcel.d() = diameters_[parceli];
}
@ -239,26 +249,4 @@ bool Foam::FieldActivatedInjection<CloudType>::fullyDescribed() const
}
template<class CloudType>
bool Foam::FieldActivatedInjection<CloudType>::validInjection
(
const label parcelI
)
{
const label celli = injectorCells_[parcelI];
if
(
nParcelsInjected_[parcelI] < nParcelsPerInjector_
&& factor_*referenceField_[celli] > thresholdField_[celli]
)
{
nParcelsInjected_[parcelI]++;
return true;
}
return false;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -47,7 +47,7 @@ SourceFiles
#define FieldActivatedInjection_H
#include "InjectionModel.H"
#include "distributionModel.H"
#include "distribution.H"
#include "volFieldsFwd.H"
#include "GlobalIOField.H"
@ -99,6 +99,9 @@ class FieldActivatedInjection
//- List of tetPt labels corresponding to injector positions
labelList injectorTetPts_;
//- Mass to inject
const scalar massTotal_;
//- Number of parcels per injector
const label nParcelsPerInjector_;
@ -115,8 +118,7 @@ class FieldActivatedInjection
scalarList diameters_;
//- Parcel size distribution model
const autoPtr<distributionModel>
sizeDistribution_;
const autoPtr<distribution> sizeDistribution_;
public:
@ -161,10 +163,10 @@ public:
scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
virtual label nParcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
//- Parcel mass to introduce relative to SOI
virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry
@ -172,7 +174,7 @@ public:
//- Set the injection position and owner cell, tetFace and tetPt
virtual void setPositionAndCell
(
const label parcelI,
const label parceli,
const label nParcels,
const scalar time,
barycentric& coordinates,
@ -185,7 +187,7 @@ public:
//- Set the parcel properties
virtual void setProperties
(
const label parcelI,
const label parceli,
const label nParcels,
const scalar time,
typename CloudType::parcelType& parcel
@ -193,10 +195,6 @@ public:
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI);
};

View File

@ -1,488 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "InflationInjection.H"
#include "mathematicalConstants.H"
#include "PackedBoolList.H"
#include "cellSet.H"
#include "ListListOps.H"
using namespace Foam::constant::mathematical;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::InflationInjection<CloudType>::InflationInjection
(
const dictionary& dict,
CloudType& owner,
const word& modelName
)
:
InjectionModel<CloudType>(dict, owner, modelName, typeName),
generationSetName_(this->coeffDict().lookup("generationCellSet")),
inflationSetName_(this->coeffDict().lookup("inflationCellSet")),
generationCells_(),
inflationCells_(),
duration_(this->coeffDict().template lookup<scalar>("duration")),
flowRateProfile_
(
TimeFunction1<scalar>
(
owner.db().time(),
"flowRateProfile",
this->coeffDict()
)
),
growthRate_
(
TimeFunction1<scalar>
(
owner.db().time(),
"growthRate",
this->coeffDict()
)
),
newParticles_(),
volumeAccumulator_(0.0),
fraction_(1.0),
selfSeed_(this->coeffDict().lookupOrDefault("selfSeed", false)),
dSeed_(small),
sizeDistribution_
(
distributionModel::New
(
this->coeffDict().subDict("sizeDistribution"),
owner.rndGen()
)
)
{
duration_ = owner.db().time().userTimeToTime(duration_);
if (selfSeed_)
{
dSeed_ = this->coeffDict().template lookup<scalar>("dSeed");
}
cellSet generationCells(this->owner().mesh(), generationSetName_);
generationCells_ = generationCells.toc();
cellSet inflationCells(this->owner().mesh(), inflationSetName_);
// Union of cellSets
inflationCells |= generationCells;
inflationCells_ = inflationCells.toc();
if (Pstream::parRun())
{
scalar generationVolume = 0.0;
forAll(generationCells_, gCI)
{
label cI = generationCells_[gCI];
generationVolume += this->owner().mesh().cellVolumes()[cI];
}
scalar totalGenerationVolume = generationVolume;
reduce(totalGenerationVolume, sumOp<scalar>());
fraction_ = generationVolume/totalGenerationVolume;
}
// Set total volume/mass to inject
this->volumeTotal_ = fraction_*flowRateProfile_.integral(0.0, duration_);
this->massTotal_ *= fraction_;
}
template<class CloudType>
Foam::InflationInjection<CloudType>::InflationInjection
(
const Foam::InflationInjection<CloudType>& im
)
:
InjectionModel<CloudType>(im),
generationSetName_(im.generationSetName_),
inflationSetName_(im.inflationSetName_),
generationCells_(im.generationCells_),
inflationCells_(im.inflationCells_),
duration_(im.duration_),
flowRateProfile_(im.flowRateProfile_),
growthRate_(im.growthRate_),
newParticles_(im.newParticles_),
volumeAccumulator_(im.volumeAccumulator_),
fraction_(im.fraction_),
selfSeed_(im.selfSeed_),
dSeed_(im.dSeed_),
sizeDistribution_(im.sizeDistribution_().clone().ptr())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::InflationInjection<CloudType>::~InflationInjection()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::InflationInjection<CloudType>::topoChange()
{}
template<class CloudType>
Foam::scalar Foam::InflationInjection<CloudType>::timeEnd() const
{
return this->SOI_ + duration_;
}
template<class CloudType>
Foam::label Foam::InflationInjection<CloudType>::parcelsToInject
(
const scalar time0,
const scalar time1
)
{
const polyMesh& mesh = this->owner().mesh();
List<DynamicList<typename CloudType::parcelType*>>& cellOccupancy =
this->owner().cellOccupancy();
scalar gR = growthRate_.value(time1);
scalar dT = time1 - time0;
// Inflate existing particles
forAll(inflationCells_, iCI)
{
label cI = inflationCells_[iCI];
typename CloudType::parcelType* pPtr = nullptr;
forAll(cellOccupancy[cI], cPI)
{
pPtr = cellOccupancy[cI][cPI];
scalar dTarget = pPtr->dTarget();
pPtr->d() = min(dTarget, pPtr->d() + gR*dT);
}
}
// Generate new particles
newParticles_.clear();
Random& rnd = this->owner().rndGen();
// Diameter factor, when splitting particles into 4, this is the
// factor that modifies the diameter.
scalar dFact = sqrt(2.0)/(sqrt(3.0) + sqrt(2.0));
if ((time0 >= 0.0) && (time0 < duration_))
{
volumeAccumulator_ +=
fraction_*flowRateProfile_.integral(time0, time1);
}
labelHashSet cellCentresUsed;
// Loop escape counter
label maxIterations = max
(
1,
(10*volumeAccumulator_)
/CloudType::parcelType::volume(sizeDistribution_().minValue())
);
label iterationNo = 0;
// Info<< "Accumulated volume to inject: "
// << returnReduce(volumeAccumulator_, sumOp<scalar>()) << endl;
while (!generationCells_.empty() && volumeAccumulator_ > 0)
{
if (iterationNo > maxIterations)
{
WarningInFunction
<< "Maximum particle split iterations ("
<< maxIterations << ") exceeded" << endl;
break;
}
label cI =
generationCells_[rnd.sampleAB<label>(0, generationCells_.size())];
// Pick a particle at random from the cell - if there are
// none, insert one at the cell centre. Otherwise, split an
// existing particle into four new ones.
if (cellOccupancy[cI].empty())
{
if (selfSeed_ && !cellCentresUsed.found(cI))
{
scalar dNew = sizeDistribution_().sample();
newParticles_.append
(
vectorPairScalarPair
(
Pair<vector>(mesh.cellCentres()[cI], Zero),
Pair<scalar>(dSeed_, dNew)
)
);
volumeAccumulator_ -= CloudType::parcelType::volume(dNew);
cellCentresUsed.insert(cI);
}
}
else
{
label cPI = rnd.sampleAB<label>(0, cellOccupancy[cI].size());
// This has to be a reference to the pointer so that it
// can be set to nullptr when the particle is deleted.
typename CloudType::parcelType*& pPtr = cellOccupancy[cI][cPI];
if (pPtr != nullptr)
{
scalar pD = pPtr->d();
// Select bigger particles by preference
if ((pD/pPtr->dTarget()) < rnd.sample01<scalar>())
{
continue;
}
const point& pP = pPtr->position(mesh);
const vector& pU = pPtr->U();
// Generate a tetrahedron of new positions with the
// four new spheres fitting inside the old one, where
// a is the diameter of the new spheres, and is
// related to the diameter of the enclosing sphere, A,
// by a = sqrt(2)*A/(sqrt(3) + sqrt(2));
// Positions around the origin, which is the
// tetrahedron centroid (centre of old sphere).
// x = a/sqrt(3)
// r = a/(2*sqrt(6))
// R = sqrt(3)*a/(2*sqrt(2))
// d = a/(2*sqrt(3))
// p0(x, 0, -r)
// p1(-d, a/2, -r)
// p2(-d, -a/2, -r)
// p3(0, 0, R)
scalar a = pD*dFact;
scalar x = a/sqrt(3.0);
scalar r = a/(2.0*sqrt(6.0));
scalar R = sqrt(3.0)*a/(2.0*sqrt(2.0));
scalar d = a/(2.0*sqrt(3.0));
scalar dNew = sizeDistribution_().sample();
scalar volNew = CloudType::parcelType::volume(dNew);
newParticles_.append
(
vectorPairScalarPair
(
Pair<vector>(vector(x, 0, -r) + pP, pU),
Pair<scalar>(a, dNew)
)
);
volumeAccumulator_ -= volNew;
dNew = sizeDistribution_().sample();
newParticles_.append
(
vectorPairScalarPair
(
Pair<vector>(vector(-d, a/2, -r) + pP, pU),
Pair<scalar>(a, dNew)
)
);
volumeAccumulator_ -= volNew;
dNew = sizeDistribution_().sample();
newParticles_.append
(
vectorPairScalarPair
(
Pair<vector>(vector(-d, -a/2, -r) + pP, pU),
Pair<scalar>(a, dNew)
)
);
volumeAccumulator_ -= volNew;
dNew = sizeDistribution_().sample();
newParticles_.append
(
vectorPairScalarPair
(
Pair<vector>(vector(0, 0, R) + pP, pU),
Pair<scalar>(a, dNew)
)
);
volumeAccumulator_ -= volNew;
// Account for the lost volume of the particle which
// is to be deleted
volumeAccumulator_ += CloudType::parcelType::volume
(
pPtr->dTarget()
);
this->owner().deleteParticle(*pPtr);
pPtr = nullptr;
}
}
iterationNo++;
}
if (Pstream::parRun())
{
List<List<vectorPairScalarPair>> gatheredNewParticles
(
Pstream::nProcs()
);
gatheredNewParticles[Pstream::myProcNo()] = newParticles_;
// Gather data onto master
Pstream::gatherList(gatheredNewParticles);
// Combine
List<vectorPairScalarPair> combinedNewParticles
(
ListListOps::combine<List<vectorPairScalarPair>>
(
gatheredNewParticles,
accessOp<List<vectorPairScalarPair>>()
)
);
if (Pstream::master())
{
newParticles_ = combinedNewParticles;
}
Pstream::scatter(newParticles_);
}
return newParticles_.size();
}
template<class CloudType>
Foam::scalar Foam::InflationInjection<CloudType>::volumeToInject
(
const scalar time0,
const scalar time1
)
{
if ((time0 >= 0.0) && (time0 < duration_))
{
return fraction_*flowRateProfile_.integral(time0, time1);
}
else
{
return 0.0;
}
}
template<class CloudType>
void Foam::InflationInjection<CloudType>::setPositionAndCell
(
const label parcelI,
const label,
const scalar,
barycentric& coordinates,
label& celli,
label& tetFacei,
label& tetPti,
label& facei
)
{
this->findCellAtPosition
(
newParticles_[parcelI].first().first(),
coordinates,
celli,
tetFacei,
tetPti,
false
);
}
template<class CloudType>
void Foam::InflationInjection<CloudType>::setProperties
(
const label parcelI,
const label,
const scalar,
typename CloudType::parcelType& parcel
)
{
parcel.U() = newParticles_[parcelI].first().second();
parcel.d() = newParticles_[parcelI].second().first();
parcel.dTarget() = newParticles_[parcelI].second().second();
}
template<class CloudType>
bool Foam::InflationInjection<CloudType>::fullyDescribed() const
{
return false;
}
template<class CloudType>
bool Foam::InflationInjection<CloudType>::validInjection(const label)
{
return true;
}
// ************************************************************************* //

View File

@ -1,209 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::InflationInjection
Description
Inflation injection - creates new particles by splitting existing
particles within in a set of generation cells, then inflating them
to a target diameter within the generation cells and an additional
set of inflation cells.
SourceFiles
InflationInjection.C
\*---------------------------------------------------------------------------*/
#ifndef InflationInjection_H
#define InflationInjection_H
#include "InjectionModel.H"
#include "distributionModel.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Structure to hold:
// + position = vectorPairScalarPair::first().first()
// + velocity = vectorPairScalarPair::first().second()
// + diameter = vectorPairScalarPair::second().first()
// + target diameter = vectorPairScalarPair::second().second()
// One structure to allow single operation parallel comms
typedef Tuple2<Pair<vector>, Pair<scalar>> vectorPairScalarPair;
/*---------------------------------------------------------------------------*\
Class InflationInjection Declaration
\*---------------------------------------------------------------------------*/
template<class CloudType>
class InflationInjection
:
public InjectionModel<CloudType>
{
// Private Data
//- Name of cellSet for generating new particles
word generationSetName_;
//- Name of cellSet for inflating new particles
word inflationSetName_;
//- Set of cells to generate particles in
labelList generationCells_;
//- Set of cells to inflate particles in, includes all
// generation cells
labelList inflationCells_;
//- Injection duration [s]
scalar duration_;
//- Flow rate profile relative to SOI [m^3/s]
TimeFunction1<scalar> flowRateProfile_;
//- Growth rate of particle diameters towards target [m/s]
TimeFunction1<scalar> growthRate_;
//- Positions, velocities, diameters and target diameters of
// new particles after splitting
DynamicList<vectorPairScalarPair> newParticles_;
//- Accumulation variable to carry over volume from one injection
// to the next
scalar volumeAccumulator_;
//- Fraction of injection controlled by this processor
scalar fraction_;
//- Switch to control whether or not the injector is allowed
// to create new particles in empty cells
Switch selfSeed_;
//- Diameter with which to create new seed particles
scalar dSeed_;
//- Parcel size distribution model
const autoPtr<distributionModel> sizeDistribution_;
public:
//- Runtime type information
TypeName("inflationInjection");
// Constructors
//- Construct from dictionary
InflationInjection
(
const dictionary& dict,
CloudType& owner,
const word& modelName
);
//- Construct copy
InflationInjection(const InflationInjection<CloudType>& im);
//- Construct and return a clone
virtual autoPtr<InjectionModel<CloudType>> clone() const
{
return autoPtr<InjectionModel<CloudType>>
(
new InflationInjection<CloudType>(*this)
);
}
//- Destructor
virtual ~InflationInjection();
// Member Functions
//- Set injector locations when mesh is updated
virtual void topoChange();
//- Return the end-of-injection time
scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
// Injection geometry
//- Set the injection position and owner cell, tetFace and tetPt
virtual void setPositionAndCell
(
const label parcelI,
const label nParcels,
const scalar time,
barycentric& coordinates,
label& celli,
label& tetFacei,
label& tetPti,
label& facei
);
//- Set the parcel properties
virtual void setProperties
(
const label parcelI,
const label nParcels,
const scalar time,
typename CloudType::parcelType& parcel
);
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "InflationInjection.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -27,64 +27,144 @@ License
#include "mathematicalConstants.H"
#include "meshTools.H"
#include "volFields.H"
#include "Scale.H"
using namespace Foam::constant::mathematical;
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
template<class CloudType>
bool Foam::InjectionModel<CloudType>::prepareForNextTimeStep
Foam::scalar Foam::InjectionModel<CloudType>::readMassTotal
(
const scalar time,
label& newParcels,
scalar& newVolumeFraction
const dictionary& dict,
CloudType& owner
)
{
// Initialise values
newParcels = 0;
newVolumeFraction = 0.0;
bool validInjection = false;
// Return if not started injection event
if (time < SOI_)
if (dict.found("nParticle"))
{
timeStep0_ = time;
return validInjection;
if (dict.found("massTotal"))
{
IOWarningInFunction(dict)
<< "If nParticle is specified then the massTotal "
<< "setting has no effect " << endl;
}
// Make times relative to SOI
scalar t0 = timeStep0_ - SOI_;
scalar t1 = time - SOI_;
// Number of parcels to inject
newParcels = this->parcelsToInject(t0, t1);
// Volume of parcels to inject
newVolumeFraction =
this->volumeToInject(t0, t1)
/(volumeTotal_ + rootVSmall);
if (newVolumeFraction > 0)
{
if (newParcels > 0)
{
timeStep0_ = time;
validInjection = true;
}
else
{
// Injection should have started, but not sufficient volume to
// produce (at least) 1 parcel - hold value of timeStep0_
validInjection = false;
}
}
else
{
timeStep0_ = time;
validInjection = false;
return NaN;
}
return validInjection;
if (owner.solution().steadyState())
{
FatalErrorInFunction
<< "The " << type() << " injection model is not compatible with "
<< "steady state solution"
<< exit(FatalError);
return NaN;
}
return dict.lookup<scalar>("massTotal");
}
template<class CloudType>
Foam::scalar Foam::InjectionModel<CloudType>::readDuration
(
const dictionary& dict,
CloudType& owner
)
{
const Time& time = owner.mesh().time();
if (owner.solution().steadyState())
{
return vGreat;
}
return
time.userTimeToTime
(
this->coeffDict().template lookup<scalar>("duration")
);
}
template<class CloudType>
Foam::TimeFunction1<Foam::scalar>
Foam::InjectionModel<CloudType>::readMassFlowRate
(
const dictionary& dict,
CloudType& owner,
const scalar duration
)
{
const Time& time = owner.mesh().time();
if (dict.found("nParticle"))
{
if (dict.found("massFlowRate") || dict.found("massTotal"))
{
IOWarningInFunction(dict)
<< "If nParticle is specified then massFlowRate and massTotal "
<< "settings have no effect " << endl;
}
return
TimeFunction1<scalar>
(
time,
Function1s::Constant<scalar>("NaN", NaN)
);
}
if (owner.solution().steadyState())
{
return TimeFunction1<scalar>(time, "massFlowRate", dict);
}
const scalar massTotal = dict.lookup<scalar>("massTotal");
if (!dict.found("flowRateProfile"))
{
return
TimeFunction1<scalar>
(
time,
Function1s::Constant<scalar>("massFlowRate", massTotal/duration)
);
}
autoPtr<Function1<scalar>> flowRateProfile =
Function1<scalar>::New("flowRateProfile", dict);
const scalar sumFlowRateProfile = flowRateProfile->integral(0, duration);
return
TimeFunction1<scalar>
(
time,
Function1s::Scale<scalar>
(
"massFlowRate",
Function1s::Constant<scalar>("m", massTotal/sumFlowRateProfile),
Function1s::Constant<scalar>("one", scalar(1)),
flowRateProfile()
)
);
}
template<class CloudType>
Foam::label Foam::InjectionModel<CloudType>::index() const
{
forAll(this->owner().injectors(), i)
{
if (this->owner().injectors()(i) == this)
{
return i;
}
}
return -1;
}
@ -201,67 +281,122 @@ void Foam::InjectionModel<CloudType>::constrainPosition
template<class CloudType>
Foam::scalar Foam::InjectionModel<CloudType>::setNumberOfParticles
(
const label parcels,
const scalar volumeFraction,
const scalar diameter,
const scalar rho
)
Foam::label Foam::InjectionModel<CloudType>::sizeSampleQ() const
{
scalar nP = 0.0;
switch (parcelBasis_)
switch (uniformParcelSize_)
{
case pbMass:
{
scalar volumep = pi/6.0*pow3(diameter);
scalar volumeTot = massTotal_/rho;
case uniformParcelSize::nParticle:
return 0;
case uniformParcelSize::surfaceArea:
return 2;
case uniformParcelSize::volume:
return 3;
}
nP = volumeFraction*volumeTot/(parcels*volumep);
break;
}
case pbNumber:
return -labelMax;
}
template<class CloudType>
void Foam::InjectionModel<CloudType>::setNumberOfParticles
(
PtrList<parcelType>& parcelPtrs,
const scalar mass
) const
{
auto size = [&](const parcelType& p)
{
nP = massTotal_/(rho*volumeTotal_);
break;
}
case pbFixed:
switch (uniformParcelSize_)
{
nP = nParticleFixed_;
break;
case uniformParcelSize::nParticle:
return scalar(1);
case uniformParcelSize::surfaceArea:
return p.areaS();
case uniformParcelSize::volume:
return p.volume();
}
default:
return NaN;
};
// Determine the total mass and size of all created particles
scalar sumMassBySize = 0;
forAll(parcelPtrs, parceli)
{
if (parcelPtrs.set(parceli))
{
const parcelType& p = parcelPtrs[parceli];
sumMassBySize += p.mass()/size(p);
}
}
reduce(sumMassBySize, sumOp<scalar>());
// Set the numbers of particles on each parcel
forAll(parcelPtrs, parceli)
{
if (parcelPtrs.set(parceli))
{
parcelType& p = parcelPtrs[parceli];
p.nParticle() = mass/size(p)/sumMassBySize;
}
}
// Check that the constraints are correct
if (debug)
{
scalar massN = 0, minSizeN = vGreat, maxSizeN = -vGreat;
forAll(parcelPtrs, parceli)
{
if (parcelPtrs.set(parceli))
{
const parcelType& p = parcelPtrs[parceli];
massN += p.nParticle()*p.mass();
minSizeN = min(minSizeN, p.nParticle()*size(p));
maxSizeN = max(minSizeN, p.nParticle()*size(p));
}
}
reduce(massN, sumOp<scalar>());
if (mag(massN - mass) > rootSmall*(massN + mass)/2)
{
nP = 0.0;
FatalErrorInFunction
<< "Unknown parcelBasis type" << nl
<< "Parcels do not have the required mass"
<< exit(FatalError);
}
reduce(minSizeN, minOp<scalar>());
reduce(maxSizeN, maxOp<scalar>());
if (maxSizeN - minSizeN > rootSmall*(maxSizeN + minSizeN)/2)
{
FatalErrorInFunction
<< "Parcel sizes are not uniform"
<< exit(FatalError);
}
}
return nP;
}
template<class CloudType>
void Foam::InjectionModel<CloudType>::postInjectCheck
(
const label parcelsAdded,
const label nParcelsAdded,
const scalar massAdded
)
{
const label allParcelsAdded = returnReduce(parcelsAdded, sumOp<label>());
const label allNParcelsAdded = returnReduce(nParcelsAdded, sumOp<label>());
if (allParcelsAdded > 0)
if (allNParcelsAdded > 0)
{
Info<< nl
<< "Cloud: " << this->owner().name()
<< " injector: " << this->modelName() << nl
<< " Added " << allParcelsAdded << " new parcels" << nl << endl;
<< " Added " << allNParcelsAdded << " new parcels" << nl << endl;
}
// Increment total number of parcels added
parcelsAddedTotal_ += allParcelsAdded;
parcelsAddedTotal_ += allNParcelsAdded;
// Increment total mass injected
massInjected_ += returnReduce(massAdded, sumOp<scalar>());
@ -280,19 +415,16 @@ template<class CloudType>
Foam::InjectionModel<CloudType>::InjectionModel(CloudType& owner)
:
CloudSubModelBase<CloudType>(owner),
SOI_(0.0),
volumeTotal_(0.0),
massTotal_(0.0),
massFlowRate_(owner.db().time(), "massFlowRate"),
SOI_(0),
massInjected_(this->template getModelProperty<scalar>("massInjected")),
nInjections_(this->template getModelProperty<label>("nInjections")),
parcelsAddedTotal_
(
this->template getModelProperty<scalar>("parcelsAddedTotal")
),
parcelBasis_(pbNumber),
nParticleFixed_(0.0),
time0_(0.0),
nParticleFixed_(-vGreat),
uniformParcelSize_(uniformParcelSize::nParticle),
time0_(0),
timeStep0_(this->template getModelProperty<scalar>("timeStep0"))
{}
@ -307,65 +439,55 @@ Foam::InjectionModel<CloudType>::InjectionModel
)
:
CloudSubModelBase<CloudType>(modelName, owner, dict, typeName, modelType),
SOI_(0.0),
volumeTotal_(0.0),
massTotal_(0.0),
massFlowRate_(owner.db().time(), "massFlowRate"),
SOI_(0),
massInjected_(this->template getModelProperty<scalar>("massInjected")),
nInjections_(this->template getModelProperty<scalar>("nInjections")),
parcelsAddedTotal_
(
this->template getModelProperty<scalar>("parcelsAddedTotal")
),
parcelBasis_(pbNumber),
nParticleFixed_(0.0),
nParticleFixed_(dict.lookupOrDefault<scalar>("nParticle", -vGreat)),
uniformParcelSize_
(
uniformParcelSizeNames_
[
!dict.found("parcelBasisType") && nParticleFixed_ > 0
? dict.lookupOrDefault<word>
(
"uniformParcelSize",
uniformParcelSizeNames_[uniformParcelSize::nParticle]
)
: dict.lookup<word>("uniformParcelSize")
]
),
time0_(owner.db().time().value()),
timeStep0_(this->template getModelProperty<scalar>("timeStep0"))
{
// Provide some info
// - also serves to initialise mesh dimensions - needed for parallel runs
// due to lazy evaluation of valid mesh dimensions
// Provide some info. Also serves to initialise mesh dimensions. This may
// be needed for parallel runs due to lazy evaluation of valid mesh
// dimensions.
Info<< " Constructing " << owner.mesh().nGeometricD() << "-D injection"
<< endl;
if
(
nParticleFixed_ > 0
&& uniformParcelSize_ != uniformParcelSize::nParticle
)
{
FatalIOErrorInFunction(dict)
<< "If nParticle is specified then the uniformParcelSize must be "
<< uniformParcelSizeNames_[uniformParcelSize::nParticle]
<< exit(FatalIOError);
}
if (owner.solution().transient())
{
this->coeffDict().lookup("massTotal") >> massTotal_;
this->coeffDict().lookup("SOI") >> SOI_;
SOI_ = owner.db().time().userTimeToTime(SOI_);
}
else
{
massFlowRate_.reset(this->coeffDict());
massTotal_ = massFlowRate_.value(owner.db().time().value());
}
const word parcelBasisType = this->coeffDict().lookup("parcelBasisType");
if (parcelBasisType == "mass")
{
parcelBasis_ = pbMass;
}
else if (parcelBasisType == "number")
{
parcelBasis_ = pbNumber;
}
else if (parcelBasisType == "fixed")
{
parcelBasis_ = pbFixed;
Info<< " Choosing nParticle to be a fixed value, massTotal "
<< "variable now does not determine anything."
<< endl;
nParticleFixed_ =
this->coeffDict().template lookup<scalar>("nParticle");
}
else
{
FatalErrorInFunction
<< "parcelBasisType must be either 'number', 'mass' or 'fixed'"
<< nl << exit(FatalError);
SOI_ =
owner.db().time().userTimeToTime
(
this->coeffDict().template lookup<scalar>("SOI")
);
}
}
@ -378,14 +500,11 @@ Foam::InjectionModel<CloudType>::InjectionModel
:
CloudSubModelBase<CloudType>(im),
SOI_(im.SOI_),
volumeTotal_(im.volumeTotal_),
massTotal_(im.massTotal_),
massFlowRate_(im.massFlowRate_),
massInjected_(im.massInjected_),
nInjections_(im.nInjections_),
parcelsAddedTotal_(im.parcelsAddedTotal_),
parcelBasis_(im.parcelBasis_),
nParticleFixed_(im.nParticleFixed_),
uniformParcelSize_(im.uniformParcelSize_),
time0_(im.time0_),
timeStep0_(im.timeStep0_)
{}
@ -408,17 +527,10 @@ void Foam::InjectionModel<CloudType>::topoChange()
template<class CloudType>
Foam::scalar Foam::InjectionModel<CloudType>::averageParcelMass()
{
label nTotal = 0.0;
if (this->owner().solution().transient())
{
nTotal = parcelsToInject(0.0, timeEnd() - timeStart());
}
else
{
nTotal = parcelsToInject(0.0, 1.0);
}
const scalar deltaT =
this->owner().solution().transient() ? timeEnd() - timeStart() : 1;
return massTotal_/nTotal;
return massToInject(0, deltaT)/nParcelsToInject(0, deltaT);
}
@ -434,28 +546,79 @@ void Foam::InjectionModel<CloudType>::inject
const scalar time = this->owner().db().time().value();
// Prepare for next time step
label parcelsAdded = 0;
scalar massAdded = 0.0;
label newParcels = 0;
scalar newVolumeFraction = 0.0;
// Reset counters
label nParcelsAdded = 0;
scalar massAdded = 0;
if (prepareForNextTimeStep(time, newParcels, newVolumeFraction))
// Get amounts to inject
label nParcels;
scalar mass;
bool inject;
if (time < SOI_)
{
// Injection has not started yet
nParcels = 0;
mass = 0;
inject = false;
timeStep0_ = time;
}
else
{
// Injection has started. Get amounts between times.
const scalar t0 = timeStep0_ - SOI_, t1 = time - SOI_;
nParcels = nParcelsToInject(t0, t1);
mass = nParticleFixed_ < 0 ? massToInject(t0, t1) : NaN;
if (nParcels > 0 && (nParticleFixed_ > 0 || mass > 0))
{
// Injection is valid
inject = true;
timeStep0_ = time;
}
else if (nParcels == 0 && (nParticleFixed_ < 0 && mass > 0))
{
// Injection should have started, but there is not a sufficient
// amount to inject a single parcel. Do not inject, but hold
// advancement of the old-time so that the mass gets added to a
// subsequent injection.
inject = false;
}
else
{
// Nothing to inject
inject = false;
timeStep0_ = time;
}
}
// Do injection
if (inject)
{
// Duration of injection period during this timestep
const scalar deltaT =
max(0.0, min(td.trackTime(), min(time - SOI_, timeEnd() - time0_)));
max
(
scalar(0),
min
(
td.trackTime(),
min
(
time - SOI_,
timeEnd() - time0_
)
)
);
// Pad injection time if injection starts during this timestep
const scalar padTime = max(0.0, SOI_ - time0_);
const scalar padTime = max(scalar(0), SOI_ - time0_);
// Introduce new parcels linearly across carrier phase timestep
for (label parcelI = 0; parcelI < newParcels; parcelI++)
// Create new parcels linearly across carrier phase timestep
PtrList<parcelType> parcelPtrs(nParcels);
forAll(parcelPtrs, parceli)
{
if (validInjection(parcelI))
{
// Calculate the pseudo time of injection for parcel 'parcelI'
scalar timeInj = time0_ + padTime + deltaT*parcelI/newParcels;
// Calculate the pseudo time of injection for parcel 'parceli'
scalar timeInj = time0_ + padTime + deltaT*parceli/nParcels;
// Determine the injection coordinates and owner cell,
// tetFace and tetPt
@ -463,8 +626,8 @@ void Foam::InjectionModel<CloudType>::inject
label celli = -1, tetFacei = -1, tetPti = -1, facei = -1;
setPositionAndCell
(
parcelI,
newParcels,
parceli,
nParcels,
timeInj,
coordinates,
celli,
@ -479,7 +642,9 @@ void Foam::InjectionModel<CloudType>::inject
const scalar dt = timeInj - time0_;
// Create a new parcel
parcelType* pPtr =
parcelPtrs.set
(
parceli,
new parcelType
(
mesh,
@ -488,52 +653,61 @@ void Foam::InjectionModel<CloudType>::inject
tetFacei,
tetPti,
facei
)
);
parcelType& p = parcelPtrs[parceli];
// Correct the position for reduced-dimension cases
constrainPosition(td, *pPtr);
constrainPosition(td, p);
// Check/set new parcel thermo properties
cloud.setParcelThermoProperties(*pPtr);
cloud.setParcelThermoProperties(p);
// Assign new parcel properties in injection model
setProperties(parcelI, newParcels, timeInj, *pPtr);
setProperties(parceli, nParcels, timeInj, p);
// Check/set new parcel injection properties
cloud.checkParcelProperties(*pPtr, fullyDescribed());
cloud.checkParcelProperties(p, index());
// Apply correction to velocity for 2-D cases
meshTools::constrainDirection
(
mesh,
mesh.solutionD(),
pPtr->U()
);
// Number of particles per parcel
pPtr->nParticle() =
setNumberOfParticles
(
newParcels,
newVolumeFraction,
pPtr->d(),
pPtr->rho()
p.U()
);
// Modify the step fraction so that the particles are
// injected continually through the time-step
pPtr->stepFraction() = dt/td.trackTime();
p.stepFraction() = dt/td.trackTime();
// Add the new parcel
parcelsAdded ++;
massAdded += pPtr->nParticle()*pPtr->mass();
cloud.addParticle(pPtr);
// Set the number of particles. If not fixed, this will set
// a junk value, which will get corrected below.
p.nParticle() = nParticleFixed_;
}
}
// Set the number of particles so that the introduced mass is correct
// and the uniform size is as specified
if (nParticleFixed_ < 0)
{
setNumberOfParticles(parcelPtrs, mass);
}
// Add the new parcels
forAll(parcelPtrs, parceli)
{
if (parcelPtrs.set(parceli))
{
parcelType& p = parcelPtrs[parceli];
nParcelsAdded ++;
massAdded += p.nParticle()*p.mass();
cloud.addParticle(parcelPtrs.set(parceli, nullptr).ptr());
}
}
}
postInjectCheck(parcelsAdded, massAdded);
postInjectCheck(nParcelsAdded, massAdded);
}
@ -547,30 +721,28 @@ void Foam::InjectionModel<CloudType>::injectSteadyState
{
const polyMesh& mesh = this->owner().mesh();
massTotal_ = massFlowRate_.value(mesh.time().value());
// Reset counters
time0_ = 0.0;
label parcelsAdded = 0;
scalar massAdded = 0.0;
label nParcelsAdded = 0;
scalar massAdded = 0;
// Set number of new parcels to inject based on first second of injection
label newParcels = parcelsToInject(0.0, 1.0);
// Get amounts to inject based on first second of injection
const label nParcels = nParcelsToInject(0, 1);
const scalar mass = nParticleFixed_ < 0 ? massToInject(0, 1) : NaN;
// Inject new parcels
for (label parcelI = 0; parcelI < newParcels; parcelI++)
// Do injection
if (nParcels > 0)
{
PtrList<parcelType> parcelPtrs(nParcels);
forAll(parcelPtrs, parceli)
{
// Volume to inject is split equally amongst all parcel streams
scalar newVolumeFraction = 1.0/scalar(newParcels);
// Determine the injection coordinates and owner cell,
// tetFace and tetPt
barycentric coordinates = barycentric::uniform(NaN);
label celli = -1, tetFacei = -1, tetPti = -1, facei = -1;
setPositionAndCell
(
parcelI,
newParcels,
parceli,
nParcels,
0,
coordinates,
celli,
@ -582,7 +754,9 @@ void Foam::InjectionModel<CloudType>::injectSteadyState
if (celli > -1)
{
// Create a new parcel
parcelType* pPtr =
parcelPtrs.set
(
parceli,
new parcelType
(
mesh,
@ -591,44 +765,55 @@ void Foam::InjectionModel<CloudType>::injectSteadyState
tetFacei,
tetPti,
facei
)
);
parcelType& p = parcelPtrs[parceli];
// Correct the position for reduced-dimension cases
constrainPosition(td, *pPtr);
constrainPosition(td, p);
// Check/set new parcel thermo properties
cloud.setParcelThermoProperties(*pPtr);
cloud.setParcelThermoProperties(p);
// Assign new parcel properties in injection model
setProperties(parcelI, newParcels, 0.0, *pPtr);
setProperties(parceli, nParcels, 0, p);
// Check/set new parcel injection properties
cloud.checkParcelProperties(*pPtr, fullyDescribed());
cloud.checkParcelProperties(p, index());
// Apply correction to velocity for 2-D cases
meshTools::constrainDirection(mesh, mesh.solutionD(), pPtr->U());
// Number of particles per parcel
pPtr->nParticle() =
setNumberOfParticles
(
1,
newVolumeFraction,
pPtr->d(),
pPtr->rho()
);
meshTools::constrainDirection(mesh, mesh.solutionD(), p.U());
// Initial step fraction
pPtr->stepFraction() = 0;
p.stepFraction() = 0;
// Add the new parcel
parcelsAdded ++;
massAdded += pPtr->nParticle()*pPtr->mass();
cloud.addParticle(pPtr);
// Set the number of particles. If not fixed, this will set
// a junk value, which will get corrected below.
p.nParticle() = nParticleFixed_;
}
}
postInjectCheck(parcelsAdded, massAdded);
// Set the number of particles so that the introduced mass is correct
// and the uniform size is as specified
if (nParticleFixed_ < 0)
{
setNumberOfParticles(parcelPtrs, mass);
}
// Add the new parcels
forAll(parcelPtrs, parceli)
{
if (parcelPtrs.set(parceli))
{
parcelType& p = parcelPtrs[parceli];
nParcelsAdded ++;
massAdded += p.nParticle()*p.mass();
cloud.addParticle(parcelPtrs.set(parceli, nullptr).ptr());
}
}
}
postInjectCheck(nParcelsAdded, massAdded);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,13 +48,11 @@ SourceFiles
#ifndef InjectionModel_H
#define InjectionModel_H
#include "IOdictionary.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "injectionModel.H"
#include "CloudSubModelBase.H"
#include "vector.H"
#include "particle.H"
#include "TimeFunction1.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -68,6 +66,7 @@ namespace Foam
template<class CloudType>
class InjectionModel
:
public injectionModel,
public CloudSubModelBase<CloudType>
{
public:
@ -76,18 +75,6 @@ public:
typedef typename CloudType::parcelType parcelType;
// Enumerations
//- Parcel basis representation options
// i.e constant number of particles OR constant mass per parcel
enum parcelBasis
{
pbNumber,
pbMass,
pbFixed
};
protected:
// Protected data
@ -97,16 +84,6 @@ protected:
//- Start of injection [s]
scalar SOI_;
//- Total volume of particles introduced by this injector [m^3]
// - scaled to ensure massTotal is achieved
scalar volumeTotal_;
//- Total mass to inject [kg]
scalar massTotal_;
//- Mass flow rate profile for steady calculations
TimeFunction1<scalar> massFlowRate_;
//- Total mass injected to date [kg]
scalar massInjected_;
@ -122,13 +99,13 @@ protected:
// Injection properties per Lagrangian time step
//- Parcel basis enumeration
parcelBasis parcelBasis_;
//- nParticle to assign to parcels when the 'fixed' basis
// is selected
//- Fixed nParticle to assign to parcels. Only valid if
// uniformParcelSize is nParticle.
scalar nParticleFixed_;
//- Size uniform to all parcels
uniformParcelSize uniformParcelSize_;
//- Continuous phase time at start of injection time step [s]
scalar time0_;
@ -138,18 +115,31 @@ protected:
// Protected Member Functions
//- Additional flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI) = 0;
//- Determine properties for next time step/injection interval
bool prepareForNextTimeStep
//- Read the total mass value for instantaneous injections
scalar readMassTotal
(
const scalar time,
label& newParcels,
scalar& newVolumeFraction
const dictionary& dict,
CloudType& owner
);
//- Read the duration for continuous injections
scalar readDuration
(
const dictionary& dict,
CloudType& owner
);
//- Read the mass flow rate function for continuous injections
TimeFunction1<scalar> readMassFlowRate
(
const dictionary& dict,
CloudType& owner,
const scalar duration
);
//- Get the index of this injector
label index() const;
//- Find the cell that contains the supplied position
// Will modify position slightly towards the owner cell centroid to
// ensure that it lies in a cell and not edge/face
@ -171,14 +161,15 @@ protected:
typename CloudType::parcelType& parcel
);
//- Return the sampling moment to be used by the size distribution
label sizeSampleQ() const;
//- Set number of particles to inject given parcel properties
scalar setNumberOfParticles
void setNumberOfParticles
(
const label parcels,
const scalar volumeFraction,
const scalar diameter,
const scalar rho
);
PtrList<parcelType>& parcelPtrs,
const scalar mass
) const;
//- Post injection checks
void postInjectCheck
@ -265,12 +256,6 @@ public:
//- Return the start-of-injection time
inline scalar timeStart() const;
//- Return the total volume to be injected across the event
inline scalar volumeTotal() const;
//- Return mass of particles to introduce
inline scalar massTotal() const;
//- Return mass of particles injected (cumulative)
inline scalar massInjected() const;
@ -278,21 +263,21 @@ public:
virtual scalar timeEnd() const = 0;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject
virtual label nParcelsToInject
(
const scalar time0,
const scalar time1
) = 0;
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject
//- Parcel mass to introduce relative to SOI
virtual scalar massToInject
(
const scalar time0,
const scalar time1
) = 0;
//- Return the average parcel mass over the injection period
virtual scalar averageParcelMass();
//- Return the average injected parcel mass
scalar averageParcelMass();
// Counters

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,20 +34,6 @@ Foam::scalar Foam::InjectionModel<CloudType>::timeStart() const
}
template<class CloudType>
Foam::scalar Foam::InjectionModel<CloudType>::volumeTotal() const
{
return volumeTotal_;
}
template<class CloudType>
Foam::scalar Foam::InjectionModel<CloudType>::massTotal() const
{
return massTotal_;
}
template<class CloudType>
Foam::scalar Foam::InjectionModel<CloudType>::massInjected() const
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -135,39 +135,6 @@ Foam::scalar Foam::InjectionModelList<CloudType>::timeEnd() const
}
template<class CloudType>
Foam::scalar Foam::InjectionModelList<CloudType>::volumeToInject
(
const scalar time0,
const scalar time1
)
{
scalar vol = 0.0;
forAll(*this, i)
{
vol += this->operator[](i).volumeToInject(time0, time1);
}
return vol;
}
template<class CloudType>
Foam::scalar Foam::InjectionModelList<CloudType>::averageParcelMass()
{
scalar mass = 0.0;
scalar massTotal = 0.0;
forAll(*this, i)
{
scalar mt = this->operator[](i).massTotal();
mass += mt*this->operator[](i).averageParcelMass();
massTotal += mt;
}
return mass/massTotal;
}
template<class CloudType>
void Foam::InjectionModelList<CloudType>::topoChange()
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -90,12 +90,6 @@ public:
//- Return the maximum end-of-injection time
scalar timeEnd() const;
//- Volume of parcels to introduce relative to SOI
scalar volumeToInject(const scalar time0, const scalar time1);
//- Return the average parcel mass
scalar averageParcelMass();
// Edit

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,34 +23,23 @@ License
\*---------------------------------------------------------------------------*/
#include "distributionModel.H"
#include "injectionModel.H"
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::autoPtr<Foam::distributionModel> Foam::distributionModel::New
(
const dictionary& dict,
Random& rndGen
)
namespace Foam
{
const word modelType(dict.lookup("type"));
Info<< "Selecting distribution model " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown distribution model type " << modelType << nl << nl
<< "Valid distribution model types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<distributionModel>(cstrIter()(dict, rndGen));
template<>
const char* NamedEnum
<
Foam::injectionModel::uniformParcelSize,
3
>::names[] = {"nParticle", "surfaceArea", "volume"};
}
const Foam::NamedEnum<Foam::injectionModel::uniformParcelSize, 3>
Foam::injectionModel::uniformParcelSizeNames_;
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,85 +22,51 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::distributionModels::fixedValue
Foam::injectionModel
Description
Returns a fixed value
Non-templated base class for lagrangian injection models
SourceFiles
fixedValue.C
injectionModel.C
\*---------------------------------------------------------------------------*/
#ifndef fixedValue_H
#define fixedValue_H
#ifndef injectionModel_H
#define injectionModel_H
#include "distributionModel.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace distributionModels
{
/*---------------------------------------------------------------------------*\
Class fixedValue Declaration
Class injectionModel Declaration
\*---------------------------------------------------------------------------*/
class fixedValue
:
public distributionModel
class injectionModel
{
// Private Data
//- Fixed value
scalar value_;
public:
//- Runtime type information
TypeName("fixedValue");
// Public Enumerations
// Constructors
//- Construct from components
fixedValue(const dictionary& dict, Random& rndGen);
//- Construct copy
fixedValue(const fixedValue& p);
//- Construct and return a clone
virtual autoPtr<distributionModel> clone() const
//- Enumeration for the parcels' uniform size
enum class uniformParcelSize
{
return autoPtr<distributionModel>(new fixedValue(*this));
}
nParticle,
surfaceArea,
volume
};
//- Destructor
virtual ~fixedValue();
// Member Functions
//- Sample the distributionModel
virtual scalar sample() const;
//- Return the minimum value
virtual scalar minValue() const;
//- Return the maximum value
virtual scalar maxValue() const;
//- Return the mean value
virtual scalar meanValue() const;
//- Names of the parcels' uniform size
static const NamedEnum<uniformParcelSize, 3> uniformParcelSizeNames_;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace distributionModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -57,13 +57,15 @@ Foam::ManualInjection<CloudType>::ManualInjection
injectorCells_(positions_.size(), -1),
injectorTetFaces_(positions_.size(), -1),
injectorTetPts_(positions_.size(), -1),
massTotal_(this->readMassTotal(dict, owner)),
U0_(this->coeffDict().lookup("U0")),
sizeDistribution_
(
distributionModel::New
distribution::New
(
this->coeffDict().subDict("sizeDistribution"),
owner.rndGen()
owner.rndGen(),
this->sizeSampleQ()
)
),
ignoreOutOfBounds_
@ -78,9 +80,6 @@ Foam::ManualInjection<CloudType>::ManualInjection
{
diameters_[i] = sizeDistribution_->sample();
}
// Determine volume of particles to inject
this->volumeTotal_ = sum(pow3(diameters_))*pi/6.0;
}
@ -98,6 +97,7 @@ Foam::ManualInjection<CloudType>::ManualInjection
injectorCells_(im.injectorCells_),
injectorTetFaces_(im.injectorTetFaces_),
injectorTetPts_(im.injectorTetPts_),
massTotal_(im.massTotal_),
U0_(im.U0_),
sizeDistribution_(im.sizeDistribution_().clone().ptr()),
ignoreOutOfBounds_(im.ignoreOutOfBounds_)
@ -165,13 +165,14 @@ Foam::scalar Foam::ManualInjection<CloudType>::timeEnd() const
template<class CloudType>
Foam::label Foam::ManualInjection<CloudType>::parcelsToInject
Foam::label Foam::ManualInjection<CloudType>::nParcelsToInject
(
const scalar time0,
const scalar time1
)
{
if ((0.0 >= time0) && (0.0 < time1))
// All parcels introduced at SOI
if (0 >= time0 && 0 < time1)
{
return positions_.size();
}
@ -183,20 +184,20 @@ Foam::label Foam::ManualInjection<CloudType>::parcelsToInject
template<class CloudType>
Foam::scalar Foam::ManualInjection<CloudType>::volumeToInject
Foam::scalar Foam::ManualInjection<CloudType>::massToInject
(
const scalar time0,
const scalar time1
)
{
// All parcels introduced at SOI
if ((0.0 >= time0) && (0.0 < time1))
if (0 >= time0 && 0 < time1)
{
return this->volumeTotal_;
return massTotal_;
}
else
{
return 0.0;
return 0;
}
}
@ -245,11 +246,4 @@ bool Foam::ManualInjection<CloudType>::fullyDescribed() const
}
template<class CloudType>
bool Foam::ManualInjection<CloudType>::validInjection(const label)
{
return true;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -45,7 +45,7 @@ SourceFiles
#define ManualInjection_H
#include "InjectionModel.H"
#include "distributionModel.H"
#include "distribution.H"
#include "Switch.H"
#include "GlobalIOField.H"
@ -86,11 +86,14 @@ class ManualInjection
//- List of tetPt labels corresponding to injector positions
labelList injectorTetPts_;
//- Mass to inject
const scalar massTotal_;
//- Initial parcel velocity
const vector U0_;
//- Parcel size distribution model
const autoPtr<distributionModel> sizeDistribution_;
const autoPtr<distribution> sizeDistribution_;
//- Flag to suppress errors if particle injection site is out-of-bounds
Switch ignoreOutOfBounds_;
@ -135,13 +138,13 @@ public:
virtual void topoChange();
//- Return the end-of-injection time
scalar timeEnd() const;
virtual scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
virtual label nParcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
//- Parcel mass to introduce relative to SOI
virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry
@ -170,10 +173,6 @@ public:
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -38,7 +38,7 @@ Foam::MomentumLookupTableInjection<CloudType>::MomentumLookupTableInjection
:
InjectionModel<CloudType>(dict, owner, modelName, typeName),
inputFileName_(this->coeffDict().lookup("inputFile")),
duration_(this->coeffDict().template lookup<scalar>("duration")),
duration_(this->readDuration(dict, owner)),
parcelsPerSecond_
(
this->coeffDict().template lookup<scalar>("parcelsPerSecond")
@ -60,22 +60,12 @@ Foam::MomentumLookupTableInjection<CloudType>::MomentumLookupTableInjection
injectorTetFaces_(0),
injectorTetPts_(0)
{
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells
injectorCells_.setSize(injectors_.size());
injectorTetFaces_.setSize(injectors_.size());
injectorTetPts_.setSize(injectors_.size());
topoChange();
// Determine volume of particles to inject
this->volumeTotal_ = 0.0;
forAll(injectors_, i)
{
this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho();
}
this->volumeTotal_ *= duration_;
}
@ -133,13 +123,13 @@ Foam::scalar Foam::MomentumLookupTableInjection<CloudType>::timeEnd() const
template<class CloudType>
Foam::label Foam::MomentumLookupTableInjection<CloudType>::parcelsToInject
Foam::label Foam::MomentumLookupTableInjection<CloudType>::nParcelsToInject
(
const scalar time0,
const scalar time1
)
{
if ((time0 >= 0.0) && (time0 < duration_))
if (time0 >= 0 && time0 < duration_)
{
return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_);
}
@ -151,22 +141,23 @@ Foam::label Foam::MomentumLookupTableInjection<CloudType>::parcelsToInject
template<class CloudType>
Foam::scalar Foam::MomentumLookupTableInjection<CloudType>::volumeToInject
Foam::scalar Foam::MomentumLookupTableInjection<CloudType>::massToInject
(
const scalar time0,
const scalar time1
)
{
scalar volume = 0.0;
if ((time0 >= 0.0) && (time0 < duration_))
scalar mass = 0;
if (time0 >= 0 && time0 < duration_)
{
forAll(injectors_, i)
{
volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
mass += injectors_[i].mDot()*(time1 - time0);
}
}
return volume;
return mass;
}
@ -230,14 +221,4 @@ bool Foam::MomentumLookupTableInjection<CloudType>::fullyDescribed() const
}
template<class CloudType>
bool Foam::MomentumLookupTableInjection<CloudType>::validInjection
(
const label
)
{
return true;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -77,7 +77,7 @@ class MomentumLookupTableInjection
const word inputFileName_;
//- Injection duration - common to all injection sources
scalar duration_;
const scalar duration_;
//- Number of parcels per injector - common to all injection sources
const scalar parcelsPerSecond_;
@ -143,13 +143,13 @@ public:
virtual void topoChange();
//- Return the end-of-injection time
scalar timeEnd() const;
virtual scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
virtual label nParcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
//- Parcel mass to introduce relative to SOI
virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry
@ -178,10 +178,6 @@ public:
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -59,12 +59,12 @@ Foam::NoInjection<CloudType>::~NoInjection()
template<class CloudType>
Foam::scalar Foam::NoInjection<CloudType>::timeEnd() const
{
return 0.0;
return 0;
}
template<class CloudType>
Foam::label Foam::NoInjection<CloudType>::parcelsToInject
Foam::label Foam::NoInjection<CloudType>::nParcelsToInject
(
const scalar,
const scalar
@ -75,13 +75,13 @@ Foam::label Foam::NoInjection<CloudType>::parcelsToInject
template<class CloudType>
Foam::scalar Foam::NoInjection<CloudType>::volumeToInject
Foam::scalar Foam::NoInjection<CloudType>::massToInject
(
const scalar,
const scalar
)
{
return 0.0;
return 0;
}
@ -113,7 +113,7 @@ void Foam::NoInjection<CloudType>::setProperties
parcel.U() = Zero;
// set particle diameter
parcel.d() = 0.0;
parcel.d() = 0;
}
@ -124,11 +124,4 @@ bool Foam::NoInjection<CloudType>::fullyDescribed() const
}
template<class CloudType>
bool Foam::NoInjection<CloudType>::validInjection(const label)
{
return false;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -83,13 +83,13 @@ public:
// Member Functions
//- Return the end-of-injection time
scalar timeEnd() const;
virtual scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
virtual label nParcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
//- Parcel mass to introduce relative to SOI
virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry
@ -117,10 +117,6 @@ public:
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,7 +25,7 @@ License
#include "PatchFlowRateInjection.H"
#include "TimeFunction1.H"
#include "distributionModel.H"
#include "distribution.H"
#include "mathematicalConstants.H"
#include "surfaceFields.H"
@ -43,7 +43,7 @@ Foam::PatchFlowRateInjection<CloudType>::PatchFlowRateInjection
patchInjectionBase(owner.mesh(), this->coeffDict().lookup("patchName")),
phiName_(this->coeffDict().template lookupOrDefault<word>("phi", "phi")),
rhoName_(this->coeffDict().template lookupOrDefault<word>("rho", "rho")),
duration_(this->coeffDict().template lookup<scalar>("duration")),
duration_(this->readDuration(dict, owner)),
concentration_
(
TimeFunction1<scalar>
@ -59,20 +59,14 @@ Foam::PatchFlowRateInjection<CloudType>::PatchFlowRateInjection
),
sizeDistribution_
(
distributionModel::New
distribution::New
(
this->coeffDict().subDict("sizeDistribution"),
owner.rndGen()
owner.rndGen(),
this->sizeSampleQ()
)
)
{
duration_ = owner.db().time().userTimeToTime(duration_);
// Re-initialise total mass/volume to inject to zero
// - will be reset during each injection
this->volumeTotal_ = 0.0;
this->massTotal_ = 0.0;
}
{}
template<class CloudType>
@ -146,13 +140,13 @@ Foam::scalar Foam::PatchFlowRateInjection<CloudType>::flowRate() const
template<class CloudType>
Foam::label Foam::PatchFlowRateInjection<CloudType>::parcelsToInject
Foam::label Foam::PatchFlowRateInjection<CloudType>::nParcelsToInject
(
const scalar time0,
const scalar time1
)
{
if ((time0 >= 0.0) && (time0 < duration_))
if (time0 >= 0 && time0 < duration_)
{
scalar dt = time1 - time0;
@ -185,33 +179,22 @@ Foam::label Foam::PatchFlowRateInjection<CloudType>::parcelsToInject
template<class CloudType>
Foam::scalar Foam::PatchFlowRateInjection<CloudType>::volumeToInject
Foam::scalar Foam::PatchFlowRateInjection<CloudType>::massToInject
(
const scalar time0,
const scalar time1
)
{
scalar volume = 0.0;
scalar volume = 0;
if ((time0 >= 0.0) && (time0 < duration_))
if (time0 >= 0 && time0 < duration_)
{
scalar c = concentration_.value(0.5*(time0 + time1));
volume = c*(time1 - time0)*flowRate();
}
this->volumeTotal_ = volume;
this->massTotal_ = volume*this->owner().constProps().rho0();
return volume;
}
template<class CloudType>
Foam::scalar Foam::PatchFlowRateInjection<CloudType>::averageParcelMass()
{
NotImplemented;
return NaN;
return volume*this->owner().constProps().rho0();
}
@ -265,11 +248,4 @@ bool Foam::PatchFlowRateInjection<CloudType>::fullyDescribed() const
}
template<class CloudType>
bool Foam::PatchFlowRateInjection<CloudType>::validInjection(const label)
{
return true;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,7 +29,6 @@ Description
velocity.
User specifies:
- Total mass to inject
- Name of patch
- Injection duration
- Injection target concentration/carrier volume flow rate
@ -56,7 +55,7 @@ SourceFiles
namespace Foam
{
class distributionModel;
class distribution;
/*---------------------------------------------------------------------------*\
Class PatchFlowRateInjection Declaration
@ -77,7 +76,7 @@ class PatchFlowRateInjection
const word rhoName_;
//- Injection duration [s]
scalar duration_;
const scalar duration_;
//- Concentration profile of particle volume to carrier volume [-]
const TimeFunction1<scalar> concentration_;
@ -86,7 +85,7 @@ class PatchFlowRateInjection
const scalar parcelConcentration_;
//- Parcel size distribution model
const autoPtr<distributionModel> sizeDistribution_;
const autoPtr<distribution> sizeDistribution_;
public:
@ -131,19 +130,16 @@ public:
virtual void topoChange();
//- Return the end-of-injection time
scalar timeEnd() const;
virtual scalar timeEnd() const;
//- Return the total volumetric flow rate across the patch [m^3/s]
virtual scalar flowRate() const;
scalar flowRate() const;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
virtual label nParcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
//- Return the average parcel mass over the injection period
virtual scalar averageParcelMass();
//- Parcel mass to introduce relative to SOI
virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry
@ -174,10 +170,6 @@ public:
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,7 +25,7 @@ License
#include "PatchInjection.H"
#include "TimeFunction1.H"
#include "distributionModel.H"
#include "distribution.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -39,35 +39,23 @@ Foam::PatchInjection<CloudType>::PatchInjection
:
InjectionModel<CloudType>(dict, owner, modelName, typeName),
patchInjectionBase(owner.mesh(), this->coeffDict().lookup("patchName")),
duration_(this->coeffDict().template lookup<scalar>("duration")),
duration_(this->readDuration(dict, owner)),
massFlowRate_(this->readMassFlowRate(dict, owner, duration_)),
parcelsPerSecond_
(
this->coeffDict().template lookup<scalar>("parcelsPerSecond")
),
U0_(this->coeffDict().lookup("U0")),
flowRateProfile_
(
TimeFunction1<scalar>
(
owner.db().time(),
"flowRateProfile",
this->coeffDict()
)
),
sizeDistribution_
(
distributionModel::New
distribution::New
(
this->coeffDict().subDict("sizeDistribution"),
owner.rndGen()
owner.rndGen(),
this->sizeSampleQ()
)
)
{
duration_ = owner.db().time().userTimeToTime(duration_);
// Set total volume/mass to inject
this->volumeTotal_ = flowRateProfile_.integral(0.0, duration_);
}
{}
template<class CloudType>
@ -79,9 +67,9 @@ Foam::PatchInjection<CloudType>::PatchInjection
InjectionModel<CloudType>(im),
patchInjectionBase(im),
duration_(im.duration_),
massFlowRate_(im.massFlowRate_),
parcelsPerSecond_(im.parcelsPerSecond_),
U0_(im.U0_),
flowRateProfile_(im.flowRateProfile_),
sizeDistribution_(im.sizeDistribution_().clone().ptr())
{}
@ -110,13 +98,13 @@ Foam::scalar Foam::PatchInjection<CloudType>::timeEnd() const
template<class CloudType>
Foam::label Foam::PatchInjection<CloudType>::parcelsToInject
Foam::label Foam::PatchInjection<CloudType>::nParcelsToInject
(
const scalar time0,
const scalar time1
)
{
if ((time0 >= 0.0) && (time0 < duration_))
if (time0 >= 0 && time0 < duration_)
{
scalar nParcels = (time1 - time0)*parcelsPerSecond_;
@ -145,19 +133,19 @@ Foam::label Foam::PatchInjection<CloudType>::parcelsToInject
template<class CloudType>
Foam::scalar Foam::PatchInjection<CloudType>::volumeToInject
Foam::scalar Foam::PatchInjection<CloudType>::massToInject
(
const scalar time0,
const scalar time1
)
{
if ((time0 >= 0.0) && (time0 < duration_))
if (time0 >= 0 && time0 < duration_)
{
return flowRateProfile_.integral(time0, time1);
return massFlowRate_.integral(time0, time1);
}
else
{
return 0.0;
return 0;
}
}
@ -212,11 +200,4 @@ bool Foam::PatchInjection<CloudType>::fullyDescribed() const
}
template<class CloudType>
bool Foam::PatchInjection<CloudType>::validInjection(const label)
{
return true;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -57,7 +57,7 @@ namespace Foam
template<class Type>
class TimeFunction1;
class distributionModel;
class distribution;
/*---------------------------------------------------------------------------*\
Class PatchInjection Declaration
@ -72,7 +72,10 @@ class PatchInjection
// Private Data
//- Injection duration [s]
scalar duration_;
const scalar duration_;
//- Mass flow rate relative to SOI []
const TimeFunction1<scalar> massFlowRate_;
//- Number of parcels to introduce per second []
const label parcelsPerSecond_;
@ -80,11 +83,8 @@ class PatchInjection
//- Initial parcel velocity [m/s]
const vector U0_;
//- Flow rate profile relative to SOI []
const TimeFunction1<scalar> flowRateProfile_;
//- Parcel size distribution model
const autoPtr<distributionModel> sizeDistribution_;
const autoPtr<distribution> sizeDistribution_;
public:
@ -132,10 +132,10 @@ public:
virtual scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
virtual label nParcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
//- Parcel mass to introduce relative to SOI
virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry
@ -166,10 +166,6 @@ public:
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI);
};

View File

@ -138,7 +138,7 @@ void Foam::SurfaceFilmModel<CloudType>::inject(TrackCloudType& cloud)
if (pPtr->nParticle() > 0.001)
{
// Check new parcel properties
cloud.checkParcelProperties(*pPtr, false);
cloud.checkParcelProperties(*pPtr, -1);
// Add the new parcel to the cloud
cloud.addParticle(pPtr);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -37,7 +37,7 @@ Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection
:
InjectionModel<CloudType>(dict, owner, modelName, typeName),
inputFileName_(this->coeffDict().lookup("inputFile")),
duration_(this->coeffDict().template lookup<scalar>("duration")),
duration_(this->readDuration(dict, owner)),
parcelsPerSecond_
(
this->coeffDict().template lookup<scalar>("parcelsPerSecond")
@ -59,8 +59,6 @@ Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection
injectorTetFaces_(0),
injectorTetPts_(0)
{
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells
injectorCoordinates_.setSize(injectors_.size());
injectorCells_.setSize(injectors_.size());
@ -68,14 +66,6 @@ Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection
injectorTetPts_.setSize(injectors_.size());
topoChange();
// Determine volume of particles to inject
this->volumeTotal_ = 0.0;
forAll(injectors_, i)
{
this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho();
}
this->volumeTotal_ *= duration_;
}
@ -133,13 +123,13 @@ Foam::scalar Foam::ReactingLookupTableInjection<CloudType>::timeEnd() const
template<class CloudType>
Foam::label Foam::ReactingLookupTableInjection<CloudType>::parcelsToInject
Foam::label Foam::ReactingLookupTableInjection<CloudType>::nParcelsToInject
(
const scalar time0,
const scalar time1
)
{
if ((time0 >= 0.0) && (time0 < duration_))
if (time0 >= 0 && time0 < duration_)
{
return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_);
}
@ -151,22 +141,23 @@ Foam::label Foam::ReactingLookupTableInjection<CloudType>::parcelsToInject
template<class CloudType>
Foam::scalar Foam::ReactingLookupTableInjection<CloudType>::volumeToInject
Foam::scalar Foam::ReactingLookupTableInjection<CloudType>::massToInject
(
const scalar time0,
const scalar time1
)
{
scalar volume = 0.0;
if ((time0 >= 0.0) && (time0 < duration_))
scalar mass = 0;
if (time0 >= 0 && time0 < duration_)
{
forAll(injectors_, i)
{
volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
mass += injectors_[i].mDot()*(time1 - time0);
}
}
return volume;
return mass;
}
@ -239,11 +230,4 @@ bool Foam::ReactingLookupTableInjection<CloudType>::fullyDescribed() const
}
template<class CloudType>
bool Foam::ReactingLookupTableInjection<CloudType>::validInjection(const label)
{
return true;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -76,7 +76,7 @@ class ReactingLookupTableInjection
const word inputFileName_;
//- Injection duration - common to all injection sources
scalar duration_;
const scalar duration_;
//- Number of parcels per injector - common to all injection sources
const scalar parcelsPerSecond_;
@ -145,11 +145,10 @@ public:
scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
virtual label nParcelsToInject(const scalar time0, const scalar time1);
//- Parcel mass to introduce relative to SOI
virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry
@ -178,10 +177,6 @@ public:
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -38,7 +38,7 @@ ReactingMultiphaseLookupTableInjection
:
InjectionModel<CloudType>(dict, owner, modelName, typeName),
inputFileName_(this->coeffDict().lookup("inputFile")),
duration_(this->coeffDict().template lookup<scalar>("duration")),
duration_(this->readDuration(dict, owner)),
parcelsPerSecond_
(
this->coeffDict().template lookup<scalar>("parcelsPerSecond")
@ -60,8 +60,6 @@ ReactingMultiphaseLookupTableInjection
injectorTetFaces_(0),
injectorTetPts_(0)
{
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells
injectorCoordinates_.setSize(injectors_.size());
injectorCells_.setSize(injectors_.size());
@ -69,14 +67,6 @@ ReactingMultiphaseLookupTableInjection
injectorTetPts_.setSize(injectors_.size());
topoChange();
// Determine volume of particles to inject
this->volumeTotal_ = 0.0;
forAll(injectors_, i)
{
this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho();
}
this->volumeTotal_ *= duration_;
}
@ -138,13 +128,13 @@ Foam::ReactingMultiphaseLookupTableInjection<CloudType>::timeEnd() const
template<class CloudType>
Foam::label
Foam::ReactingMultiphaseLookupTableInjection<CloudType>::parcelsToInject
Foam::ReactingMultiphaseLookupTableInjection<CloudType>::nParcelsToInject
(
const scalar time0,
const scalar time1
)
{
if ((time0 >= 0.0) && (time0 < duration_))
if (time0 >= 0 && time0 < duration_)
{
return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_);
}
@ -157,22 +147,23 @@ Foam::ReactingMultiphaseLookupTableInjection<CloudType>::parcelsToInject
template<class CloudType>
Foam::scalar
Foam::ReactingMultiphaseLookupTableInjection<CloudType>::volumeToInject
Foam::ReactingMultiphaseLookupTableInjection<CloudType>::massToInject
(
const scalar time0,
const scalar time1
)
{
scalar volume = 0.0;
if ((time0 >= 0.0) && (time0 < duration_))
scalar mass = 0;
if (time0 >= 0 && time0 < duration_)
{
forAll(injectors_, i)
{
volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
mass += injectors_[i].mDot()*(time1 - time0);
}
}
return volume;
return mass;
}
@ -255,14 +246,4 @@ Foam::ReactingMultiphaseLookupTableInjection<CloudType>::fullyDescribed() const
}
template<class CloudType>
bool Foam::ReactingMultiphaseLookupTableInjection<CloudType>::validInjection
(
const label
)
{
return true;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -79,7 +79,7 @@ class ReactingMultiphaseLookupTableInjection
const word inputFileName_;
//- Injection duration - common to all injection sources
scalar duration_;
const scalar duration_;
//- Number of parcels per injector - common to all injection sources
const scalar parcelsPerSecond_;
@ -148,10 +148,10 @@ public:
scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
virtual label nParcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
//- Parcel mass to introduce relative to SOI
virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry
@ -180,10 +180,6 @@ public:
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -37,7 +37,6 @@ Foam::LISAAtomisation<CloudType>::LISAAtomisation
AtomisationModel<CloudType>(dict, owner, typeName),
Cl_(this->coeffDict().template lookup<scalar>("Cl")),
cTau_(this->coeffDict().template lookup<scalar>("cTau")),
Q_(this->coeffDict().template lookup<scalar>("Q")),
lisaExp_(this->coeffDict().template lookup<scalar>("lisaExp")),
injectorDirection_(this->coeffDict().lookup("injectorDirection")),
SMDCalcMethod_(this->coeffDict().lookup("SMDCalculationMethod"))
@ -71,7 +70,6 @@ Foam::LISAAtomisation<CloudType>::LISAAtomisation
AtomisationModel<CloudType>(am),
Cl_(am.Cl_),
cTau_(am.cTau_),
Q_(am.Q_),
lisaExp_(am.lisaExp_),
injectorDirection_(am.injectorDirection_),
SMDCalcMethod_(am.SMDCalcMethod_)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -79,7 +79,6 @@ private:
scalar Cl_;
scalar cTau_;
scalar Q_;
scalar lisaExp_;
vector injectorDirection_;
word SMDCalcMethod_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -179,6 +179,7 @@ public:
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
) = 0;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -94,6 +94,7 @@ bool Foam::ETAB<CloudType>::update
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -127,6 +127,7 @@ public:
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -77,6 +77,7 @@ bool Foam::NoBreakup<CloudType>::update
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -99,6 +99,7 @@ public:
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -86,6 +86,7 @@ bool Foam::PilchErdman<CloudType>::update
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -131,6 +131,7 @@ public:
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -92,6 +92,7 @@ bool Foam::ReitzDiwakar<CloudType>::update
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -125,6 +125,7 @@ public:
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -98,6 +98,7 @@ bool Foam::ReitzKHRT<CloudType>::update
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
)
@ -105,7 +106,7 @@ bool Foam::ReitzKHRT<CloudType>::update
bool addParcel = false;
const scalar averageParcelMass =
this->owner().injectors().averageParcelMass();
this->owner().injectors()[injectori].averageParcelMass();
scalar r = 0.5*d;
scalar d3 = pow3(d);
@ -190,14 +191,13 @@ bool Foam::ReitzKHRT<CloudType>::update
// reduce the diameter according to the rate-equation
d = (fraction*dc + d)/(1.0 + fraction);
// scalar ms0 = rho*pow3(dc)*mathematicalConstant::pi/6.0;
scalar ms0 = mass0*(1.0 - pow3(d/d0));
ms += ms0;
// calculate the stripped mass
ms += mass0*(1.0 - pow3(d/d0));
if (ms/averageParcelMass > msLimit_)
{
// Correct evaluation of the number of child droplets and the
// diameter of parcel droplets after breaukp
// diameter of parcel droplets after breakup
// Solution of cubic equation for the diameter of the parent
// drops after breakup, see Eq. 18 in
// Patterson & Reitz, SAE 980131

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -112,6 +112,7 @@ public:
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -134,6 +134,7 @@ bool Foam::SHF<CloudType>::update
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -154,6 +154,7 @@ public:
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -106,6 +106,7 @@ bool Foam::TAB<CloudType>::update
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -139,6 +139,7 @@ public:
const vector& Urel,
const scalar Urmag,
const scalar tMom,
const label injectori,
scalar& dChild,
scalar& massChild
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -38,7 +38,7 @@ Foam::ThermoLookupTableInjection<CloudType>::ThermoLookupTableInjection
:
InjectionModel<CloudType>(dict, owner, modelName, typeName),
inputFileName_(this->coeffDict().lookup("inputFile")),
duration_(this->coeffDict().template lookup<scalar>("duration")),
duration_(this->readDuration(dict, owner)),
parcelsPerSecond_
(
this->coeffDict().template lookup<scalar>("parcelsPerSecond")
@ -60,8 +60,6 @@ Foam::ThermoLookupTableInjection<CloudType>::ThermoLookupTableInjection
injectorTetFaces_(0),
injectorTetPts_(0)
{
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells
injectorCoordinates_.setSize(injectors_.size());
injectorCells_.setSize(injectors_.size());
@ -69,14 +67,6 @@ Foam::ThermoLookupTableInjection<CloudType>::ThermoLookupTableInjection
injectorTetPts_.setSize(injectors_.size());
topoChange();
// Determine volume of particles to inject
this->volumeTotal_ = 0.0;
forAll(injectors_, i)
{
this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho();
}
this->volumeTotal_ *= duration_;
}
@ -134,13 +124,13 @@ Foam::scalar Foam::ThermoLookupTableInjection<CloudType>::timeEnd() const
template<class CloudType>
Foam::label Foam::ThermoLookupTableInjection<CloudType>::parcelsToInject
Foam::label Foam::ThermoLookupTableInjection<CloudType>::nParcelsToInject
(
const scalar time0,
const scalar time1
)
{
if ((time0 >= 0.0) && (time0 < duration_))
if (time0 >= 0 && time0 < duration_)
{
return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_);
}
@ -152,22 +142,23 @@ Foam::label Foam::ThermoLookupTableInjection<CloudType>::parcelsToInject
template<class CloudType>
Foam::scalar Foam::ThermoLookupTableInjection<CloudType>::volumeToInject
Foam::scalar Foam::ThermoLookupTableInjection<CloudType>::massToInject
(
const scalar time0,
const scalar time1
)
{
scalar volume = 0.0;
if ((time0 >= 0.0) && (time0 < duration_))
scalar mass = 0;
if (time0 >= 0 && time0 < duration_)
{
forAll(injectors_, i)
{
volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
mass += injectors_[i].mDot()*(time1 - time0);
}
}
return volume;
return mass;
}
@ -237,11 +228,4 @@ bool Foam::ThermoLookupTableInjection<CloudType>::fullyDescribed() const
}
template<class CloudType>
bool Foam::ThermoLookupTableInjection<CloudType>::validInjection(const label)
{
return true;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -75,7 +75,7 @@ class ThermoLookupTableInjection
const word inputFileName_;
//- Injection duration - common to all injection sources
scalar duration_;
const scalar duration_;
//- Number of parcels per injector - common to all injection sources
const scalar parcelsPerSecond_;
@ -144,11 +144,10 @@ public:
scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
virtual label nParcelsToInject(const scalar time0, const scalar time1);
//- Parcel mass to introduce relative to SOI
virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry
@ -177,10 +176,6 @@ public:
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const;
//- Return flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI);
};

Some files were not shown because too many files have changed in this diff Show More