Exploring MFEM

mfem c++ fem library

With little time I have after office and playing with kids , I am devoting some to this MFEM library.

Really good piece of software. Exploration continues.

So What is MFEM?

No, it’s not Ministry of Finance and Economics Management, it’s …….

MFEM is a lightweight, general, scalable C++ library for finite element methods and available at http://mfem.googlecode.com

The goal of MFEM is to enable research and development of scalable
finite element discretization and solver algorithms through general
finite element abstractions, accurate and flexible visualization, and
tight integration with the hypre linear solvers library. Its features
– 2D and 3D, arbitrary high-order H1, H(curl), H(div), L2 and NURBS
– Parallel version scalable to hundreds of thousands of MPI cores.
– Conforming or nonconforming adaptive mesh refinement (AMR),
including anisotropic refinement.
– Galerkin, mixed, isogeometric, DG and DPG discretizations.
– Support for triangular, quadrilateral, tetrahedral and hexahedral
elements with curved boundaries.
– Lightweight interactive OpenGL visualization with GLVis,

An interactive documentation of MFEM’s serial and parallel example
codes can be found here
MFEM is freely available under LGPL 2.1.



What can Software Teams Learn From Aviation?

This pycon talk combines my two passions, aviation and software development. Grab a cold coffee and watch this very interesting talk. Just a little over half an hour, if you have any interest in any of this two stream, you will like the talk.

What can Python-based software teams learn from aviation? Why should software always fail hard? What’s wrong with too many error logs? And why are ops people already like pilots? Learn all this, and about planes, too.

If in hurry, you can download the PDF of the presentation.

Government and software.

Read this sometime in Jan. But unfortunately lost the link to where I read it.

Regulating a society is like writing software. It sounds easy to amateurs, but it can be amazingly difficult.

Software programmers typically cannot prove that their software will work. At best, in many practical cases, they can test it for typical cases. Unfortunately, government regulators don’t follow any of the good practices software programmers use. Worse: they never accept bug reports.

Any programmer will tell you what to do when testing is hard and failure is not an option: keep the software as simple as possible.

That’s not at all what government do. And, unsurprisingly, they are full of bugs

How to Read HDF5 with Python – a simple introduction

HDF keeps coming into my world from one place or the other. A colleague is working on it, then it showed up in a side project i am working and now I stumbled on a video praising hdf5. So finally decided to dig into it and find more about it.

  1. HDF stands for Hierarchical Data Format. This (HDF, HDF4, or HDF5) is a set of file formats and libraries designed to store and organize large amounts of numerical data. Originally developed at the National Center for Supercomputing Applications, it is supported by the non-profit HDF Group.
  2. HDF5 format supports any kind of data for digital storage regardless of their origin and some.
  3. HDF5 stores data in a highly organised and hierarchical format
  4. HDF5 is highly efficient chunked input output operations.
  5. HDF5 allows inclusion of metadata and attribute.
  6. The format is platform independent and is widely used in scientific codes.
  7. HDF5 data model consists of two major objects, Datasets and Groups.

Enough theory? Here’s a super simple introduction to reading hdf5 data via python.



Read more about HDF5 here [pdf] and here

Simple Code to Find Which Excel Row is Being Modified

Excel’s inbuilt functions are powerful. They can achieve a lot. Almost anything can be conquered with these functions.

Well almost……everything!!

Recently needed a function to know which row is being modified. As far as i know, there’s no way this can be achieved by using excel’s function. This is where little bit of vba helps.

Here’s the code that helped.

Private Sub Worksheet_Change(ByVal Target As Range)
    If (Target.Column = 3 Or Target.Column = 4) Then
        If Target.Row > 1 Then Cells(1, 6) = Target.Row
    End If
End Sub

In the above sheet change method, the code checks if any row has changed in the columns 3 and 4 and if something has changed beyond row 1 in these columns, the F1 cell is updated with the row number.

Simple and small code but very useful when one wants to know which row is getting modified in excel.

The information about the row being modified can be used to do lot of things using excel in built functions.

Now think where can one use this. Stay tuned I have a follow up post on the use.

Few Toy Programs to Mesh Excel and Fortran together

Fortran DLL and Excel
Fortran 90 with Excel – gfortran example is one of the post that constantly gets lot of attention as measured by the top posts sidebar widget on this blog.

So thought about revisiting it and this post is to show some toy programs that shows how to link fortran program as a dll with excel.

I am using gfortran and the following simple fortran programs to create a DLL which is called from excel.

Continue reading

Sieve of Eratosthenes

In mathematics, the sieve of Eratosthenes is a simple, ancient algorithm for finding all prime numbers up to any given limit. Here’s a Python Implementation of sieve of Eratosthenes.

Created on Wed Sep 25 14:07:59 2013
@author: sukhbinder
Python Implementation of sieve of Eratosthenes
In mathematics, the sieve of Eratosthenes , one of a number of prime number sieves,
is a simple, ancient algorithm for finding all prime numbers up to any given limit.
It does so by iteratively marking as composite (i.e. not prime) the multiples of 
each prime, starting with the multiples of 2.
import numpy as np
def SOE(n):
    is_p = np.ones((n,),dtype=bool)
    nmax = np.int(np.sqrt(n))
    #print nmax,range(2,nmax)
    for j in range(2,nmax+1):
        #print is_p.nonzero()
    #print is_p
    return is_p.nonzero()

Prime Seive

So what are the prime weeks of the year?
print SOE(53)

[ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]

What are the prime days in the month?
print SOE(32)

[ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]

What are the prime days in the year?
print SOE(366)

[ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101,
103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,
241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313,
317, 331, 337, 347, 349, 353, 359]