lagrangian: Mesh change hooks and usability improvements

The clouds fvModel and all the clouds it creates now contain a full set
of mesh change hooks. Some of these ultimately result in
"NotImplemented" errors, but this is an area under active development
and support may be added in the near future.

In addition, the list of cloud names is now specified from within the
fvModel, using a "clouds" entry. If this entry is omitted then a single
cloud named "cloud" is assumed as before. An example fvModel
specification for multiple clouds might be as follows:

    clouds
    {
        type    clouds;

        libs    ("liblagrangianParcel.so" "liblagrangianParcelTurbulence.so");

        clouds  (coalCloud limestoneCloud); // <-- New entry. Replaces
                                            //     the constant/clouds
                                            //     file.
    }

Lagrangian solvers that construct clouds explicitly now do so via a new
"parcelClouds" mesh object. This ensures that they, too, are correctly
modified as a result of mesh changes.

Neither mechanism now permits no clouds. If there is not a "clouds"
entry (clouds fvModel), or a constant/clouds file (lagrangian solvers),
and there is not a constant/cloudProperties file for the default cloud,
then an error will be generated. Previously the code executed the solver
with no clouds. Intentional usage of the fvModel or lagrangian solvers
without clouds is considered highly unlikely.
This commit is contained in:
Will Bainbridge
2022-09-21 10:43:59 +01:00
parent c90671c8b7
commit 6cf099fd40
42 changed files with 627 additions and 305 deletions

View File

@ -122,7 +122,7 @@ volScalarField alphac
);
Info<< "Constructing clouds" << endl;
parcelCloudList clouds(rhoc, Uc, muc, g);
parcelClouds& clouds = parcelClouds::New(mesh, rhoc, Uc, muc, g);
// Particle fraction upper limit
scalar alphacMin

View File

@ -83,7 +83,7 @@ namespace Foam
#include "CorrectPhi.H"
#include "fvModels.H"
#include "fvConstraints.H"
#include "parcelCloudList.H"
#include "parcelClouds.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -54,7 +54,7 @@ volScalarField mu
);
Info<< "Constructing clouds" << endl;
parcelCloudList clouds(rhoInf, U, mu, g);
parcelClouds& clouds = parcelClouds::New(mesh, rhoInf, U, mu, g);
typeIOobject<volVectorField> Hheader
(

View File

@ -35,7 +35,7 @@ Description
#include "fvCFD.H"
#include "viscosityModel.H"
#include "incompressibleMomentumTransportModels.H"
#include "parcelCloudList.H"
#include "parcelClouds.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -50,4 +50,4 @@ autoPtr<compressible::momentumTransportModel> turbulence
);
Info<< "Constructing clouds" << endl;
parcelCloudList clouds(rho, U, thermo.mu(), g);
parcelClouds& clouds = parcelClouds::New(mesh, rho, U, thermo.mu(), g);

View File

@ -34,7 +34,7 @@ Description
#include "fvCFD.H"
#include "fluidThermo.H"
#include "compressibleMomentumTransportModels.H"
#include "parcelCloudList.H"
#include "parcelClouds.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -636,8 +636,6 @@ fields/UniformDimensionedFields/uniformDimensionedFields.C
fields/UniformGeometricFields/uniformGeometricFields.C
fields/cloud/cloud.C
Fields = fields/Fields
$(Fields)/fieldMappers/directFieldMapper/directFieldMapper.C

View File

