|
[Sponsors] |
Question: How to vectorField & dimensionedVector? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 1, 2017, 10:30 |
Question: How to vectorField & dimensionedVector?
|
#1 |
Senior Member
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 15 |
So, I was wondering how to do the inner product between a dimensionedVector and a vectorField other than looping directly over the vectorField itself.
|
|
March 1, 2017, 11:39 |
|
#2 |
New Member
Mohamed Elshahat Ouda
Join Date: May 2010
Posts: 29
Rep Power: 16 |
Did you try just using "&" operator.
I've used it and I get the expected values as if I dot the vector by each vector in the vector field. Here is the code: Code:
object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField nonuniform List<vector> 9 ( (-9.66371e-05 0 -0.133191) (-0.000274768 0 -0.132876) (-0.000411 0 -0.131537) (-0.000544201 0 -0.129738) (-0.000672783 0 -0.12728) (-0.00077639 0 -0.124466) (-0.000874089 0 -0.121203) (-0.000942926 0 -0.117627) (-0.00100253 0 -0.113825) ) ; Code:
dimensionedVector v1 ("v1", dimVelocity, vector (0.2, 0.3, 0.4)); Info << (v1.value() & U ) << endl; Code:
dimensions [0 1 -1 0 0 0 0]; internalField nonuniform List<scalar> 9(-0.0532957 -0.0532054 -0.052697 -0.052004 -0.0510466 -0.0499417 -0.048656 -0.0472394 -0.0457305); Code:
outlet { type calculated; value nonuniform List<scalar> 3(-0.052697 -0.0499417 -0.0457305); |
|
March 1, 2017, 13:54 |
Not so fast...
|
#3 |
Senior Member
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 15 |
Hi @me.ouda
Well, I though so as well, that the & operator should be overloaded. But the thing is that my vectorField is not a volVectorField, but rather is over a patch. When I do the operation, the compiler throws a type-cast error. Ok, to be precise let me show what I'm trying to do: Code:
vectorField topPatchVelocity = interpolatorBotToTop.faceInterpolate ( UBot.boundaryField()[botPatchID] ); topPatchVelocity = momentumDensityRatio & topPatchVelocity; topBC = topPatchVelocity; |
|
March 1, 2017, 15:53 |
|
#4 | |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21 |
Quote:
Extracting the non-dimensional value should work too: Code:
topPatchVelocity = momentumDensityRatio.value() & topPatchVelocity; |
||
March 1, 2017, 16:45 |
|
#5 | |
Senior Member
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 15 |
Quote:
Code:
setDirichlet.H: In function ‘int main(int, char**)’: setDirichlet.H:10:19: error: no match for ‘operator=’ (operand types are ‘Foam::vectorField {aka Foam::Field<Foam::Vector<double> >}’ and ‘Foam::tmp<Foam::Field<double> >’) topPatchVelocity = momentumDensityRatio.value() & topPatchVelocity; |
||
March 2, 2017, 05:57 |
I kind of forgot my lessons on Tensor Analysis... Sorry
|
#6 |
Senior Member
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 15 |
Guys, I saw what the problem was: I was doing the contraction of two vector, and I needed a linear application on a vector (to scale it of course). I changed the scaling term to a dimensionedTensor and everything runs smoothly. Now I'll run the code and see what comes out.
Thanks |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Question about symmetry in Autodesk Cfd 2016 | ecto | Autodesk Simulation CFD | 0 | October 20, 2015 04:16 |
small question about the functionalities of topological changes in OpenFoam | ngj | OpenFOAM Running, Solving & CFD | 2 | February 28, 2013 10:02 |
Question Re Engineering Data Source | imnull | ANSYS | 0 | March 5, 2012 13:51 |
internal field question - PitzDaily Case | atareen64 | OpenFOAM Running, Solving & CFD | 2 | January 26, 2011 15:26 |
Poisson Solver question | Suresh | Main CFD Forum | 3 | August 12, 2005 04:37 |