Files
OpenFOAM-12/applications/solvers/multiphase/multiphaseEulerFoam/functionObjects/sizeDistribution/sizeDistribution.H
Will Bainbridge 25a6d068f0 sampledSets, streamlines: Various improvements
Sampled sets and streamlines now write all their fields to the same
file. This prevents excessive duplication of the geometry and makes
post-processing tasks more convenient.

"axis" entries are now optional in sampled sets and streamlines. When
omitted, a default entry will be used, which is chosen appropriately for
the coordinate set and the write format. Some combinations are not
supported. For example, a scalar ("x", "y", "z" or "distance") axis
cannot be used to write in the vtk format, as vtk requires 3D locations
with which to associate data. Similarly, a point ("xyz") axis cannot be
used with the gnuplot format, as gnuplot needs a single scalar to
associate with the x-axis.

Streamlines can now write out fields of any type, not just scalars and
vectors, and there is no longer a strict requirement for velocity to be
one of the fields.

Streamlines now output to postProcessing/<functionName>/time/<file> in
the same way as other functions. The additional "sets" subdirectory has
been removed.

The raw set writer now aligns columns correctly.

The handling of segments in coordSet and sampledSet has been
fixed/completed. Segments mean that a coordinate set can represent a
number of contiguous lines, disconnected points, or some combination
thereof. This works in parallel; segments remain contiguous across
processor boundaries. Set writers now only need one write method, as the
previous "writeTracks" functionality is now handled by streamlines
providing the writer with the appropriate segment structure.

Coordinate sets and set writers now have a convenient programmatic
interface. To write a graph of A and B against some coordinate X, in
gnuplot format, we can call the following:

    setWriter::New("gnuplot")->write
    (
        directoryName,
        graphName,
        coordSet(true, "X", X), // <-- "true" indicates a contiguous
        "A",                    //     line, "false" would mean
        A,                      //     disconnected points
        "B",
        B
    );

This write function is variadic. It supports any number of
field-name-field pairs, and they can be of any primitive type.

Support for Jplot and Xmgrace formats has been removed. Raw, CSV,
Gnuplot, VTK and Ensight formats are all still available.

The old "graph" functionality has been removed from the code, with the
exception of the randomProcesses library and associated applications
(noise, DNSFoam and boxTurb). The intention is that these should also
eventually be converted to use the setWriters. For now, so that it is
clear that the "graph" functionality is not to be used elsewhere, it has
been moved into a subdirectory of the randomProcesses library.
2021-12-07 11:18:27 +00:00

274 lines
7.6 KiB
C++

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-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::functionObjects::sizeDistribution
Description
This function object calculates and outputs volume-averaged information
about the size distribution of the dispersed phase, such as the number
density function or its moments. It is designed to be used exclusively with
the population balance modeling functionality of the multiphaseEulerFoam
solver. It can be applied to a specific cellZone or the entire domain. The
function type determines whether the density function and its moments are
based on the number of dispersed phase elements in a size group or their
total volume.
Example of function object specification:
\verbatim
numberDensity
{
type sizeDistribution;
libs ("libmultiphaseEulerFoamFunctionObjects.so");
...
populationBalance bubbles;
regionType cellZone;
name zone0;
functionType number;
coordinateType volume;
densityFunction yes;
}
\endverbatim
Usage
\table
Property | Description | Required | Default value
type | type name: sizeDistribution | yes |
populationBalance | corresponding populationBalance | yes |
functionType | number/volume/moments/stdDev | yes |
coordinateType | used for density/moment calculation | yes |
normalise | normalise concentrations | no | no
densityFunction | compute densityFunction | no | no
logBased | use log of coordinate for density | no | no
maxOrder | maxim order of moment output | no | 3
\endtable
SourceFiles
sizeDistribution.C
\*---------------------------------------------------------------------------*/
#ifndef sizeDistribution_H
#define sizeDistribution_H
#include "fvMeshFunctionObject.H"
#include "volRegion.H"
#include "logFiles.H"
#include "populationBalanceModel.H"
#include "writeFile.H"
#include "setWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class sizeDistribution Declaration
\*---------------------------------------------------------------------------*/
class sizeDistribution
:
public fvMeshFunctionObject,
public volRegion,
public logFiles
{
public:
// Public Data Types
//- Function type enumeration
enum functionType
{
ftMoments,
ftStdDev,
ftNumber,
ftVolume
};
//- Ordinate type names
static const NamedEnum<functionType, 4> functionTypeNames_;
//- Coordinate type enumeration
enum coordinateType
{
ctVolume,
ctArea,
ctDiameter,
ctProjectedAreaDiameter
};
//- Coordinate type names
static const NamedEnum<coordinateType, 4> coordinateTypeNames_;
protected:
// Protected Data
//- Reference to fvMesh
const fvMesh& mesh_;
//- File containing data for all functionTypes except moments
writeFile file_;
//- Output formatter
autoPtr<setWriter> formatterPtr_;
//- Reference to populationBalanceModel
const Foam::diameterModels::populationBalanceModel& popBal_;
//- Function to evaluate
functionType functionType_;
//- Abscissa type
coordinateType coordinateType_;
//- List of volume-averaged number concentrations
scalarField N_;
//- ???
scalarField V_;
//- List of volume-averaged surface areas
scalarField a_;
//- List of volume-averaged diameters
scalarField d_;
//- Normalise number/volume concentrations
Switch normalise_;
//- Determines whether density function is calculated
Switch densityFunction_;
//- Geometric standard deviation/density function
Switch geometric_;
//- Highest moment order
label maxOrder_;
// Protected Member Functions
//- Filter field according to cellIds
tmp<scalarField> filterField(const scalarField& field) const;
//- Bin component used according to chosen coordinate type
inline const scalarField& bin() const
{
switch (coordinateType_)
{
case ctVolume:
return V_;
case ctArea:
return a_;
case ctDiameter:
return d_;
case ctProjectedAreaDiameter:
return d_;
}
return scalarField::null();
}
//- Correct volume averages
void correctVolAverages();
//- Write moments
void writeMoments();
//- Write standard deviation
void writeStdDev();
//- Write distribution
void writeDistribution();
//- Output file header information for functionType moments
virtual void writeFileHeader(const label i);
public:
//- Runtime type information
TypeName("sizeDistribution");
// Constructors
//- Construct from Time and dictionary
sizeDistribution
(
const word& name,
const Time& runTime,
const dictionary& dict
);
//- Disallow default bitwise copy construction
sizeDistribution(const sizeDistribution&) = delete;
//- Destructor
virtual ~sizeDistribution();
// Member Functions
//- Read the sizeDistribution data
virtual bool read(const dictionary&);
//- Return the list of fields required
virtual wordList fields() const
{
return wordList::null();
}
//- Execute, currently does nothing
virtual bool execute();
//- Execute at the final time-loop, currently does nothing
virtual bool end();
//- Calculate and write the size distribution
virtual bool write();
// Member Operators
//- Disallow default bitwise assignment
void operator=(const sizeDistribution&) = delete;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //