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

Inner product of tensor and vector

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

Reply
 
LinkBack Thread Tools Display Modes
Old   December 3, 2013, 04:11
Question Inner product of tensor and vector
  #1
New Member
 
Johannes
Join Date: Mar 2011
Location: Valencia, Spain
Posts: 7
Rep Power: 6
jfw_cfd is on a distinguished road
Hello!

I try to implement an equation of scalar fluxes (an equation of type fvVectorMatrix) in OpenFOAM-1.6 where terms of an inner product of a tensor and a vector have to be calculated such as

-\rho C_s u_j z \frac {\partial U_i}{\partial x_j} - \rho u_i u_j \frac {\partial Z}{\partial x_j}

u_jz is a vector (volVectorField), so the first term is the inner product of a vector and a tensor
u_i u_j is the Reynolds stress tensor and Z is a scalar (volScalarField), so the second term is the inner product of a symmetric tensor and a vector
At the moment I wrote this in OpenFOAM as
Code:
 rho*Cs* uz & fvc::grad(U) + rho*turbulence->R() & fvc::grad(Z)
but it results in an error of " no match for 'operator==' ", actually this message
Code:
ZEqns.H:36: error: no match for ‘operator==’ in ‘Foam::operator-(const Foam::tmp<Foam::fvMatrix<Type> >&, const Foam::tmp<Foam::fvMatrix<Type> >&) [with Type = Foam::Vector<double>](((const Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > >&)((const Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > >*)(& Foam::fvm::laplacian(const Foam::tmp<Foam::GeometricField<GType, Foam::fvPatchField, Foam::volMesh> >&, Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&) [with Type = Foam::Vector<double>, GType = Foam::SymmTensor<double>](((Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&)(& uz))))))) == Foam::operator*(const Foam::tmp<Foam::GeometricField<double, PatchField, GeoMesh> >&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = Foam::SymmTensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::tmp<Foam::GeometricField<Foam::SymmTensor<double>, Foam::fvPatchField, Foam::volMesh> >&)((const Foam::tmp<Foam::GeometricField<Foam::SymmTensor<double>, Foam::fvPatchField, Foam::volMesh> >*)(& Foam::compressible::turbulenceModel::R()))))’
/opt/OpenFOAM/OpenFOAM-1.6/src/thermophysicalModels/specie/lnInclude/perfectGasI.H:148: note: candidates are: Foam::perfectGas Foam::operator==(const Foam::perfectGas&, const Foam::perfectGas&)
/opt/OpenFOAM/OpenFOAM-1.6/src/thermophysicalModels/specie/lnInclude/specieI.H:190: note:                 Foam::specie Foam::operator==(const Foam::specie&, const Foam::specie&)
/opt/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/triFaceI.H:304: note:                 bool Foam::operator==(const Foam::triFace&, const Foam::triFace&)
/opt/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/objectMapI.H:95: note:                 bool Foam::operator==(const Foam::objectMap&, const Foam::objectMap&)
/opt/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/objectHit.H:110: note:                 bool Foam::operator==(const Foam::objectHit&, const Foam::objectHit&)
/opt/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/cellShape.H:158: note:                 bool Foam::operator==(const Foam::cellShape&, const Foam::cellShape&)
/opt/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/cellModelI.H:124: note:                 bool Foam::operator==(const Foam::cellModel&, const Foam::cellModel&)
/opt/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/cell.H:134: note:                 bool Foam::operator==(const Foam::cell&, const Foam::cell&)
/opt/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/faceI.H:138: note:                 bool Foam::operator==(const Foam::face&, const Foam::face&)
/opt/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/edgeI.H:171: note:                 bool Foam::operator==(const Foam::edge&, const Foam::edge&)
/opt/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/instant.H:140: note:                 bool Foam::operator==(const Foam::instant&, const Foam::instant&)
Any ideas how to implement this inner product in OpenFOAM-1.6 ? The & operator should be the correct one for an inner product. Do I use the operator the wrong way or on wrong types or isn't it defined for these types?

Thanks in advance for any comment!

Greetings,
Johannes
jfw_cfd is offline   Reply With Quote

Old   December 3, 2013, 08:02
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
The error message you give does not relate to the posted code, because there is no "==" in there.
Bernhard is offline   Reply With Quote

Old   December 3, 2013, 08:11
Default
  #3
New Member
 
