/*---------------------------------------------------------------------------*\ ========= | \\ / 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