/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2022 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 "lagrangianReconstructor.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); // constant(true), zero(true)
argList::noParallel();
#include "addAllRegionOptions.H"
argList::addVerboseOption("Additional verbosity");
argList::addOption
(
"fields",
"wordRes",
"Specify single or multiple fields to reconstruct (all by default)."
" Eg, 'T' or '(p T U \"alpha.*\")'"
);
argList::addBoolOption
(
"no-fields", // noFields
"Skip reconstructing fields"
);
argList::addOptionCompat("no-fields", {"noFields", 2106});
argList::addOption
(
"lagrangianFields",
"wordRes",
"Specify single or multiple lagrangian fields to reconstruct"
" (all by default)."
" Eg, '(U d)'"
" - Positions are always included."
);
argList::addBoolOption
(
"no-lagrangian", // noLagrangian
"Skip reconstructing lagrangian positions and fields"
);
argList::addOptionCompat("no-lagrangian", {"noLagrangian", 2106});
argList::addBoolOption
(
"no-sets",
"Skip reconstructing cellSets, faceSets, pointSets"
);
argList::addOptionCompat("no-sets", {"noSets", 2106});
argList::addBoolOption
(
"newTimes",
"Only reconstruct new times (i.e. that do not exist already)"
);
#include "setRootCase.H"
#include "createTime.H"
const bool doFields = !args.found("no-fields");
wordRes selectedFields;
if (doFields)
{
args.readListIfPresent("fields", selectedFields);
}
else
{
Info<< "Skipping reconstructing fields";
if (args.found("fields"))
{
Info<< ". Ignore -fields option";
}
Info<< nl << endl;
}
const bool doFiniteArea = !args.found("no-finite-area");
if (!doFiniteArea)
{
Info<< "Skipping reconstructing finiteArea mesh/fields"
<< nl << endl;
}
const bool doLagrangian = !args.found("no-lagrangian");
wordRes selectedLagrangianFields;
if (doLagrangian)
{
args.readListIfPresent
(
"lagrangianFields", selectedLagrangianFields
);
}
else
{
Info<< "Skipping reconstructing lagrangian positions/fields";
if (args.found("lagrangianFields"))
{
Info<< ". Ignore -lagrangianFields option";
}
Info<< nl << endl;
}
const bool doReconstructSets = !args.found("no-sets");
if (!doReconstructSets)
{
Info<< "Skipping reconstructing cellSets, faceSets and pointSets"
<< nl << endl;
}
const bool newTimes = args.found("newTimes");
// Get region names
#include "getAllRegionOptions.H"
// Determine the processor count
label nProcs{0};
if (regionNames.empty())
{
FatalErrorInFunction
<< "No regions specified or detected."
<< exit(FatalError);
}
else if (regionNames[0] == polyMesh::defaultRegion)
{
nProcs = fileHandler().nProcs(args.path());
}
else
{
nProcs = fileHandler().nProcs(args.path(), regionNames[0]);
if (regionNames.size() == 1)
{
Info<< "Using region: " << regionNames[0] << nl << endl;
}
}
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