the finite element method in scientific computing math
play

The Finite Element Method in Scientific Computing MATH 9830 Timo - PowerPoint PPT Presentation

The Finite Element Method in Scientific Computing MATH 9830 Timo Heister (heister@clemson.edu) http://www.math.clemson.edu/~heister/math983-spring2014/ Goals of this course Learn about the software library deal.II understand practical


  1. The Finite Element Method in Scientific Computing MATH 9830 Timo Heister (heister@clemson.edu) http://www.math.clemson.edu/~heister/math983-spring2014/

  2. Goals of this course ● Learn about the software library deal.II ● understand practical aspects of finite element software ● use the library deal.II for own computations ● Build, document, and present a sophisticated software project ● solve nonlinear, time-dependent, and coupled PDEs ● use advanced tools in software development (IDEs, debuggers, ...) ● Not: – Teach the Finite Element Method (see 8660) – Learn how to program in C++ (but I am happy to help!)

  3. Topics ● basics of FEM, structure of FEM codes, algorithmic aspects ● modern tools for software development (IDEs, debuggers, …) ● some C++ topics (templates, …) used in large software projects ● iterative solvers and preconditioners ● coupled PDEs, block systems ● nonlinear problems ● time discretization ● parallel computations ● software engineering practices

  4. deal.II ● “A Finite Element D ifferential E quations A nalysis L ibrary” ● Open source, c++ library ● I am one of the three maintainers ● One of the most widely used libraries: – ~400 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 – Raviart-Thomas, Nedelec, … – Higher order elements, hp adaptivity – 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. For you ● Join the mailing lists – Ask questions – Just read and learn ● Become a contributor – Smallest changes are welcome! (find a typo? Documentation of a function lacking? Implement a small feature?) ● Cite deal.II if you use it

  9. Homework 1 ● Due on Friday: – Create google document, share with timo.heister@gmail.com and start taking notes! – Watch lecture 1 ● Setup and bring a laptop running Linux (preferred), or Mac OS – Dual booting Windows and Ubuntu possible – I am happy to help

  10. 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)

  11. 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

  12. On Mac OS ● See https://code.google.com/p/dealii/wiki/MacOSX ● Install xcode ● Install command line tools (under under preferences->Downloads->Components, or xcode-select –install depending on version) ● If OSX 10.9 follow instructions from wiki, else from source using: ● Cmake: download Mac OSX 64/32-bit Universal .dmg file from http://www.cmake.org/cmake/resources/software.html, click to install, hit "install links into /local/bin" ● Later manually: eclipse, paraview ● Optionally: ...

  13. 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

  14. 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

  15. 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

  16. 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 . . .

  17. 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)

  18. 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 ●

  19. 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));

  20. 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 ( 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 > ( ) ;

  21. 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 ( 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 ) { . . .

  22. 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 ;

Recommend


More recommend