Inner product of tensor and vector

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

 December 3, 2013, 04:11 Inner product of tensor and vector #1 New Member   Johannes Join Date: Mar 2011 Location: Austria Posts: 11 Rep Power: 7 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 is a vector (volVectorField), so the first term is the inner product of a vector and a tensor 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 >&, const Foam::tmp >&) [with Type = Foam::Vector](((const Foam::tmp > >&)((const Foam::tmp > >*)(& Foam::fvm::laplacian(const Foam::tmp >&, Foam::GeometricField&) [with Type = Foam::Vector, GType = Foam::SymmTensor](((Foam::GeometricField, Foam::fvPatchField, Foam::volMesh>&)(& uz))))))) == Foam::operator*(const Foam::tmp >&, const Foam::tmp >&) [with Type = Foam::SymmTensor, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::tmp, Foam::fvPatchField, Foam::volMesh> >&)((const Foam::tmp, 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

 December 3, 2013, 08:02 #2 Senior Member   Bernhard Join Date: Sep 2009 Location: Delft Posts: 790 Rep Power: 14 The error message you give does not relate to the posted code, because there is no "==" in there.

 December 3, 2013, 08:11 #3 New Member   Johannes Join Date: Mar 2011 Location: Austria Posts: 11 Rep Power: 7 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....

 December 3, 2013, 14:03 possible solution #4 New Member   Johannes Join Date: Mar 2011 Location: Austria Posts: 11 Rep Power: 7 As I sad before, I'll come back with a solution which I would like to share with you. I finally implemented this equation = where 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.

 July 7, 2014, 10:04 #5 New Member   Xiangyu Gao Join Date: Sep 2013 Location: West Lafayette, IN, USA Posts: 29 Rep Power: 5 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

 July 7, 2014, 10:33 proposed solution should work #6 New Member   Johannes Join Date: Mar 2011 Location: Austria Posts: 11 Rep Power: 7 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

 July 7, 2014, 10:36 #7 New Member   Xiangyu Gao Join Date: Sep 2013 Location: West Lafayette, IN, USA Posts: 29 Rep Power: 5 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

 July 7, 2014, 10:41 #8 New Member   Johannes Join Date: Mar 2011 Location: Austria Posts: 11 Rep Power: 7 Perfect! That's good to hear, Xiangyu!

 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

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