|
[Sponsors] |
[mesh manipulation] Calculate cross product of mesh points and given vector |
|
LinkBack | Thread Tools | Search this Thread | 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: 14 |
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 |
|
February 6, 2012, 15:13 |
|
#2 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
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: 14 |
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: 740
Rep Power: 28 |
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! |
|
February 12, 2012, 11:32 |
|
#5 |
New Member
Join Date: Feb 2012
Location: Braunschweig, Germany
Posts: 4
Rep Power: 14 |
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: 57
Rep Power: 11 |
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(); } Peter |
|
|
|