@ -1,74 +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/>.
InNamespace
Foam::mapClouds
Description
Generic Geometric field mapper. For "real" mapping, add template
specialisations for mapping of internal fields depending on mesh
type.
\*---------------------------------------------------------------------------*/
#ifndef mapClouds_H
#define mapClouds_H
#include "cloud.H"
#include "objectRegistry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//- Generic Geometric field mapper.
// For "real" mapping, add template specialisations for mapping of internal
// fields depending on mesh type.
inline void mapClouds(const objectRegistry& db, const polyTopoChangeMap& mapper)
{
HashTable<const cloud*> clouds(db.lookupClass<cloud>());
forAllIter(HashTable<const cloud*>, clouds, iter)
{
cloud& c = const_cast<cloud&>(*iter());
if (polyMesh::debug)
{
Info<< "Mapping cloud " << c.name() << endl;
}
c.autoMap(mapper);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -121,7 +121,7 @@ Type& Foam::MeshObject<Mesh, MeshObjectType, Type>::New
{
if (found(mesh))
{
return mesh.thisDb().objectRegistry::template lookupObject<Type>
return mesh.thisDb().objectRegistry::template lookupObjectRef<Type>
(
Type::typeName
);

View File

@ -44,7 +44,6 @@ License
#include "pointMesh.H"
#include "pointMeshMapper.H"
#include "MapPointField.H"
#include "mapClouds.H"
#include "MeshObject.H"
#include "HashPtrTable.H"
#include "CompactListList.H"
@ -1039,9 +1038,6 @@ void Foam::fvMesh::mapFields(const polyTopoChangeMap& map)
(mapper);
FOR_ALL_FIELD_TYPES(mapPointFieldType);
}
// Map all the clouds in the objectRegistry
mapClouds(*this, map);
}

View File

@ -1084,16 +1084,44 @@ void Foam::DSMCCloud<ParcelType>::dumpParticlePositions() const
template<class ParcelType>
void Foam::DSMCCloud<ParcelType>::autoMap(const polyTopoChangeMap& mapper)
void Foam::DSMCCloud<ParcelType>::topoChange(const polyTopoChangeMap& map)
{
Cloud<ParcelType>::autoMap(mapper);
Cloud<ParcelType>::topoChange(map);
// Update the cell occupancy field
cellOccupancy_.setSize(mesh_.nCells());
buildCellOccupancy();
// Update the inflow BCs
this->inflowBoundary().autoMap(mapper);
this->inflowBoundary().topoChange();
}
template<class ParcelType>
void Foam::DSMCCloud<ParcelType>::mapMesh(const polyMeshMap& map)
{
Cloud<ParcelType>::mapMesh(map);
// Update the cell occupancy field
cellOccupancy_.setSize(mesh_.nCells());
buildCellOccupancy();
// Update the inflow BCs
this->inflowBoundary().topoChange();
}
template<class ParcelType>
void Foam::DSMCCloud<ParcelType>::distribute(const polyDistributionMap& map)
{
Cloud<ParcelType>::distribute(map);
// Update the cell occupancy field
cellOccupancy_.setSize(mesh_.nCells());
buildCellOccupancy();
// Update the inflow BCs
this->inflowBoundary().topoChange();
}

View File

@ -470,8 +470,14 @@ public:
// Mapping
//- Remap the particles to the correct cells following mesh change
virtual void autoMap(const polyTopoChangeMap&);
//- Update topology using the given map
virtual void topoChange(const polyTopoChangeMap&);
//- Update from another mesh using the given map
virtual void mapMesh(const polyMeshMap&);
//- Redistribute or update using the given distribution map
virtual void distribute(const polyDistributionMap&);
// Member Operators

View File

@ -116,7 +116,7 @@ Foam::FreeStream<CloudType>::~FreeStream()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::FreeStream<CloudType>::autoMap(const polyTopoChangeMap& mapper)
void Foam::FreeStream<CloudType>::topoChange()
{
CloudType& cloud(this->owner());
const polyMesh& mesh(cloud.mesh());

View File

@ -95,8 +95,9 @@ public:
// Mapping
//- Remap the particles to the correct cells following mesh change
virtual void autoMap(const polyTopoChangeMap&);
//- Update following mesh change
virtual void topoChange();
//- Introduce particles
virtual void inflow();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -87,6 +87,11 @@ const Foam::dictionary& Foam::InflowBoundaryModel<CloudType>::coeffDict() const
}
template<class CloudType>
void Foam::InflowBoundaryModel<CloudType>::topoChange()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "InflowBoundaryModelNew.C"

View File

@ -109,29 +109,31 @@ public:
CloudType& owner
);
// Member Functions
// Access
// Access
//- Return const access the owner cloud object
inline const CloudType& owner() const;
//- Return const access the owner cloud object
inline const CloudType& owner() const;
//- Return non-const access the owner cloud object for manipulation
inline CloudType& owner();
//- Return non-const access the owner cloud object for manipulation
inline CloudType& owner();
//- Return the owner cloud dictionary
inline const dictionary& dict() const;
//- Return the owner cloud dictionary
inline const dictionary& dict() const;
//- Return the coefficients dictionary
inline const dictionary& coeffDict() const;
//- Return the coefficients dictionary
inline const dictionary& coeffDict() const;
// Mapping
//- Remap the particles to the correct cells following mesh change
virtual void autoMap(const polyTopoChangeMap&)
{}
// Mapping
//- Introduce particles
virtual void inflow() = 0;
//- Update following mesh change
virtual void topoChange();
//- Introduce particles
virtual void inflow() = 0;
};

