From 14a39405c22873036e5c11c8028c9d1a03173666 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 17 Oct 2018 17:37:23 +0200 Subject: [PATCH] ENH: simple dataCloud function object (issue #1044) - writes positions and a single field (eg, diameter) in plain ASCII files, suitable for importing in a spreadsheet or manipulation with scripting tools. - code integrated from https://develop.openfoam.com/Community/OpenFOAM-addOns --- src/functionObjects/lagrangian/Make/files | 1 + .../lagrangian/dataCloud/dataCloud.C | 227 ++++++++++++++++++ .../lagrangian/dataCloud/dataCloud.H | 180 ++++++++++++++ .../lagrangian/dataCloud/dataCloudTemplates.C | 130 ++++++++++ .../simplifiedSiwek/system/controlDict | 1 + .../simplifiedSiwek/system/dataCloud | 13 + 6 files changed, 552 insertions(+) create mode 100644 src/functionObjects/lagrangian/dataCloud/dataCloud.C create mode 100644 src/functionObjects/lagrangian/dataCloud/dataCloud.H create mode 100644 src/functionObjects/lagrangian/dataCloud/dataCloudTemplates.C create mode 100644 tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/dataCloud 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