From 6cf099fd408a283ec9a51ee18bd7329f8c9aa6df Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Wed, 21 Sep 2022 10:43:59 +0100 Subject: [PATCH] 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. --- .../denseParticleFoam/createFields.H | 2 +- .../denseParticleFoam/denseParticleFoam.C | 2 +- .../lagrangian/particleFoam/createFields.H | 2 +- .../lagrangian/particleFoam/particleFoam.C | 2 +- .../lagrangian/rhoParticleFoam/createFields.H | 2 +- .../rhoParticleFoam/rhoParticleFoam.C | 2 +- src/OpenFOAM/Make/files | 2 - src/OpenFOAM/fields/cloud/mapClouds.H | 74 -------- src/OpenFOAM/meshes/MeshObject/MeshObject.C | 2 +- src/finiteVolume/fvMesh/fvMesh.C | 4 - .../clouds/Templates/DSMCCloud/DSMCCloud.C | 34 +++- .../clouds/Templates/DSMCCloud/DSMCCloud.H | 10 +- .../FreeStream/FreeStream.C | 2 +- .../FreeStream/FreeStream.H | 5 +- .../InflowBoundaryModel/InflowBoundaryModel.C | 7 +- .../InflowBoundaryModel/InflowBoundaryModel.H | 32 ++-- src/lagrangian/basic/Cloud/Cloud.C | 28 +++- src/lagrangian/basic/Cloud/Cloud.H | 14 +- src/lagrangian/basic/Make/files | 4 + .../fields => lagrangian/basic}/cloud/cloud.C | 14 +- .../fields => lagrangian/basic}/cloud/cloud.H | 14 +- src/lagrangian/basic/particle/particle.C | 4 +- src/lagrangian/basic/particle/particle.H | 2 +- src/lagrangian/parcel/Make/files | 3 +- .../Templates/MomentumCloud/MomentumCloud.C | 29 +++- .../Templates/MomentumCloud/MomentumCloud.H | 12 +- .../Templates/ReactingCloud/ReactingCloud.C | 9 - .../Templates/ReactingCloud/ReactingCloud.H | 7 - .../ReactingMultiphaseCloud.C | 12 -- .../ReactingMultiphaseCloud.H | 7 - .../Templates/ThermoCloud/ThermoCloud.C | 9 - .../Templates/ThermoCloud/ThermoCloud.H | 7 - .../parcel/fvModels/clouds/clouds.C | 20 ++- .../parcel/fvModels/clouds/clouds.H | 3 + .../parcel/parcelCloud/ParcelCloud.H | 34 +++- .../parcel/parcelCloud/parcelCloud.H | 31 +++- .../parcelCloudList.C | 158 +++++++++++------- .../parcelCloudList.H | 74 ++++++-- .../parcel/parcelCloud/parcelClouds.C | 96 +++++++++++ .../parcel/parcelCloud/parcelClouds.H | 134 +++++++++++++++ .../simplifiedSiwek/constant/clouds | 22 --- .../simplifiedSiwek/constant/fvModels | 1 + 42 files changed, 627 insertions(+), 305 deletions(-) delete mode 100644 src/OpenFOAM/fields/cloud/mapClouds.H rename src/{OpenFOAM/fields => lagrangian/basic}/cloud/cloud.C (91%) rename src/{OpenFOAM/fields => lagrangian/basic}/cloud/cloud.H (87%) rename src/lagrangian/parcel/{parcelCloudList => parcelCloud}/parcelCloudList.C (73%) rename src/lagrangian/parcel/{parcelCloudList => parcelCloud}/parcelCloudList.H (68%) create mode 100644 src/lagrangian/parcel/parcelCloud/parcelClouds.C create mode 100644 src/lagrangian/parcel/parcelCloud/parcelClouds.H delete mode 100644 tutorials/modules/multicomponentFluid/simplifiedSiwek/constant/clouds diff --git a/applications/solvers/lagrangian/denseParticleFoam/createFields.H b/applications/solvers/lagrangian/denseParticleFoam/createFields.H index 2ae4203624..c942a5697d 100644 --- a/applications/solvers/lagrangian/denseParticleFoam/createFields.H +++ b/applications/solvers/lagrangian/denseParticleFoam/createFields.H @@ -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 diff --git a/applications/solvers/lagrangian/denseParticleFoam/denseParticleFoam.C b/applications/solvers/lagrangian/denseParticleFoam/denseParticleFoam.C index e9bd197284..7a821579e6 100644 --- a/applications/solvers/lagrangian/denseParticleFoam/denseParticleFoam.C +++ b/applications/solvers/lagrangian/denseParticleFoam/denseParticleFoam.C @@ -83,7 +83,7 @@ namespace Foam #include "CorrectPhi.H" #include "fvModels.H" #include "fvConstraints.H" -#include "parcelCloudList.H" +#include "parcelClouds.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/lagrangian/particleFoam/createFields.H b/applications/solvers/lagrangian/particleFoam/createFields.H index 2dfff06109..20a3ab7689 100644 --- a/applications/solvers/lagrangian/particleFoam/createFields.H +++ b/applications/solvers/lagrangian/particleFoam/createFields.H @@ -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 Hheader ( diff --git a/applications/solvers/lagrangian/particleFoam/particleFoam.C b/applications/solvers/lagrangian/particleFoam/particleFoam.C index 47f7ce505f..177c8b9df9 100644 --- a/applications/solvers/lagrangian/particleFoam/particleFoam.C +++ b/applications/solvers/lagrangian/particleFoam/particleFoam.C @@ -35,7 +35,7 @@ Description #include "fvCFD.H" #include "viscosityModel.H" #include "incompressibleMomentumTransportModels.H" -#include "parcelCloudList.H" +#include "parcelClouds.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/lagrangian/rhoParticleFoam/createFields.H b/applications/solvers/lagrangian/rhoParticleFoam/createFields.H index 55dd6469ef..dc0edcb1d1 100644 --- a/applications/solvers/lagrangian/rhoParticleFoam/createFields.H +++ b/applications/solvers/lagrangian/rhoParticleFoam/createFields.H @@ -50,4 +50,4 @@ autoPtr turbulence ); Info<< "Constructing clouds" << endl; -parcelCloudList clouds(rho, U, thermo.mu(), g); +parcelClouds& clouds = parcelClouds::New(mesh, rho, U, thermo.mu(), g); diff --git a/applications/solvers/lagrangian/rhoParticleFoam/rhoParticleFoam.C b/applications/solvers/lagrangian/rhoParticleFoam/rhoParticleFoam.C index 393d8f5e28..b288527495 100644 --- a/applications/solvers/lagrangian/rhoParticleFoam/rhoParticleFoam.C +++ b/applications/solvers/lagrangian/rhoParticleFoam/rhoParticleFoam.C @@ -34,7 +34,7 @@ Description #include "fvCFD.H" #include "fluidThermo.H" #include "compressibleMomentumTransportModels.H" -#include "parcelCloudList.H" +#include "parcelClouds.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 01f85aa58d..f97bb5afe8 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -636,8 +636,6 @@ fields/UniformDimensionedFields/uniformDimensionedFields.C fields/UniformGeometricFields/uniformGeometricFields.C -fields/cloud/cloud.C - Fields = fields/Fields $(Fields)/fieldMappers/directFieldMapper/directFieldMapper.C diff --git a/src/OpenFOAM/fields/cloud/mapClouds.H b/src/OpenFOAM/fields/cloud/mapClouds.H deleted file mode 100644 index 84ff7e2880..0000000000 --- a/src/OpenFOAM/fields/cloud/mapClouds.H +++ /dev/null @@ -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 . - -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 clouds(db.lookupClass()); - - forAllIter(HashTable, clouds, iter) - { - cloud& c = const_cast(*iter()); - - if (polyMesh::debug) - { - Info<< "Mapping cloud " << c.name() << endl; - } - - c.autoMap(mapper); - } -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/MeshObject/MeshObject.C b/src/OpenFOAM/meshes/MeshObject/MeshObject.C index 783d4eb7ff..5b7348d245 100644 --- a/src/OpenFOAM/meshes/MeshObject/MeshObject.C +++ b/src/OpenFOAM/meshes/MeshObject/MeshObject.C @@ -121,7 +121,7 @@ Type& Foam::MeshObject::New { if (found(mesh)) { - return mesh.thisDb().objectRegistry::template lookupObject + return mesh.thisDb().objectRegistry::template lookupObjectRef ( Type::typeName ); diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index 68adce6224..830af031b4 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -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); } diff --git a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C index ae7dfc68cb..96e906a6c2 100644 --- a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C +++ b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C @@ -1084,16 +1084,44 @@ void Foam::DSMCCloud::dumpParticlePositions() const template -void Foam::DSMCCloud::autoMap(const polyTopoChangeMap& mapper) +void Foam::DSMCCloud::topoChange(const polyTopoChangeMap& map) { - Cloud::autoMap(mapper); + Cloud::topoChange(map); // Update the cell occupancy field cellOccupancy_.setSize(mesh_.nCells()); buildCellOccupancy(); // Update the inflow BCs - this->inflowBoundary().autoMap(mapper); + this->inflowBoundary().topoChange(); +} + + +template +void Foam::DSMCCloud::mapMesh(const polyMeshMap& map) +{ + Cloud::mapMesh(map); + + // Update the cell occupancy field + cellOccupancy_.setSize(mesh_.nCells()); + buildCellOccupancy(); + + // Update the inflow BCs + this->inflowBoundary().topoChange(); +} + + +template +void Foam::DSMCCloud::distribute(const polyDistributionMap& map) +{ + Cloud::distribute(map); + + // Update the cell occupancy field + cellOccupancy_.setSize(mesh_.nCells()); + buildCellOccupancy(); + + // Update the inflow BCs + this->inflowBoundary().topoChange(); } diff --git a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.H b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.H index 127a085dc8..8f1b367b79 100644 --- a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.H +++ b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.H @@ -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 diff --git a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C index 93567989c9..d837a3019c 100644 --- a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C +++ b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C @@ -116,7 +116,7 @@ Foam::FreeStream::~FreeStream() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -void Foam::FreeStream::autoMap(const polyTopoChangeMap& mapper) +void Foam::FreeStream::topoChange() { CloudType& cloud(this->owner()); const polyMesh& mesh(cloud.mesh()); diff --git a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.H b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.H index f81c704cef..71fddd9da0 100644 --- a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.H +++ b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.H @@ -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(); diff --git a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.C b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.C index 57dec69f03..6da370499e 100644 --- a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.C +++ b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.C @@ -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::coeffDict() const } +template +void Foam::InflowBoundaryModel::topoChange() +{} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "InflowBoundaryModelNew.C" diff --git a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.H b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.H index c3344a2caa..5bf1f91d31 100644 --- a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.H +++ b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/InflowBoundaryModel/InflowBoundaryModel.H @@ -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; }; diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index fdc17f3093..95844049bc 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -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::move template -void Foam::Cloud::autoMap(const polyTopoChangeMap& mapper) +void Foam::Cloud::topoChange(const polyTopoChangeMap& map) { if (!globalPositionsPtr_.valid()) { @@ -432,12 +434,26 @@ void Foam::Cloud::autoMap(const polyTopoChangeMap& mapper) label i = 0; forAllIter(typename Cloud, *this, iter) { - iter().autoMap(positions[i], mapper); + iter().autoMap(positions[i], map); ++ i; } } +template +void Foam::Cloud::mapMesh(const polyMeshMap& map) +{ + NotImplemented; +} + + +template +void Foam::Cloud::distribute(const polyDistributionMap& map) +{ + NotImplemented; +} + + template void Foam::Cloud::writePositions() const { @@ -460,10 +476,10 @@ void Foam::Cloud::writePositions() const template void Foam::Cloud::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())); diff --git a/src/lagrangian/basic/Cloud/Cloud.H b/src/lagrangian/basic/Cloud/Cloud.H index df1101d48f..04914b4838 100644 --- a/src/lagrangian/basic/Cloud/Cloud.H +++ b/src/lagrangian/basic/Cloud/Cloud.H @@ -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 diff --git a/src/lagrangian/basic/Make/files b/src/lagrangian/basic/Make/files index ab257894f8..2481b8d1bb 100644 --- a/src/lagrangian/basic/Make/files +++ b/src/lagrangian/basic/Make/files @@ -1,6 +1,10 @@ particle/particle.C particle/particleIO.C + IOPosition/IOPositionName.C + +cloud/cloud.C + passiveParticle/passiveParticleCloud.C indexedParticle/indexedParticleCloud.C diff --git a/src/OpenFOAM/fields/cloud/cloud.C b/src/lagrangian/basic/cloud/cloud.C similarity index 91% rename from src/OpenFOAM/fields/cloud/cloud.C rename to src/lagrangian/basic/cloud/cloud.C index 707e8e9394..f5f038a1ec 100644 --- a/src/OpenFOAM/fields/cloud/cloud.C +++ b/src/lagrangian/basic/cloud/cloud.C @@ -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; } diff --git a/src/OpenFOAM/fields/cloud/cloud.H b/src/lagrangian/basic/cloud/cloud.H similarity index 87% rename from src/OpenFOAM/fields/cloud/cloud.H rename to src/lagrangian/basic/cloud/cloud.H index 6d939b1da4..b99bfc26d3 100644 --- a/src/OpenFOAM/fields/cloud/cloud.H +++ b/src/lagrangian/basic/cloud/cloud.H @@ -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 diff --git a/src/lagrangian/basic/particle/particle.C b/src/lagrangian/basic/particle/particle.C index a74fddd598..079c3f4658 100644 --- a/src/lagrangian/basic/particle/particle.C +++ b/src/lagrangian/basic/particle/particle.C @@ -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." ); diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index f939d62994..0a02b128df 100644 --- a/src/lagrangian/basic/particle/particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -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 diff --git a/src/lagrangian/parcel/Make/files b/src/lagrangian/parcel/Make/files index d3c113d841..f9c4378511 100644 --- a/src/lagrangian/parcel/Make/files +++ b/src/lagrangian/parcel/Make/files @@ -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 diff --git a/src/lagrangian/parcel/clouds/Templates/MomentumCloud/MomentumCloud.C b/src/lagrangian/parcel/clouds/Templates/MomentumCloud/MomentumCloud.C index 3dfa88a557..2fa92c4933 100644 --- a/src/lagrangian/parcel/clouds/Templates/MomentumCloud/MomentumCloud.C +++ b/src/lagrangian/parcel/clouds/Templates/MomentumCloud/MomentumCloud.C @@ -744,20 +744,41 @@ void Foam::MomentumCloud::patchData template -void Foam::MomentumCloud::topoChange() +void Foam::MomentumCloud::topoChange(const polyTopoChangeMap& map) { + Cloud::topoChange(map); + updateCellOccupancy(); + injectors_.topoChange(); + cellLengthScale_ = mag(cbrt(this->mesh().V())); } template -void Foam::MomentumCloud::autoMap(const polyTopoChangeMap& mapper) +void Foam::MomentumCloud::mapMesh(const polyMeshMap& map) { - Cloud::autoMap(mapper); + Cloud::mapMesh(map); - topoChange(); + updateCellOccupancy(); + + injectors_.topoChange(); + + cellLengthScale_ = mag(cbrt(this->mesh().V())); +} + + +template +void Foam::MomentumCloud::distribute(const polyDistributionMap& map) +{ + Cloud::distribute(map); + + updateCellOccupancy(); + + injectors_.topoChange(); + + cellLengthScale_ = mag(cbrt(this->mesh().V())); } diff --git a/src/lagrangian/parcel/clouds/Templates/MomentumCloud/MomentumCloud.H b/src/lagrangian/parcel/clouds/Templates/MomentumCloud/MomentumCloud.H index 7a028ecb71..df8713e789 100644 --- a/src/lagrangian/parcel/clouds/Templates/MomentumCloud/MomentumCloud.H +++ b/src/lagrangian/parcel/clouds/Templates/MomentumCloud/MomentumCloud.H @@ -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 diff --git a/src/lagrangian/parcel/clouds/Templates/ReactingCloud/ReactingCloud.C b/src/lagrangian/parcel/clouds/Templates/ReactingCloud/ReactingCloud.C index a9ea958704..436933b8e1 100644 --- a/src/lagrangian/parcel/clouds/Templates/ReactingCloud/ReactingCloud.C +++ b/src/lagrangian/parcel/clouds/Templates/ReactingCloud/ReactingCloud.C @@ -308,15 +308,6 @@ void Foam::ReactingCloud::evolve() } -template -void Foam::ReactingCloud::autoMap(const polyTopoChangeMap& mapper) -{ - Cloud::autoMap(mapper); - - this->topoChange(); -} - - template void Foam::ReactingCloud::info() { diff --git a/src/lagrangian/parcel/clouds/Templates/ReactingCloud/ReactingCloud.H b/src/lagrangian/parcel/clouds/Templates/ReactingCloud/ReactingCloud.H index 3d0ed1cf5b..456dbd7193 100644 --- a/src/lagrangian/parcel/clouds/Templates/ReactingCloud/ReactingCloud.H +++ b/src/lagrangian/parcel/clouds/Templates/ReactingCloud/ReactingCloud.H @@ -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 diff --git a/src/lagrangian/parcel/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C b/src/lagrangian/parcel/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C index 50e9576927..867ab2af37 100644 --- a/src/lagrangian/parcel/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C +++ b/src/lagrangian/parcel/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C @@ -246,18 +246,6 @@ void Foam::ReactingMultiphaseCloud::evolve() } -template -void Foam::ReactingMultiphaseCloud::autoMap -( - const polyTopoChangeMap& mapper -) -{ - Cloud::autoMap(mapper); - - this->topoChange(); -} - - template void Foam::ReactingMultiphaseCloud::info() { diff --git a/src/lagrangian/parcel/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H b/src/lagrangian/parcel/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H index 99a943ed09..437119379b 100644 --- a/src/lagrangian/parcel/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H +++ b/src/lagrangian/parcel/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H @@ -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 diff --git a/src/lagrangian/parcel/clouds/Templates/ThermoCloud/ThermoCloud.C b/src/lagrangian/parcel/clouds/Templates/ThermoCloud/ThermoCloud.C index fd2bd2d24f..5693211a4a 100644 --- a/src/lagrangian/parcel/clouds/Templates/ThermoCloud/ThermoCloud.C +++ b/src/lagrangian/parcel/clouds/Templates/ThermoCloud/ThermoCloud.C @@ -477,15 +477,6 @@ void Foam::ThermoCloud::evolve() } -template -void Foam::ThermoCloud::autoMap(const polyTopoChangeMap& mapper) -{ - Cloud::autoMap(mapper); - - this->topoChange(); -} - - template void Foam::ThermoCloud::info() { diff --git a/src/lagrangian/parcel/clouds/Templates/ThermoCloud/ThermoCloud.H b/src/lagrangian/parcel/clouds/Templates/ThermoCloud/ThermoCloud.H index 151ded1f38..15158ad4ba 100644 --- a/src/lagrangian/parcel/clouds/Templates/ThermoCloud/ThermoCloud.H +++ b/src/lagrangian/parcel/clouds/Templates/ThermoCloud/ThermoCloud.H @@ -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 diff --git a/src/lagrangian/parcel/fvModels/clouds/clouds.C b/src/lagrangian/parcel/fvModels/clouds/clouds.C index f66ed18631..38b0e26974 100644 --- a/src/lagrangian/parcel/fvModels/clouds/clouds.C +++ b/src/lagrangian/parcel/fvModels/clouds/clouds.C @@ -119,6 +119,14 @@ Foam::fv::clouds::clouds new volScalarField("mu", tRho_()*tCarrierViscosity_().nu()) ) ), + cloudNames_ + ( + dict.lookupOrDefault + ( + "clouds", + parcelCloudList::defaultCloudNames + ) + ), rhoName_(dict.lookupOrDefault("rho", "rho")), UName_(dict.lookupOrDefault("U", "U")), cloudsPtr_ @@ -126,6 +134,7 @@ Foam::fv::clouds::clouds carrierHasThermo_ ? new parcelCloudList ( + cloudNames_, mesh.lookupObject(rhoName_), mesh.lookupObject(UName_), g_, @@ -133,6 +142,7 @@ Foam::fv::clouds::clouds ) : new parcelCloudList ( + cloudNames_, tRho_(), mesh.lookupObject(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) diff --git a/src/lagrangian/parcel/fvModels/clouds/clouds.H b/src/lagrangian/parcel/fvModels/clouds/clouds.H index 92282d7807..65d82f61fb 100644 --- a/src/lagrangian/parcel/fvModels/clouds/clouds.H +++ b/src/lagrangian/parcel/fvModels/clouds/clouds.H @@ -117,6 +117,9 @@ class clouds //- Viscosity field. Valid only if the carrier does not have thermo. tmp tMu_; + //- Names of the clouds + const wordList cloudNames_; + //- Name of the density field const word rhoName_; diff --git a/src/lagrangian/parcel/parcelCloud/ParcelCloud.H b/src/lagrangian/parcel/parcelCloud/ParcelCloud.H index 6126eeb4e9..977a1e5429 100644 --- a/src/lagrangian/parcel/parcelCloud/ParcelCloud.H +++ b/src/lagrangian/parcel/parcelCloud/ParcelCloud.H @@ -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 diff --git a/src/lagrangian/parcel/parcelCloud/parcelCloud.H b/src/lagrangian/parcel/parcelCloud/parcelCloud.H index 6a3a1d542b..a15a8f1612 100644 --- a/src/lagrangian/parcel/parcelCloud/parcelCloud.H +++ b/src/lagrangian/parcel/parcelCloud/parcelCloud.H @@ -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 diff --git a/src/lagrangian/parcel/parcelCloudList/parcelCloudList.C b/src/lagrangian/parcel/parcelCloud/parcelCloudList.C similarity index 73% rename from src/lagrangian/parcel/parcelCloudList/parcelCloudList.C rename to src/lagrangian/parcel/parcelCloud/parcelCloudList.C index 2befdf3a8f..331e45507b 100644 --- a/src/lagrangian/parcel/parcelCloudList/parcelCloudList.C +++ b/src/lagrangian/parcel/parcelCloud/parcelCloudList.C @@ -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 -void Foam::parcelCloudList::initialise -( - const Args& ... args -) +Foam::wordList Foam::parcelCloudList::cloudNames(const objectRegistry& db) { - typeIOobject cloudsIO + typeIOobject 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 cloudIO + ( + defaultCloudName + "Properties", + db.time().constant(), + db, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (cloudIO.headerOk()) { - typeIOobject 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(), 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(), + 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(), - 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::parcelCloudList::theta() const ( volScalarField::New ( - cloudsName + ":theta", + cloudNamesName + ":theta", mesh_, dimensionedScalar(dimless, 0), extrapolatedCalculatedFvPatchScalarField::typeName @@ -168,7 +194,7 @@ Foam::tmp Foam::parcelCloudList::UTrans() const ( volVectorField::Internal::New ( - cloudsName + ":UTrans", + cloudNamesName + ":UTrans", mesh_, dimensionedVector(dimMass*dimVelocity, Zero) ) @@ -187,7 +213,7 @@ Foam::tmp Foam::parcelCloudList::UCoeff() const ( volScalarField::Internal::New ( - cloudsName + ":UCoeff", + cloudNamesName + ":UCoeff", mesh_, dimensionedScalar(dimMass, Zero) ) @@ -220,7 +246,7 @@ Foam::tmp Foam::parcelCloudList::hsTrans() const ( volScalarField::Internal::New ( - cloudsName + ":hsTrans", + cloudNamesName + ":hsTrans", mesh_, dimensionedScalar(dimEnergy, Zero) ) @@ -239,7 +265,7 @@ Foam::tmp Foam::parcelCloudList::hsCoeff() const ( volScalarField::Internal::New ( - cloudsName + ":hsCoeff", + cloudNamesName + ":hsCoeff", mesh_, dimensionedScalar(dimEnergy/dimTemperature, Zero) ) @@ -258,7 +284,7 @@ Foam::tmp 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::parcelCloudList::ap() const ( volScalarField::New ( - cloudsName + ":radiation:ap", + cloudNamesName + ":radiation:ap", mesh_, dimensionedScalar(dimless/dimLength, 0) ) @@ -297,7 +323,7 @@ Foam::tmp Foam::parcelCloudList::sigmap() const ( volScalarField::New ( - cloudsName + ":radiation:sigmap", + cloudNamesName + ":radiation:sigmap", mesh_, dimensionedScalar(dimless/dimLength, 0) ) @@ -345,7 +371,7 @@ Foam::tmp 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) diff --git a/src/lagrangian/parcel/parcelCloudList/parcelCloudList.H b/src/lagrangian/parcel/parcelCloud/parcelCloudList.H similarity index 68% rename from src/lagrangian/parcel/parcelCloudList/parcelCloudList.H rename to src/lagrangian/parcel/parcelCloud/parcelCloudList.H index 80575ee643..9b562e81f7 100644 --- a/src/lagrangian/parcel/parcelCloudList/parcelCloudList.H +++ b/src/lagrangian/parcel/parcelCloud/parcelCloudList.H @@ -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 - 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 diff --git a/src/lagrangian/parcel/parcelCloud/parcelClouds.C b/src/lagrangian/parcel/parcelCloud/parcelClouds.C new file mode 100644 index 0000000000..6a316e6ca8 --- /dev/null +++ b/src/lagrangian/parcel/parcelCloud/parcelClouds.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#include "parcelClouds.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::parcelClouds::parcelClouds +( + const fvMesh& mesh, + const volScalarField& rho, + const volVectorField& U, + const volScalarField& mu, + const dimensionedVector& g +) +: + MeshObject(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(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); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/parcel/parcelCloud/parcelClouds.H b/src/lagrangian/parcel/parcelCloud/parcelClouds.H new file mode 100644 index 0000000000..f306abe3a2 --- /dev/null +++ b/src/lagrangian/parcel/parcelCloud/parcelClouds.H @@ -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 . + +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, + 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; + + +public: + + // Constructors + + //- Disallow default bitwise copy construction + parcelClouds(const parcelClouds&) = delete; + + //- Inherit the base New method + using MeshObject::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 + +// ************************************************************************* // diff --git a/tutorials/modules/multicomponentFluid/simplifiedSiwek/constant/clouds b/tutorials/modules/multicomponentFluid/simplifiedSiwek/constant/clouds deleted file mode 100644 index 12cb2deccc..0000000000 --- a/tutorials/modules/multicomponentFluid/simplifiedSiwek/constant/clouds +++ /dev/null @@ -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 -) - -// ************************************************************************* // diff --git a/tutorials/modules/multicomponentFluid/simplifiedSiwek/constant/fvModels b/tutorials/modules/multicomponentFluid/simplifiedSiwek/constant/fvModels index b13d523212..2e3ad0b14f 100644 --- a/tutorials/modules/multicomponentFluid/simplifiedSiwek/constant/fvModels +++ b/tutorials/modules/multicomponentFluid/simplifiedSiwek/constant/fvModels @@ -23,6 +23,7 @@ clouds { type clouds; libs ("liblagrangianParcel.so" "liblagrangianParcelTurbulence.so"); + clouds (coalCloud limestoneCloud); } radiation