CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Programming & Development

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

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   May 6, 2016, 14:15
Default How to call function that operates cell-wise on many fields
Thomas Oliveira
Join Date: Apr 2015
Posts: 92
Rep Power: 4
t.oliveira is on a distinguished road
Sponsored Links
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:

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]); 
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,
t.oliveira is offline   Reply With Quote
Sponsored Links


chemical reaction, parallel calculation, volscalarfield list

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to define to right point for locationInMesh Mirage12 OpenFOAM Native Meshers: snappyHexMesh and Others 7 March 13, 2016 15:07
Compiling User Fortran with CFX 14.0 on Win64 Raijin Thunderkeg CFX 29 March 9, 2016 12: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

Sponsored Links

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