Sunday, July 24, 2011

Some thoughts on numerical software and the scientist and some info on libMesh, OctMesh

I am slowly delving into the world of open source alternatives to mathematical software. Partially because I am taking a numerical PDE course and working on the assigned problems in the class and partially because of general interest. My computer and programming skills, I would say are at a general low level knowledge base and skills. That is, I know a bit about a medium range of stuff from classes and picking up things from my environment (colleagues, my own investigations, etc.)

I think it is important as scientists and engineers to not only be able to use these software but also have some idea of what is happening in the black box. Of course depending on the situation and interest level, just running the software and not caring how or why may be necessary.

Many of the topics and materials are over my head, especially the programming based material. I mean I have some inkling because I am pretty capable at utilizing MATLAB/Octave type m-files to program a routine, but the deeper stuff I am trying to learn. Yeah, we had a intro to C program class in undergrad, but unless you use it frequently and somewhat indepthly then you're going to forget the little you knew, especially at a younger age when you may not realize the importance of it.

I feel like it is imperative that scientists and engineers in my field at a PhD level should be well equipped to deal with numerics and computers since we are involved with them in not only our everyday tasks but also, more than likely, our scientific endeavors. You almost should have or need a computer science degree as well if you want to under things a bit better. It doesn't have to be a literal degree either, you can do a majority of research and teaching to yourself like I am attempting, :P.

However, one problem with the computational sciences is that there is an immense gorge of knowledge to explore. That is, there are several languages in use which in turn use there own format even if algorithm structure doesn't change between languages for a routine (that is, say for example to program a Runge-Kutta solver you would take the same or very similar steps, but the input and commands might and probably will differ; also most software comes with packages which probably have a Runge-Kutta function of some sort. I was just giving an example which is a probable problem in a numerical mathematics class). Some languages are used more often in certain areas or are for specific goals while others are more popular among groups. For example, engineers may be more comfortable with a MATLAB/Octave base software while others more inclined in the CS may use C++, Fortran, or Python. Another example involves antiquity. It is my feeling that Fortran is pretty old and not favorable among newer programmers while Python seems to be the new guy in town over C++, Java, etc. Code also varies for purposes such as LaTeX code for document typesetting and HTML code for website development.

Another area of vastness is the differences in operating systems that computers use. The big three are Microsoft Windows, the Mac OS (not even sure what it is called) based on Unix, and Linux OSs such as Ubuntu, Fedora, etc. Now in most cases, when in MS Windows you probably won't use the command line too often if ever and the same goes for Mac since they are largely based on GUIs with the users. Now you may have to know a few tricks here and there such as pointing something to a path name and such depending on your activities. I mean, I really don't even know much about that as well. Mac OS is based on UNIX which is closely related to the Linux kernel, but I am not sure about this either??!? Linux is based on command line interfaces but has plenty of friendly GUI based distros. I guess Linux is more accessible to the guts of the software code which it should be since it is open source. In Linux you are probably going to have to use the command line eventually (like me) because you'll need to get into the guts to make some things work (one bad thing about open source) to implement someone's work for a fix (the good thing about open source). For example, say setting up a quad display for four monitors is apparently a little more difficult or labor intensive than Windows which I have heard works fine (I am working on this, more later). My point is that you may run into deeper stuff when dealing with OSs instead of the common and general surfacey use of the GUI at a somewhat blindly method for everyday usage. That is, grandma can probably read and write email while the grandson can setup a contact list and chat using messenger and Outlook or Thunderbird. Grandma isn't going to care much about anything else, she just wants to check facebook while the grandson will be more open to and exposed more to the deep computer world even if it only goes as deep as Outlook/Thunderbird.

