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

[mesh manipulation] Calculate cross product of mesh points and given vector

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By DE25VT
  • 2 Post By mturcios777

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 6, 2012, 13:38
Default Calculate cross product of mesh points and given vector
  #1
New Member
 
Join Date: Feb 2012
Location: Braunschweig, Germany
Posts: 4
Rep Power: 14
DE25VT is on a distinguished road
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
File Type: c get_normal.C (3.4 KB, 43 views)
Kummi likes this.
DE25VT is offline   Reply With Quote

Old   February 6, 2012, 14:13
Default
  #2
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
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.
mturcios777 is offline   Reply With Quote

Old   February 7, 2012, 09:27
Default
  #3
New Member
 
Join Date: Feb 2012
Location: Braunschweig, Germany
Posts: 4
Rep Power: 14
DE25VT is on a distinguished road
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?
DE25VT is offline   Reply With Quote

Old   February 7, 2012, 12:52
Default
  #4
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
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 and Kummi like this.
mturcios777 is offline   Reply With Quote

Old   February 12, 2012, 10:32
Default
  #5
New Member
 
Join Date: Feb 2012
Location: Braunschweig, Germany
Posts: 4
Rep Power: 14
DE25VT is on a distinguished road
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.
DE25VT is offline   Reply With Quote

Old   January 13, 2016, 10:05
Default
  #6
Member
 
Peter
Join Date: Nov 2015
Location: Hamburg, Germany
Posts: 57
Rep Power: 10
potentialFoam is on a distinguished road
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
potentialFoam 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



All times are GMT -4. The time now is 03:02.