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

Matrix manipulation

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

Like Tree1Likes
  • 1 Post By santiagomarquezd

Reply
 
LinkBack Thread Tools Display Modes
Old   February 13, 2012, 10:23
Default Matrix manipulation
  #1
Senior Member
 
Bernhard Linseisen
Join Date: May 2010
Location: Geneva
Posts: 116
Blog Entries: 1
Rep Power: 5
Linse is on a distinguished road
Hello all!

According to some standard books (Patankar, Versteeg, etc.), the common way of solving CFD-problems (abbreviatedly) consists of getting the equations into a form of aX + bX + cX = D, which is put into a matrix A of coefficients a, b and c and two vectors of X and D, basically giving a system [A] X = D.
Several steps are needed for solving this equation system, among others
- getting a, b and c into a form that makes [A] consisting of one diagonal of values instead of three (use of recurrence relations)
- calculating the actual value for X based on the results of the recurrence calculations

My question now is:
In which parts of the code are these steps done?
And how could these steps be manipulated?
Ideally I would like to access the equations/matrices on a cell-level and change/control them cell-wise...

I guess I will have to manipulate the matrices themselves, but how is that done? Any information/pointing to information would be highly welcome!

Thank you all in advance!
Linse is offline   Reply With Quote

Old   February 13, 2012, 12:42
Default
  #2
New Member
 
Andreas Ruopp
Join Date: Aug 2009
Location: Stuttgart / Germany
Posts: 16
Rep Power: 5
andyru is on a distinguished road
Hi,

if you look into the solver ico-Foam for example, the main coefficients of the matrix are calculated with function A():

Code:
volScalarField rUA = 1.0/UEqn.A();
Here you can acces them an manipulate them.

Code:
forAll(rUA,celli)
{
...
}
So, this depends, what you want to do?

I'm facing almost the same problem and I need to manipulate the source term grad(vsf) (Manipulating source fvc::grad(vsf1+vsf2))

What is your physical application?


Greetings

Andy
andyru is offline   Reply With Quote

Old   February 21, 2012, 21:28
Default
  #3
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 371
Rep Power: 11
santiagomarquezd will become famous soon enough
Quote:
Originally Posted by Linse View Post
Hello all!

According to some standard books (Patankar, Versteeg, etc.), the common way of solving CFD-problems (abbreviatedly) consists of getting the equations into a form of aX + bX + cX = D, which is put into a matrix A of coefficients a, b and c and two vectors of X and D, basically giving a system [A] X = D.
Several steps are needed for solving this equation system, among others
- getting a, b and c into a form that makes [A] consisting of one diagonal of values instead of three (use of recurrence relations)
- calculating the actual value for X based on the results of the recurrence calculations

My question now is:
In which parts of the code are these steps done?
And how could these steps be manipulated?
Ideally I would like to access the equations/matrices on a cell-level and change/control them cell-wise...

I guess I will have to manipulate the matrices themselves, but how is that done? Any information/pointing to information would be highly welcome!

Thank you all in advance!
The questions are not so clear. I could help but I can't understand the problem.

Regards.
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Post-doctoral Fellow
Research Center for Computational Mechanics (CIMEC) - CONICET/FICH-UNL
T.E.: 54-342-4511594 Ext. 1005
Güemes 3450 - (3000) Santa Fe
Santa Fe - Argentina
http://www.cimec.org.ar
santiagomarquezd is offline   Reply With Quote

Old   April 4, 2012, 05:58
Default
  #4
Member
 
Avdeev Evgeniy
Join Date: Jan 2011
Location: Togliatty, Russia
Posts: 33
Blog Entries: 1
Rep Power: 4
j-avdeev is on a distinguished road
Send a message via Skype™ to j-avdeev
Propably, I have same problem.
I want to save matrices A to separate file (A from AX=D).

http://openfoamwiki.net/index.php/Op...x_coefficients
Quote:
OpenFOAM stores:
  • diagonal coefficients as a scalar field, indexed by cell volume; and
  • off-diagonal coefficients as two scalar fields, indexed by face centres.
lduAddressing is used to related the two indexing methods.
but how to write it in separate file?
j-avdeev is offline   Reply With Quote

Old   April 4, 2012, 07:08
Default
  #5
Senior Member
 
Elvis
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 410
Blog Entries: 4
Rep Power: 11
elvis is on a distinguished road
I guess they want to do something similar that
Santiago Marquez Damian described in his post Can someone tell me more about vulashaka
elvis is offline   Reply With Quote

Old   April 4, 2012, 08:52
Default
  #6
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 371
Rep Power: 11
santiagomarquezd will become famous soon enough
Maybe you need http://openfoamwiki.net/index.php/Contrib_gdbOF, it has an specific tool to do that.

Regards
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Post-doctoral Fellow
Research Center for Computational Mechanics (CIMEC) - CONICET/FICH-UNL
T.E.: 54-342-4511594 Ext. 1005
Güemes 3450 - (3000) Santa Fe
Santa Fe - Argentina
http://www.cimec.org.ar
santiagomarquezd is offline   Reply With Quote

