diff --git a/modules/avalanche b/modules/avalanche index fdf0f40d7a..3e147ba27a 160000 --- a/modules/avalanche +++ b/modules/avalanche @@ -1 +1 @@ -Subproject commit fdf0f40d7a24c7b08c255ba2ee05ecbb847cc264 +Subproject commit 3e147ba27a59e6dc008c7d32cbebfd29f58b5a36 diff --git a/src/functionObjects/utilities/Make/files b/src/functionObjects/utilities/Make/files index a274f616e1..c64ef4e531 100644 --- a/src/functionObjects/utilities/Make/files +++ b/src/functionObjects/utilities/Make/files @@ -2,6 +2,8 @@ abort/abort.C codedFunctionObject/codedFunctionObject.C +areaWrite/areaWrite.C + ensightWrite/ensightWrite.C ensightWrite/ensightWriteUpdate.C diff --git a/src/functionObjects/utilities/Make/options b/src/functionObjects/utilities/Make/options index 67eeb1ac21..5ba64ac1d6 100644 --- a/src/functionObjects/utilities/Make/options +++ b/src/functionObjects/utilities/Make/options @@ -5,6 +5,7 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/conversion/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/ODE/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ @@ -16,6 +17,7 @@ LIB_LIBS = \ -lmeshTools \ -lconversion \ -lsampling \ + -lsurfMesh \ -ldynamicMesh \ -lfluidThermophysicalModels \ -lcompressibleTransportModels \ diff --git a/src/functionObjects/utilities/areaWrite/areaWrite.C b/src/functionObjects/utilities/areaWrite/areaWrite.C new file mode 100644 index 0000000000..9f44cf4be2 --- /dev/null +++ b/src/functionObjects/utilities/areaWrite/areaWrite.C @@ -0,0 +1,396 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 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 "areaWrite.H" +#include "polySurface.H" + +#include "fvMesh.H" +#include "mapPolyMesh.H" +#include "areaFields.H" +#include "HashOps.H" +#include "Time.H" +#include "UIndirectList.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(areaWrite, 0); + + addToRunTimeSelectionTable + ( + functionObject, + areaWrite, + dictionary + ); +} + +Foam::scalar Foam::areaWrite::mergeTol_ = 1e-10; + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::areaWrite::areaWrite +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + functionObjects::fvMeshFunctionObject(name, runTime, dict), + loadFromFiles_(false), + verbose_(false), + outputPath_ + ( + time_.globalPath()/functionObject::outputPrefix/name + ), + selectAreas_(), + fieldSelection_(), + meshes_(), + surfaces_(nullptr), + writers_() +{ + outputPath_.clean(); // Remove unneeded ".." + + read(dict); +} + + +Foam::areaWrite::areaWrite +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + functionObjects::fvMeshFunctionObject(name, obr, dict), + loadFromFiles_(loadFromFiles), + verbose_(false), + outputPath_ + ( + time_.globalPath()/functionObject::outputPrefix/name + ), + selectAreas_(), + fieldSelection_(), + meshes_(), + surfaces_(nullptr), + writers_() +{ + outputPath_.clean(); // Remove unneeded ".." + + read(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::areaWrite::verbose(const bool verbosity) +{ + verbose_ = verbosity; +} + + +bool Foam::areaWrite::read(const dictionary& dict) +{ + fvMeshFunctionObject::read(dict); + + writers_.clear(); + selectAreas_.clear(); + fieldSelection_.clear(); + + surfaces_.reset + ( + new objectRegistry + ( + IOobject + ( + "::areaWrite::", + obr_.time().constant(), + obr_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ) + ) + ); + + verbose_ = dict.lookupOrDefault("verbose", false); + + // All possible area meshes for the given fvMesh region + meshes_ = obr().lookupClass(); + + dict.readIfPresent("areas", selectAreas_); + + if (selectAreas_.empty()) + { + word areaName; + if (!dict.readIfPresent("area", areaName)) + { + wordList available = obr().sortedNames(); + + if (available.size()) + { + areaName = available.first(); + } + } + + if (!areaName.empty()) + { + selectAreas_.resize(1); + selectAreas_.first() = areaName; + } + } + + // Restrict to specified meshes + meshes_.filterKeys(selectAreas_); + + dict.readEntry("fields", fieldSelection_); + fieldSelection_.uniq(); + + + // Surface writer type and format options + const word writerType = dict.get("surfaceFormat"); + + const dictionary writerOptions + ( + dict.subOrEmptyDict("formatOptions").subOrEmptyDict(writerType) + ); + + for (const word& areaName : meshes_.keys()) + { + // Define surface writer, but do NOT yet attach a surface + + auto surfWriter = surfaceWriter::New(writerType, writerOptions); + + // Use outputDir/TIME/surface-name + surfWriter->useTimeDir() = true; + surfWriter->verbose() = verbose_; + + writers_.set(areaName, surfWriter); + } + + // Ensure all surfaces and merge information are expired + expire(); + + return true; +} + + +bool Foam::areaWrite::execute() +{ + return true; +} + + +bool Foam::areaWrite::write() +{ + // Just needed for warnings + wordList allFields; + HashTable selected; + DynamicList