|
[Sponsors] |
Assign one vector to another - still a field? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 26, 2011, 12:01 |
Assign one vector to another - still a field?
|
#1 |
Member
David GISEN
Join Date: Jul 2009
Location: Germany
Posts: 69
Rep Power: 17 |
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]); ... } Code:
error: no match for call to ‘(Foam::vector) (Foam::tmp<Foam::Field<Foam::Vector<double> > >)’ 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, 13:39 |
|
#2 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
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, 10:13 |
|
#3 |
Member
David GISEN
Join Date: Jul 2009
Location: Germany
Posts: 69
Rep Power: 17 |
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] ); 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. |
|
May 27, 2011, 11:47 |
|
#4 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
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) |
|
|
|
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 |