CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Can OpenFOAM handle Third-Rank Tensor (https://www.cfd-online.com/Forums/openfoam/75856-can-openfoam-handle-third-rank-tensor.html)

JinBiao May 7, 2010 04:12

Can OpenFOAM handle Third-Rank Tensor
 
Hi Foamers,

In the documentation for OpenFOAM the rank-3 tensor is mention. But I can't find a corresponding class in the OpenFOAM code. And there seems rare information on this forum. Anyone have an idea where to find it? Or there is no class like that in the OF.

Thanks in advance.

Jinbiao

alberto May 7, 2010 21:00

What do you have to do? Solve a transport equation for a 3x3 matrix as unknown? Manipulate tensors?

OpenFOAM can do that with fvTensorMatrix and volTensorField / surfaceTensorField.

If you provide some more detail, we can answer better ;-)

Best,

JinBiao May 9, 2010 01:06

Alberto, thanks for your reply.

I am implementing a second moment closure for reynolds stress. Here I have to solve equations for a symmetric third rank tensor, u_i*u_j*u_k. The highest rank of tensor involved is rank 4.

For a better understanding, I provide the major equations below

rms = root mean square

Code:

D(u_i*u_j*u_k)/Dt = P_i,j,k + phi_i,j,k + d_i,j,k + eps_i,j,k

d_i,j,k = d( rms(u_i*u_j) * rms(u_k*u_l) + rms(u_k*u_j) * rms(u_i*u_l) + rms(u_i*u_k) * rms(u_j*u_l) ) / dt

Best

Jinbiao

alberto May 9, 2010 01:20

A transport equation for a symmetric tensor can be solved using fvSymmTensorMatrix, while for asymmetric tensors you have to use fvTensorMatrix.

If you have higher rank matrices, you have to deal with them independently (you can either use scalar equations for each component (easier and faster to do), or extend fvMatrix (more complicated)).

P.S. You can take a look at the implementation of Reynolds stress models too.

Best,

JinBiao May 9, 2010 02:28

Alberto, thank you so much for the encouraging message.

Actually I am solving a matrix for symmetric rank 3 tensor. I am trapped at the beginning because I can not find a class for rank 3 tensor. Do you know where to find it or I have to write this into OpenFOAM by myself?

Thanks again.

Regards.

Jinbiao

alberto May 9, 2010 02:36

For symmetric tensors (not field):

http://foam.sourceforge.net/doc/Doxy...ymmTensor.html

For symmetric tensor fields:

http://foam.sourceforge.net/doc/Doxy...nsorField.html

Best,

JinBiao May 9, 2010 02:41

Sorry, I am still confused about this.

These two classes are for rank 2 tensors. The components and operators of rank 3 tensor is different from provided by them. How can I relate them together?

Thanks again.

Jinbiao

deepsterblue May 9, 2010 09:03

27 components... Hmm.. That doesn't exist as yet, but I don't see why not. You'd have to write your own rank-3 tensor class, but although the extension process is straightforward, writing all that code is not. Taking its gradient, for instance, would be quite a laborious process indeed.
I guess you would still have to solve such a system in the conventional segregated sense (one component at a time). Hopefully, there's some way in which you can manipulate your equations to reduce the rank.

alberto May 9, 2010 12:27

Sorry for the confusion. I should stop answering late... ;-)

As Sandeep said, there is no implementation of rank > 2 tensors in OpenFOAM. Simply use scalar transport equations, maybe collected in a list to have a cleaner code.

Best,

alberto May 9, 2010 20:47

Some additional hints that might help you to carry your 27 equations without writing too much spaghetti code :D

You can collect equations in a PtrList defined as

Code:

PtrList<fvScalarMatrix> myScalarEquations(nScalars);
where nScalars is the number of scalars you want to use (remember, it starts for 0 and ends at 26 if you have a complete rank 3 tensor).

To set your equations you can loop for i = 0 to i < nScalars, adding each scalar equation to the PtrList as follows:

Code:

for (int i = 0; i < nScalars; i++)
{
  myScalarEquations.set
  (
      i,
      new fvScalarMatrix
      (
        // Put the terms of your equation here, as usual
      )
  );
}

Once defined, you can relax all of them with

Code:

for (int i = 0; i < nScalars; i++)
{
  myScalarEquations[i].relax();  // you can put a label inside relax to use always the same URF
}

and then you can solve them with

Code:

for (int i = 0; i < nScalars; i++)
{
  myScalarEquations[i].solve();  // you can put a label inside solve to specify the linear solver only once in fvSolution (see pimpleFoam to see how this is done).
}

You can use PtrList in a similar way to collect fields. The idea is always the same.

I hope this helps (and it doesn't confuse you more than what I did before :().

Best,

JinBiao May 9, 2010 21:31

Alberto and Sandeep, Thanks a lot.

Now I have the direction to solve my problem. I will post it here, if I have further questions.

Many thanks again. By the way, spaghetti tastes very good. :p


All times are GMT -4. The time now is 13:59.