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

Convert volScalarField to dimensionedScalar to be defined in transportProperties

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By sabago
  • 2 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 6, 2015, 13:04
Default Convert volScalarField to dimensionedScalar to be defined in transportProperties
  #1
Member
 
Sandra
Join Date: Oct 2014
Posts: 58
Rep Power: 11
sabago is on a distinguished road
Hello OpenFOAMers

I have a variable,x that is mapped in my code so it's a volScalarField and I would like to fix it in the transportProperties dictionary as a dimensionedScalar.

Originally, x was set in the 0 folder but I want to fix it in transportProperties so that it doesn't go to zero as it currently does.

I've seen a few posts about converting a dimensioned scalar to volScalarField but I wasn't successful with those methods.

Any ideas?

Best,
Sandra
Kummi likes this.
sabago is offline   Reply With Quote

Old   May 10, 2015, 03:18
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Here is an example from laminar turbulence model:

Code:
        ...
        new volScalarField
        (
            IOobject
            (
                "nut",
                runTime_.timeName(),
                mesh_,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            mesh_,
            dimensionedScalar("nut", nu()().dimensions(), 0.0)
        )
        ...
Did you try this constructor (you need to correct the name of the field, dimensions, and instead of dimensionedScalar(...) you should put the constant you have read from transportProperties dictionary)? What error did you get?
Tolga KURUMUS and lpz456 like this.
alexeym is offline   Reply With Quote

Old   May 14, 2015, 12:17
Default
  #3
Member
 
Sandra
Join Date: Oct 2014
Posts: 58
Rep Power: 11
sabago is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Hi,

Here is an example from laminar turbulence model:

Code:
        ...
        new volScalarField
        (
            IOobject
            (
                "nut",
                runTime_.timeName(),
                mesh_,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            mesh_,
            dimensionedScalar("nut", nu()().dimensions(), 0.0)
        )
        ...
Did you try this constructor (you need to correct the name of the field, dimensions, and instead of dimensionedScalar(...) you should put the constant you have read from transportProperties dictionary)? What error did you get?

Hi Alexey!

Thank you for that contructor. Here's what I did

volScalarField jbvagCell
(
IOobject
(
"jbvag",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("jbvag", dimensionSet(0,-3,0,0,0,1,0), 2e6)
);
where 2e6 is the value that I want to fix.

wmake for the solver works fine. However, in the .H file where I use jbvag, I have
Info<<jbvag<<endl; to show me the values as the simulation proceeds and for some reason jbvag is zero.

Any thoughts please?


Best,
Sandra
sabago is offline   Reply With Quote

Old   May 14, 2015, 13:58
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Your volScalarField is called jbvagCell, in your output statement variable is jbvag. Also if you would like to create volScalarField from dimensionedScalar (so there is no need to create file in 0 folder), you should not use read-constructor (i.e. with IOobject::MUST_READ flag, as you can see in the example the flag has value IOobject::NO_READ).
alexeym is offline   Reply With Quote

Old   May 14, 2015, 14:05
Default
  #5
Member
 
Sandra
Join Date: Oct 2014
Posts: 58
Rep Power: 11
sabago is on a distinguished road
Hello!

I don't have files in the 0 folder for this variable.
Here's what I have now

volScalarField jbvagCell
(
IOobject
(
"jbvagCell",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("jbvagCell", dimensionSet(0,-3,0,0,0,1,0), 2e6)

jbvagCell still goes to zero when I check.

Sandra
sabago is offline   Reply With Quote

Old   May 14, 2015, 16:40
Default
  #6
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Post your code or at least relevant parts. I can continue guessing what is wrong but I do not want to.
alexeym is offline   Reply With Quote

Old   June 1, 2015, 10:36
Default
  #7
Member
 
Sandra
Join Date: Oct 2014
Posts: 58
Rep Power: 11
sabago is on a distinguished road
Hi Alexey!

Here's the equation that I'm trying to solve

jbvagCell = iagCell*((Foam::exp(alphaaa*F*EttaaCell/(Rg*T)))-(Foam::exp(-alphaca*F*EttaaCell/(Rg*T))));

where jbvagCell is the fixed value in the createFields.H; iagCell is calculated elsewhere just fine. alphaaa, F, Rg, T and alphaca are constants in the transportProperties.

And EttaaCell is what I'm solving for.

Please note that this equation cannot be rearranged such that EttaaCell is the subject of the equation.

Note: when I rewrite the equation as f(EttaaCell) = 0; jbvagCell is fixed but EttaaCell remains zero!

Many thanks in advance.

Sandra
sabago is offline   Reply With Quote

Old   June 1, 2015, 11:12
Default
  #8
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Unfortunately during the whole thread you are trying to show how you create volume field. Yet the most interesting parts are elsewhere and it is not possible to deduce:

- What do you do with the field after creation?
- What do you mean by "...still goes to zero when I check."?
- How do you check the values of the field?
- When do you check these values?
- Are you sure you do not modify the field?

You have shown this piece of code:

Code:
jbvagCell = iagCell*((Foam::exp(alphaaa*F*EttaaCell/(Rg*T)))-(Foam::exp(-alphaca*F*EttaaCell/(Rg*T))));
From this I just can guess, that somewhere in your code, you update jbvagCell. If iagCell if 0, jbvagCell is 0. I do not know values of alphaaa, F, Rg, T, alphaca, so I can suppose, that alphaaa*F*EttaaCell/(Rg*T) == -infinity and -alphaca*F*EttaaCell/(Rg*T) == -infinity, so your exponents are 0 and again jbvagCell is 0.
alexeym is offline   Reply With Quote

Old   June 1, 2015, 12:11
Default
  #9
Member
 
Sandra
Join Date: Oct 2014
Posts: 58
Rep Power: 11
sabago is on a distinguished road
-What do you do with the field after creation?
I set the field in createFields.H then use it in the above equation in a file.H and that's all I do with it.
- What do you mean by "...still goes to zero when I check."?
- How do you check the values of the field?
- When do you check these values?
In file.H, under the above eqn I have...

Info<<jbvagCell>>endl;
Info<<EttaaCell>>endl;
Info<<iagCell>>endl;

and that's how I track the values.

- Are you sure you do not modify the field?
I'm quite sure...the variable jbvagCell only appears twice; in the createFields.H and file.H

Sandra
sabago is offline   Reply With Quote

Reply


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
[openSmoke] libOpenSMOKE Tobi OpenFOAM Community Contributions 562 January 25, 2023 09:21
[ICEM] How can I define different zones in ICEM? llrr ANSYS Meshing & Geometry 14 February 12, 2017 13:44
define volscalarfield vahidzanganeh OpenFOAM 6 January 21, 2013 06:35
OpenFOAM static build on Cray XT5 asaijo OpenFOAM Installation 9 April 6, 2011 12:21
OpenFOAM13 for Mac OSX Darwin 104 hjasak OpenFOAM Installation 70 September 24, 2010 05:06


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