CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

How to read in vectors

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By ngj

Reply
 
LinkBack Thread Tools Display Modes
Old   April 12, 2010, 09:03
Default How to read in vectors
  #1
New Member
 
Michael Gruber
Join Date: Oct 2009
Location: Graz
Posts: 13
Rep Power: 7
gruber is on a distinguished road
Hello,

I'm trying to read in a vector, eg. the gravity, from a dictionary and to initialize it as constant of a class, eg. A. With bool variables it is possible to programm the constructor like this:

A::A()
:
dict_(IOobject(
"dict",
U.time().constant(),
U.db(),
IOobject::MUST_READ,
IOobject::NO_WRITE)),
a_(readBool(dict_.lookup("a")))
{}

Does there exist a readVector command similar to the readBool like:
b_(readVector(dict_.lookup("b")))
or how could this be done?

Thanks,
Michael
gruber is offline   Reply With Quote

Old   April 12, 2010, 09:13
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Deltares, Delft, The Netherlands
Posts: 1,619
Rep Power: 25
ngj will become famous soon enoughngj will become famous soon enough
Hi Michael

It depends on what format the vector is given in the dictionary. If it is merely a vector, you can read it as

vector(dict.lookup("a"))

however if it is a dimensioned vector in the dict, then you should type

dimensionedVector(dict.lookup("a"))

Hope it helps,

Niels
SamMallinson likes this.
ngj is offline   Reply With Quote

Old   April 12, 2010, 09:17
Default
  #3
New Member
 
Silvan Brändli
Join Date: Aug 2009
Posts: 27
Rep Power: 8
s_braendli is on a distinguished road
Hi Michael

I use something like this:

environmentalProperties_
(
IOobject
(
"environmentalProperties",
runTime_.constant(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
g_(environmentalProperties_.lookup("g")),

with g_ being:
dimensionedVector g_;

Hope this helps

Silvan
s_braendli is offline   Reply With Quote

Old   April 12, 2010, 09:57
Default
  #4
New Member
 
Michael Gruber
Join Date: Oct 2009
Location: Graz
Posts: 13
Rep Power: 7
gruber is on a distinguished road
Thank you for your replies. They helped me quite a lot.
gruber is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem when converting mesh (made by ICEM) using fluentMeshToFoam Forrest_Lei OpenFOAM 11 October 16, 2009 06:28
Phase locked average in run time panara OpenFOAM 2 February 20, 2008 15:37
Integration Points and normal area vectors Bloshchitsyn Vladimir CFX 0 November 26, 2007 08:35
2 velocity vectors ashish CFX 3 June 19, 2007 18:32
Error Fluents TDL FLUENT 6 April 26, 2005 06:02


All times are GMT -4. The time now is 09:39.