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

Matrix and Varialbe Definition

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 12, 2012, 02:51
Default Matrix and Varialbe Definition
  #1
Member
 
Join Date: Mar 2012
Location: Munich, Germany
Posts: 67
Rep Power: 14
treima is on a distinguished road
Hello,

is it possible to define a 5x5 matrix in OpenFoam? If yes, how?

The same question is, if there is a possibility to define a vector with 5 components? But Iīve to make this definition in "createFields.H"

I would like to solve the equation

\frac{d}{dt} v + A \frac{d}{dx} v + B \frac{d}{dy} v + C \frac{d}{dz} v = 0

where A,B,C are 5x5 matrices and v a 5x1 vector.


Best regards

treima
treima is offline   Reply With Quote

Old   July 13, 2012, 02:27
Default
  #2
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
Is it just the equation or are you going to solve that on a finite-volume grid?

In Version 1.6-ext there is support for NxN matrices. You might want to check this out!

Best

Kathrin
kathrin_kissling is offline   Reply With Quote

Old   July 13, 2012, 02:49
Default
  #3
Member
 
Join Date: Mar 2012
Location: Munich, Germany
Posts: 67
Rep Power: 14
treima is on a distinguished road
Thanks.

Iīd like to solve that one the grid for v, yes. Iīve tried to divied this into three equations like the density, momentum and energy equation like the "normal" way, but they are coupled.

Have you ever tried this with OpenFoam 2.1.0, too? Or have you any experience if there is support, too?

And the last question . Do you know how it is done in 1.6-ext?


Best

treima
treima is offline   Reply With Quote

Old   August 10, 2012, 03:23
Default
  #4
Member
 
Join Date: Mar 2012
Location: Munich, Germany
Posts: 67
Rep Power: 14
treima is on a distinguished road
Hello,

I didnīt work on this for a while, but now Iīve found some possiblities and, of course, new problems.

Here ist my partial differential equation system, which i like to solve:

\frac{\partial}{\partial t} \begin{pmatrix} \Lambda_1 \\ \Lambda_2 \\ \Lambda_3 \\ \Lambda_ 4 \\ \Lambda_5 \end{pmatrix} +
\begin{pmatrix} 0 & a_{21} & a_{31} & a_{41} & a_{51} \\ 1 & a_{22} & a_{32} & a_{42} & a_{52} \\ 
    0 & a_{23} & a_{33} & 0 & a_{53} \\ 0 & a_{24} & 0 & a_{44} & a_{54} \\ 0 & a_{25} & 0 & 0 & a_{55} \end{pmatrix} \frac{\partial}{\partial x}  \begin{pmatrix} \Lambda_1 \\ \Lambda_2 \\ \Lambda_3 \\ \Lambda_ 4 \\ \Lambda_5 \end{pmatrix} +
+ \begin{pmatrix} 0 & b_{21} & b_{31} & b_{41} & b_{51} \\ 0 & b_{22} & b_{32} & 0 & b_{52} \\
      1 & b_{23} & b_{33} & b_{43} & b_{53} \\ 0 & 0 & b_{34} & b_{44} & b_{54} \\
      0 & 0 & b_{35} & 0 & b_{55} \end{pmatrix} \frac{\partial}{\partial y} \begin{pmatrix} \Lambda_1 \\ \Lambda_2 \\ \Lambda_3 \\ \Lambda_4 \\ \Lambda_5 \end{pmatrix} +
+
\begin{pmatrix} 0 & c_{21} & c_{31} & c_{41} & c_{51} \\ 0 & c_{22} & 0 & c_{42} & c_{52} \\
      0 & 0 & c_{33} & c_{43} & c_{53} \\ 1 & c_{24} & c_{34} & c_{44} & c_{54} \\
      0 & 0 & 0 & c_{45} & c_{55} \end{pmatrix} \frac{\partial}{\partial z}
\begin{pmatrix} \Lambda_1 \\ \Lambda_2 \\ \Lambda_3 \\ \Lambda_4 \\ \Lambda_5 \end{pmatrix} = 0 \,.

Iīve defined the matrices via
Matrix<volScalarField,scalarField> jacobi_f(5,5), jacobi_g(5,5), jacobi_h(5,5);
and assigned the elements via
jacobi_f[i][j] = functions;
and so on.

My problem is now, how to deal with vectors of dimension five. Itīs not possible to define a five-dimensional volVectorField and to combine this with my matrices.
Is it possible to solve the five dimensional coupled system with OpenFoam? If yes, how can this be done? Do you have any ideas?


regards,
treima
treima is offline   Reply With Quote

