/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- 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 . Application reconstructPar Group grpParallelUtilities Description Reconstructs fields of a case that is decomposed for parallel execution of OpenFOAM. \*---------------------------------------------------------------------------*/ #include "argList.H" #include "timeSelector.H" #include "fvCFD.H" #include "IOobjectList.H" #include "processorMeshes.H" #include "regionProperties.H" #include "fvFieldReconstructor.H" #include "pointFieldReconstructor.H" #include "reconstructLagrangian.H" #include "faCFD.H" #include "faMesh.H" #include "processorFaMeshes.H" #include "faFieldReconstructor.H" #include "cellSet.H" #include "faceSet.H" #include "pointSet.H" #include "hexRef8Data.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // bool haveAllTimes ( const wordHashSet& masterTimeDirSet, const instantList& timeDirs ) { // Loop over all times for (const instant& t : timeDirs) { if (!masterTimeDirSet.found(t.name())) { return false; } } return true; } int main(int argc, char *argv[]) { argList::addNote ( "Reconstruct fields of a parallel case" ); // Enable -constant ... if someone really wants it // Enable -withZero to prevent accidentally trashing the initial fields timeSelector::addOptions(true, true); argList::noParallel(); #include "addRegionOption.H" argList::addBoolOption ( "allRegions", "operate on all regions in regionProperties" ); argList::addOption ( "fields", "list", "specify a list of fields to be reconstructed. Eg, '(U T p)' - " "regular expressions not currently supported" ); argList::addBoolOption ( "noFields", "skip reconstructing fields" ); argList::addOption ( "lagrangianFields", "list", "specify a list of lagrangian fields to be reconstructed. Eg, '(U d)' -" "regular expressions not currently supported, " "positions always included." ); argList::addBoolOption ( "noLagrangian", "skip reconstructing lagrangian positions and fields" ); argList::addBoolOption ( "noSets", "skip reconstructing cellSets, faceSets, pointSets" ); argList::addBoolOption ( "newTimes", "only reconstruct new times (i.e. that do not exist already)" ); #include "setRootCase.H" #include "createTime.H" wordHashSet selectedFields; args.readIfPresent("fields", selectedFields); const bool noFields = args.found("noFields"); if (noFields) { Info<< "Skipping reconstructing fields" << nl << endl; } const bool noLagrangian = args.found("noLagrangian"); if (noLagrangian) { Info<< "Skipping reconstructing lagrangian positions and fields" << nl << endl; } const bool noReconstructSets = args.found("noSets"); if (noReconstructSets) { Info<< "Skipping reconstructing cellSets, faceSets and pointSets" << nl << endl; } wordHashSet selectedLagrangianFields; if (args.readIfPresent("lagrangianFields", selectedLagrangianFields)) { if (noLagrangian) { FatalErrorInFunction << "Cannot specify noLagrangian and lagrangianFields " << "options together." << exit(FatalError); } } const bool newTimes = args.found("newTimes"); const bool allRegions = args.found("allRegions"); wordList regionNames; wordList regionDirs; if (allRegions) { Info<< "Reconstructing all regions in regionProperties" << nl << endl; regionProperties rp(runTime); wordHashSet names; forAllConstIters(rp, iter) { names.insertMany(iter.object()); } regionNames = names.sortedToc(); regionDirs = regionNames; } else { regionNames = {fvMesh::defaultRegion}; if (args.readIfPresent("region", regionNames[0])) { regionDirs = regionNames; } else { regionDirs = {word::null}; } } // Determine the processor count label nProcs = fileHandler().nProcs(args.path(), regionDirs[0]); if (!nProcs) { FatalErrorInFunction << "No processor* directories found" << exit(FatalError); } // Warn fileHandler of number of processors const_cast(fileHandler()).setNProcs(nProcs); // Create the processor databases PtrList