Finally, a difference exists between mathematical software and general programming too. Say in Mathematica, you can probably "program" it to check your derivative, plot some graphs, and generate a matrix of data (say velocity on an r,z map). It's pretty simple once you learn the commands, but you can also delve deeper into the guts (I don't really know an example right now, :\). The same goes for MATLAB. As I've said before, most software comes with packages built in so the user doesn't have to worry about starting from scratch. This is what I like about MATLAB. It is less intensive than say a more "naked" approach such as C++. This also makes it more friendly to less technologically inclined users reaching a further and bigger audience. Say, a middle school teacher. Plus, you are not going to start from scratch in C++ writing a program to solve an equation unless it is an assignment, you are investigating a new approach, or you are simply just interested.

So, trying to reel it in now, the post was originally about some open source software which I was going to provide a brief explanation and a link to. But, I feel like this is relevant and it is the purpose of this blog. Eventually, I hope to post more examples and video of how to use all of this software and computer junk! This blog will help me keep things somewhat organized and at the same time develop a list/source for quick reference for others to enjoy if they like (I also have a wiki-website which will help organize material better while the blog will alert those who care about new post, however, I have not kept up with the webiste, maybe one day!). I know I learn better and more quickly to some extend by short examples. I then can built off those. However, for the open source software material and support are sometimes hard to come by! For example, I am trying to solve a simple PDE for my numerical class, but I am learning a new software, Octave. Octave is very similar to MATLAB, but doesn't have as much development as MATLAB. The good thing there are people, like me, who want to use open source and who are more skilled at development (unlike me) will contribute to making a package, software support, etc. For example, say Octave doesn't have the exact package like MATLAB for pdes. Someone can jump in and develop a similar package or one that might be a different technique works just as well. Many open source projects have mailing lists for updates, bugs, and releases and also things to be done or suggestions. For example, the Octave-Forge site has links for the extra packages for GNU Octave, developers, documentation, FAQ, bugs, mailing lists, etc.

Also, there are a few programs out there that will get the same goals accomplished. For instance, supposedly SciLab will accomplish MATLAB tasks, but I think it has a little different structure than the MATLAB/Octave type. So not only do you have choices you also have learning curves. For example, right now I am struggling with learning some Mathematica and MATLAB open source replacements, but once I learn them, I will be that much better later on. You may have to do some investigation, but that is what research and science is all about. Of course you should moderate yourself so you are productive and efficient. I will try to keep up this blog so that others may be able to learn from my endeavors. My hope is to become proficient in Mathematica type software wxMaxima/Maxima and SAGE, MATLAB type software such as Octave/QtOctave and maybe SciLab, and Origin type software such as QtiPlot and SciDavis. I also would like to learn a little about most of the programming languages by providing examples and videos of the same example say in Octave, C++, Fortran, JAVA, Python, etc. I am also hoping to become more knowledgeable in open source CFD and meshing so I won't have to rely as much on Fluent, even though Fluent is a great program but very costly! I will probably be posting examples of Fluent too.

One last thing which I have hinted at through this post. The inviting thing, and the idea that intrigue me and got me hooked, is the ability to customize and be creative and free (I know, I sound like a hippy, but hippies are bad, are they?! :P). Using open-source stuff such as Linux and LaTeX gives the user a wide range of unique outlets that you would not or rarely get with MS and their software. Of course with so many choices the user can become overwhelmed and overload on information. My advice is to pick a few things and built off that. For example, for new users to Linux I would suggest using Ubuntu. Then later on once you get a slight idea, a little grasp of what's going on, you can then begin to explore other distros if you like. The best thing to do, IMO, is to start off slow and with a few choices (2 or 3 max), maybe narrow down the choices to one, then build up gradually at your own pace, but do not let it overwhelm you so you do not become productive, then once you become comfortable, somewhat skilled, and productive you can move on or try something else if you like to see if there is something out there for you. For example, I started off with Texmaker as my LaTeX editor. I then tried Kile and really liked it. I used Kile most of the time, but would jump back to TM every now and then just to make sure I still liked Kile just a little more. I then tried Lyx, didn't like it because it was a different format even though it was based on TeX. I tried Texworks. I didn't like it because it went all weird on me one day and erased a file. I tried gedit with the LaTeX plugin and I didn't like that either. I also tried GNU TeXmacs, but I didn't like it for the same reasons as Lyx. I kept coming back to Kile, and love it. It has all the right options, it's simple, stable, and aesthetically pleasing. Although, I still might try Emacs with Auctex or the VIM editor with the LaTeX-suite. So, as you can see, my LaTeX editor serves a great example of what I am talking about and trying to convey.

