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 \ -lmomentumTransportModels \
-lfilmCompressibleMomentumTransportModels \ -lfilmCompressibleMomentumTransportModels \
-linterfaceProperties \ -linterfaceProperties \
-ldistributionModels \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools \ -lmeshTools \
-lsampling \ -lsampling \

View File

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

View File

@ -4,7 +4,6 @@ cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for library compilation # Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
wmake $targetType distributionModels
wmake $targetType basic wmake $targetType basic
wmake $targetType solidParticle wmake $targetType solidParticle
wmake $targetType parcel 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)/nonEquilibrium/nonEquilibrium.C
$(MPPICTIMESCALE)/isotropic/isotropic.C $(MPPICTIMESCALE)/isotropic/isotropic.C
# injection model
submodels/Momentum/InjectionModel/InjectionModel/injectionModel.C
# integration schemes # integration schemes
integrationScheme/integrationScheme/integrationScheme.C integrationScheme/integrationScheme/integrationScheme.C
integrationScheme/integrationScheme/integrationSchemeNew.C integrationScheme/integrationScheme/integrationSchemeNew.C

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -171,12 +171,14 @@ template<class CloudType>
void Foam::ReactingMultiphaseCloud<CloudType>::checkParcelProperties void Foam::ReactingMultiphaseCloud<CloudType>::checkParcelProperties
( (
parcelType& parcel, 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 idGas = this->composition().idGas();
label idLiquid = this->composition().idLiquid(); label idLiquid = this->composition().idLiquid();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -78,6 +78,7 @@ inline Foam::ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel
) )
: :
ParcelType(mesh, coordinates, celli, tetFacei, tetPti, facei), ParcelType(mesh, coordinates, celli, tetFacei, tetPti, facei),
mass0_(0),
YGas_(0), YGas_(0),
YLiquid_(0), YLiquid_(0),
YSolid_(0), YSolid_(0),
@ -94,6 +95,7 @@ inline Foam::ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel
) )
: :
ParcelType(mesh, position, celli), ParcelType(mesh, position, celli),
mass0_(0),
YGas_(0), YGas_(0),
YLiquid_(0), YLiquid_(0),
YSolid_(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> template<class ParcelType>
inline const Foam::scalarField& Foam::ReactingMultiphaseParcel<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> template<class ParcelType>
inline Foam::scalarField& Foam::ReactingMultiphaseParcel<ParcelType>::YGas() inline Foam::scalarField& Foam::ReactingMultiphaseParcel<ParcelType>::YGas()
{ {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -161,6 +161,7 @@ Foam::CellZoneInjection<CloudType>::CellZoneInjection
: :
InjectionModel<CloudType>(dict, owner, modelName, typeName), InjectionModel<CloudType>(dict, owner, modelName, typeName),
cellZoneName_(this->coeffDict().lookup("cellZone")), cellZoneName_(this->coeffDict().lookup("cellZone")),
massTotal_(this->readMassTotal(dict, owner)),
numberDensity_(this->coeffDict().template lookup<scalar>("numberDensity")), numberDensity_(this->coeffDict().template lookup<scalar>("numberDensity")),
injectorCoordinates_(), injectorCoordinates_(),
injectorCells_(), injectorCells_(),
@ -170,9 +171,11 @@ Foam::CellZoneInjection<CloudType>::CellZoneInjection
U0_(this->coeffDict().lookup("U0")), U0_(this->coeffDict().lookup("U0")),
sizeDistribution_ 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), InjectionModel<CloudType>(im),
cellZoneName_(im.cellZoneName_), cellZoneName_(im.cellZoneName_),
massTotal_(im.massTotal_),
numberDensity_(im.numberDensity_), numberDensity_(im.numberDensity_),
injectorCoordinates_(im.injectorCoordinates_), injectorCoordinates_(im.injectorCoordinates_),
injectorCells_(im.injectorCells_), injectorCells_(im.injectorCells_),
@ -252,9 +256,6 @@ void Foam::CellZoneInjection<CloudType>::topoChange()
diameters_[i] = sizeDistribution_->sample(); 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> template<class CloudType>
Foam::label Foam::CellZoneInjection<CloudType>::parcelsToInject Foam::label Foam::CellZoneInjection<CloudType>::nParcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
if ((0.0 >= time0) && (0.0 < time1)) // All parcels introduced at SOI
if (0 >= time0 && 0 < time1)
{ {
return injectorCoordinates_.size(); return injectorCoordinates_.size();
} }
@ -285,20 +287,20 @@ Foam::label Foam::CellZoneInjection<CloudType>::parcelsToInject
template<class CloudType> template<class CloudType>
Foam::scalar Foam::CellZoneInjection<CloudType>::volumeToInject Foam::scalar Foam::CellZoneInjection<CloudType>::massToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
// All parcels introduced at SOI // All parcels introduced at SOI
if ((0.0 >= time0) && (0.0 < time1)) if (0 >= time0 && 0 < time1)
{ {
return this->volumeTotal_; return massTotal_;
} }
else 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,7 +46,7 @@ SourceFiles
#define CellZoneInjection_H #define CellZoneInjection_H
#include "InjectionModel.H" #include "InjectionModel.H"
#include "distributionModel.H" #include "distribution.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -67,6 +67,9 @@ class CellZoneInjection
//- Name of cell zone //- Name of cell zone
const word cellZoneName_; const word cellZoneName_;
//- Mass to inject
const scalar massTotal_;
//- Number density //- Number density
const scalar numberDensity_; const scalar numberDensity_;
@ -89,7 +92,7 @@ class CellZoneInjection
const vector U0_; const vector U0_;
//- Parcel size distribution model //- Parcel size distribution model
const autoPtr<distributionModel> sizeDistribution_; const autoPtr<distribution> sizeDistribution_;
// Private Member Functions // Private Member Functions
@ -137,13 +140,13 @@ public:
virtual void topoChange(); virtual void topoChange();
//- Return the end-of-injection time //- Return the end-of-injection time
scalar timeEnd() const; virtual scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI //- 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 //- Parcel mass to introduce relative to SOI
scalar volumeToInject(const scalar time0, const scalar time1); virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry // Injection geometry
@ -172,10 +175,6 @@ public:
//- Flag to identify whether model fully describes the parcel //- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const; 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -142,20 +142,12 @@ Foam::ConeInjection<CloudType>::ConeInjection
injectorCell_(-1), injectorCell_(-1),
injectorTetFace_(-1), injectorTetFace_(-1),
injectorTetPt_(-1), injectorTetPt_(-1),
duration_(this->coeffDict().template lookup<scalar>("duration")), duration_(this->readDuration(dict, owner)),
massFlowRate_(this->readMassFlowRate(dict, owner, duration_)),
parcelsPerSecond_ parcelsPerSecond_
( (
this->coeffDict().template lookup<scalar>("parcelsPerSecond") this->coeffDict().template lookup<scalar>("parcelsPerSecond")
), ),
flowRateProfile_
(
TimeFunction1<scalar>
(
owner.db().time(),
"flowRateProfile",
this->coeffDict()
)
),
thetaInner_ thetaInner_
( (
TimeFunction1<scalar> TimeFunction1<scalar>
@ -176,9 +168,11 @@ Foam::ConeInjection<CloudType>::ConeInjection
), ),
sizeDistribution_ sizeDistribution_
( (
distributionModel::New distribution::New
( (
this->coeffDict().subDict("sizeDistribution"), owner.rndGen() this->coeffDict().subDict("sizeDistribution"),
owner.rndGen(),
this->sizeSampleQ()
) )
), ),
dInner_(vGreat), dInner_(vGreat),
@ -187,15 +181,10 @@ Foam::ConeInjection<CloudType>::ConeInjection
Cd_(owner.db().time(), "Cd"), Cd_(owner.db().time(), "Cd"),
Pinj_(owner.db().time(), "Pinj") Pinj_(owner.db().time(), "Pinj")
{ {
duration_ = owner.db().time().userTimeToTime(duration_);
setInjectionMethod(); setInjectionMethod();
setFlowType(); setFlowType();
// Set total volume to inject
this->volumeTotal_ = flowRateProfile_.integral(0, duration_);
topoChange(); topoChange();
} }
@ -217,8 +206,8 @@ Foam::ConeInjection<CloudType>::ConeInjection
injectorTetFace_(im.injectorTetFace_), injectorTetFace_(im.injectorTetFace_),
injectorTetPt_(im.injectorTetPt_), injectorTetPt_(im.injectorTetPt_),
duration_(im.duration_), duration_(im.duration_),
massFlowRate_(im.massFlowRate_),
parcelsPerSecond_(im.parcelsPerSecond_), parcelsPerSecond_(im.parcelsPerSecond_),
flowRateProfile_(im.flowRateProfile_),
thetaInner_(im.thetaInner_), thetaInner_(im.thetaInner_),
thetaOuter_(im.thetaOuter_), thetaOuter_(im.thetaOuter_),
sizeDistribution_(im.sizeDistribution_().clone().ptr()), sizeDistribution_(im.sizeDistribution_().clone().ptr()),
@ -265,7 +254,7 @@ Foam::scalar Foam::ConeInjection<CloudType>::timeEnd() const
template<class CloudType> template<class CloudType>
Foam::label Foam::ConeInjection<CloudType>::parcelsToInject Foam::label Foam::ConeInjection<CloudType>::nParcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
@ -287,7 +276,7 @@ Foam::label Foam::ConeInjection<CloudType>::parcelsToInject
template<class CloudType> template<class CloudType>
Foam::scalar Foam::ConeInjection<CloudType>::volumeToInject Foam::scalar Foam::ConeInjection<CloudType>::massToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
@ -295,7 +284,7 @@ Foam::scalar Foam::ConeInjection<CloudType>::volumeToInject
{ {
if (time0 >= 0 && time0 < duration_) if (time0 >= 0 && time0 < duration_)
{ {
return flowRateProfile_.integral(time0, time1); return massFlowRate_.integral(time0, time1);
} }
else else
{ {
@ -465,10 +454,8 @@ void Foam::ConeInjection<CloudType>::setProperties
case ftFlowRateAndDischarge: case ftFlowRateAndDischarge:
{ {
const scalar A = 0.25*pi*(sqr(dOuter_) - sqr(dInner_)); const scalar A = 0.25*pi*(sqr(dOuter_) - sqr(dInner_));
const scalar massFlowRate =
this->massTotal()*flowRateProfile_.value(t)/this->volumeTotal();
const scalar Umag = const scalar Umag =
massFlowRate/(parcel.rho()*Cd_.value(t)*A); massFlowRate_.value(t)/(parcel.rho()*Cd_.value(t)*A);
parcel.U() = Umag*dirVec; parcel.U() = Umag*dirVec;
break; 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -141,7 +141,7 @@ SourceFiles
#define ConeInjection_H #define ConeInjection_H
#include "InjectionModel.H" #include "InjectionModel.H"
#include "distributionModel.H" #include "distribution.H"
#include "TimeFunction1.H" #include "TimeFunction1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -208,14 +208,14 @@ private:
label injectorTetPt_; label injectorTetPt_;
//- Injection duration [s] //- 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 //- Number of parcels to introduce per second
const label parcelsPerSecond_; const label parcelsPerSecond_;
//- Flow rate profile relative to SOI []
const TimeFunction1<scalar> flowRateProfile_;
//- Inner half-cone angle relative to SOI [deg] //- Inner half-cone angle relative to SOI [deg]
const TimeFunction1<scalar> thetaInner_; const TimeFunction1<scalar> thetaInner_;
@ -223,7 +223,7 @@ private:
const TimeFunction1<scalar> thetaOuter_; const TimeFunction1<scalar> thetaOuter_;
//- Parcel size distribution model //- Parcel size distribution model
const autoPtr<distributionModel> sizeDistribution_; const autoPtr<distribution> sizeDistribution_;
// Disc geometry // Disc geometry
@ -298,11 +298,10 @@ public:
scalar timeEnd() const; scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI //- 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 // Injection geometry
@ -331,10 +330,6 @@ public:
//- Flag to identify whether model fully describes the parcel //- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const; 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -71,6 +71,7 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
injectorCells_(positions_.size()), injectorCells_(positions_.size()),
injectorTetFaces_(positions_.size()), injectorTetFaces_(positions_.size()),
injectorTetPts_(positions_.size()), injectorTetPts_(positions_.size()),
massTotal_(this->readMassTotal(dict, owner)),
nParcelsPerInjector_ nParcelsPerInjector_
( (
this->coeffDict().template lookup<label>("parcelsPerInjector") this->coeffDict().template lookup<label>("parcelsPerInjector")
@ -80,10 +81,11 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
diameters_(positions_.size()), diameters_(positions_.size()),
sizeDistribution_ sizeDistribution_
( (
distributionModel::New distribution::New
( (
this->coeffDict().subDict("sizeDistribution"), this->coeffDict().subDict("sizeDistribution"),
owner.rndGen() owner.rndGen(),
this->sizeSampleQ()
) )
) )
{ {
@ -93,10 +95,6 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
diameters_[i] = sizeDistribution_->sample(); diameters_[i] = sizeDistribution_->sample();
} }
// Determine total volume of particles to inject
this->volumeTotal_ =
nParcelsPerInjector_*sum(pow3(diameters_))*pi/6.0;
topoChange(); topoChange();
} }
@ -117,6 +115,7 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
injectorCells_(im.injectorCells_), injectorCells_(im.injectorCells_),
injectorTetFaces_(im.injectorTetFaces_), injectorTetFaces_(im.injectorTetFaces_),
injectorTetPts_(im.injectorTetPts_), injectorTetPts_(im.injectorTetPts_),
massTotal_(im.massTotal_),
nParcelsPerInjector_(im.nParcelsPerInjector_), nParcelsPerInjector_(im.nParcelsPerInjector_),
nParcelsInjected_(im.nParcelsInjected_), nParcelsInjected_(im.nParcelsInjected_),
U0_(im.U0_), U0_(im.U0_),
@ -160,7 +159,7 @@ Foam::scalar Foam::FieldActivatedInjection<CloudType>::timeEnd() const
template<class CloudType> template<class CloudType>
Foam::label Foam::FieldActivatedInjection<CloudType>::parcelsToInject Foam::label Foam::FieldActivatedInjection<CloudType>::nParcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
@ -178,7 +177,7 @@ Foam::label Foam::FieldActivatedInjection<CloudType>::parcelsToInject
template<class CloudType> template<class CloudType>
Foam::scalar Foam::FieldActivatedInjection<CloudType>::volumeToInject Foam::scalar Foam::FieldActivatedInjection<CloudType>::massToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
@ -186,7 +185,7 @@ Foam::scalar Foam::FieldActivatedInjection<CloudType>::volumeToInject
{ {
if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size()) if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
{ {
return this->volumeTotal_/nParcelsPerInjector_; return massTotal_/nParcelsPerInjector_;
} }
else else
{ {
@ -198,7 +197,7 @@ Foam::scalar Foam::FieldActivatedInjection<CloudType>::volumeToInject
template<class CloudType> template<class CloudType>
void Foam::FieldActivatedInjection<CloudType>::setPositionAndCell void Foam::FieldActivatedInjection<CloudType>::setPositionAndCell
( (
const label parcelI, const label parceli,
const label, const label,
const scalar, const scalar,
barycentric& coordinates, barycentric& coordinates,
@ -208,17 +207,28 @@ void Foam::FieldActivatedInjection<CloudType>::setPositionAndCell
label& facei label& facei
) )
{ {
coordinates = injectorCoordinates_[parcelI]; const label injectorCelli = injectorCells_[parceli];
celli = injectorCells_[parcelI];
tetFacei = injectorTetFaces_[parcelI]; if
tetPti = injectorTetPts_[parcelI]; (
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> template<class CloudType>
void Foam::FieldActivatedInjection<CloudType>::setProperties void Foam::FieldActivatedInjection<CloudType>::setProperties
( (
const label parcelI, const label parceli,
const label, const label,
const scalar, const scalar,
typename CloudType::parcelType& parcel typename CloudType::parcelType& parcel
@ -228,7 +238,7 @@ void Foam::FieldActivatedInjection<CloudType>::setProperties
parcel.U() = U0_; parcel.U() = U0_;
// set particle diameter // 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -47,7 +47,7 @@ SourceFiles
#define FieldActivatedInjection_H #define FieldActivatedInjection_H
#include "InjectionModel.H" #include "InjectionModel.H"
#include "distributionModel.H" #include "distribution.H"
#include "volFieldsFwd.H" #include "volFieldsFwd.H"
#include "GlobalIOField.H" #include "GlobalIOField.H"
@ -99,6 +99,9 @@ class FieldActivatedInjection
//- List of tetPt labels corresponding to injector positions //- List of tetPt labels corresponding to injector positions
labelList injectorTetPts_; labelList injectorTetPts_;
//- Mass to inject
const scalar massTotal_;
//- Number of parcels per injector //- Number of parcels per injector
const label nParcelsPerInjector_; const label nParcelsPerInjector_;
@ -115,8 +118,7 @@ class FieldActivatedInjection
scalarList diameters_; scalarList diameters_;
//- Parcel size distribution model //- Parcel size distribution model
const autoPtr<distributionModel> const autoPtr<distribution> sizeDistribution_;
sizeDistribution_;
public: public:
@ -161,10 +163,10 @@ public:
scalar timeEnd() const; scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI //- 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 //- Parcel mass to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1); virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry // Injection geometry
@ -172,7 +174,7 @@ public:
//- Set the injection position and owner cell, tetFace and tetPt //- Set the injection position and owner cell, tetFace and tetPt
virtual void setPositionAndCell virtual void setPositionAndCell
( (
const label parcelI, const label parceli,
const label nParcels, const label nParcels,
const scalar time, const scalar time,
barycentric& coordinates, barycentric& coordinates,
@ -185,7 +187,7 @@ public:
//- Set the parcel properties //- Set the parcel properties
virtual void setProperties virtual void setProperties
( (
const label parcelI, const label parceli,
const label nParcels, const label nParcels,
const scalar time, const scalar time,
typename CloudType::parcelType& parcel typename CloudType::parcelType& parcel
@ -193,10 +195,6 @@ public:
//- Flag to identify whether model fully describes the parcel //- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const; 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -27,64 +27,144 @@ License
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
#include "meshTools.H" #include "meshTools.H"
#include "volFields.H" #include "volFields.H"
#include "Scale.H"
using namespace Foam::constant::mathematical; using namespace Foam::constant::mathematical;
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
template<class CloudType> template<class CloudType>
bool Foam::InjectionModel<CloudType>::prepareForNextTimeStep Foam::scalar Foam::InjectionModel<CloudType>::readMassTotal
( (
const scalar time, const dictionary& dict,
label& newParcels, CloudType& owner
scalar& newVolumeFraction
) )
{ {
// Initialise values if (dict.found("nParticle"))
newParcels = 0;
newVolumeFraction = 0.0;
bool validInjection = false;
// Return if not started injection event
if (time < SOI_)
{ {
timeStep0_ = time; if (dict.found("massTotal"))
return validInjection; {
IOWarningInFunction(dict)
<< "If nParticle is specified then the massTotal "
<< "setting has no effect " << endl;
} }
// Make times relative to SOI return NaN;
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 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> template<class CloudType>
Foam::scalar Foam::InjectionModel<CloudType>::setNumberOfParticles Foam::label Foam::InjectionModel<CloudType>::sizeSampleQ() const
(
const label parcels,
const scalar volumeFraction,
const scalar diameter,
const scalar rho
)
{ {
scalar nP = 0.0; switch (uniformParcelSize_)
switch (parcelBasis_)
{ {
case pbMass: case uniformParcelSize::nParticle:
{ return 0;
scalar volumep = pi/6.0*pow3(diameter); case uniformParcelSize::surfaceArea:
scalar volumeTot = massTotal_/rho; return 2;
case uniformParcelSize::volume:
return 3;
}
nP = volumeFraction*volumeTot/(parcels*volumep); return -labelMax;
break; }
}
case pbNumber:
template<class CloudType>
void Foam::InjectionModel<CloudType>::setNumberOfParticles
(
PtrList<parcelType>& parcelPtrs,
const scalar mass
) const
{
auto size = [&](const parcelType& p)
{ {
nP = massTotal_/(rho*volumeTotal_); switch (uniformParcelSize_)
break;
}
case pbFixed:
{ {
nP = nParticleFixed_; case uniformParcelSize::nParticle:
break; 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 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); << exit(FatalError);
} }
} }
return nP;
} }
template<class CloudType> template<class CloudType>
void Foam::InjectionModel<CloudType>::postInjectCheck void Foam::InjectionModel<CloudType>::postInjectCheck
( (
const label parcelsAdded, const label nParcelsAdded,
const scalar massAdded 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 Info<< nl
<< "Cloud: " << this->owner().name() << "Cloud: " << this->owner().name()
<< " injector: " << this->modelName() << nl << " injector: " << this->modelName() << nl
<< " Added " << allParcelsAdded << " new parcels" << nl << endl; << " Added " << allNParcelsAdded << " new parcels" << nl << endl;
} }
// Increment total number of parcels added // Increment total number of parcels added
parcelsAddedTotal_ += allParcelsAdded; parcelsAddedTotal_ += allNParcelsAdded;
// Increment total mass injected // Increment total mass injected
massInjected_ += returnReduce(massAdded, sumOp<scalar>()); massInjected_ += returnReduce(massAdded, sumOp<scalar>());
@ -280,19 +415,16 @@ template<class CloudType>
Foam::InjectionModel<CloudType>::InjectionModel(CloudType& owner) Foam::InjectionModel<CloudType>::InjectionModel(CloudType& owner)
: :
CloudSubModelBase<CloudType>(owner), CloudSubModelBase<CloudType>(owner),
SOI_(0.0), SOI_(0),
volumeTotal_(0.0),
massTotal_(0.0),
massFlowRate_(owner.db().time(), "massFlowRate"),
massInjected_(this->template getModelProperty<scalar>("massInjected")), massInjected_(this->template getModelProperty<scalar>("massInjected")),
nInjections_(this->template getModelProperty<label>("nInjections")), nInjections_(this->template getModelProperty<label>("nInjections")),
parcelsAddedTotal_ parcelsAddedTotal_
( (
this->template getModelProperty<scalar>("parcelsAddedTotal") this->template getModelProperty<scalar>("parcelsAddedTotal")
), ),
parcelBasis_(pbNumber), nParticleFixed_(-vGreat),
nParticleFixed_(0.0), uniformParcelSize_(uniformParcelSize::nParticle),
time0_(0.0), time0_(0),
timeStep0_(this->template getModelProperty<scalar>("timeStep0")) timeStep0_(this->template getModelProperty<scalar>("timeStep0"))
{} {}
@ -307,65 +439,55 @@ Foam::InjectionModel<CloudType>::InjectionModel
) )
: :
CloudSubModelBase<CloudType>(modelName, owner, dict, typeName, modelType), CloudSubModelBase<CloudType>(modelName, owner, dict, typeName, modelType),
SOI_(0.0), SOI_(0),
volumeTotal_(0.0),
massTotal_(0.0),
massFlowRate_(owner.db().time(), "massFlowRate"),
massInjected_(this->template getModelProperty<scalar>("massInjected")), massInjected_(this->template getModelProperty<scalar>("massInjected")),
nInjections_(this->template getModelProperty<scalar>("nInjections")), nInjections_(this->template getModelProperty<scalar>("nInjections")),
parcelsAddedTotal_ parcelsAddedTotal_
( (
this->template getModelProperty<scalar>("parcelsAddedTotal") this->template getModelProperty<scalar>("parcelsAddedTotal")
), ),
parcelBasis_(pbNumber), nParticleFixed_(dict.lookupOrDefault<scalar>("nParticle", -vGreat)),
nParticleFixed_(0.0), uniformParcelSize_
(
uniformParcelSizeNames_
[
!dict.found("parcelBasisType") && nParticleFixed_ > 0
? dict.lookupOrDefault<word>
(
"uniformParcelSize",
uniformParcelSizeNames_[uniformParcelSize::nParticle]
)
: dict.lookup<word>("uniformParcelSize")
]
),
time0_(owner.db().time().value()), time0_(owner.db().time().value()),
timeStep0_(this->template getModelProperty<scalar>("timeStep0")) timeStep0_(this->template getModelProperty<scalar>("timeStep0"))
{ {
// Provide some info // Provide some info. Also serves to initialise mesh dimensions. This may
// - also serves to initialise mesh dimensions - needed for parallel runs // be needed for parallel runs due to lazy evaluation of valid mesh
// due to lazy evaluation of valid mesh dimensions // dimensions.
Info<< " Constructing " << owner.mesh().nGeometricD() << "-D injection" Info<< " Constructing " << owner.mesh().nGeometricD() << "-D injection"
<< endl; << 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()) if (owner.solution().transient())
{ {
this->coeffDict().lookup("massTotal") >> massTotal_; SOI_ =
this->coeffDict().lookup("SOI") >> SOI_; owner.db().time().userTimeToTime
SOI_ = owner.db().time().userTimeToTime(SOI_); (
} this->coeffDict().template lookup<scalar>("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);
} }
} }
@ -378,14 +500,11 @@ Foam::InjectionModel<CloudType>::InjectionModel
: :
CloudSubModelBase<CloudType>(im), CloudSubModelBase<CloudType>(im),
SOI_(im.SOI_), SOI_(im.SOI_),
volumeTotal_(im.volumeTotal_),
massTotal_(im.massTotal_),
massFlowRate_(im.massFlowRate_),
massInjected_(im.massInjected_), massInjected_(im.massInjected_),
nInjections_(im.nInjections_), nInjections_(im.nInjections_),
parcelsAddedTotal_(im.parcelsAddedTotal_), parcelsAddedTotal_(im.parcelsAddedTotal_),
parcelBasis_(im.parcelBasis_),
nParticleFixed_(im.nParticleFixed_), nParticleFixed_(im.nParticleFixed_),
uniformParcelSize_(im.uniformParcelSize_),
time0_(im.time0_), time0_(im.time0_),
timeStep0_(im.timeStep0_) timeStep0_(im.timeStep0_)
{} {}
@ -408,17 +527,10 @@ void Foam::InjectionModel<CloudType>::topoChange()
template<class CloudType> template<class CloudType>
Foam::scalar Foam::InjectionModel<CloudType>::averageParcelMass() Foam::scalar Foam::InjectionModel<CloudType>::averageParcelMass()
{ {
label nTotal = 0.0; const scalar deltaT =
if (this->owner().solution().transient()) this->owner().solution().transient() ? timeEnd() - timeStart() : 1;
{
nTotal = parcelsToInject(0.0, timeEnd() - timeStart());
}
else
{
nTotal = parcelsToInject(0.0, 1.0);
}
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(); const scalar time = this->owner().db().time().value();
// Prepare for next time step // Reset counters
label parcelsAdded = 0; label nParcelsAdded = 0;
scalar massAdded = 0.0; scalar massAdded = 0;
label newParcels = 0;
scalar newVolumeFraction = 0.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 // Duration of injection period during this timestep
const scalar deltaT = 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 // 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 // Create new parcels linearly across carrier phase timestep
for (label parcelI = 0; parcelI < newParcels; parcelI++) 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/nParcels;
// Calculate the pseudo time of injection for parcel 'parcelI'
scalar timeInj = time0_ + padTime + deltaT*parcelI/newParcels;
// Determine the injection coordinates and owner cell, // Determine the injection coordinates and owner cell,
// tetFace and tetPt // tetFace and tetPt
@ -463,8 +626,8 @@ void Foam::InjectionModel<CloudType>::inject
label celli = -1, tetFacei = -1, tetPti = -1, facei = -1; label celli = -1, tetFacei = -1, tetPti = -1, facei = -1;
setPositionAndCell setPositionAndCell
( (
parcelI, parceli,
newParcels, nParcels,
timeInj, timeInj,
coordinates, coordinates,
celli, celli,
@ -479,7 +642,9 @@ void Foam::InjectionModel<CloudType>::inject
const scalar dt = timeInj - time0_; const scalar dt = timeInj - time0_;
// Create a new parcel // Create a new parcel
parcelType* pPtr = parcelPtrs.set
(
parceli,
new parcelType new parcelType
( (
mesh, mesh,
@ -488,52 +653,61 @@ void Foam::InjectionModel<CloudType>::inject
tetFacei, tetFacei,
tetPti, tetPti,
facei facei
)
); );
parcelType& p = parcelPtrs[parceli];
// Correct the position for reduced-dimension cases // Correct the position for reduced-dimension cases
constrainPosition(td, *pPtr); constrainPosition(td, p);
// Check/set new parcel thermo properties // Check/set new parcel thermo properties
cloud.setParcelThermoProperties(*pPtr); cloud.setParcelThermoProperties(p);
// Assign new parcel properties in injection model // Assign new parcel properties in injection model
setProperties(parcelI, newParcels, timeInj, *pPtr); setProperties(parceli, nParcels, timeInj, p);
// Check/set new parcel injection properties // Check/set new parcel injection properties
cloud.checkParcelProperties(*pPtr, fullyDescribed()); cloud.checkParcelProperties(p, index());
// Apply correction to velocity for 2-D cases // Apply correction to velocity for 2-D cases
meshTools::constrainDirection meshTools::constrainDirection
( (
mesh, mesh,
mesh.solutionD(), mesh.solutionD(),
pPtr->U() p.U()
);
// Number of particles per parcel
pPtr->nParticle() =
setNumberOfParticles
(
newParcels,
newVolumeFraction,
pPtr->d(),
pPtr->rho()
); );
// Modify the step fraction so that the particles are // Modify the step fraction so that the particles are
// injected continually through the time-step // injected continually through the time-step
pPtr->stepFraction() = dt/td.trackTime(); p.stepFraction() = dt/td.trackTime();
// Add the new parcel // Set the number of particles. If not fixed, this will set
parcelsAdded ++; // a junk value, which will get corrected below.
massAdded += pPtr->nParticle()*pPtr->mass(); p.nParticle() = nParticleFixed_;
cloud.addParticle(pPtr);
} }
} }
// 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(); const polyMesh& mesh = this->owner().mesh();
massTotal_ = massFlowRate_.value(mesh.time().value());
// Reset counters // Reset counters
time0_ = 0.0; label nParcelsAdded = 0;
label parcelsAdded = 0; scalar massAdded = 0;
scalar massAdded = 0.0;
// Set number of new parcels to inject based on first second of injection // Get amounts to inject based on first second of injection
label newParcels = parcelsToInject(0.0, 1.0); const label nParcels = nParcelsToInject(0, 1);
const scalar mass = nParticleFixed_ < 0 ? massToInject(0, 1) : NaN;
// Inject new parcels // Do injection
for (label parcelI = 0; parcelI < newParcels; parcelI++) 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, // Determine the injection coordinates and owner cell,
// tetFace and tetPt // tetFace and tetPt
barycentric coordinates = barycentric::uniform(NaN); barycentric coordinates = barycentric::uniform(NaN);
label celli = -1, tetFacei = -1, tetPti = -1, facei = -1; label celli = -1, tetFacei = -1, tetPti = -1, facei = -1;
setPositionAndCell setPositionAndCell
( (
parcelI, parceli,
newParcels, nParcels,
0, 0,
coordinates, coordinates,
celli, celli,
@ -582,7 +754,9 @@ void Foam::InjectionModel<CloudType>::injectSteadyState
if (celli > -1) if (celli > -1)
{ {
// Create a new parcel // Create a new parcel
parcelType* pPtr = parcelPtrs.set
(
parceli,
new parcelType new parcelType
( (
mesh, mesh,
@ -591,44 +765,55 @@ void Foam::InjectionModel<CloudType>::injectSteadyState
tetFacei, tetFacei,
tetPti, tetPti,
facei facei
)
); );
parcelType& p = parcelPtrs[parceli];
// Correct the position for reduced-dimension cases // Correct the position for reduced-dimension cases
constrainPosition(td, *pPtr); constrainPosition(td, p);
// Check/set new parcel thermo properties // Check/set new parcel thermo properties
cloud.setParcelThermoProperties(*pPtr); cloud.setParcelThermoProperties(p);
// Assign new parcel properties in injection model // Assign new parcel properties in injection model
setProperties(parcelI, newParcels, 0.0, *pPtr); setProperties(parceli, nParcels, 0, p);
// Check/set new parcel injection properties // Check/set new parcel injection properties
cloud.checkParcelProperties(*pPtr, fullyDescribed()); cloud.checkParcelProperties(p, index());
// Apply correction to velocity for 2-D cases // Apply correction to velocity for 2-D cases
meshTools::constrainDirection(mesh, mesh.solutionD(), pPtr->U()); meshTools::constrainDirection(mesh, mesh.solutionD(), p.U());
// Number of particles per parcel
pPtr->nParticle() =
setNumberOfParticles
(
1,
newVolumeFraction,
pPtr->d(),
pPtr->rho()
);
// Initial step fraction // Initial step fraction
pPtr->stepFraction() = 0; p.stepFraction() = 0;
// Add the new parcel // Set the number of particles. If not fixed, this will set
parcelsAdded ++; // a junk value, which will get corrected below.
massAdded += pPtr->nParticle()*pPtr->mass(); p.nParticle() = nParticleFixed_;
cloud.addParticle(pPtr);
} }
} }
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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -48,13 +48,11 @@ SourceFiles
#ifndef InjectionModel_H #ifndef InjectionModel_H
#define InjectionModel_H #define InjectionModel_H
#include "IOdictionary.H" #include "injectionModel.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "CloudSubModelBase.H" #include "CloudSubModelBase.H"
#include "vector.H"
#include "particle.H" #include "particle.H"
#include "TimeFunction1.H" #include "TimeFunction1.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -68,6 +66,7 @@ namespace Foam
template<class CloudType> template<class CloudType>
class InjectionModel class InjectionModel
: :
public injectionModel,
public CloudSubModelBase<CloudType> public CloudSubModelBase<CloudType>
{ {
public: public:
@ -76,18 +75,6 @@ public:
typedef typename CloudType::parcelType parcelType; 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:
// Protected data // Protected data
@ -97,16 +84,6 @@ protected:
//- Start of injection [s] //- Start of injection [s]
scalar SOI_; 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] //- Total mass injected to date [kg]
scalar massInjected_; scalar massInjected_;
@ -122,13 +99,13 @@ protected:
// Injection properties per Lagrangian time step // Injection properties per Lagrangian time step
//- Parcel basis enumeration //- Fixed nParticle to assign to parcels. Only valid if
parcelBasis parcelBasis_; // uniformParcelSize is nParticle.
//- nParticle to assign to parcels when the 'fixed' basis
// is selected
scalar nParticleFixed_; scalar nParticleFixed_;
//- Size uniform to all parcels
uniformParcelSize uniformParcelSize_;
//- Continuous phase time at start of injection time step [s] //- Continuous phase time at start of injection time step [s]
scalar time0_; scalar time0_;
@ -138,18 +115,31 @@ protected:
// Protected Member Functions // Protected Member Functions
//- Additional flag to identify whether or not injection of parcelI is //- Read the total mass value for instantaneous injections
// permitted scalar readMassTotal
virtual bool validInjection(const label parcelI) = 0;
//- Determine properties for next time step/injection interval
bool prepareForNextTimeStep
( (
const scalar time, const dictionary& dict,
label& newParcels, CloudType& owner
scalar& newVolumeFraction
); );
//- 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 //- Find the cell that contains the supplied position
// Will modify position slightly towards the owner cell centroid to // Will modify position slightly towards the owner cell centroid to
// ensure that it lies in a cell and not edge/face // ensure that it lies in a cell and not edge/face
@ -171,14 +161,15 @@ protected:
typename CloudType::parcelType& parcel 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 //- Set number of particles to inject given parcel properties
scalar setNumberOfParticles void setNumberOfParticles
( (
const label parcels, PtrList<parcelType>& parcelPtrs,
const scalar volumeFraction, const scalar mass
const scalar diameter, ) const;
const scalar rho
);
//- Post injection checks //- Post injection checks
void postInjectCheck void postInjectCheck
@ -265,12 +256,6 @@ public:
//- Return the start-of-injection time //- Return the start-of-injection time
inline scalar timeStart() const; 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) //- Return mass of particles injected (cumulative)
inline scalar massInjected() const; inline scalar massInjected() const;
@ -278,21 +263,21 @@ public:
virtual scalar timeEnd() const = 0; virtual scalar timeEnd() const = 0;
//- Number of parcels to introduce relative to SOI //- Number of parcels to introduce relative to SOI
virtual label parcelsToInject virtual label nParcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) = 0; ) = 0;
//- Volume of parcels to introduce relative to SOI //- Parcel mass to introduce relative to SOI
virtual scalar volumeToInject virtual scalar massToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) = 0; ) = 0;
//- Return the average parcel mass over the injection period //- Return the average injected parcel mass
virtual scalar averageParcelMass(); scalar averageParcelMass();
// Counters // Counters

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License 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> template<class CloudType>
Foam::scalar Foam::InjectionModel<CloudType>::massInjected() const Foam::scalar Foam::InjectionModel<CloudType>::massInjected() const
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License 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> template<class CloudType>
void Foam::InjectionModelList<CloudType>::topoChange() void Foam::InjectionModelList<CloudType>::topoChange()
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -90,12 +90,6 @@ public:
//- Return the maximum end-of-injection time //- Return the maximum end-of-injection time
scalar timeEnd() const; 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 // Edit

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -57,13 +57,15 @@ Foam::ManualInjection<CloudType>::ManualInjection
injectorCells_(positions_.size(), -1), injectorCells_(positions_.size(), -1),
injectorTetFaces_(positions_.size(), -1), injectorTetFaces_(positions_.size(), -1),
injectorTetPts_(positions_.size(), -1), injectorTetPts_(positions_.size(), -1),
massTotal_(this->readMassTotal(dict, owner)),
U0_(this->coeffDict().lookup("U0")), U0_(this->coeffDict().lookup("U0")),
sizeDistribution_ sizeDistribution_
( (
distributionModel::New distribution::New
( (
this->coeffDict().subDict("sizeDistribution"), this->coeffDict().subDict("sizeDistribution"),
owner.rndGen() owner.rndGen(),
this->sizeSampleQ()
) )
), ),
ignoreOutOfBounds_ ignoreOutOfBounds_
@ -78,9 +80,6 @@ Foam::ManualInjection<CloudType>::ManualInjection
{ {
diameters_[i] = sizeDistribution_->sample(); 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_), injectorCells_(im.injectorCells_),
injectorTetFaces_(im.injectorTetFaces_), injectorTetFaces_(im.injectorTetFaces_),
injectorTetPts_(im.injectorTetPts_), injectorTetPts_(im.injectorTetPts_),
massTotal_(im.massTotal_),
U0_(im.U0_), U0_(im.U0_),
sizeDistribution_(im.sizeDistribution_().clone().ptr()), sizeDistribution_(im.sizeDistribution_().clone().ptr()),
ignoreOutOfBounds_(im.ignoreOutOfBounds_) ignoreOutOfBounds_(im.ignoreOutOfBounds_)
@ -165,13 +165,14 @@ Foam::scalar Foam::ManualInjection<CloudType>::timeEnd() const
template<class CloudType> template<class CloudType>
Foam::label Foam::ManualInjection<CloudType>::parcelsToInject Foam::label Foam::ManualInjection<CloudType>::nParcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
if ((0.0 >= time0) && (0.0 < time1)) // All parcels introduced at SOI
if (0 >= time0 && 0 < time1)
{ {
return positions_.size(); return positions_.size();
} }
@ -183,20 +184,20 @@ Foam::label Foam::ManualInjection<CloudType>::parcelsToInject
template<class CloudType> template<class CloudType>
Foam::scalar Foam::ManualInjection<CloudType>::volumeToInject Foam::scalar Foam::ManualInjection<CloudType>::massToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
// All parcels introduced at SOI // All parcels introduced at SOI
if ((0.0 >= time0) && (0.0 < time1)) if (0 >= time0 && 0 < time1)
{ {
return this->volumeTotal_; return massTotal_;
} }
else 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -45,7 +45,7 @@ SourceFiles
#define ManualInjection_H #define ManualInjection_H
#include "InjectionModel.H" #include "InjectionModel.H"
#include "distributionModel.H" #include "distribution.H"
#include "Switch.H" #include "Switch.H"
#include "GlobalIOField.H" #include "GlobalIOField.H"
@ -86,11 +86,14 @@ class ManualInjection
//- List of tetPt labels corresponding to injector positions //- List of tetPt labels corresponding to injector positions
labelList injectorTetPts_; labelList injectorTetPts_;
//- Mass to inject
const scalar massTotal_;
//- Initial parcel velocity //- Initial parcel velocity
const vector U0_; const vector U0_;
//- Parcel size distribution model //- Parcel size distribution model
const autoPtr<distributionModel> sizeDistribution_; const autoPtr<distribution> sizeDistribution_;
//- Flag to suppress errors if particle injection site is out-of-bounds //- Flag to suppress errors if particle injection site is out-of-bounds
Switch ignoreOutOfBounds_; Switch ignoreOutOfBounds_;
@ -135,13 +138,13 @@ public:
virtual void topoChange(); virtual void topoChange();
//- Return the end-of-injection time //- Return the end-of-injection time
scalar timeEnd() const; virtual scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI //- 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 //- Parcel mass to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1); virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry // Injection geometry
@ -170,10 +173,6 @@ public:
//- Flag to identify whether model fully describes the parcel //- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const; 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,7 +38,7 @@ Foam::MomentumLookupTableInjection<CloudType>::MomentumLookupTableInjection
: :
InjectionModel<CloudType>(dict, owner, modelName, typeName), InjectionModel<CloudType>(dict, owner, modelName, typeName),
inputFileName_(this->coeffDict().lookup("inputFile")), inputFileName_(this->coeffDict().lookup("inputFile")),
duration_(this->coeffDict().template lookup<scalar>("duration")), duration_(this->readDuration(dict, owner)),
parcelsPerSecond_ parcelsPerSecond_
( (
this->coeffDict().template lookup<scalar>("parcelsPerSecond") this->coeffDict().template lookup<scalar>("parcelsPerSecond")
@ -60,22 +60,12 @@ Foam::MomentumLookupTableInjection<CloudType>::MomentumLookupTableInjection
injectorTetFaces_(0), injectorTetFaces_(0),
injectorTetPts_(0) injectorTetPts_(0)
{ {
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells // Set/cache the injector cells
injectorCells_.setSize(injectors_.size()); injectorCells_.setSize(injectors_.size());
injectorTetFaces_.setSize(injectors_.size()); injectorTetFaces_.setSize(injectors_.size());
injectorTetPts_.setSize(injectors_.size()); injectorTetPts_.setSize(injectors_.size());
topoChange(); 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> template<class CloudType>
Foam::label Foam::MomentumLookupTableInjection<CloudType>::parcelsToInject Foam::label Foam::MomentumLookupTableInjection<CloudType>::nParcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
if ((time0 >= 0.0) && (time0 < duration_)) if (time0 >= 0 && time0 < duration_)
{ {
return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_); return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_);
} }
@ -151,22 +141,23 @@ Foam::label Foam::MomentumLookupTableInjection<CloudType>::parcelsToInject
template<class CloudType> template<class CloudType>
Foam::scalar Foam::MomentumLookupTableInjection<CloudType>::volumeToInject Foam::scalar Foam::MomentumLookupTableInjection<CloudType>::massToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
scalar volume = 0.0; scalar mass = 0;
if ((time0 >= 0.0) && (time0 < duration_))
if (time0 >= 0 && time0 < duration_)
{ {
forAll(injectors_, i) 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -77,7 +77,7 @@ class MomentumLookupTableInjection
const word inputFileName_; const word inputFileName_;
//- Injection duration - common to all injection sources //- Injection duration - common to all injection sources
scalar duration_; const scalar duration_;
//- Number of parcels per injector - common to all injection sources //- Number of parcels per injector - common to all injection sources
const scalar parcelsPerSecond_; const scalar parcelsPerSecond_;
@ -143,13 +143,13 @@ public:
virtual void topoChange(); virtual void topoChange();
//- Return the end-of-injection time //- Return the end-of-injection time
scalar timeEnd() const; virtual scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI //- 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 //- Parcel mass to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1); virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry // Injection geometry
@ -178,10 +178,6 @@ public:
//- Flag to identify whether model fully describes the parcel //- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const; 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -59,12 +59,12 @@ Foam::NoInjection<CloudType>::~NoInjection()
template<class CloudType> template<class CloudType>
Foam::scalar Foam::NoInjection<CloudType>::timeEnd() const Foam::scalar Foam::NoInjection<CloudType>::timeEnd() const
{ {
return 0.0; return 0;
} }
template<class CloudType> template<class CloudType>
Foam::label Foam::NoInjection<CloudType>::parcelsToInject Foam::label Foam::NoInjection<CloudType>::nParcelsToInject
( (
const scalar, const scalar,
const scalar const scalar
@ -75,13 +75,13 @@ Foam::label Foam::NoInjection<CloudType>::parcelsToInject
template<class CloudType> template<class CloudType>
Foam::scalar Foam::NoInjection<CloudType>::volumeToInject Foam::scalar Foam::NoInjection<CloudType>::massToInject
( (
const scalar, const scalar,
const scalar const scalar
) )
{ {
return 0.0; return 0;
} }
@ -113,7 +113,7 @@ void Foam::NoInjection<CloudType>::setProperties
parcel.U() = Zero; parcel.U() = Zero;
// set particle diameter // 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -83,13 +83,13 @@ public:
// Member Functions // Member Functions
//- Return the end-of-injection time //- Return the end-of-injection time
scalar timeEnd() const; virtual scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI //- 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 //- Parcel mass to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1); virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry // Injection geometry
@ -117,10 +117,6 @@ public:
//- Flag to identify whether model fully describes the parcel //- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const; 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,7 +25,7 @@ License
#include "PatchFlowRateInjection.H" #include "PatchFlowRateInjection.H"
#include "TimeFunction1.H" #include "TimeFunction1.H"
#include "distributionModel.H" #include "distribution.H"
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
#include "surfaceFields.H" #include "surfaceFields.H"
@ -43,7 +43,7 @@ Foam::PatchFlowRateInjection<CloudType>::PatchFlowRateInjection
patchInjectionBase(owner.mesh(), this->coeffDict().lookup("patchName")), patchInjectionBase(owner.mesh(), this->coeffDict().lookup("patchName")),
phiName_(this->coeffDict().template lookupOrDefault<word>("phi", "phi")), phiName_(this->coeffDict().template lookupOrDefault<word>("phi", "phi")),
rhoName_(this->coeffDict().template lookupOrDefault<word>("rho", "rho")), rhoName_(this->coeffDict().template lookupOrDefault<word>("rho", "rho")),
duration_(this->coeffDict().template lookup<scalar>("duration")), duration_(this->readDuration(dict, owner)),
concentration_ concentration_
( (
TimeFunction1<scalar> TimeFunction1<scalar>
@ -59,20 +59,14 @@ Foam::PatchFlowRateInjection<CloudType>::PatchFlowRateInjection
), ),
sizeDistribution_ sizeDistribution_
( (
distributionModel::New distribution::New
( (
this->coeffDict().subDict("sizeDistribution"), 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> template<class CloudType>
@ -146,13 +140,13 @@ Foam::scalar Foam::PatchFlowRateInjection<CloudType>::flowRate() const
template<class CloudType> template<class CloudType>
Foam::label Foam::PatchFlowRateInjection<CloudType>::parcelsToInject Foam::label Foam::PatchFlowRateInjection<CloudType>::nParcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
if ((time0 >= 0.0) && (time0 < duration_)) if (time0 >= 0 && time0 < duration_)
{ {
scalar dt = time1 - time0; scalar dt = time1 - time0;
@ -185,33 +179,22 @@ Foam::label Foam::PatchFlowRateInjection<CloudType>::parcelsToInject
template<class CloudType> template<class CloudType>
Foam::scalar Foam::PatchFlowRateInjection<CloudType>::volumeToInject Foam::scalar Foam::PatchFlowRateInjection<CloudType>::massToInject
( (
const scalar time0, const scalar time0,
const scalar time1 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)); scalar c = concentration_.value(0.5*(time0 + time1));
volume = c*(time1 - time0)*flowRate(); volume = c*(time1 - time0)*flowRate();
} }
this->volumeTotal_ = volume; return volume*this->owner().constProps().rho0();
this->massTotal_ = volume*this->owner().constProps().rho0();
return volume;
}
template<class CloudType>
Foam::scalar Foam::PatchFlowRateInjection<CloudType>::averageParcelMass()
{
NotImplemented;
return NaN;
} }
@ -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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,7 +29,6 @@ Description
velocity. velocity.
User specifies: User specifies:
- Total mass to inject
- Name of patch - Name of patch
- Injection duration - Injection duration
- Injection target concentration/carrier volume flow rate - Injection target concentration/carrier volume flow rate
@ -56,7 +55,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
class distributionModel; class distribution;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class PatchFlowRateInjection Declaration Class PatchFlowRateInjection Declaration
@ -77,7 +76,7 @@ class PatchFlowRateInjection
const word rhoName_; const word rhoName_;
//- Injection duration [s] //- Injection duration [s]
scalar duration_; const scalar duration_;
//- Concentration profile of particle volume to carrier volume [-] //- Concentration profile of particle volume to carrier volume [-]
const TimeFunction1<scalar> concentration_; const TimeFunction1<scalar> concentration_;
@ -86,7 +85,7 @@ class PatchFlowRateInjection
const scalar parcelConcentration_; const scalar parcelConcentration_;
//- Parcel size distribution model //- Parcel size distribution model
const autoPtr<distributionModel> sizeDistribution_; const autoPtr<distribution> sizeDistribution_;
public: public:
@ -131,19 +130,16 @@ public:
virtual void topoChange(); virtual void topoChange();
//- Return the end-of-injection time //- 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] //- 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 //- 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 //- Parcel mass to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1); virtual scalar massToInject(const scalar time0, const scalar time1);
//- Return the average parcel mass over the injection period
virtual scalar averageParcelMass();
// Injection geometry // Injection geometry
@ -174,10 +170,6 @@ public:
//- Flag to identify whether model fully describes the parcel //- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const; 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,7 +25,7 @@ License
#include "PatchInjection.H" #include "PatchInjection.H"
#include "TimeFunction1.H" #include "TimeFunction1.H"
#include "distributionModel.H" #include "distribution.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -39,35 +39,23 @@ Foam::PatchInjection<CloudType>::PatchInjection
: :
InjectionModel<CloudType>(dict, owner, modelName, typeName), InjectionModel<CloudType>(dict, owner, modelName, typeName),
patchInjectionBase(owner.mesh(), this->coeffDict().lookup("patchName")), 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_ parcelsPerSecond_
( (
this->coeffDict().template lookup<scalar>("parcelsPerSecond") this->coeffDict().template lookup<scalar>("parcelsPerSecond")
), ),
U0_(this->coeffDict().lookup("U0")), U0_(this->coeffDict().lookup("U0")),
flowRateProfile_
(
TimeFunction1<scalar>
(
owner.db().time(),
"flowRateProfile",
this->coeffDict()
)
),
sizeDistribution_ sizeDistribution_
( (
distributionModel::New distribution::New
( (
this->coeffDict().subDict("sizeDistribution"), 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> template<class CloudType>
@ -79,9 +67,9 @@ Foam::PatchInjection<CloudType>::PatchInjection
InjectionModel<CloudType>(im), InjectionModel<CloudType>(im),
patchInjectionBase(im), patchInjectionBase(im),
duration_(im.duration_), duration_(im.duration_),
massFlowRate_(im.massFlowRate_),
parcelsPerSecond_(im.parcelsPerSecond_), parcelsPerSecond_(im.parcelsPerSecond_),
U0_(im.U0_), U0_(im.U0_),
flowRateProfile_(im.flowRateProfile_),
sizeDistribution_(im.sizeDistribution_().clone().ptr()) sizeDistribution_(im.sizeDistribution_().clone().ptr())
{} {}
@ -110,13 +98,13 @@ Foam::scalar Foam::PatchInjection<CloudType>::timeEnd() const
template<class CloudType> template<class CloudType>
Foam::label Foam::PatchInjection<CloudType>::parcelsToInject Foam::label Foam::PatchInjection<CloudType>::nParcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
if ((time0 >= 0.0) && (time0 < duration_)) if (time0 >= 0 && time0 < duration_)
{ {
scalar nParcels = (time1 - time0)*parcelsPerSecond_; scalar nParcels = (time1 - time0)*parcelsPerSecond_;
@ -145,19 +133,19 @@ Foam::label Foam::PatchInjection<CloudType>::parcelsToInject
template<class CloudType> template<class CloudType>
Foam::scalar Foam::PatchInjection<CloudType>::volumeToInject Foam::scalar Foam::PatchInjection<CloudType>::massToInject
( (
const scalar time0, const scalar time0,
const scalar time1 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 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -57,7 +57,7 @@ namespace Foam
template<class Type> template<class Type>
class TimeFunction1; class TimeFunction1;
class distributionModel; class distribution;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class PatchInjection Declaration Class PatchInjection Declaration
@ -72,7 +72,10 @@ class PatchInjection
// Private Data // Private Data
//- Injection duration [s] //- 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 [] //- Number of parcels to introduce per second []
const label parcelsPerSecond_; const label parcelsPerSecond_;
@ -80,11 +83,8 @@ class PatchInjection
//- Initial parcel velocity [m/s] //- Initial parcel velocity [m/s]
const vector U0_; const vector U0_;
//- Flow rate profile relative to SOI []
const TimeFunction1<scalar> flowRateProfile_;
//- Parcel size distribution model //- Parcel size distribution model
const autoPtr<distributionModel> sizeDistribution_; const autoPtr<distribution> sizeDistribution_;
public: public:
@ -132,10 +132,10 @@ public:
virtual scalar timeEnd() const; virtual scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI //- 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 //- Parcel mass to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1); virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry // Injection geometry
@ -166,10 +166,6 @@ public:
//- Flag to identify whether model fully describes the parcel //- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const; 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) if (pPtr->nParticle() > 0.001)
{ {
// Check new parcel properties // Check new parcel properties
cloud.checkParcelProperties(*pPtr, false); cloud.checkParcelProperties(*pPtr, -1);
// Add the new parcel to the cloud // Add the new parcel to the cloud
cloud.addParticle(pPtr); cloud.addParticle(pPtr);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -37,7 +37,7 @@ Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection
: :
InjectionModel<CloudType>(dict, owner, modelName, typeName), InjectionModel<CloudType>(dict, owner, modelName, typeName),
inputFileName_(this->coeffDict().lookup("inputFile")), inputFileName_(this->coeffDict().lookup("inputFile")),
duration_(this->coeffDict().template lookup<scalar>("duration")), duration_(this->readDuration(dict, owner)),
parcelsPerSecond_ parcelsPerSecond_
( (
this->coeffDict().template lookup<scalar>("parcelsPerSecond") this->coeffDict().template lookup<scalar>("parcelsPerSecond")
@ -59,8 +59,6 @@ Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection
injectorTetFaces_(0), injectorTetFaces_(0),
injectorTetPts_(0) injectorTetPts_(0)
{ {
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells // Set/cache the injector cells
injectorCoordinates_.setSize(injectors_.size()); injectorCoordinates_.setSize(injectors_.size());
injectorCells_.setSize(injectors_.size()); injectorCells_.setSize(injectors_.size());
@ -68,14 +66,6 @@ Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection
injectorTetPts_.setSize(injectors_.size()); injectorTetPts_.setSize(injectors_.size());
topoChange(); 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> template<class CloudType>
Foam::label Foam::ReactingLookupTableInjection<CloudType>::parcelsToInject Foam::label Foam::ReactingLookupTableInjection<CloudType>::nParcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
if ((time0 >= 0.0) && (time0 < duration_)) if (time0 >= 0 && time0 < duration_)
{ {
return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_); return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_);
} }
@ -151,22 +141,23 @@ Foam::label Foam::ReactingLookupTableInjection<CloudType>::parcelsToInject
template<class CloudType> template<class CloudType>
Foam::scalar Foam::ReactingLookupTableInjection<CloudType>::volumeToInject Foam::scalar Foam::ReactingLookupTableInjection<CloudType>::massToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
scalar volume = 0.0; scalar mass = 0;
if ((time0 >= 0.0) && (time0 < duration_))
if (time0 >= 0 && time0 < duration_)
{ {
forAll(injectors_, i) 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -76,7 +76,7 @@ class ReactingLookupTableInjection
const word inputFileName_; const word inputFileName_;
//- Injection duration - common to all injection sources //- Injection duration - common to all injection sources
scalar duration_; const scalar duration_;
//- Number of parcels per injector - common to all injection sources //- Number of parcels per injector - common to all injection sources
const scalar parcelsPerSecond_; const scalar parcelsPerSecond_;
@ -145,11 +145,10 @@ public:
scalar timeEnd() const; scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI //- 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 // Injection geometry
@ -178,10 +177,6 @@ public:
//- Flag to identify whether model fully describes the parcel //- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const; 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,7 +38,7 @@ ReactingMultiphaseLookupTableInjection
: :
InjectionModel<CloudType>(dict, owner, modelName, typeName), InjectionModel<CloudType>(dict, owner, modelName, typeName),
inputFileName_(this->coeffDict().lookup("inputFile")), inputFileName_(this->coeffDict().lookup("inputFile")),
duration_(this->coeffDict().template lookup<scalar>("duration")), duration_(this->readDuration(dict, owner)),
parcelsPerSecond_ parcelsPerSecond_
( (
this->coeffDict().template lookup<scalar>("parcelsPerSecond") this->coeffDict().template lookup<scalar>("parcelsPerSecond")
@ -60,8 +60,6 @@ ReactingMultiphaseLookupTableInjection
injectorTetFaces_(0), injectorTetFaces_(0),
injectorTetPts_(0) injectorTetPts_(0)
{ {
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells // Set/cache the injector cells
injectorCoordinates_.setSize(injectors_.size()); injectorCoordinates_.setSize(injectors_.size());
injectorCells_.setSize(injectors_.size()); injectorCells_.setSize(injectors_.size());
@ -69,14 +67,6 @@ ReactingMultiphaseLookupTableInjection
injectorTetPts_.setSize(injectors_.size()); injectorTetPts_.setSize(injectors_.size());
topoChange(); 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> template<class CloudType>
Foam::label Foam::label
Foam::ReactingMultiphaseLookupTableInjection<CloudType>::parcelsToInject Foam::ReactingMultiphaseLookupTableInjection<CloudType>::nParcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
if ((time0 >= 0.0) && (time0 < duration_)) if (time0 >= 0 && time0 < duration_)
{ {
return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_); return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_);
} }
@ -157,22 +147,23 @@ Foam::ReactingMultiphaseLookupTableInjection<CloudType>::parcelsToInject
template<class CloudType> template<class CloudType>
Foam::scalar Foam::scalar
Foam::ReactingMultiphaseLookupTableInjection<CloudType>::volumeToInject Foam::ReactingMultiphaseLookupTableInjection<CloudType>::massToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
scalar volume = 0.0; scalar mass = 0;
if ((time0 >= 0.0) && (time0 < duration_))
if (time0 >= 0 && time0 < duration_)
{ {
forAll(injectors_, i) 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -79,7 +79,7 @@ class ReactingMultiphaseLookupTableInjection
const word inputFileName_; const word inputFileName_;
//- Injection duration - common to all injection sources //- Injection duration - common to all injection sources
scalar duration_; const scalar duration_;
//- Number of parcels per injector - common to all injection sources //- Number of parcels per injector - common to all injection sources
const scalar parcelsPerSecond_; const scalar parcelsPerSecond_;
@ -148,10 +148,10 @@ public:
scalar timeEnd() const; scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI //- 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 //- Parcel mass to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1); virtual scalar massToInject(const scalar time0, const scalar time1);
// Injection geometry // Injection geometry
@ -180,10 +180,6 @@ public:
//- Flag to identify whether model fully describes the parcel //- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const; 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -37,7 +37,6 @@ Foam::LISAAtomisation<CloudType>::LISAAtomisation
AtomisationModel<CloudType>(dict, owner, typeName), AtomisationModel<CloudType>(dict, owner, typeName),
Cl_(this->coeffDict().template lookup<scalar>("Cl")), Cl_(this->coeffDict().template lookup<scalar>("Cl")),
cTau_(this->coeffDict().template lookup<scalar>("cTau")), cTau_(this->coeffDict().template lookup<scalar>("cTau")),
Q_(this->coeffDict().template lookup<scalar>("Q")),
lisaExp_(this->coeffDict().template lookup<scalar>("lisaExp")), lisaExp_(this->coeffDict().template lookup<scalar>("lisaExp")),
injectorDirection_(this->coeffDict().lookup("injectorDirection")), injectorDirection_(this->coeffDict().lookup("injectorDirection")),
SMDCalcMethod_(this->coeffDict().lookup("SMDCalculationMethod")) SMDCalcMethod_(this->coeffDict().lookup("SMDCalculationMethod"))
@ -71,7 +70,6 @@ Foam::LISAAtomisation<CloudType>::LISAAtomisation
AtomisationModel<CloudType>(am), AtomisationModel<CloudType>(am),
Cl_(am.Cl_), Cl_(am.Cl_),
cTau_(am.cTau_), cTau_(am.cTau_),
Q_(am.Q_),
lisaExp_(am.lisaExp_), lisaExp_(am.lisaExp_),
injectorDirection_(am.injectorDirection_), injectorDirection_(am.injectorDirection_),
SMDCalcMethod_(am.SMDCalcMethod_) SMDCalcMethod_(am.SMDCalcMethod_)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,7 +38,7 @@ Foam::ThermoLookupTableInjection<CloudType>::ThermoLookupTableInjection
: :
InjectionModel<CloudType>(dict, owner, modelName, typeName), InjectionModel<CloudType>(dict, owner, modelName, typeName),
inputFileName_(this->coeffDict().lookup("inputFile")), inputFileName_(this->coeffDict().lookup("inputFile")),
duration_(this->coeffDict().template lookup<scalar>("duration")), duration_(this->readDuration(dict, owner)),
parcelsPerSecond_ parcelsPerSecond_
( (
this->coeffDict().template lookup<scalar>("parcelsPerSecond") this->coeffDict().template lookup<scalar>("parcelsPerSecond")
@ -60,8 +60,6 @@ Foam::ThermoLookupTableInjection<CloudType>::ThermoLookupTableInjection
injectorTetFaces_(0), injectorTetFaces_(0),
injectorTetPts_(0) injectorTetPts_(0)
{ {
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells // Set/cache the injector cells
injectorCoordinates_.setSize(injectors_.size()); injectorCoordinates_.setSize(injectors_.size());
injectorCells_.setSize(injectors_.size()); injectorCells_.setSize(injectors_.size());
@ -69,14 +67,6 @@ Foam::ThermoLookupTableInjection<CloudType>::ThermoLookupTableInjection
injectorTetPts_.setSize(injectors_.size()); injectorTetPts_.setSize(injectors_.size());
topoChange(); 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> template<class CloudType>
Foam::label Foam::ThermoLookupTableInjection<CloudType>::parcelsToInject Foam::label Foam::ThermoLookupTableInjection<CloudType>::nParcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
if ((time0 >= 0.0) && (time0 < duration_)) if (time0 >= 0 && time0 < duration_)
{ {
return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_); return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_);
} }
@ -152,22 +142,23 @@ Foam::label Foam::ThermoLookupTableInjection<CloudType>::parcelsToInject
template<class CloudType> template<class CloudType>
Foam::scalar Foam::ThermoLookupTableInjection<CloudType>::volumeToInject Foam::scalar Foam::ThermoLookupTableInjection<CloudType>::massToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) )
{ {
scalar volume = 0.0; scalar mass = 0;
if ((time0 >= 0.0) && (time0 < duration_))
if (time0 >= 0 && time0 < duration_)
{ {
forAll(injectors_, i) 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -75,7 +75,7 @@ class ThermoLookupTableInjection
const word inputFileName_; const word inputFileName_;
//- Injection duration - common to all injection sources //- Injection duration - common to all injection sources
scalar duration_; const scalar duration_;
//- Number of parcels per injector - common to all injection sources //- Number of parcels per injector - common to all injection sources
const scalar parcelsPerSecond_; const scalar parcelsPerSecond_;
@ -144,11 +144,10 @@ public:
scalar timeEnd() const; scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI //- 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 // Injection geometry
@ -177,10 +176,6 @@ public:
//- Flag to identify whether model fully describes the parcel //- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const; 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