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

Assign one vector to another - still a field?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 26, 2011, 12:01
Default Assign one vector to another - still a field?
  #1
Member
 
David GISEN
Join Date: Jul 2009
Location: Germany
Posts: 70
Rep Power: 17
David* is on a distinguished road
Hi Foamers,

I have some problems with a vector assignment. To do some further computations, I need the unit normal vector of a patch stored as a vector. My command for this is

Code:
vector unitNormalVector;
...
forAll(wallshearstress4Rho.boundaryField(), patchi)
{
unitNormalVector(-mesh.Sf().boundaryField()[patchi]/mesh.magSf().boundaryField()[patchi]);
...
}
I tried also with an equal (=) symbol. I assume, that on both sides of the equation is a vector with three components. But on the right hand side, it's something more complicated, as wmake's error message shows:

Code:
error: no match for call to ‘(Foam::vector) (Foam::tmp<Foam::Field<Foam::Vector<double> > >)’
Which looks like a template vector field (?). But how can there be a field, if I choose a specific patch by using [patchi] within a forAll-loop?
I'm a beginner with C++, so I ask someone more experienced to tell me what I'm doing wrong.

Regards,
David
David* is offline   Reply With Quote

Old   May 26, 2011, 13:39
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
Hey there fellow David G,

boundaryField()[patchi] is not a single control face - it is an entire patch, made up of several faces. I think you can access it a bit more directly:

wallshearstress4Rho.boundaryField()[patchi].nf()

I believe this returns a vector field of all the normal vectors on the patch faces. As for finding the exact centre unit vector, I'm not sure. Maybe look at an fvPatchField that you guess would need to know its unit vector, and see how they do it.
marupio is offline   Reply With Quote

Old   May 27, 2011, 10:13
Default
  #3
Member
 
David GISEN
Join Date: Jul 2009
Location: Germany
Posts: 70
Rep Power: 17
David* is on a distinguished road
Hi David,

thanks for pointing that out, I was really on the wrong track. The line you posted didn't work for me, maybe I missed something before. But the assignment works, if I define unitNormalVector as a vectorField (like I learned now), and add an "&":
Code:
            unitNormalVector&
            (
                  0.00041
                * -mesh.Sf().boundaryField()[patchi]
                / mesh.magSf().boundaryField()[patchi]
            );
I multiply with a factor to get the point(s) at a specific distance from the wall.

At the moment, my code does compile, but ends with a segmentation fault while running. I'll see if I can fix this.

nice weekend,
David


//Edit: 1 month later: the above is NOT an assignment, but I believe a multiplication. A good way to find out if everythings right is to use the Info output, e.g.
Info<< "Cell number = " << number << endl;

Last edited by David*; June 21, 2011 at 09:29.
David* is offline   Reply With Quote

Old   May 27, 2011, 11:47
Default
  #4
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
I track down segmentation faults by compiling in debug mode, and using gbd...

gdb solverName
>run
-Crashes
>bt
(backtrace - it shows where in the code it crashed)
marupio 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
Phase Field modeling in OpenFOAM adona058 OpenFOAM Running, Solving & CFD 35 November 16, 2021 01:16
problems after decomposing for running alessio.nz OpenFOAM 7 March 5, 2021 05:49
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
Zero size field taranov OpenFOAM Bugs 2 April 20, 2010 05:51
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51


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