CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

How to access scalarField values correctly

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 22, 2021, 13:22
Lightbulb How to access scalarField values correctly
  #1
New Member
 
ChenYe
Join Date: Feb 2012
Posts: 5
Rep Power: 14
chenye1717 is on a distinguished road
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.
chenye1717 is offline   Reply With Quote

Old   December 13, 2021, 13:55
Smile
  #2
New Member
 
ChenYe
Join Date: Feb 2012
Posts: 5
Rep Power: 14
chenye1717 is on a distinguished road
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!
chenye1717 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 23:33.