# Assign one vector to another - still a field?

 Register Blogs Members List Search Today's Posts Mark Forums Read

 May 26, 2011, 11:01 Assign one vector to another - still a field? #1 Member   David GISEN Join Date: Jul 2009 Location: Germany Posts: 37 Rep Power: 8 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 > >)’` 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

 May 26, 2011, 12:39 #2 Senior Member   David Gaden Join Date: Apr 2009 Location: Winnipeg, Canada Posts: 397 Rep Power: 12 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.

 May 27, 2011, 09:13 #3 Member   David GISEN Join Date: Jul 2009 Location: Germany Posts: 37 Rep Power: 8 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 08:29.

 May 27, 2011, 10:47 #4 Senior Member   David Gaden Join Date: Apr 2009 Location: Winnipeg, Canada Posts: 397 Rep Power: 12 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)

 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

 Similar Threads Thread Thread Starter Forum Replies Last Post adona058 OpenFOAM Running, Solving & CFD 24 January 31, 2015 07:01 Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20 alessio.nz OpenFOAM 5 April 20, 2011 08:44 taranov OpenFOAM Bugs 2 April 20, 2010 04:51 matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51

All times are GMT -4. The time now is 17:50.