# Calculate cross product of mesh points and given vector

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 LinkBack Thread Tools Display Modes
February 6, 2012, 14:38
Calculate cross product of mesh points and given vector
#1
New Member

Join Date: Feb 2012
Location: Braunschweig, Germany
Posts: 4
Rep Power: 7
Sponsored Links
Dear Foamers,

I am currently working on an application, which calculates the cross product of the mesh points and a given constant vector and then writes the new vector into a file.
Therefore I just want to read in the mesh points given in the constant/polyMesh direction and multiply those with my vector.
In the code I read in the points as a volVectorField, but in the points file in the polyMesh directory the points are a vectorField. So when I try to use my application I get the error:
--> FOAM FATAL IO ERROR:
unexpected class name vectorField expected volVectorField
while reading object points

But if I change from volVectorField to vectorField in my application, the compiler does not recognize the code for the cross product.
So I was wondering, if anyone could give me a tip, how to calculate with mesh points.
And what exactly is the difference between volVectorField and vectorField.
I had a look at the source code and couldn't find volVectorField, but in vectorField the operator I need to use is not defined.
It would be great if someone would answer.
Please find the file of the application attached.
I am using Foam version 2.1.0.

Thanks,
DE25VT
Attached Files
 get_normal.C (3.4 KB, 33 views)

 Sponsored Links

 February 6, 2012, 15:13 #2 Senior Member     Marco A. Turcios Join Date: Mar 2009 Location: Vancouver, BC, Canada Posts: 733 Rep Power: 21 A volVectorField is a vector field that is defined on a volume mesh. Even though the operator for cross product isn't defined for the field as a whole, it should be relatively straightforward to step through the field and perform the operation vector by vector.

 February 7, 2012, 10:27 #3 New Member   Join Date: Feb 2012 Location: Braunschweig, Germany Posts: 4 Rep Power: 7 Thank you for your help. I was able to calculate the vectorField using a for-loop. And afterwards putting the single vectors back together into a vectorField. Do you know a way, how I can write out the field, like I can do with volVectorField, because I would like to have a look at the file at a later time and with the command used for volVectorField or volScalarField (see attached) I can not write out a vectorField. volScalarField pPrime2 ( IOobject ( "pPrime2", runTime.timeName(), mesh, IOobject::NO_READ ), sqr(p - pMean) ); pPrime2.write(); } How do I have to change this for a vectorField?

 February 7, 2012, 13:52 #4 Senior Member     Marco A. Turcios Join Date: Mar 2009 Location: Vancouver, BC, Canada Posts: 733 Rep Power: 21 When you say the code you posted does not work, do you mean that the code doesn't compile or that you don't get the field written out the way you want to? The process you need to follow to write out the fields is: 1) Create the vectorField , using a constructor similar to what you posted, but use the IOobject::NO_READ and IOobject::AUTO_WRITE options (look at the createFields.H of nearly any solver or utility for examples) 2) Perform your cross product calculation. 3) Write out the field either using the field.write() command, or with all the other fields by using the global write command. Good luck! meth likes this.

 February 12, 2012, 11:32 #5 New Member   Join Date: Feb 2012 Location: Braunschweig, Germany Posts: 4 Rep Power: 7 I tried using the same way to put out my vectorField given in all the solvers. Unfortunately, the operator I am using is not known this way, but Foam knows it, when instead of vectorField, I use volVectorField. So I am not sure whether that is the right way to get it done. So right know I am having a look at BlockMesh, because this is similar to what I want, the field 'points' is a vectorField as well. So if I figure out how this works I can use it for my case. Thank you for your help. Ideas are always warmly welcomed.

 January 13, 2016, 11:05 #6 Member   Peter Join Date: Nov 2015 Location: Hamburg, Germany Posts: 43 Rep Power: 3 Dear Foamers and/or DE25VT, did you finally solve the problem? I've got the same issue, I would like to write out a vectorField variable like I would do with a volVectorField variable: Code: ```volVectorField test = U; if (mesh().time().outputTime()) { test.write(); }``` Regards, Peter

 Thread Tools Display Modes Linear Mode

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

 Sponsored Links

All times are GMT -4. The time now is 14:42.

 Contact Us - CFD Online - Top