|
[Sponsors] |
Assign values in an array to each cell of volscalarfield |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 3, 2020, 17:22 |
Assign values in an array to each cell of volscalarfield
|
#1 |
New Member
Join Date: Jun 2020
Posts: 10
Rep Power: 6 |
Hi Foamers,
I got an output array in Openfoam7. The values in the array correspond to each cell of the mesh. I want to output the values in the array to a volscalarfield and write to files for visualization. I have defined the field in "createfields.H". But I don't know how to assign values between array and volscalarfields. Regards, Yongqiang |
|
June 3, 2020, 18:53 |
|
#2 | |
New Member
Join Date: Jun 2020
Posts: 10
Rep Power: 6 |
In other words, is it allowed to assign values cell by cell in OpenFOAM?
Quote:
|
||
June 3, 2020, 19:59 |
|
#3 |
Member
Hasan Celik
Join Date: Sep 2016
Posts: 64
Rep Power: 10 |
Are you trying to do something like this?
Code:
volScalarField p ( IOobject ( "p", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), p_rgh + rho*gh ); Code:
p = p_rgh + rho*gh |
|
June 4, 2020, 04:17 |
|
#4 | |
New Member
Join Date: Jun 2020
Posts: 10
Rep Power: 6 |
Hi Positron,
Thank you for your reply. I coupled OpenFOAM with another chemical simulator. They chemical simulator outputs an array. However, I aim to transfer the data in an array to an volscalarfield so that I can do visualization in ParaView. It is to assign value for each of volscalarfield from an array. It seems that the following code is not what intends to do. Thanks, Yongqiang Quote:
|
||
June 7, 2020, 03:44 |
|
#5 |
Senior Member
Yogesh Bapat
Join Date: Oct 2010
Posts: 102
Rep Power: 16 |
You can use forAll loop.
|
|
June 7, 2020, 10:13 |
|
#6 |
New Member
Join Date: Jun 2020
Posts: 10
Rep Power: 6 |
||
June 7, 2020, 10:16 |
|
#7 |
Member
Hasan Celik
Join Date: Sep 2016
Posts: 64
Rep Power: 10 |
||
June 7, 2020, 10:19 |
|
#8 |
New Member
Join Date: Jun 2020
Posts: 10
Rep Power: 6 |
It's just as you suggested. Use forAll to loop over all the volscalarfield and = to directly assign values from the array . It is straightforward.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Setting cell variable values in a fluid zone using UDF | eromon84 | Fluent UDF and Scheme Programming | 6 | March 28, 2021 12:59 |
Set cell volume integrated field values to preserve integral | Diro7 | OpenFOAM Pre-Processing | 2 | June 3, 2018 11:44 |
How to scale a volScalarField by cell volume? | tgvosk | OpenFOAM Running, Solving & CFD | 2 | July 9, 2012 11:25 |
Ensight - node values -cell values | leo | FLUENT | 1 | May 12, 2010 09:47 |
Cell face values computation un unstructured grids | Sergio Rossi | Main CFD Forum | 2 | May 28, 2006 11:04 |