Johannes
Join Date: Mar 2011
Location: Valencia, Spain
Posts: 7
Rep Power: 6
jfw_cfd is on a distinguished road
Hello Bernhard!

Thank you for your reply.
My fault, since I didn't post the whole equation, only two terms of it.

Anyway, I guess I found a solution with which I'll come back a bit later to get an opinion from others.

Greetings and let's "read" again in a while....
jfw_cfd is offline   Reply With Quote

Old   December 3, 2013, 14:03
Lightbulb possible solution
  #4
New Member
 
Johannes
Join Date: Mar 2011
Location: Valencia, Spain
Posts: 7
Rep Power: 6
jfw_cfd is on a distinguished road
As I sad before, I'll come back with a solution which I would like to share with you.

I finally implemented this equation

{\partial \rho u'_iz' \over \partial t}
    + {\partial \rho u'_iz' U_j \over \partial x_j}
    - {\partial \over \partial x_j} \left(C_s \rho \frac{k}{\varepsilon} u'_jz' {\partial U_i \over \partial x_j} \right)
=
\rho (C_2-1) u'_j z' \frac {\partial U_i}{\partial x_j}
- \rho u'_i u'_j \frac {\partial Z}{\partial x_j}
- \rho C_1 \frac{\varepsilon}{k}  u'_iz'
where u'_iz' is the vector (volVectorField) which has to be solved
in OpenFOAM-1.6 as
Code:
    volVectorField R_Z = turbulence->R() & fvc::grad(Z);
    volVectorField uz_gU = uz & fvc::grad(U);

    fvVectorMatrix uzEqn
    (
        fvm::ddt(rho, uz)
      + fvm::div(phi, uz)
      - fvm::laplacian(rho*C_s*turbulence->k()/turbulence->epsilon()*turbulence->R(), uz)
      ==
        rho*(C_2 - 1)*uz_gU
      - rho*R_Z
      - rho*C_1*turbulence->epsilon()/turbulence->k()*uz
    );
The point is, that one has to calculate the two inner products of tensor and vector (which give volVectorFields) outside or before the actual equation. It compiles and runs, but not very stable. I use it together with the LRR turbulence model, but not with the default diffusion term (as explained here laplacian(tensor,tensor) seg faults ).

Any comments? Is there a better way or more "stable form" to implement the equation?

Thank you and kind regards,
Johannes

Last edited by jfw_cfd; December 4, 2013 at 12:59.
jfw_cfd is offline   Reply With Quote

Old   July 7, 2014, 10:04
Default
  #5
New Member
 
Xiangyu Gao
Join Date: Sep 2013
Location: West Lafayette, IN, USA
Posts: 29
Rep Power: 3
gxy200992243 is on a distinguished road
Hi, Johannes

Have you got the solution to this problem? I am also facing the inner product of a tensor and a vector. Can you post the solution to this problem?

Best regards,

Xiangyu
gxy200992243 is offline   Reply With Quote

Old   July 7, 2014, 10:33
Arrow proposed solution should work
  #6
New Member
 
Johannes
Join Date: Mar 2011
Location: Valencia, Spain
Posts: 7
Rep Power: 6
jfw_cfd is on a distinguished road
Hello Xiangyu!

Well, the solution of how to calculate the inner product of a tensor and a vector which I stated in my previous post should actually work (I guess you can see the code snippet). At least it worked for me (compiled and calculated). The instabilities I mentioned above, did not arise from this part of the code as far as I remember (all this happened quite some months ago...).

Unfortunately, I don't have any further news about this topic. So I hope the above code works for you, which should be the case if just the inner product is the problem.

Kind regards,
Johannes
jfw_cfd is offline   Reply With Quote

Old   July 7, 2014, 10:36
Default
  #7
New Member
 
Xiangyu Gao
Join Date: Sep 2013
Location: West Lafayette, IN, USA
Posts: 29
Rep Power: 3
gxy200992243 is on a distinguished road
Hi, Johannes!

Thank you very much for your reply! I just tried. Your solution works for my case perfectly! Thank you again for your help!

Best regards,

Xiangyu
gxy200992243 is offline   Reply With Quote

Old   July 7, 2014, 10:41
Thumbs up
  #8
New Member
 
Johannes
Join Date: Mar 2011
Location: Valencia, Spain
Posts: 7
Rep Power: 6
jfw_cfd is on a distinguished road
Perfect! That's good to hear, Xiangyu!
jfw_cfd is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:01.