# Solving System of Linear equations

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

 September 29, 2009, 08:33 Solving System of Linear equations #1 Member   Mihails Ščepanskis Join Date: Jul 2009 Posts: 36 Rep Power: 10 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: 10 Thank you, Stanley! Can you show how to use this function? What H-file I should include solve function to work?

 October 1, 2009, 00:09 #3 Member   Mihails Ščepanskis Join Date: Jul 2009 Posts: 36 Rep Power: 10 //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: Germany Posts: 1,261 Rep Power: 23 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: 10 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: 10 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   Lukasz Miroslaw Join Date: Dec 2009 Location: Poland Posts: 66 Rep Power: 9 Why don't you use our GPU-baed 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: 10 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   Lukasz Miroslaw Join Date: Dec 2009 Location: Poland Posts: 66 Rep Power: 9 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: 10 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: 10 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: 10 Hi, if you want to use Gauss-algorithm 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: 10 Perfect! It works as expected. Thanks /NW

 December 5, 2013, 11:40 #14 Member   Evangelos Join Date: Sep 2011 Posts: 85 Rep Power: 7 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 Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20 xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 15:33 carsten OpenFOAM Bugs 11 September 12, 2008 11:16 msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58 liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 19:07

All times are GMT -4. The time now is 09:52.