From 7edfb4d08db49cff12caa5aeeff1d0bdad666299 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 17 May 2015 14:57:33 +0100 Subject: [PATCH] faceSource: Corrected handling of totalArea in parallel Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1693 --- .../field/fieldValues/cellSource/cellSource.C | 10 +++++++--- .../field/fieldValues/cellSource/cellSource.H | 3 +++ .../field/fieldValues/faceSource/faceSource.C | 10 +++++++--- .../field/fieldValues/faceSource/faceSource.H | 3 +++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C index dbc7ff73a5..f672579b83 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C @@ -142,10 +142,12 @@ void Foam::fieldValues::cellSource::initialise(const dictionary& dict) return; } + volume_ = volume(); + Info<< type() << " " << name_ << ":" << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " total cells = " << nCells_ << nl - << " total volume = " << gSum(filterField(mesh().V())) + << " total volume = " << volume_ << nl << endl; if (dict.readIfPresent("weightField", weightFieldName_)) @@ -164,7 +166,7 @@ void Foam::fieldValues::cellSource::writeFileHeader(const label i) writeCommented(file(), "Cells : "); file() << nCells_ << endl; writeCommented(file(), "Volume : "); - file() << volume() << endl; + file() << volume_ << endl; writeCommented(file(), "Time"); if (writeVolume_) @@ -238,10 +240,12 @@ void Foam::fieldValues::cellSource::write() if (writeVolume_) { + volume_ = volume(); if (Pstream::master()) { - file() << tab << volume(); + file() << tab << volume_; } + Info(log_)<< " total volume = " << volume_ << endl; } forAll(fields_, i) diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H index a945e91b97..a02584e769 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H @@ -192,6 +192,9 @@ protected: //- Weight field name - only used for opWeightedAverage mode word weightFieldName_; + //- Volume of the cellSource + scalar volume_; + //- Optionally write the volume of the cellSource bool writeVolume_; diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C index 1fdfa478e2..924b3cdc22 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C @@ -447,10 +447,12 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict) surfacePtr_().update(); } + totalArea_ = totalArea(); + Info<< type() << " " << name_ << ":" << nl << " total faces = " << nFaces_ << nl - << " total area = " << totalArea() + << " total area = " << totalArea_ << nl; if (dict.readIfPresent("weightField", weightFieldName_)) @@ -534,7 +536,7 @@ void Foam::fieldValues::faceSource::writeFileHeader(const label i) writeCommented(file(), "Faces : "); file() << nFaces_ << endl; writeCommented(file(), "Area : "); - file() << totalArea() << endl; + file() << totalArea_ << endl; writeCommented(file(), "Time"); if (writeArea_) @@ -694,10 +696,12 @@ void Foam::fieldValues::faceSource::write() if (writeArea_) { + totalArea_ = totalArea(); if (Pstream::master()) { - file() << tab << totalArea(); + file() << tab << totalArea_; } + Info(log_)<< " total area = " << totalArea_ << endl; } // construct weight field. Note: zero size means weight = 1 diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H index 9932b82015..87403aadb7 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H @@ -258,6 +258,9 @@ protected: //- Scale factor - optional scalar scaleFactor_; + //- Total area of the faceSource + scalar totalArea_; + //- Optionally write the area of the faceSource bool writeArea_;