View Issue Details

IDProjectCategoryView StatusLast Update
0004104OpenFOAMBugpublic2024-07-01 09:53
Reporterbonnymei Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Versiondev 
Fixed in Version11 
Summary0004104: setFields excludes the last boundary field in the boundary list
DescriptionsetFields commands sets the boundaries except the last boundary in the list as in the attached figures, midPlane1 and midPlane2.

After some inspection of the case, I found that this behavior occurred when the last boundary was set to conditions other than symmetry, symmetryPlane, zeorGradient, wall.


in the code from line 241 - 249 of setFields.C,

        label nNonProcPatches = 0;
        forAll(fieldBf, patchi)
        {
            nNonProcPatches = patchi;
            if (isA<processorFvPatch>(mesh.boundary()[patchi]))
            {
                break;
            }
        }


the primary culprit is the variable 'nNonProcPatches', which name is a bit confusing since it is representing the last index of the list instead of total number of boundaries.
the variable is updated to the last boundary index in the following loop until it find processor type patch in case of parallel run.

in the line of 260,

        labelList nonProcPatchNChangedFaces(nNonProcPatches, 0);

the size of array 'nonProcPatchNChangedFaces' is set to nNonProcPatches.
Since nNonProcPatches is one short of the total count and the size of the array is set to the total count,
It should be modified as follows:

        labelList nonProcPatchNChangedFaces(nNonProcPatches+1, 0);

in the line of 284,

      if (patches[i] >= nNonProcPatches)

the statement is checking if the patch index is over the last index.
But nNonProcPatches is not the total count but the last index and the statement should be modified as follows:

      if (patches[i] > nNonProcPatches)

I attached the modification for your reference.
Steps To Reproducetry setFields with any cases.

if the last boundary type is not symmetry, symmetryPlane, zeroGradient, wall, the boundary would not be affected by the setFields command.

Test with the attached tar ball case by changing boundary type.
TagsNo tags attached.

Activities

bonnymei

2024-06-28 06:47

reporter  

patch.diff (870 bytes)   
--- /opt/HPC/apps/FOAM/OpenFOAM/OpenFOAM-dev/applications/utilities/preProcessing/setFields/setFields.C	2024-01-29 07:59:34.355475757 +0900
+++ setFields.C	2024-06-28 12:53:12.446137257 +0900
@@ -257,7 +257,7 @@
 
         // Loop selected faces and set values in the copied boundary field
         bool haveWarnedInternal = false, haveWarnedProc = false;
-        labelList nonProcPatchNChangedFaces(nNonProcPatches, 0);
+        labelList nonProcPatchNChangedFaces(nNonProcPatches+1, 0);
         forAll(selectedFaces, i)
         {
             const label facei = selectedFaces[i];
@@ -281,7 +281,7 @@
 
                 forAll(patches, i)
                 {
-                    if (patches[i] >= nNonProcPatches)
+                    if (patches[i] > nNonProcPatches)
                     {
                         if (!haveWarnedProc)
                         {
patch.diff (870 bytes)   
setFieldsTest.tar.gz (2,912 bytes)
midPlane1.png (20,564 bytes)   
midPlane1.png (20,564 bytes)   
midPlane2.png (33,298 bytes)   
midPlane2.png (33,298 bytes)   

henry

2024-07-01 09:53

manager   ~0013289

Thanks for the bug-report and detailed analysis.
Resolved in OpenFOAM-11 by commit 9cbf94f3339dd49286633b303c4155fd10ea8200
Resolved in OpenFOAM-dev by commit b366424bda15a66d18d62ea04066c5d11d7c2e5a

Issue History

Date Modified Username Field Change
2024-06-28 06:47 bonnymei New Issue
2024-06-28 06:47 bonnymei File Added: patch.diff
2024-06-28 06:47 bonnymei File Added: setFieldsTest.tar.gz
2024-06-28 06:47 bonnymei File Added: midPlane1.png
2024-06-28 06:47 bonnymei File Added: midPlane2.png
2024-07-01 09:53 henry Assigned To => henry
2024-07-01 09:53 henry Status new => resolved
2024-07-01 09:53 henry Resolution open => fixed
2024-07-01 09:53 henry Fixed in Version => 11
2024-07-01 09:53 henry Note Added: 0013289