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

Declaring a New Scalar Field

Register Blogs Community New Posts Updated Threads Search

Like Tree8Likes
  • 2 Post By Redfocus
  • 4 Post By Lieven
  • 2 Post By Lieven

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 5, 2013, 04:40
Default Declaring a New Scalar Field
  #1
New Member
 
Matt Mosquera
Join Date: Jun 2013
Posts: 3
Rep Power: 12
Redfocus is on a distinguished road
Greetings,

I've just recently started working with openFOAM and this is my first experience programming in C++ or anything similar. I have MATLAB experience but that's about it. I've worked through some tutorials but am still having trouble getting my feet on the ground.

I am writing a solver for a transport equation and would like to define a new constant tau,
which would be given by

tau = 1/(c*omega)

where c is some constant and omega is a volScalarField I am reading from.

tau would ideally then be used in a solve function.

What would be the best way to implement this in my solver?
Kummi and Gang Wang like this.
Redfocus is offline   Reply With Quote

Old   June 5, 2013, 09:21
Default
  #2
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
Hi Matt,

There are a few options but this one could do the trick:
Code:
volScalarField tau("tau", 1/(c*omega));
I hope this is clear! If not, just say so ;-)

Lieven
Lieven is offline   Reply With Quote

Old   June 5, 2013, 09:34
Default
  #3
New Member
 
Matt Mosquera
Join Date: Jun 2013
Posts: 3
Rep Power: 12
Redfocus is on a distinguished road
That worked perfectly, I'm just amazed I couldn't find anything written like that anywhere. That was very helpful, thank you!

If you had time, could you quickly explain the difference between declaring a volScalarField and a ScalarField?
Redfocus is offline   Reply With Quote

Old   June 5, 2013, 09:48
Default
  #4
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
Hi Matt,

To put maybe a bit overly simplistic but I hope you get the point:
A volScalarField is constructed from the internal field and the boundary fields of a variable. Both the internalField and the boundaryfields are (dimensioned) scalarFields. So a scalarField (you can compare this with a simple 1D-array in matlab) is one of the buildings blocks of a volScalarField.

Just for your information, all information about the code structure, definitions of classes etc. can be found at http://www.openfoam.org/docs/cpp/
It's in the beginning a bit overwhelming to work with it, but after a while you get used to it and you can really learn a lot from it.

Cheers,

Lieven
calf.Z and Gang Wang like this.
Lieven is offline   Reply With Quote

Old   June 5, 2013, 10:00
Default
  #5
New Member
 
Matt Mosquera
Join Date: Jun 2013
Posts: 3
Rep Power: 12
Redfocus is on a distinguished road
Ok, that makes a good bit more sense. So when I'm defining a scalar field throughout my mesh I'm using volScalarField, which is composed of scalarFields.

Thanks again for the help, I really appreciate it.

-Matt
Redfocus 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
Tangential component of gradient of scalar field at surface tehache OpenFOAM Running, Solving & CFD 5 July 4, 2013 07:13
jumpCyclic bc not for scalar field? doubtsincfd OpenFOAM 0 July 12, 2011 18:02
Gradient at face center of a scalar volume field praveen OpenFOAM 5 June 30, 2011 08:00
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 06:51
MeshPhi for scalar field in 14 gone tehache OpenFOAM Running, Solving & CFD 0 June 18, 2007 06:20


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