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

How to access identity matrix in OF?

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By jherb
  • 1 Post By alexeym
  • 1 Post By infinity

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 16, 2015, 02:21
Default How to access identity matrix in OF?
  #1
Senior Member
 
T. Chourushi
Join Date: Jul 2009
Posts: 321
Blog Entries: 1
Rep Power: 18
Tushar@cfd is on a distinguished road
Dear Foamers,

I wish to use identity matrix "I" for a Tensor field. I am using the following line for writing the identity matrix.

Code:
    volTensorField Ei = I ;
The above code line generates the following error, by looking at error it is clear that problem seems to be with the transformation of Tensors (spherical -to- volume field). For my case I need volTensorField to represent the identity matrix. How to resolve this issue?

Code:
testFoam.C: In function ‘int main(int, char**)’:
testFoam.C:71:22: error: conversion from ‘const sphericalTensor {aka const Foam::SphericalTensor<double>}’ to non-scalar type ‘Foam::volTensorField {aka Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>}’ requested

Thanks in Advance!

Tushar@cfd is offline   Reply With Quote

Old   January 16, 2015, 05:46
Default
  #2
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22
jherb is on a distinguished road
Try something like
Code:
 volTensorField Ei = tensor::one;
Tushar@cfd likes this.
jherb is offline   Reply With Quote

Old   January 16, 2015, 06:02
Default
  #3
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Either use correct constructor (something like this):

Code:
volTensorField Ei
(
    IOobject
    (
         "Ei",
         runTime.timeName(),
         mesh,
         IOobject::NO_READ,
         IOobject::AUTO_WRITE
    ),
    mesh,
    <dimensions>,
    <BC type>,
    I
);
if you plan to modify the field later, or, if you just need a constant in expression, use I.
Tushar@cfd likes this.
alexeym is offline   Reply With Quote

Old   January 16, 2015, 06:27
Default
  #4
Senior Member
 
T. Chourushi
Join Date: Jul 2009
Posts: 321
Blog Entries: 1
Rep Power: 18
Tushar@cfd is on a distinguished road
Thanks a lot for your quick replies. It worked
Tushar@cfd is offline   Reply With Quote

Old   March 7, 2015, 00:43
Default
  #5
New Member
 
Amir
Join Date: Jul 2011
Location: Shiraz
Posts: 15
Rep Power: 15
infinity is on a distinguished road
Hi
I've put
Code:
   volTensorField Ei;
in my header file and this

Code:
 Ei
     (
         IOobject
         (
              "Ei",
              runTime_.timeName(),
              mesh_,
              IOobject::NO_READ,
              IOobject::AUTO_WRITE
         ),
         mesh_,
     ),
in my LES model constructor to define the identity tensor but unfortunately compiler said

Code:
error: expected primary-expression before ‘)’ token
any idea?
infinity is offline   Reply With Quote

Old   March 7, 2015, 01:49
Default
  #6
Senior Member
 
T. Chourushi
Join Date: Jul 2009
Posts: 321
Blog Entries: 1
Rep Power: 18
Tushar@cfd is on a distinguished road
Quote:
Originally Posted by infinity View Post
Hi
I've put
Code:
   volTensorField Ei;
in my header file and this

Code:
 Ei
     (
         IOobject
         (
              "Ei",
              runTime_.timeName(),
              mesh_,
              IOobject::NO_READ,
              IOobject::AUTO_WRITE
         ),
         mesh_,
     ),
in my LES model constructor to define the identity tensor but unfortunately compiler said

Code:
error: expected primary-expression before ‘)’ token
any idea?
Dear Amir,

Try these:

Code:
 volTensorField Ei
     (
         IOobject
         (
              "Ei",
              runTime_.timeName(),
              mesh_,
              IOobject::NO_READ,
              IOobject::AUTO_WRITE
         ),
         mesh_,
     );
and

Code:
Ei = tensor::one;
This will do the job.

-
Best Luck!
Tushar@cfd is offline   Reply With Quote

Old   March 9, 2015, 00:47
Default
  #7
New Member
 
Amir
Join Date: Jul 2011
Location: Shiraz
Posts: 15
Rep Power: 15
infinity is on a distinguished road
Dear Tushar

I solved the problem by using

tensor Ei(1,0,0,0,1,0,0,0,1);

and it worked ,

wish U the best my friend and thanks a lot for quick answering
acs likes this.
infinity 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
Convection Diffusion 1-D Matrix Problem balrog Main CFD Forum 1 November 3, 2014 14:34
more equation in block matrix system yhaomin2007 OpenFOAM 1 September 6, 2012 09:33
Access to arrays of Pressure matrix in CFX omidiut CFX 5 October 14, 2011 13:05
Force can not converge colopolo CFX 13 October 4, 2011 23:03
OpenFOAM version 1.6 details lakeat OpenFOAM Running, Solving & CFD 42 August 26, 2009 22:47


All times are GMT -4. The time now is 06:11.