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

How to call function that operates cell-wise on many fields

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 6, 2016, 14:15
Default How to call function that operates cell-wise on many fields
  #1
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
Dear all,

My model transports N chemical species. The distribution of each species in the domain is a volScalarField. These fields are grouped in a PtrList<volScalarField>.

Now, I want to call a function foo that, for each cell, takes the amount of all species, calculate a new amount of them, and changes the volScalarFields accordingly.

A pseudocode of that could be:

Code:
PtrList< volScalarField > species; 

int numberOfSpecies = species.size(); 
int numberOfCells = species[0].size(); 
  
PtrList< scalar > cellComposition (numberOfSpecies); 
  
for (int j=0; j<numberOfCells; j++){ 
    for (int i=0; i<numberOfSpecies; i++) 
        cellComposition.set(i, species[j][i]); 
    
    foo(cellComposition); 
}
I had some tries but nothing worked yet. It is worth noting that the calculation of the new composition is done cell-wise, with no contribution from the neighbours. In theory, it should be easy to parallelise this calculation.

Could you please share your ideas on how you would solve this problem and how one could take advantage of the existing infrastructure in OpenFOAM to run it in parallel?

Best regards,
Thomas
t.oliveira is offline   Reply With Quote

Reply

Tags
chemical reaction, parallel calculation, volscalarfield list


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
[snappyHexMesh] How to define to right point for locationInMesh Mirage12 OpenFOAM Meshing & Mesh Conversion 7 March 13, 2016 14:07
Compiling User Fortran with CFX 14.0 on Win64 Raijin Thunderkeg CFX 29 March 9, 2016 11:45
Journal file error magicalmarshmallow FLUENT 3 April 4, 2014 12:25
a reconstructPar issue immortality OpenFOAM Post-Processing 8 June 16, 2013 11:25
an odd(at least for me!) reconstructPar error on a field immortality OpenFOAM Running, Solving & CFD 3 June 3, 2013 22:36


All times are GMT -4. The time now is 13:35.