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

Perform calculations using neighbouring cell data

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 26, 2021, 07:14
Default Perform calculations using neighbouring cell data
  #1
New Member
 
Elliott Sutton
Join Date: Dec 2019
Posts: 5
Rep Power: 6
Ells96 is on a distinguished road
Hi everyone,

I'm quite new to programming with OpenFOAM and need some help.

I am trying to create a new scalar field that calculates the total difference in viscosity between a given cell and all of its neighbouring cells. What is the syntax I need to get the value of a variable in a given cell and the value in all cells directly adjacent?

I'm hoping to get this to work for an AMR method and to work in parallel.

Thanks,

Elliott
Ells96 is offline   Reply With Quote

Old   July 26, 2021, 12:43
Default
  #2
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
How to get the neighbour of one cell?

Just a few seconds googling helps a lot
mAlletto is offline   Reply With Quote

Old   August 3, 2021, 06:01
Default
  #3
New Member
 
Elliott Sutton
Join Date: Dec 2019
Posts: 5
Rep Power: 6
Ells96 is on a distinguished road
Quote:
Originally Posted by mAlletto View Post
How to get the neighbour of one cell?

Just a few seconds googling helps a lot
Thank you for this.

I've performed the calculation as shown below, but receive the error that " 'celli' was not declared in this scope". I'm not sure how to properly declare 'celli' as any cell in the mesh. Any help would be appreciated.

Declaration of the variable in the .C file, initialised based on a viscosity field:
Code:
    etaGrad_
    (
        IOobject
        (
            "etaGrad" + name,
            U.time().timeName(),
            U.mesh(),
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        eta_
    ),
The actual calculation in .C:
Code:
   
   const objectRegistry& db();
   const volVectorField& U = db().lookupObject<volVectorField>("U");
   const fvMesh& mesh = U.mesh();
   const labelList& neighbour = mesh.cellCells[celli]();
   
   forAll(neighbour,celli)
   {
      etaGrad_[celli] += mag(eta_[celli] - eta_[neighbour[celli]]);
   }
Declaration in the .H file:
Code:
        //- Viscosity gradient field
        volScalarField etaGrad_;
Ells96 is offline   Reply With Quote

Reply

Tags
neighbouring cells, parallel calculation, scalar field


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
[General] what is difference between point data and cell data? kyurinPark ParaView 1 June 19, 2018 18:49
Run OpenFoam in 2 nodes of a cluster WhiteW OpenFOAM Running, Solving & CFD 16 December 20, 2016 00:51
paraview - cell data or point data on plot over line bye bye my blue OpenFOAM 0 December 13, 2016 06:07
Copy the data vector from a reference cell heksel8i OpenFOAM Programming & Development 0 December 2, 2016 16:51
[General] Creating 2D contour with Cell Data mutto233 ParaView 0 August 2, 2016 17:54


All times are GMT -4. The time now is 21:27.