
[Sponsors] 
September 29, 2009, 08:33 
Solving System of Linear equations

#1 
Member
Mihails Ščepanskis
Join Date: Jul 2009
Posts: 36
Rep Power: 8 
Hi!
I need to solve in OpenFOAM system of linear equation like A*b = c where A is tensor (rank 2) and c is vector. A and c are constants. How can I solve this equation? Thank you 

September 30, 2009, 01:03 

#2 
Member
Mihails Ščepanskis
Join Date: Jul 2009
Posts: 36
Rep Power: 8 
Thank you, Stanley!
Can you show how to use this function? What Hfile I should include solve function to work? 

October 1, 2009, 00:09 

#3 
Member
Mihails Ščepanskis
Join Date: Jul 2009
Posts: 36
Rep Power: 8 
//I've created tensor A:
tensor A(Axx, Axy, Axz, Ayx, Ayy, Ayz, Azx, Azy, Azz); //and vector c: vector c(cx, cy, cz); and now I want to get vector b: A*b=c 

October 1, 2009, 19:05 

#4 
Senior Member
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 981
Rep Power: 17 
Why use OpenFOAM instead of MATLAB / Octave for this?


October 2, 2009, 00:46 

#5 
Member
Mihails Ščepanskis
Join Date: Jul 2009
Posts: 36
Rep Power: 8 
Anton, because it is only one step of big programm.
First I solve MHD turbulent equations in crucible. Then I solve lagrangian equation for solid particle motion. I take into acount lift force to (proportional U x rot(U)). And to solve this aquation I need to solve system of linear algebraic equations. 

November 14, 2010, 14:03 

#6 
Member
Niklas Winkler
Join Date: Mar 2009
Location: Stockholm, Stockholm, Sweden
Posts: 73
Rep Power: 8 
Hi Mihails,
I would also be able to solve a system of linear equations in OF as a part of a larger code. Did you ever find out if there is a possibility to solve a system of linear equations i OF? Thanks 

November 14, 2010, 16:04 

#7 
Member

Why don't you use our GPUbaed code (speedit.vratis.com)? It can be easily plugged to OF. So far we support CG/BiCGSTAB for solving symmetric/unsymmetric matrices in single/double precision (soon also with complex values).


November 15, 2010, 03:50 

#8 
Member
Mihails Ščepanskis
Join Date: Jul 2009
Posts: 36
Rep Power: 8 
Year ago I decided that it is much easier for me to write my own code that solve systems of linear equation using Gauss method.
__________________
Mihails Ščepanskis Laboratory for Mathematical Modelling of Environmental and Technological Processes University of Latvia 

November 15, 2010, 05:30 

#9 
Member

But happens if the matrix is huge and sparse. The memory requirements are quite high for Gauss method.


November 15, 2010, 05:40 

#10 
Member
Mihails Ščepanskis
Join Date: Jul 2009
Posts: 36
Rep Power: 8 
Of course you are right, Lukasz. I am solving my specific problem and I have no goal to write universal code for systems of linear equations.
__________________
Mihails Ščepanskis Laboratory for Mathematical Modelling of Environmental and Technological Processes University of Latvia 

November 16, 2010, 05:27 

#11 
Member
Niklas Winkler
Join Date: Mar 2009
Location: Stockholm, Stockholm, Sweden
Posts: 73
Rep Power: 8 
Thanks both of you!
The simplest way for me is to go for Michails suggestion, which I've already implemented in Matlab. Now I will just need to rewrite it into OF which for me will be the tricky part. Regards 

November 16, 2010, 05:36 

#12 
Senior Member
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 8 
Hi,
if you want to use Gaussalgorithm only, you don't have to hardcode it. There is already a class called simpleMatrix which can do this job. The source is located in src/OpenFOAM/matrices/simpleMatrix/ . I don't know if there is an example in any solver, but it is quite simple to use. Regards, Stefan 

November 16, 2010, 07:52 

#13 
Member
Niklas Winkler
Join Date: Mar 2009
Location: Stockholm, Stockholm, Sweden
Posts: 73
Rep Power: 8 
Perfect!
It works as expected. Thanks /NW 

December 5, 2013, 11:40 

#14 
Member
Evangelos
Join Date: Sep 2011
Posts: 68
Rep Power: 6 
Hello ! can you tell me how you add simpleMatrix to your code ?
I am trying to do the same thing but i have a lot of problems ! 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Moving mesh  Niklas Wikstrom (Wikstrom)  OpenFOAM Running, Solving & CFD  122  June 15, 2014 06:20 
How to write k and epsilon before the abnormal end  xiuying  OpenFOAM Running, Solving & CFD  8  August 27, 2013 15:33 
Differences between serial and parallel runs  carsten  OpenFOAM Bugs  11  September 12, 2008 11:16 
IcoFoam parallel woes  msrinath80  OpenFOAM Running, Solving & CFD  9  July 22, 2007 02:58 
Could anybody help me see this error and give help  liugx212  OpenFOAM Running, Solving & CFD  3  January 4, 2006 19:07 