|
[Sponsors] |
|
December 19, 2019, 22:23 |
How to assign value in OpenFOAM
|
#1 |
Senior Member
Nguyen Duy Trong
Join Date: Apr 2014
Posts: 124
Rep Power: 12 |
Hi everyone,
I have a problem related to assign value in OpenFOAM, the detail is as follow: in interFoam solver, two variable alpha1 and alpha2 are defined as: volScalarField& alpha1(mixture.alpha1()); volScalarField& alpha2(mixture.alpha2()); Now, I declare a variable with same type as: volScalarField H ( IOobject ( "H", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), alpha1 ); to compute something. After computation, I want to reassign value of alpha1 by H as: alpha1 = H; However, my assignment did not work since when I check the printed output of two files alpha1 and H, the value in same cell mesh are not identical as shown in the attachement. Could anyone help me to explain the reason for that. I thank you very much in advance. |
|
December 22, 2019, 12:56 |
|
#2 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51 |
Hi,
I would expect that this is related to the topic when is the mixture updated. E.g., your alpha is referenced to the mixture class (mixture.alpha1()). Now, if you would do the following: Code:
alpha1 = H; Info<< alpha1 << endl; Info<< H << endl; You should have both variables with the H values. However, depending when you set this assignment, the following can happen: Code:
alpha1 = H; Info<< alpha1 << endl; Info<< H << endl; // Other code that is executed and the mixture is updated some code that updates the mixture // Now alpha1 is updated with the mixture class again // alpha1 != H // Even though you assigned H to alpha 1 before, it was overwritten again by the mixture class runTime.write();
__________________
Keep foaming, Tobias Holzmann |
|
December 22, 2019, 22:46 |
|
#3 | |
Senior Member
Nguyen Duy Trong
Join Date: Apr 2014
Posts: 124
Rep Power: 12 |
Quote:
I thank you very much for your comments. You are right at alpha1 = H and the value have same as H values. My alpha1 value differ from H value because of update in MULES that I called after above assignment. Kind regards, Trong Nguyen |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFOAM 5.0 Released | CFDFoundation | OpenFOAM Announcements from OpenFOAM Foundation | 11 | June 5, 2018 23:48 |
OpenFOAM Training Jan-Jul 2017, Virtual, London, Houston, Berlin | CFDFoundation | OpenFOAM Announcements from Other Sources | 0 | January 4, 2017 06:15 |
OpenFOAM Training, London, Chicago, Munich, Sep-Oct 2015 | cfd.direct | OpenFOAM Announcements from Other Sources | 2 | August 31, 2015 13:36 |
Superlinear speedup in OpenFOAM 13 | msrinath80 | OpenFOAM Running, Solving & CFD | 18 | March 3, 2015 05:36 |
Adventure of fisrst openfoam installation on Ubuntu 710 | jussi | OpenFOAM Installation | 0 | April 24, 2008 14:25 |