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

Grabbing value of a dimensioned quantity / Problem creating a dimensioned tensor

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AndreasG

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 30, 2013, 08:39
Default Grabbing value of a dimensioned quantity / Problem creating a dimensioned tensor
  #1
Member
 
Thomas Vossel
Join Date: Aug 2013
Location: Germany
Posts: 45
Rep Power: 12
ThomasV is on a distinguished road
Hi!

I'm starting to write my first solver and when testing some simple measure that might come in handy for bughunting I encountered a problem concerning dimensioned values:
I wanted to print a component of the gravitational acceleration in the terminal when running the solver. I would have thought that this has to look like this:
Code:
Info << g.z();
That won't compile though. What works is simply rephrasing this as:
Code:
Info << g;
which gives:
Quote:
g [0 1 -2 0 0 0 0] (0 0 -9.81)
So checking the values works but I'd like to know how to extract a certain value like the z-component of g from a dimensioned value. Which command does one have to use here?

In addition to that I tried using the following code to create a dimensioned tensor which I took right out of the programmer's guide (as I thought maybe the way g is integrated via the readGravitationalAcceleration.H file might be the reason why g.z() won't work):
Code:
dimensionedTensor sigma
(
"sigma",
dimensionSet(1, -1, -2, 0, 0, 0, 0),
tensor(1e6,0,0,0,1e6,0,0,0,1e6),
);
This gives an error while compiling though. Why is that? My solver includes anything that icoFoam has and e.g. the creation of a simple tensor (i.e. without dimensions) works just fine...
ThomasV is offline   Reply With Quote

Old   September 30, 2013, 10:06
Default
  #2
New Member
 
Andreas Groß
Join Date: Sep 2013
Posts: 8
Rep Power: 12
AndreasG is on a distinguished road
Hey ThomasV,
first of all, showing compiler errors helps helping... ;-)

Didn't try, but
Code:
g.value().z()
should work, as g is a dimensioned<vector> and its member function dimensioned<Type>::value() returns a Type object, in your case a vector, which has a member z().
ThomasV likes this.
AndreasG is offline   Reply With Quote

Old   October 1, 2013, 03:38
Default
  #3
Member
 
Thomas Vossel
Join Date: Aug 2013
Location: Germany
Posts: 45
Rep Power: 12
ThomasV is on a distinguished road
Hey!

Thanks for your help - g.value().z() worked...

Concerning the compiler messages: Those unfortunately said pretty much nothing as the compiling process simply was aborted with a
Quote:
make: *** [Make/linux64GccDPOpt/nameOfMySolver.o] Error 1
for both the value reading problem just as when using the given code for the creation of the dimensionedTensor...
ThomasV is offline   Reply With Quote

Old   October 1, 2013, 04:06
Default
  #4
New Member
 
Andreas Groß
Join Date: Sep 2013
Posts: 8
Rep Power: 12
AndreasG is on a distinguished road
The compiler tells us more (at least g++ (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8) does):

Code:
(...)
minimalTestFoam.C: In Funktion »int main(int, char**)«:
minimalTestFoam.C:55:5: Fehler: expected primary-expression before »)« token
make: *** [Make/linux64GccDPOpt/minimalTestFoam.o] Error 1
This tells us, that it expected something before the closing bracket in line 55:
Code:
     50     dimensionedTensor sigma
     51     (
     52         "sigma",
     53         dimensionSet(1, -1, -2, 0, 0, 0, 0),
     54         tensor(1e6,0,0,0,1e6,0,0,0,1e6),
     55     );
If there is a comma behind an argument to a function, the compiler expects another (secend, third, forth,...) argument to come after previous one. But there is no extra argument after last comma (last char in line 54) so the compiler complains about this unexpected end of the argument list. Remove that comma and the code will compile.

//EDIT: fixed bracket...
AndreasG is offline   Reply With Quote

Old   October 1, 2013, 07:27
Default
  #5
Member
 
Thomas Vossel
Join Date: Aug 2013
Location: Germany
Posts: 45
Rep Power: 12
ThomasV is on a distinguished road
Well that's interesting. So your compiler writes those notifications right into the terminal? I'll have to check then if this is suppressed over here or something like that as currently I only get this make: *** message which then aborts the compilation process without further comments as to what caused this...

I'll also try to report this issue so this gets corrected in the programmer's guide...
ThomasV is offline   Reply With Quote

Old   February 18, 2019, 11:05
Default
  #6
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 8
deepbandivadekar is on a distinguished road
Quote:
Originally Posted by ThomasV View Post
Hey!

Thanks for your help - g.value().z() worked...

Concerning the compiler messages: Those unfortunately said pretty much nothing as the compiling process simply was aborted with a
for both the value reading problem just as when using the given code for the creation of the dimensionedTensor...
Old thread but bumping this up again.
This doesn't seem to output the set of dimensions, at least in OF6.


I am particularly interested in the dimensions of fields calculated at a given point in solver. These may or may not be defined fields e.g. U and p are defined but say I want to find out calculated dimensions of a quantity "U/p".
Is there any way to do that in OF6?
deepbandivadekar 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
F_YI(f,t,i) is creating a problem techy Fluent UDF and Scheme Programming 7 April 2, 2015 05:36
Problem in creating .gtm & .pre file HMR CFX 0 January 14, 2011 21:17
Problem in defining and using the deformation rate tensor titio OpenFOAM Running, Solving & CFD 0 November 19, 2009 12:50
Having problem in creating a volume mech in GAMBIT Jake FLUENT 1 April 25, 2008 05:01
[Other] Problem when trying to generate a new mesh gaottino OpenFOAM Meshing & Mesh Conversion 0 June 30, 2006 07:51


All times are GMT -4. The time now is 21:58.