|
[Sponsors] |
initializing a volScalarField in solvers' code |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 7, 2018, 07:47 |
initializing a volScalarField in solvers' code
|
#1 | |
Senior Member
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12 |
Hi all
I want to define a volScalarField in one of the viscous model codes. I saw this function that is set 0 for initial value of a dimensionedScalar: Code:
virtual const dimensionedScalar etaP() { return (dimensionedScalar ("zeroU", dimensionSet(...), 0) ) } Code:
virtual const volScalarField etaP() { return (volScalarField ("zeroU", dimensionSet(...), 0) ) } Code:
volScalarField AA = 0; Code:
virtual const volScalarField etaP() { volScalarField A = dimensionedScalar ("zeroU", dimensionSet(...), 0); return A; } Quote:
Thanks Last edited by alimea; June 7, 2018 at 08:14. Reason: to complete it |
||
June 7, 2018, 10:45 |
|
#2 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
||
June 7, 2018, 11:12 |
|
#3 | |
Senior Member
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12 |
Quote:
Thanks for your reply. Those are very useful, but at the middle of a viscousity model code, I can't use non of them! If I want to define as Code:
volScalarField etaP ( IOobject ( "etaP", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh ); If I want to use Code:
volScalrField etaP ("etaP", 0.*p); So, How to do that? Regards, |
||
June 7, 2018, 11:26 |
|
#4 |
New Member
JPeternel
Join Date: Oct 2014
Posts: 19
Rep Power: 12 |
You need to get mesh and time objects, they do not exist in every class under this names.
Maybe try to Access them through velocity field, something like: U_.mesh() instead of mesh and U_.time() instead of runTime |
|
June 7, 2018, 11:40 |
|
#5 | ||
Senior Member
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12 |
Quote:
Thanks for your reply. could you plz explain it more? I have written it as: Code:
volScalarField etaP ( IOobject ( "etaP", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh ); so as you mentioned I have changed them to: Code:
volScalarField etaP ( IOobject ( "etaP", U_.time(), U_.mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), U_.mesh() ); Quote:
|
|||
June 7, 2018, 11:46 |
|
#6 |
New Member
JPeternel
Join Date: Oct 2014
Posts: 19
Rep Power: 12 |
Yes, that is exactly what I meant. Only one thing should be changed:
in original, you have written: runTime.timeName() That is a call to function timeName() of the runTime. So, when you replace runTime by U_.time(), you still need to call the function timeName(): ... IOobject ( "etaP", U_.time().timeName(), U_.mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), ... |
|
June 7, 2018, 11:49 |
|
#7 | ||
Senior Member
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12 |
Quote:
Thenk you, but it gives me again this error: Quote:
Regards, |
|||
June 7, 2018, 12:07 |
|
#8 | |
Senior Member
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12 |
Quote:
That is solved! I was wrong in last "mesh" component. Thank you |
||
Tags |
initializing, volscalarfield |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Hypersonic and Supersonic Flow Solvers | hyFoam | OpenFOAM Announcements from Other Sources | 26 | March 14, 2021 23:52 |
Strange oscillations in my hydrodynamics code | selig5576 | Main CFD Forum | 1 | August 31, 2016 23:51 |
A question about the source code of realizableKE.C | yuhai | OpenFOAM Programming & Development | 1 | June 26, 2009 09:05 |
Design Integration with CFD? | John C. Chien | Main CFD Forum | 19 | May 17, 2001 16:56 |
What is the Better Way to Do CFD? | John C. Chien | Main CFD Forum | 54 | April 23, 2001 09:10 |