From 0adb707ec7b4ebd8763dcbd1c20f7ae0f4ee0575 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Wed, 20 Nov 2013 16:03:02 +0000 Subject: [PATCH] ENH: reconstructParMesh: write cellDist field to 0 --- .../reconstructParMesh/reconstructParMesh.C | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C index b223446c26e..00efb6f237f 100644 --- a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C +++ b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C @@ -650,32 +650,45 @@ int main(int argc, char *argv[]) << " for use in manual decomposition." << endl; - // Write as volScalarField for postprocessing. - volScalarField cellDist - ( - IOobject + // Write as volScalarField for postprocessing. Change time to 0 + // if was 'constant' + { + const scalar oldTime = runTime.value(); + const label oldIndex = runTime.timeIndex(); + if (runTime.timeName() == runTime.constant() && oldIndex == 0) + { + runTime.setTime(0, oldIndex+1); + } + + volScalarField cellDist ( - "cellDist", - runTime.timeName(), + IOobject + ( + "cellDist", + runTime.timeName(), + masterMesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), masterMesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - masterMesh, - dimensionedScalar("cellDist", dimless, 0), - zeroGradientFvPatchScalarField::typeName - ); + dimensionedScalar("cellDist", dimless, 0), + zeroGradientFvPatchScalarField::typeName + ); - forAll(cellDecomposition, cellI) - { - cellDist[cellI] = cellDecomposition[cellI]; - } + forAll(cellDecomposition, cellI) + { + cellDist[cellI] = cellDecomposition[cellI]; + } - cellDist.write(); + cellDist.write(); - Info<< nl << "Wrote decomposition as volScalarField to " - << cellDist.name() << " for use in postprocessing." - << endl; + Info<< nl << "Wrote decomposition as volScalarField to " + << cellDist.name() << " for use in postprocessing." + << endl; + + // Restore time + runTime.setTime(oldTime, oldIndex); + } } } -- GitLab