View File

@ -28,6 +28,8 @@ License
#include "globalMeshData.H"
#include "PstreamCombineReduceOps.H"
#include "polyTopoChangeMap.H"
#include "polyMeshMap.H"
#include "polyDistributionMap.H"
#include "Time.H"
#include "OFstream.H"
#include "wallPolyPatch.H"
@ -411,7 +413,7 @@ void Foam::Cloud<ParticleType>::move
template<class ParticleType>
void Foam::Cloud<ParticleType>::autoMap(const polyTopoChangeMap& mapper)
void Foam::Cloud<ParticleType>::topoChange(const polyTopoChangeMap& map)
{
if (!globalPositionsPtr_.valid())
{
@ -432,12 +434,26 @@ void Foam::Cloud<ParticleType>::autoMap(const polyTopoChangeMap& mapper)
label i = 0;
forAllIter(typename Cloud<ParticleType>, *this, iter)
{
iter().autoMap(positions[i], mapper);
iter().autoMap(positions[i], map);
++ i;
}
}
template<class ParticleType>
void Foam::Cloud<ParticleType>::mapMesh(const polyMeshMap& map)
{
NotImplemented;
}
template<class ParticleType>
void Foam::Cloud<ParticleType>::distribute(const polyDistributionMap& map)
{
NotImplemented;
}
template<class ParticleType>
void Foam::Cloud<ParticleType>::writePositions() const
{
@ -460,10 +476,10 @@ void Foam::Cloud<ParticleType>::writePositions() const
template<class ParticleType>
void Foam::Cloud<ParticleType>::storeGlobalPositions() const
{
// Store the global positions for later use by autoMap. It would be
// preferable not to need this. If the polyTopoChangeMap object passed to
// autoMap had a copy of the old mesh then the global positions could be
// recovered within autoMap, and this pre-processing would not be necessary.
// Store the global positions for later use by mapping functions. It would
// be preferable not to need this. If the objects passed to had a copy of
// the old mesh then the global positions could be recovered within the
// mapping functions, and this pre-processing would not be necessary.
globalPositionsPtr_.reset(new vectorField(this->size()));

View File

@ -255,9 +255,17 @@ public:
const scalar trackTime
);
//- Remap the cells of particles corresponding to the
// mesh topology change
void autoMap(const polyTopoChangeMap&);
// Mapping
//- Update topology using the given map
virtual void topoChange(const polyTopoChangeMap&);
//- Update from another mesh using the given map
virtual void mapMesh(const polyMeshMap&);
//- Redistribute or update using the given distribution map
virtual void distribute(const polyDistributionMap&);
// Read

View File

@ -1,6 +1,10 @@
particle/particle.C
particle/particleIO.C
IOPosition/IOPositionName.C
cloud/cloud.C
passiveParticle/passiveParticleCloud.C
indexedParticle/indexedParticleCloud.C

View File

@ -64,7 +64,19 @@ Foam::cloud::~cloud()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cloud::autoMap(const polyTopoChangeMap&)
void Foam::cloud::topoChange(const polyTopoChangeMap&)
{
NotImplemented;
}
void Foam::cloud::mapMesh(const polyMeshMap&)
{
NotImplemented;
}
void Foam::cloud::distribute(const polyDistributionMap&)
{
NotImplemented;
}

View File

@ -42,8 +42,9 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class polyTopoChangeMap;
class polyMeshMap;
class polyDistributionMap;
/*---------------------------------------------------------------------------*\
Class cloud Declaration
@ -81,11 +82,14 @@ public:
// Member Functions
// Edit
//- Update topology using the given map
virtual void topoChange(const polyTopoChangeMap&);
//- Remap the cells of particles corresponding to the
// mesh topology change
virtual void autoMap(const polyTopoChangeMap&);
//- Update from another mesh using the given map
virtual void mapMesh(const polyMeshMap&);
//- Redistribute or update using the given distribution map
virtual void distribute(const polyDistributionMap&);
// Member Operators

View File

@ -1258,13 +1258,13 @@ Foam::label Foam::particle::procTetPt
void Foam::particle::autoMap
(
const vector& position,
const polyTopoChangeMap& mapper
const polyTopoChangeMap& map
)
{
locate
(
position,
mapper.reverseCellMap()[celli_],
map.reverseCellMap()[celli_],
true,
"Particle mapped to a location outside of the mesh."
);

View File

@ -688,7 +688,7 @@ public:
// Mapping
//- Map after a topology change
void autoMap(const vector& position, const polyTopoChangeMap& mapper);
void autoMap(const vector& position, const polyTopoChangeMap& map);
// I-O

View File

@ -13,7 +13,8 @@ parcelThermo/parcelThermo.C
parcelCloud/parcelCloudBase.C
parcelCloud/parcelCloud.C
parcelCloud/parcelCloudNew.C
parcelCloudList/parcelCloudList.C
parcelCloud/parcelCloudList.C
parcelCloud/parcelClouds.C
# cloud names
$(CLOUDS)/Templates/MomentumCloud/MomentumCloudName.C

View File

@ -744,20 +744,41 @@ void Foam::MomentumCloud<CloudType>::patchData
template<class CloudType>
void Foam::MomentumCloud<CloudType>::topoChange()
void Foam::MomentumCloud<CloudType>::topoChange(const polyTopoChangeMap& map)
{
Cloud<parcelType>::topoChange(map);
updateCellOccupancy();
injectors_.topoChange();
cellLengthScale_ = mag(cbrt(this->mesh().V()));
}
template<class CloudType>
void Foam::MomentumCloud<CloudType>::autoMap(const polyTopoChangeMap& mapper)
void Foam::MomentumCloud<CloudType>::mapMesh(const polyMeshMap& map)
{
Cloud<parcelType>::autoMap(mapper);
Cloud<parcelType>::mapMesh(map);
topoChange();
updateCellOccupancy();
injectors_.topoChange();
cellLengthScale_ = mag(cbrt(this->mesh().V()));
}
template<class CloudType>
void Foam::MomentumCloud<CloudType>::distribute(const polyDistributionMap& map)
{
Cloud<parcelType>::distribute(map);
updateCellOccupancy();
injectors_.topoChange();
cellLengthScale_ = mag(cbrt(this->mesh().V()));
}

View File

@ -611,12 +611,14 @@ public:
// Mapping
//- Update mesh
void topoChange();
//- Update topology using the given map
virtual void topoChange(const polyTopoChangeMap&);
//- Remap the cells of particles corresponding to the
// mesh topology change with a default tracking data object
virtual void autoMap(const polyTopoChangeMap&);
//- Update from another mesh using the given map
virtual void mapMesh(const polyMeshMap&);
//- Redistribute or update using the given distribution map
virtual void distribute(const polyDistributionMap&);
// I-O

View File

@ -308,15 +308,6 @@ void Foam::ReactingCloud<CloudType>::evolve()
}
template<class CloudType>
void Foam::ReactingCloud<CloudType>::autoMap(const polyTopoChangeMap& mapper)
{
Cloud<parcelType>::autoMap(mapper);
this->topoChange();
}
template<class CloudType>
void Foam::ReactingCloud<CloudType>::info()
{

View File

@ -292,13 +292,6 @@ public:
void evolve();
// Mapping
//- Remap the cells of particles corresponding to the
// mesh topology change with a default tracking data object
virtual void autoMap(const polyTopoChangeMap&);
// I-O
//- Print cloud information

View File

@ -246,18 +246,6 @@ void Foam::ReactingMultiphaseCloud<CloudType>::evolve()
}
template<class CloudType>
void Foam::ReactingMultiphaseCloud<CloudType>::autoMap
(
const polyTopoChangeMap& mapper
)
{
Cloud<parcelType>::autoMap(mapper);
this->topoChange();
}
template<class CloudType>
void Foam::ReactingMultiphaseCloud<CloudType>::info()
{

View File

@ -282,13 +282,6 @@ public:
void evolve();
// Mapping
//- Remap the cells of particles corresponding to the
// mesh topology change with a default tracking data object
virtual void autoMap(const polyTopoChangeMap&);
// I-O
//- Print cloud information

View File

@ -477,15 +477,6 @@ void Foam::ThermoCloud<CloudType>::evolve()
}
template<class CloudType>
void Foam::ThermoCloud<CloudType>::autoMap(const polyTopoChangeMap& mapper)
{
Cloud<parcelType>::autoMap(mapper);
this->topoChange();
}
template<class CloudType>
void Foam::ThermoCloud<CloudType>::info()
{

View File

@ -384,13 +384,6 @@ public:
void evolve();
// Mapping
//- Remap the cells of particles corresponding to the
// mesh topology change with a default tracking data object
virtual void autoMap(const polyTopoChangeMap&);
// I-O
//- Print cloud information

View File

@ -119,6 +119,14 @@ Foam::fv::clouds::clouds
new volScalarField("mu", tRho_()*tCarrierViscosity_().nu())
)
),
cloudNames_
(
dict.lookupOrDefault<wordList>
(
"clouds",
parcelCloudList::defaultCloudNames
)
),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
UName_(dict.lookupOrDefault<word>("U", "U")),
cloudsPtr_
@ -126,6 +134,7 @@ Foam::fv::clouds::clouds
carrierHasThermo_
? new parcelCloudList
(
cloudNames_,
mesh.lookupObject<volScalarField>(rhoName_),
mesh.lookupObject<volVectorField>(UName_),
g_,
@ -133,6 +142,7 @@ Foam::fv::clouds::clouds
)
: new parcelCloudList
(
cloudNames_,
tRho_(),
mesh.lookupObject<volVectorField>(UName_),
tMu_(),
@ -330,12 +340,16 @@ void Foam::fv::clouds::preUpdateMesh()
}
void Foam::fv::clouds::topoChange(const polyTopoChangeMap&)
{}
void Foam::fv::clouds::topoChange(const polyTopoChangeMap& map)
{
cloudsPtr_().topoChange(map);
}
void Foam::fv::clouds::mapMesh(const polyMeshMap& map)
{}
{
cloudsPtr_().mapMesh(map);
}
void Foam::fv::clouds::distribute(const polyDistributionMap& map)

View File

@ -117,6 +117,9 @@ class clouds
//- Viscosity field. Valid only if the carrier does not have thermo.
tmp<volScalarField> tMu_;
//- Names of the clouds
const wordList cloudNames_;
//- Name of the density field
const word rhoName_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2020-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,12 +58,32 @@ public:
// Member Functions
//- Call this before a topology change. Stores the particles global
// positions in the database for use during mapping.
virtual void storeGlobalPositions()
{
CloudType::storeGlobalPositions();
}
// Mesh changes
//- Call this before a topology change. Stores the particles global
// positions in the database for use during mapping.
virtual void storeGlobalPositions()
{
CloudType::storeGlobalPositions();
}
//- Update topology using the given map
virtual void topoChange(const polyTopoChangeMap& map)
{
CloudType::topoChange(map);
}
//- Update from another mesh using the given map
virtual void mapMesh(const polyMeshMap& map)
{
CloudType::mapMesh(map);
}
//- Redistribute or update using the given distribution map
virtual void distribute(const polyDistributionMap& map)
{
CloudType::distribute(map);
}
// Evolution

View File

@ -133,15 +133,30 @@ public:
// Member Functions
//- Call this before a topology change. Stores the particles global
// positions in the database for use during mapping.
virtual void storeGlobalPositions() = 0;
// Mesh changes
//- Call this before a topology change. Stores the particles global
// positions in the database for use during mapping.
virtual void storeGlobalPositions() = 0;
//- Update topology using the given map
virtual void topoChange(const polyTopoChangeMap&)
{
NotImplemented;
}
//- Update from another mesh using the given map
virtual void mapMesh(const polyMeshMap&)
{
NotImplemented;
}
//- Redistribute or update using the given distribution map
virtual void distribute(const polyDistributionMap& map)
{
NotImplemented;
}
//- Redistribute or update using the given distribution map
virtual void distribute(const polyDistributionMap& map)
{
NotImplemented;
}
// Evolution

View File

@ -30,61 +30,51 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::word Foam::parcelCloudList::cloudsName("clouds");
const Foam::word Foam::parcelCloudList::defaultCloudName("cloud");
const Foam::wordList Foam::parcelCloudList::defaultCloudNames(1, "cloud");
const Foam::word Foam::parcelCloudList::cloudNamesName("clouds");
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * Private Static Member Functions * * * * * * * * * * * //
template<class ... Args>
void Foam::parcelCloudList::initialise
(
const Args& ... args
)
Foam::wordList Foam::parcelCloudList::cloudNames(const objectRegistry& db)
{
typeIOobject<wordGlobalIOList> cloudsIO
typeIOobject<wordGlobalIOList> cloudNamesIO
(
cloudsName,
mesh_.time().constant(),
mesh_,
cloudNamesName,
db.time().constant(),
db,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (cloudsIO.headerOk())
if (cloudNamesIO.headerOk())
{
wordGlobalIOList cloudNames(cloudsIO);
this->setSize(cloudNames.size());
forAll(cloudNames, i)
{
this->set(i, parcelCloud::New(cloudNames[i], args ...));
}
return wordGlobalIOList(cloudNamesIO);
}
else
typeIOobject<IOdictionary> cloudIO
(
defaultCloudName + "Properties",
db.time().constant(),
db,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (cloudIO.headerOk())
{
typeIOobject<IOdictionary> cloudIO
(
"cloudProperties",
mesh_.time().constant(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (cloudIO.headerOk())
{
this->setSize(1);
this->set(0, parcelCloud::New("cloud", args ...));
}
else
{
Info<< "Clouds not active: Neither "
<< cloudsIO.relativeObjectPath()
<< " nor " << cloudIO.relativeObjectPath() << " found" << endl;
}
return wordList(1, defaultCloudName);
}
FatalErrorInFunction
<< "Cloud properties were not found in either "
<< cloudNamesIO.relativeObjectPath() << " or "
<< cloudIO.relativeObjectPath() << exit(FatalError);
return wordList::null();
}
@ -92,6 +82,7 @@ void Foam::parcelCloudList::initialise
Foam::parcelCloudList::parcelCloudList
(
const wordList& cloudNames,
const volScalarField& rho,
const volVectorField& U,
const volScalarField& mu,
@ -101,10 +92,48 @@ Foam::parcelCloudList::parcelCloudList
PtrList<parcelCloud>(),
mesh_(rho.mesh())
{
initialise(rho, U, mu, g);
this->setSize(cloudNames.size());
forAll(cloudNames, i)
{
this->set(i, parcelCloud::New(cloudNames[i], rho, U, mu, g));
}
}
Foam::parcelCloudList::parcelCloudList
(
const wordList& cloudNames,
const volScalarField& rho,
const volVectorField& U,
const dimensionedVector& g,
const fluidThermo& carrierThermo
)
:
PtrList<parcelCloud>(),
mesh_(rho.mesh())
{
this->setSize(cloudNames.size());
forAll(cloudNames, i)
{
this->set(i, parcelCloud::New(cloudNames[i], rho, U, g, carrierThermo));
}
}
Foam::parcelCloudList::parcelCloudList
(
const volScalarField& rho,
const volVectorField& U,
const volScalarField& mu,
const dimensionedVector& g
)
:
parcelCloudList(cloudNames(rho.mesh()), rho, U, mu, g)
{}
Foam::parcelCloudList::parcelCloudList
(
const volScalarField& rho,
@ -113,11 +142,8 @@ Foam::parcelCloudList::parcelCloudList
const fluidThermo& carrierThermo
)
:
PtrList<parcelCloud>(),
mesh_(rho.mesh())
{
initialise(rho, U, g, carrierThermo);
}
parcelCloudList(cloudNames(rho.mesh()), rho, U, g, carrierThermo)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -134,7 +160,7 @@ const Foam::tmp<Foam::volScalarField> Foam::parcelCloudList::theta() const
(
volScalarField::New
(
cloudsName + ":theta",
cloudNamesName + ":theta",
mesh_,
dimensionedScalar(dimless, 0),
extrapolatedCalculatedFvPatchScalarField::typeName
@ -168,7 +194,7 @@ Foam::tmp<Foam::volVectorField::Internal> Foam::parcelCloudList::UTrans() const
(
volVectorField::Internal::New
(
cloudsName + ":UTrans",
cloudNamesName + ":UTrans",
mesh_,
dimensionedVector(dimMass*dimVelocity, Zero)
)
@ -187,7 +213,7 @@ Foam::tmp<Foam::volScalarField::Internal> Foam::parcelCloudList::UCoeff() const
(
volScalarField::Internal::New
(
cloudsName + ":UCoeff",
cloudNamesName + ":UCoeff",
mesh_,
dimensionedScalar(dimMass, Zero)
)
@ -220,7 +246,7 @@ Foam::tmp<Foam::volScalarField::Internal> Foam::parcelCloudList::hsTrans() const
(
volScalarField::Internal::New
(
cloudsName + ":hsTrans",
cloudNamesName + ":hsTrans",
mesh_,
dimensionedScalar(dimEnergy, Zero)
)
@ -239,7 +265,7 @@ Foam::tmp<Foam::volScalarField::Internal> Foam::parcelCloudList::hsCoeff() const
(
volScalarField::Internal::New
(
cloudsName + ":hsCoeff",
cloudNamesName + ":hsCoeff",
mesh_,
dimensionedScalar(dimEnergy/dimTemperature, Zero)
)
@ -258,7 +284,7 @@ Foam::tmp<Foam::volScalarField> Foam::parcelCloudList::Ep() const
(
volScalarField::New
(
cloudsName + ":radiation:Ep",
cloudNamesName + ":radiation:Ep",
mesh_,
dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero)
)
@ -277,7 +303,7 @@ Foam::tmp<Foam::volScalarField> Foam::parcelCloudList::ap() const
(
volScalarField::New
(
cloudsName + ":radiation:ap",
cloudNamesName + ":radiation:ap",
mesh_,
dimensionedScalar(dimless/dimLength, 0)
)
@ -297,7 +323,7 @@ Foam::tmp<Foam::volScalarField> Foam::parcelCloudList::sigmap() const
(
volScalarField::New
(
cloudsName + ":radiation:sigmap",
cloudNamesName + ":radiation:sigmap",
mesh_,
dimensionedScalar(dimless/dimLength, 0)
)
@ -345,7 +371,7 @@ Foam::tmp<Foam::volScalarField::Internal> Foam::parcelCloudList::Srho() const
(
volScalarField::Internal::New
(
cloudsName + ":Srho",
cloudNamesName + ":Srho",
mesh_,
dimensionedScalar(dimDensity/dimTime, Zero)
)
@ -385,6 +411,24 @@ void Foam::parcelCloudList::storeGlobalPositions()
}
void Foam::parcelCloudList::topoChange(const polyTopoChangeMap& map)
{
forAll(*this, i)
{
operator[](i).topoChange(map);
}
}
void Foam::parcelCloudList::mapMesh(const polyMeshMap& map)
{
forAll(*this, i)
{
operator[](i).mapMesh(map);
}
}
void Foam::parcelCloudList::distribute(const polyDistributionMap& map)
{
forAll(*this, i)

View File

@ -26,8 +26,11 @@ Class
Description
List of parcel clouds, with the same interface as an individual parcel
cloud. This is the object that should be constructed by a solver in order
to support the coupled simulation of multiple clouds.
cloud. This is the object that should be constructed by an fvModel, or any
system that can call this class' mesh change functions. A solver should
*not* construct this object, as that would not provide a mechanism for the
mesh change functions to be executed. A solver should construct a
parcelClouds object instead.
SourceFiles
parcelCloudList.C
@ -52,30 +55,57 @@ class parcelCloudList
{
private:
// Private Static Member Functions
//- Get the cloud names for this case
static wordList cloudNames(const objectRegistry& db);
// Private data
//- Reference to the mesh
const fvMesh& mesh_;
// Private member functions
//- Initialise the pointer list of clouds
template <class ... Args>
void initialise(const Args& ... args);
public:
// Static Data Members
//- The name of the clouds
static const word cloudsName;
//- The default cloud name
static const word defaultCloudName;
//- The default cloud names (i.e., a list of length one with the
// defaultCloudName as its value)
static const wordList defaultCloudNames;
//- The name of the clouds file in which multiple cloud names are
// specified
static const word cloudNamesName;
// Constructors
//- Construct with given carrier fields
//- Construct specified clouds with given carrier fields
parcelCloudList
(
const wordList& cloudNames,
const volScalarField& rho,
const volVectorField& U,
const volScalarField& mu,
const dimensionedVector& g
);
//- Construct specified clouds with given carrier fields and thermo
parcelCloudList
(
const wordList& cloudNames,
const volScalarField& rho,
const volVectorField& U,
const dimensionedVector& g,
const fluidThermo& carrierThermo
);
//- Construct detected clouds with given carrier fields
parcelCloudList
(
const volScalarField& rho,
@ -84,7 +114,7 @@ public:
const dimensionedVector& g
);
//- Construct with given carrier fields and thermo
//- Construct detected clouds with given carrier fields and thermo
parcelCloudList
(
const volScalarField& rho,
@ -172,12 +202,20 @@ public:
void evolve();
//- Call this before a topology change. Stores the particles global
// positions in the database for use during mapping.
void storeGlobalPositions();
// Mesh changes
//- Redistribute or update using the given distribution map
void distribute(const polyDistributionMap&);
//- Call this before a topology change. Stores the particles global
// positions in the database for use during mapping.
void storeGlobalPositions();
//- Update topology using the given map
void topoChange(const polyTopoChangeMap&);
//- Update from another mesh using the given map
void mapMesh(const polyMeshMap&);
//- Redistribute or update using the given distribution map
void distribute(const polyDistributionMap&);
// Member Operators

View File

@ -0,0 +1,96 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 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 "parcelClouds.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::parcelClouds::parcelClouds
(
const fvMesh& mesh,
const volScalarField& rho,
const volVectorField& U,
const volScalarField& mu,
const dimensionedVector& g
)
:
MeshObject<fvMesh, UpdateableMeshObject, parcelClouds>(mesh),
parcelCloudList(rho, U, mu, g)
{}
Foam::parcelClouds::parcelClouds
(
const fvMesh& mesh,
const volScalarField& rho,
const volVectorField& U,
const dimensionedVector& g,
const fluidThermo& carrierThermo
)
:
MeshObject<fvMesh, UpdateableMeshObject, parcelClouds>(mesh),
parcelCloudList(rho, U, g, carrierThermo)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::parcelClouds::~parcelClouds()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::parcelClouds::preUpdateMesh()
{
parcelCloudList::storeGlobalPositions();
}
bool Foam::parcelClouds::movePoints()
{
return true;
}
void Foam::parcelClouds::topoChange(const polyTopoChangeMap& map)
{
parcelCloudList::topoChange(map);
}
void Foam::parcelClouds::mapMesh(const polyMeshMap& map)
{
parcelCloudList::mapMesh(map);
}
void Foam::parcelClouds::distribute(const polyDistributionMap& map)
{
parcelCloudList::distribute(map);
}
// ************************************************************************* //

View File

@ -0,0 +1,134 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 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::parcelClouds
Description
List of parcel clouds, with the same interface as an individual parcel
cloud. Is a mesh object, so mesh change hooks are provided and will be
applied to the contained cloud. This is the object that should be
constructed by a solver in order to support the coupled simulation of
multiple clouds. An fvModel should *not* construct this object, as that
would nest two mesh objects. An fvModel should construct the base
parcelCloudList instead.
SourceFiles
parcelClouds.C
\*---------------------------------------------------------------------------*/
#ifndef parcelClouds_H
#define parcelClouds_H
#include "MeshObject.H"
#include "parcelCloudList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class parcelClouds Declaration
\*---------------------------------------------------------------------------*/
class parcelClouds
:
public MeshObject<fvMesh, UpdateableMeshObject, parcelClouds>,
public parcelCloudList
{
private:
// Private Constructors
//- Construct with given mesh and carrier fields
parcelClouds
(
const fvMesh& mesh,
const volScalarField& rho,
const volVectorField& U,
const volScalarField& mu,
const dimensionedVector& g
);
//- Construct with given mesh and carrier fields and thermo
parcelClouds
(
const fvMesh& mesh,
const volScalarField& rho,
const volVectorField& U,
const dimensionedVector& g,
const fluidThermo& carrierThermo
);
//- Let Private Cesh object call the private constructors
friend class MeshObject<fvMesh, UpdateableMeshObject, parcelClouds>;
public:
// Constructors
//- Disallow default bitwise copy construction
parcelClouds(const parcelClouds&) = delete;
//- Inherit the base New method
using MeshObject<fvMesh, UpdateableMeshObject, parcelClouds>::New;
//- Destructor
virtual ~parcelClouds();
// Member Functions
// Mesh changes
//- Prepare for mesh update
virtual void preUpdateMesh();
//- Update for mesh motion
virtual bool movePoints();
//- Update topology using the given map
virtual void topoChange(const polyTopoChangeMap&);
//- Update from another mesh using the given map
virtual void mapMesh(const polyMeshMap&);
//- Redistribute or update using the given distribution map
virtual void distribute(const polyDistributionMap&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,22 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class wordList;
location "constant";
object clouds;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
(
coalCloud
limestoneCloud
)
// ************************************************************************* //

View File

@ -23,6 +23,7 @@ clouds
{
type clouds;
libs ("liblagrangianParcel.so" "liblagrangianParcelTurbulence.so");
clouds (coalCloud limestoneCloud);
}
radiation