How to access scalarField values correctly
Dear all,
I am new to OpenFOAM and I have met a problem of accessing the scalarField element values in my code. Please help to take a look. I used a 3D fluent mesh file generated by ICEM and concerted to OpenFOAM by 'Fluent3DMeshToFoam'. The simulation works well but I want to also output the surface element area at the inlet. So I tried to modify ./0/U using 'codedFixedValue'. According to some online resources, I have done these: const fvPatch& boundaryPatch = patch(); const fvBoundaryMesh& boundaryMesh = boundaryPatch.boundaryMesh(); const fvMesh& mesh = boundaryMesh.mesh(); label patchID = mesh.boundaryMesh().findPatchID("INLET_R"); const surfaceScalarField& magSf = mesh.magSf(); const scalarField& magSf0 = magSf.boundaryField()[patchID]; As you may see, I have found the patchID of the particular inlet I am looking at and the value of patchID is correct. My question is how can I output the values in either magSf or magSf0 one by one? I have tried to output the sum of both magSf and magSf0 by 'gSum(magSf.boundaryField()[patchID])' and 'gSum(magSf0)'. The values are both correct. I tried to use: forAll(magSf.boundaryField()[patchID],ii) { Info << "ii "<<ii<<" Area "<<magSf.boundaryField()[patchID][ii]<<endl; } But it never outputs. Could you guys help to find out the reason? Thanks, and best regards. |
Hi all,
This issue has been fixed. The problem is caused by the inconsistent mesh information between fluent mesh and the initial simulation file of ./constant/polyMesh/boundary. Thanks! |
All times are GMT -4. The time now is 21:08. |