Old   April 23, 2012, 17:27
Default
  #7
Member
 
Avdeev Evgeniy
Join Date: Jan 2011
Location: Togliatty, Russia
Posts: 33
Blog Entries: 1
Rep Power: 4
j-avdeev is on a distinguished road
Send a message via Skype™ to j-avdeev
Santiago, yes, GdbOF looks like what I want.
I've read GdbOF-Manual.pdf - it has a lot of, but very general examples like

Example 3 "View Boundary Field values with gdbOF"
Code:
$ (gdb) ppatchvalues vSF 0
and not written exactly when, from which directory I have to type this command.
Maybe it's very simple for describing - but I need at least one step-by-step example.

I like example from (gdb)+OF
Code:
go to cavity tutorial directory
$cd cavity
run icoFoam in debug
$gdb icoFoam
create breakpoint
$b icoFoam.C:77

$run
There are two ways of stepping in the file:

$n (next) will step to the next line in the current file, but will not go into functions and
included files.
$s (step) will go to the next line, also in functions and included files.

- I want similar, but for GdbOF (with pfvmatrixfull or pfvmatrixsparse commands).

Can someone describe sequence of commands for describing? Or correct me, if I do something wrong.
j-avdeev is offline   Reply With Quote

Old   April 23, 2012, 17:33
Default
  #8
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 371
Rep Power: 11
santiagomarquezd will become famous soon enough
Well, it suppose some basic knowledge about gdb as a pre-requisite, tell us which solver do you want to debug and what system within it.

Regards
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Post-doctoral Fellow
Research Center for Computational Mechanics (CIMEC) - CONICET/FICH-UNL
T.E.: 54-342-4511594 Ext. 1005
Güemes 3450 - (3000) Santa Fe
Santa Fe - Argentina
http://www.cimec.org.ar
santiagomarquezd is offline   Reply With Quote

Old   April 24, 2012, 16:11
Default
  #9
Member
 
Avdeev Evgeniy
Join Date: Jan 2011
Location: Togliatty, Russia
Posts: 33
Blog Entries: 1
Rep Power: 4
j-avdeev is on a distinguished road
Send a message via Skype™ to j-avdeev
Solver - let it be simpleFoam.
Which solver to use - not matter for me (at least I think so now).

What system within solver... == what algoritm of solver?

About simpleFoam exist article here The_SIMPLE_algorithm_in_OpenFOAM
but equations of solver far from Ax=b (it would be cool for me to know this moment, where equation like
Code:
fvm::div(phi, U) - laplacian(nu, U)
become single matrix like A or I wrong?)

Also if needs case for example of debugging - it could be
$FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily

Thanks.
j-avdeev is offline   Reply With Quote

Old   April 24, 2012, 16:28
Default
  #10
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 371
Rep Power: 11
santiagomarquezd will become famous soon enough
Well,

Quote:
Originally Posted by j-avdeev View Post
it would be cool for me to know this moment, where equation like
Code:
fvm::div(phi, U) - laplacian(nu, U)
become single matrix like A or I wrong?)
it's a long story about FVM discretization and C++ implementation, but in order to be helpful, suppose you're solving a tutorial for scalarTransportFoam and you want to see the equation for following lines in scalarTransportFoam.C (the scalar advection diffusion equation without sources)

Code:
00058             solve
00059             (
00060                 fvm::ddt(T)
00061               + fvm::div(phi, T)
00062               - fvm::laplacian(DT, T)
00063             );


then go the case directory, for eample $FOAM_TUTORIALS/basic/scalarTransportFoam/pitzDaily and start gdb

$ gdb scalarTransportFoam

once you you're within gdb:

$ start
$ b fvMatrixSolve.C:140
$ continue
$ pfvmatrixfull this AdvDiff.dat
$ shell cat AdvDiff.dat

these lines will show you the matrix for this system. You also can read the AdvDiff.dat in octave or Matlab as a matrix.

Regards.
j-avdeev likes this.
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Post-doctoral Fellow
Research Center for Computational Mechanics (CIMEC) - CONICET/FICH-UNL
T.E.: 54-342-4511594 Ext. 1005
Güemes 3450 - (3000) Santa Fe
Santa Fe - Argentina
http://www.cimec.org.ar
santiagomarquezd 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Force can not converge colopolo CFX 13 October 4, 2011 22:03
How to find the product of A+ matrix and A- matrix arjun shanker Main CFD Forum 0 November 12, 2010 22:12
OpenFOAM version 1.6 details lakeat OpenFOAM Running, Solving & CFD 42 August 26, 2009 21:47
A question about matrix eigenvalues. Demidov Main CFD Forum 0 November 14, 2004 04:51
Elemtary matrix to CSR global matrix xueying Main CFD Forum 2 September 24, 2002 09:44


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