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

Question: How to vectorField & dimensionedVector?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 1, 2017, 10:30
Default Question: How to vectorField & dimensionedVector?
  #1
Senior Member
 
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 15
Santiago is on a distinguished road
So, I was wondering how to do the inner product between a dimensionedVector and a vectorField other than looping directly over the vectorField itself.
Santiago is offline   Reply With Quote

Old   March 1, 2017, 11:39
Default
  #2
New Member
 
Mohamed Elshahat Ouda
Join Date: May 2010
Posts: 29
Rep Power: 16
me.ouda is on a distinguished road
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;
The result field:
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);
The old boundary conditions was "zeroGradient", for the new field it becomes "calculated":
Code:
outlet
    {
        type            calculated;
        value           nonuniform List<scalar> 3(-0.052697 -0.0499417 -0.0457305);
May be someone can help on how the resultant boundary condition is defined when we multiply two fields
me.ouda is offline   Reply With Quote

Old   March 1, 2017, 13:54
Default Not so fast...
  #3
Senior Member
 
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 15
Santiago is on a distinguished road
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;
This piece of code throws me an error in the last-but-one line. Note that momentumDensityRatio is a dimensionedVector.
Santiago is offline   Reply With Quote

Old   March 1, 2017, 15:53
Default
  #4
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
Quote:
Originally Posted by Santiago View Post
Code:
topPatchVelocity = momentumDensityRatio & topPatchVelocity;
This won't compile unless momentumDensityRatio's dimension is dimLess. Dimensions to the left of = should be the same as dimensions on the r.h.s.

Extracting the non-dimensional value should work too:
Code:
topPatchVelocity = momentumDensityRatio.value() & topPatchVelocity;
Zeppo is offline   Reply With Quote

Old   March 1, 2017, 16:45
Default
  #5
Senior Member
 
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 15
Santiago is on a distinguished road
Quote:
Originally Posted by Zeppo View Post
This won't compile unless momentumDensityRatio's dimension is dimLess. Dimensions to the left of = should be the same as dimensions on the r.h.s.

Extracting the non-dimensional value should work too:
Code:
topPatchVelocity = momentumDensityRatio.value() & topPatchVelocity;
Nope, It didn't work. Now I get a type-cast error on the assignment operator:

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;
Santiago is offline   Reply With Quote

Old   March 2, 2017, 05:57
Default 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
Santiago is on a distinguished road
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
Santiago 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
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


All times are GMT -4. The time now is 12:25.