So back to the original topics. I stumbled across this software called libMesh on sourceforge.net Sourceforge is a website which helps promote open source projects by hosting them for download, documentation, help, forums, etc as I mentioned earlier about Octave-Forge which is also on Sourceforge.


libMesh - C++ Finite Element Library

From the libMesh site

The libMesh library provides a framework for the numerical simulation of partial differential equations using arbitrary unstructured discretizations on serial and parallel platforms. A major goal of the library is to provide support for adaptive mesh refinement (AMR) computations in parallel while allowing a research scientist to focus on the physics they are modeling.

libMesh currently supports 1D, 2D, and 3D steady and transient simulations on a variety of popular geometric and finite element types. The library makes use of high-quality, existing software whenever possible. PETSc is used for the solution of linear systems on both serial and parallel platforms, and LASPack is included with the library to provide linear solver support on serial machines. An optional interface to SLEPc is also provided for solving both standard and generalized eigenvalue problems.

The libMesh library has been actively developed at The University of Texas at Austin in the CFDLab since March 2002. Major contributions have come from developers at the Technische Universität Hamburg-Harburg Institute of Modelling and Computation, and recent contributions have been made by CFDLab graduates at Sandia National Laboratories and NASA Lyndon B. Johnson Space Center. The libMesh developers welcome contributions in the form of patches and bug reports (preferably with a minimal test case that reliably reproduces the error) to the official mailing lists. Many thanks to SourceForge for hosting the project. You can find out what is currently happening in the development branch by checking out the SVN Logs online, and you can see many people are downloading the library on the statistics page.


This is OctMesh where I found the link to libMesh.

OctMesh - J. Rafael Rodríguez Galván - February 1, 2007 - http://octmesh.forja.rediris.es/

From the website (because they can generally say it better than I can reword it!),

OctMesh is a toolbox for the resolution of partial differential equations (PDE) by means of the finite element method on Octave. Octave is “a high-level language, primarily intended for numerical computations (...) that is mostly compatible with Matlab”. It may be used interactively or as a batch-oriented language.

Technically, OctMesh, constitutes an interface for the access from Octave to LibMesh, a C++ library for the numerical simulation of PDE by means of the finite element method (also with free license) developed, mostly, in the CFDLab of the University of Texas (although also it has counted with the contribution of other people and organizations). LibMesh facilitates the development of numerical simulations using 1D, 2D or 3D elements in parallel architectures (although it can work in sequential machines). It also includes methods for adaptive mesh refinement/coarsening.
OctMesh has been developed with the intention to unite the power of LibMesh with the ease of use of the Matlab language, and trying to facilitate the development from Octave of parallel numerical 1D, 2D or 3D, experiments.

Internally, it consists of a series of dynamic extensions for Octave (.oct-files), written in C++, that acts as a connection with LibMesh, introducing a space of additional functions that extend the Octave ones. These functions allow defining meshes, associating them finite elements spaces and quadrature formulae, mounting and solving the equation systems associated to the variational formulations of the EDP. All in a interactive way or in programs (.m-files) that use the Octave/Matlab interpreted language.
When creating these new functions in Octave, we have tried to conserve, as far as possible, the original syntax of the C++ classes that compose LibMesh. This has not been easy, because the Matlab language (and therefore Octave) is not Object Oriented. Nevertheless, some techniques was used that allowed to avoid this disadvantage successfully.
Although using an interpreted language implies certain performance loss in OctMesh, it exist a possibility that will be useful to advanced users: critic parts of the algorithm may be developed in C++ (with LibMesh) and used from Octave (with OctMesh).


Again, most of this is foggy to me. I will update if I use and/or understand more. In general, I just hope maybe someone will find it useful.

No comments:

Post a Comment