1 / 8

Using PyTrilinos: A Tutorial

Using PyTrilinos: A Tutorial. Bill Spotz Sandia National Laboratories 2006 Trilinos Users Group Meeting Nov 8, 2006. Outline. Building PyTrilinos (Teuchos & Epetra only) Installing PyTrilinos Getting help for PyTrilinos An interactive exploration of Epetra Parameter lists

ula
Télécharger la présentation

Using PyTrilinos: A Tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using PyTrilinos:A Tutorial Bill Spotz Sandia National Laboratories 2006 Trilinos Users Group Meeting Nov 8, 2006

  2. Outline • Building PyTrilinos (Teuchos & Epetra only) • Installing PyTrilinos • Getting help for PyTrilinos • An interactive exploration of Epetra • Parameter lists • Writing scripts to solve problems

  3. Building PyTrilinos • Configure script: • Take a working configure script, and just add --enable-python • For our purposes, restrict to Teuchos and Epetra: --disable-default-packages \ --enable-teuchos \ --enable-epetra • You may need to be explicit about the C++ compiler: CXX=g++ • Think about where you want to install: --prefix=PREFIX • Building • Invoking configureandmake should do the trick…

  4. Installing PyTrilinos • Install command: $ [sudo] make install • If no prefix specified, then PyTrilinos is installed where your python knows to find it • If you specified prefix, then you need to tell python how to find the PyTrilinos package: • Environment variables: LD_LIBRARY_PATH=PREFIX/lib PYTHONPATH=PREFIX/lib/python2.4/site-packages • Within python (e.g. .pythonrc): import sys sys.path.append("PREFIX/lib/python2.4/site-packages") • Try it: $ python >>> from PyTrilinos import Epetra

  5. Getting Help • From shell: $ pydoc PyTrilinos • From python: $ python >>> from PyTrilinos import Epetra >>> help(Epetra) >>> dir(Epetra) • From web site: • FAQ • Overview • Release 7.0 (including tutorial) • Development (including tutorial) • Trilinos doxygen pages • Submitting bugs: • Under bugzilla, submit to the appropriate Trilinos package, specifying the “Python wrappers” component

  6. Exploring Epetra Interactively • Communicators • Printing Epetra objects • Maps • C-arrays as return objects • Vectors • NumPy hybrids • MultiVectors • CrsMatrix objects

  7. Parameter Lists • Old school: >>> from PyTrilinos import Teuchos >>> pList = Teuchos.ParameterList() >>> pList.set("one", 1) >>> . . . • Python dictionaries can be used in place of ParameterLists: • Keys must be strings • Values must be bool, int, float, str, or dict (or ParameterList) >>> pList = {"one" : 1, "two" : 2} • Returned ParameterLists are actually PyDictParameterLists

  8. Writing Scripts • Feel free to tackle your own problem • Write a function that returns your favorite Epetra.CrsMatrix • Suggestion: Power method (see software.sandia.gov/ Trilinos/packages/docs/dev/ packages/epetra/doc/html/ index.html) • Alternatively: CG algorithm (from G&vL):

More Related