Old   August 10, 2012, 03:32
Default
  #5
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
Check out the VectorN class in 1.6-ext.

There is no such thing in the vanilla version.

Sorry

Best

Kathrin
kathrin_kissling is offline   Reply With Quote

Old   August 10, 2012, 05:05
Default
  #6
Member
 
Join Date: Mar 2012
Location: Munich, Germany
Posts: 67
Rep Power: 14
treima is on a distinguished road
Thanks a lot for this quick reply!

Iīve to make some changes in my solver for using it with 1.6-ext.

But do you know an existing solver where VectorN is used?
treima is offline   Reply With Quote

Old   August 10, 2012, 05:14
Default
  #7
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
Hey treima,

in 1.6-ext there is blockCoupledScalarTransportFoam

documentation and application of the tecnique can be found in Ivor Cliffords work (6th OFW training material) and in my work (see this years OFW presentation slides)

Best

Kathrin
kathrin_kissling is offline   Reply With Quote

Old   August 11, 2012, 07:36
Default
  #8
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Hello

I think you can go around your problem in OF 2.x by dividing your equation into 5 scalar equations and solve each separately.

I mean the interaction-terms can be treated explicitly and you iterate to converge (the segregated way)

Regards,
Hisham
Hisham is offline   Reply With Quote

Old   August 14, 2012, 02:30
Default
  #9
Member
 
Join Date: Mar 2012
Location: Munich, Germany
Posts: 67
Rep Power: 14
treima is on a distinguished road
Hello,

Iīve thought about this, too. But the five equations are coupled with each other, so that it isnīt possible to extract parts with less then four variables and I think. In OpenFOAM you canīt solve equations with more than one variable, right? Perhaps I didnīt understand this solution, but at the moment I canīt see your point

Thanks Kathrin for hints, Iīll have a closer look at the blockCoupled-solver and try to extend this one for five equations!


Regards
treima
treima is offline   Reply With Quote

Old   August 24, 2012, 09:34
Default
  #10
Member
 
Join Date: Mar 2012
Location: Munich, Germany
Posts: 67
Rep Power: 14
treima is on a distinguished road
Hello,

Iīve tried to sperate these equations, like Hisham suggested, in scalar equations. Now Iīm solving this problem (for demonstration, I take the first row)

\frac{\partial}{\partial t} \Lambda_1 + a_{21} \frac{\partial}{\partial x} \Lambda_2 + a_{31} \frac{\partial}{\partial x} \Lambda_3 + a_{41} \frac{\partial}{\partial x} \Lambda_4 + a_{51} \frac{\partial}{\partial x} +
b_{21} \frac{\partial}{\partial y} \Lambda_2 + b_{31}  \frac{\partial}{\partial y} \Lambda_3 + b_{41} \frac{\partial}{\partial y} \Lambda_4 + b_{51} \frac{\partial}{\partial y} +
c_{21} \frac{\partial}{\partial z} \Lambda_2 + c_{31}  \frac{\partial}{\partial z} \Lambda_3 + c_{41} \frac{\partial}{\partial z} \Lambda_4 + c_{51} \frac{\partial}{\partial z} = 0

+ the four other equations.

In OpenFOAM Iīve Implemented this:

solve
(
fvm::ddt(Lambda_1) + a21*gradXLambda2 + 1./tcoeff*a31*gradXLambda3 +
1./tcoeff*a41*gradXLambda4 + 1./pow(tcoeff,2)*a51*gradXLambda5 +
1./tcoeff*b21*gradYLambda2 + 1./tcoeff*b31*gradYLambda3 +
1./tcoeff*b41*gradYLambda4 + 1./pow(tcoeff,2)*b51*gradYLambda5 +
1./tcoeff*c21*gradZLambda2 + 1./tcoeff*c31*gradZLambda3 +
1./tcoeff*c41*gradZLambda4 + 1./pow(tcoeff,2)*c51*gradZLambda5
);

solve
(
equation2
);

solve
(
equation3
);

solve
(
equation4
);

solve
(
equation5
);

where tcoeff is a cofactor to get the right dimensions (at the end, dimensions doesnīt matter) and gradXLambda2, gradXLambda3 are defined as followed:

volScalarField gradXLambda2 (unitVector_x & fvc::grad(Lambda_2));

Is this the right way to do this? The results are a little bit confusing. Perhaps the mistake is in my implementation, in my derivation of the equations, in my boundary conditions or somewhere else.

Do anyone have any experience or suggestions concerning my problem?

Thanks,
treima
treima 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



All times are GMT -4. The time now is 08:37.