|
[Sponsors] |
November 22, 2021, 13:22 |
How to access scalarField values correctly
|
#1 |
New Member
ChenYe
Join Date: Feb 2012
Posts: 5
Rep Power: 14 |
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. |
|
December 13, 2021, 13:55 |
|
#2 |
New Member
ChenYe
Join Date: Feb 2012
Posts: 5
Rep Power: 14 |
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! |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
TimeVaryingMappedFixedValue | irishdave | OpenFOAM Running, Solving & CFD | 32 | June 16, 2021 06:55 |
How to calculate T+gradT where T is volScalarField and gradT is scalarField ??? | Zhiheng Wang | OpenFOAM Programming & Development | 4 | May 28, 2016 13:51 |
using chemkin | JMDag2004 | OpenFOAM Pre-Processing | 2 | March 8, 2016 22:38 |
max node values exceed max element values in contour plot | jason_t | FLUENT | 0 | August 19, 2009 11:32 |
exact face values | RubenG | Main CFD Forum | 0 | June 22, 2009 11:09 |