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

Accessing local cell index with global cell index in functionObject

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   May 16, 2021, 16:53
Default Accessing local cell index with global cell index in functionObject
  #1
Member
 
Join Date: Feb 2020
Posts: 90
Rep Power: 6
Shibi is on a distinguished road
Hello to all,

In a functionObject I am coding, I need to access the values of pressure of cellID {20, 70, 30, 50, 90}, in this order.


I using a 2D square domain with 10x10 cells for testing decomposed in 2 processors.


I have the following code.

Code:
   List<scalar> cellIds{20, 70, 30, 50, 90};
   List<scalar> pValues(cellIds.size() );

   const volScalarField& sField = lookupObject<volScalarField>("p");

    forAll(cellIds, cellI)
    {
          pValues[cellI] = sField [ cellIds [cellI] ];

    }
In serial, this will run without a problem. In parallel the domain is decomposed into 50 cells for each processor. So, when I try to access
sField[70], it will give me the following error:


Code:
[1] 
[1] 
[1] --> FOAM FATAL ERROR: (openfoam-2012)
[1] index 70 out of range [0,50]
[1] 
[1]     From void Foam::UList<T>::checkIndex(Foam::label) const [with T = double; Foam::label = int]
[1]     in file /home/pc/OpenFOAM/OpenFOAM-v2012/src/OpenFOAM/lnInclude/UListI.H at line 138.
[1] 
FOAM parallel run aborting
[1] 
[0] 
[0] 
[0] --> FOAM FATAL ERROR: (openfoam-2012)
[0] index 70 out of range [0,50]
[0] 
[0]     From void Foam::UList<T>::checkIndex(Foam::label) const [with T = double; Foam::label = int]
[0]     in file /home/pc/OpenFOAM/OpenFOAM-v2012/src/OpenFOAM/lnInclude/UListI.H at line 138.
[0] 
FOAM parallel run aborting





Is it possible of access the local cellID on each processor based on the global cellID?


Any builtin function to do this?


Best Regards

Shibi is offline   Reply With Quote

 


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
time step continuity problem in VAWT simulation lpz_michele OpenFOAM Running, Solving & CFD 5 February 22, 2018 19:50
pimpleDyMFoam computation randomly stops babapeti OpenFOAM Running, Solving & CFD 5 January 24, 2018 05:28
dynamic Mesh is faster than MRF???? sharonyue OpenFOAM Running, Solving & CFD 14 August 26, 2013 07:47
[blockMesh] BlockMeshmergePatchPairs hjasak OpenFOAM Meshing & Mesh Conversion 11 August 15, 2008 07:36
Convergence moving mesh lr103476 OpenFOAM Running, Solving & CFD 30 November 19, 2007 14:09


All times are GMT -4. The time now is 12:01.