View Issue Details

IDProjectCategoryView StatusLast Update
0003979OpenFOAMPatchpublic2023-05-15 16:17
Reportercgoessni Assigned Tohenry  
PrioritylowSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Versiondev 
Fixed in Versiondev 
Summary0003979: fvCellSet::writeFileHeader() does not correctly write number of cells in case of parallel run
DescriptionfvCellSet does not correctly write the number of cells of a cell set in the log file in case of a parallel run.

The problem is visible when running tutorials/modules/compressibleVoF/ballValve. The mesh has 30400 cells. However, inside postProcessing/cavitationVolume/0/volFieldValue.dat, which is the output of a function that integrates the water vapour fraction over all cells, the second line suggests that the mesh has only 7600 cells.

Attached diff would fix the small bug for me.
TagsNo tags attached.

Activities

cgoessni

2023-05-15 14:26

reporter  

diff_fvCellSet.txt (1,966 bytes)   
diff --git a/src/finiteVolume/fvMesh/fvCellSet/fvCellSet.C b/src/finiteVolume/fvMesh/fvCellSet/fvCellSet.C
index 7dfdcbf..31429ff 100644
--- a/src/finiteVolume/fvMesh/fvCellSet/fvCellSet.C
+++ b/src/finiteVolume/fvMesh/fvCellSet/fvCellSet.C
@@ -40,10 +40,10 @@ void Foam::fvCellSet::setV()
         V_ += mesh_.V()[cells[i]];
     }
     reduce(V_, sumOp<scalar>());
+    nCells_ = returnReduce(cells.size(), sumOp<label>());
 
     Info<< indent
-        << "- selected " << returnReduce(cells.size(), sumOp<label>())
-        << " cell(s) with volume " << V_ << endl;
+        << "- selected " << nCells_ << " cell(s) with volume " << V_ << endl;
 
     Info<< decrIndent;
 }
@@ -60,8 +60,8 @@ void Foam::fvCellSet::writeFileHeader
     wf.writeCommented(file, "Selection");
     file<< setw(1) << ':' << setw(1) << ' '
         << selectionTypeNames[selectionType()] << " " << cellSetName() << endl;
-    wf.writeHeaderValue(file, "Cells", nCells());
-    wf.writeHeaderValue(file, "Volume", V());
+    wf.writeHeaderValue(file, "Cells", nCells_);
+    wf.writeHeaderValue(file, "Volume", V_);
 }
 
 
@@ -71,7 +71,8 @@ Foam::fvCellSet::fvCellSet(const fvMesh& mesh)
 :
     polyCellSet(mesh),
     mesh_(mesh),
-    V_(gSum(mesh_.V()))
+    V_(gSum(mesh_.V())),
+    nCells_(returnReduce(cells().size(), sumOp<label>()))
 {}
 
 
@@ -79,7 +80,8 @@ Foam::fvCellSet::fvCellSet(const fvMesh& mesh, const dictionary& dict)
 :
     polyCellSet(mesh, dict),
     mesh_(mesh),
-    V_(NaN)
+    V_(NaN),
+    nCells_(-1)
 {
     setV();
 }
diff --git a/src/finiteVolume/fvMesh/fvCellSet/fvCellSet.H b/src/finiteVolume/fvMesh/fvCellSet/fvCellSet.H
index 0647d07..8157a83 100644
--- a/src/finiteVolume/fvMesh/fvCellSet/fvCellSet.H
+++ b/src/finiteVolume/fvMesh/fvCellSet/fvCellSet.H
@@ -95,6 +95,9 @@ class fvCellSet
         //- Sum of cell volumes
         mutable scalar V_;
 
+        //- Number of cells
+        mutable label nCells_;
+
 
     // Private functions
 
diff_fvCellSet.txt (1,966 bytes)   

henry

2023-05-15 16:17

manager   ~0013015

Resolved by commit b2d74bfdb4f7fc6b4ee3072694fe696f44e5c69b

Issue History

Date Modified Username Field Change
2023-05-15 14:26 cgoessni New Issue
2023-05-15 14:26 cgoessni File Added: diff_fvCellSet.txt
2023-05-15 16:17 henry Assigned To => henry
2023-05-15 16:17 henry Status new => resolved
2023-05-15 16:17 henry Resolution open => fixed
2023-05-15 16:17 henry Fixed in Version => dev
2023-05-15 16:17 henry Note Added: 0013015