diff --git a/src/functionObjects/lagrangian/Make/files b/src/functionObjects/lagrangian/Make/files index 921ca2d707..c7feb02e33 100644 --- a/src/functionObjects/lagrangian/Make/files +++ b/src/functionObjects/lagrangian/Make/files @@ -1,3 +1,4 @@ +dataCloud/dataCloud.C cloudInfo/cloudInfo.C icoUncoupledKinematicCloud/icoUncoupledKinematicCloud.C dsmcFields/dsmcFields.C diff --git a/src/functionObjects/lagrangian/dataCloud/dataCloud.C b/src/functionObjects/lagrangian/dataCloud/dataCloud.C new file mode 100644 index 0000000000..53267ab025 --- /dev/null +++ b/src/functionObjects/lagrangian/dataCloud/dataCloud.C @@ -0,0 +1,227 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ 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 "dataCloud.H" +#include "Cloud.H" +#include "dictionary.H" +#include "fvMesh.H" +#include "pointList.H" +#include "OFstream.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(dataCloud, 0); + addToRunTimeSelectionTable(functionObject, dataCloud, dictionary); +} +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::dataCloud::writeCloud +( + const fileName& outputName, + const word& cloudName +) +{ + const auto* objPtr = mesh_.findObject(cloudName); + if (!objPtr) + { + return false; + } + + objectRegistry obrTmp + ( + IOobject + ( + "tmp::dataCloud::" + cloudName, + mesh_.time().constant(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ) + ); + + objPtr->writeObjects(obrTmp); + + const auto* pointsPtr = obrTmp.findObject("position"); + + if (!pointsPtr) + { + // This should be impossible + return false; + } + + // Total number of parcels on all processes + label nTotParcels = pointsPtr->size(); + reduce(nTotParcels, sumOp