sparse matrix algorithms and advanced topics in fem math
play

Sparse Matrix Algorithms and Advanced Topics in FEM MATH 9830 Timo - PowerPoint PPT Presentation

Sparse Matrix Algorithms and Advanced Topics in FEM MATH 9830 Timo Heister (heister@clemson.edu) http://www.math.clemson.edu/~heister/math9830-spring2015/ Tasks Lab 1 Grab class repo Git clone https://github.com/tjhei/spring15_9830


  1. Sparse Matrix Algorithms and Advanced Topics in FEM MATH 9830 Timo Heister (heister@clemson.edu) http://www.math.clemson.edu/~heister/math9830-spring2015/

  2. Tasks Lab 1 ● Grab class repo – Git clone https://github.com/tjhei/spring15_9830 – Compile example: g++ main.cc – Run: ./a.out – Do question 2 from homework 1 – Work on the other tasks listed in the cc ● Install deal.II ● Run deal.II step 2 – Print sparsity pattern, change refinement – Use cuthill_mckee, other ordering? – Change to dim=3, etc.

  3. Tasks Lab 2 ● Deal.II intro ● Work on hw2 ● Bonus: step 2 – Print sparsity pattern, change refinement – Use cuthill_mckee, other ordering? – Change to dim=3, etc.

  4. deal.II ● “A Finite Element D ifferential E quations A nalysis L ibrary” ● Open source, c++ library ● I am one of the four maintainers ● One of the most widely used libraries: – ~600 papers using and citing deal.II – ~600 downloads/month – 100+ people have contributed in the past 10 years – ~600,000 lines of code – 10,000+ pages of documentation ● Website: www.dealii.org

  5. Features ● 1d, 2d, 3d computations, adaptive mesh refinement (on quads/hexas only) ● Finite element types: – Continuous and DG Lagrangian elements – Higher order elements, hp adaptivity – Raviart-Thomas, Nedelec, … – And arbitrary combinations

  6. Features, part II ● Linear Algebra – Own sparse and dense library – Interfaces to PETSc, Trilinos, UMFPACK, BLAS, .. ● Parallelization – Multi-threading on multi-core machines – MPI: 16,000+ processors ● Output in many visualization file formats

  7. Development of deal.II ● Professional-level development style ● Development in the open, open repository ● Mailing lists for users and developers ● Test suite with 6,000+ tests after every change ● Platform support: – Linux/Unix – Mac – Work in progress: Windows

  8. Installation ● How to install from source code, configure, compile, test, run “step-1” ● Ubuntu (or any other linux) or Mac OSX ● Steps: – Detect compilers/dependencies/etc. (cmake) – Compile & install deal.II (make)

  9. Prerequisites on Linux ● Compiler: GNU g++ ● Recommended: $ s u d o a p t - g e t i n s t a l l s u b v e r s i o n o p e n m p i 1 . 6 - b i n o p e n m p i 1 . 6 - c o m m o n g + + g f o r t r a n l i b o p e n b l a s - d e v l i b l a p a c k - d e v z l i b 1 g - d e v g i t e m a c s g n u p l o t ● manually: cmake (in a minute) ● Later: eclipse, paraview ● Optional manually: visit, p4est, PETSc, Trilinos, hdf5

  10. On Mac OS ● If OSX 10.9 follow instructions from wiki: https://github.com/dealii/dealii/wiki/MacOSX ● Later manually: eclipse, paraview ●

  11. cmake ● Ubuntu 12.04 has a version that is too old ● If newer ubuntu do: $ s u d o a p t - g e t i n s t a l l c m a k e … and you are done ● Otherwise: install cmake from source or download the 32bit binary

  12. cmake from binary ● Do: e x p o r t C M A K E V E R = 2 . 8 . 1 2 . 1 w g e t h t t p : / / w w w . c m a k e . o r g / f i l e s / v 2 . 8 / c m a k e - $ C M A K E V E R - L i n u x - i 3 8 6 . s h c h m o d u + x c m a k e - $ C M A K E V E R - L i n u x - i 3 8 6 . s h . / c m a k e - $ C M A K E V E R - L i n u x - i 3 8 6 . s h ● Answer “q”, yes and yes ● Add the bin directory to your path (.bashrc) ● You might need s u d o a p t - g e t i n s t a l l i a 3 2 - l i b s

  13. Cmake from source w g e t ¬ h t t p : / / w w w . c m a k e . o r g / f i l e s / v 2 . 8 / c m a k e - 2 . 8 . 1 2 . 1 . t a r . g z t a r x f c m a k e - 2 . 8 . 1 1 . 1 . t a r . g z . / c o n f i g u r e m a k e i n s t a l l

  14. Install deal.II ● http://www.dealii.org/8.1.0/readme.html Test part two: ● ● Extract: c d e x a m p l e s / s t e p - 1 t a r x f d e a l . I I - 8 . 1 . 0 . t a r . g z c m a k e - D D E A L _ I I _ D I R = / ? / ? . ● Build directory: m a k e r u n c d d e a l . I I ; m k d i r b u i l d ; c d b u i l d Recommended layout: ● ● Configuration: d e a l . I I / c m a k e - D C M A K E _ I N S T A L L _ P R E F I X = / ? / ? . . (where /?/? is your installation directory) < build files b u i l d ● Compile (5-60 minutes): < your inst. dir i n s t a l l e d < all examples! m a k e - j X i n s t a l l e x a m p l e s (where X is the number of cores you have) i n c l u d e ● Test: s o u r c e (in build directory) m a k e t e s t . . .

  15. Running examples In short: ● cd examples/step-1 cmake . make run cmake: ● Detect configuration, only needs to be run once – Input: CMakeLists.txt – Output: Makefile, (other files like CmakeCache.txt) – make: ● Tool to execute commands in Makefile, do every time you change your code – Input: step-1.cc, Makefile – Output: step-1 (the binary executable file) – Run your program with ● ./step-1 Or (compile and run): ● make run

  16. How to create an eclipse project ● Run this once in your project: cmake -G "Eclipse CDT4 - Unix Makefiles" . ● Now create a new project in eclipse (“file- >import->existing project” and select your folder for the project above) ● Eclipse intro: http://www.math.tamu.edu/~bangerth/videos.676.7.html – http://www.math.tamu.edu/~bangerth/videos.676.8.html –

  17. Templates in C++ ● “blueprints” to generate functions and/or classes ● Template arguments are either numbers or types ● No performance penalty! ● Very powerful feature of C++: difficult syntax, ugly error messages, slow compilation ● More info: http://www.cplusplus.com/doc/tutorial/templates/ http://www.math.tamu.edu/~bangerth/videos.676.12 .html ●

  18. Why used in deal.II? ● Write your program once and run in 1d, 2d, 3d: DoFHandler<dim>::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); for (; cell!=endc; ++cell) { ... cell_matrix(i,j) += (fe_values.shape_grad (i, q_point) * fe_values.shape_grad (j, q_point) * ● Also: large parts of the library independent of dimension fe_values.JxW (q_point));

  19. Function Templates ● Blueprint for a function t e m p l a t e < t y p e n a m e n u m b e r > n u m b e r s q u a r e ( c o n s t n u m b e r x ) ● One type called “ number ” { r e t u r n x * x ; } ; ● You can use i n t x = 3 ; i n t y = s q u a r e < i n t > ( x ) ; “typename” or “class” ● Sometimes you need to state which function you want to call: t e m p l a t e < t y p e n a m e T > v o i d y e l l ( ) { T t e s t ; t e s t . s h o u t ( “ H I ! ” ) ; } ; / / c a t i s a c l a s s t h a t h a s s h o u t ( ) y e l l < c a t > ( ) ;

  20. Value Templates ● Template arguments can also be values (like int) instead of types: t e m p l a t e < i n t d i m > v o i d m a k e _ g r i d ( T r i a n g u l a t i o n < d i m > & t r i a n g u l a t i o n ) { … } T r i a n g u l a t i o n < 2 > t r i a ; m a k e _ g r i d < 2 > ( t r i a ) ; ● Of course this would have worked here too: t e m p l a t e < t y p e n a m e T > v o i d m a k e _ g r i d ( T & t r i a n g u l a t i o n ) { … / / n o w w e c a n n o t a c c e s s “ d i m ” t h o u g h

  21. Class templates ● Whole classes from a blueprint ● Same idea: t e m p l a t e < i n t d i m > n a m e s p a c e s t d c l a s s P o i n t { { t e m p l a t e < t y p e n a m e n u m b e r > d o u b l e e l e m e n t s [ d i m ] ; c l a s s v e c t o r ; / / . . . } } s t d : : v e c t o r < i n t > l i s t _ o f _ i n t s ; P o i n t < 2 > a _ p o i n t ; s t d : : v e c t o r < c a t > c a t s ; P o i n t < 5 > d i f f e r e n t _ p o i n t ;

  22. Example t e m p l a t e < u n s i g n e d i n t N > d o u b l e n o r m ( c o n s t P o i n t < N > & p ) { d o u b l e t m p = 0 ; f o r ( u n s i g n e d i n t i = 0 ; i < N ; + + i ) t m p + = s q u a r e ( v . e l e m e n t s [ i ] ) ; r e t u r n s q r t ( t m p ) ; } ; ● Value of N known at compile time ● Compiler can optimize (unroll loop) ● Fixed size arrays faster than dynamic (dealii::Point<dim> vs dealii::Vector<double>)

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend