Here are some frequently asked questions (with assorted frequently given answers...). Please check these before contacting us with any problems.
Recent versions of the gcc compilers enforce the C++ standard much more rigorously than earlier versions. Unfortunately, the standard includes some rules that are so counter-intuitive that it is hard get into the habit of using them, especially if code is developed on a compiler that does not enforce the standard as rigorously.
The most frequent problem arises in classes that are derived from a templated base class. The C++ standard insists that all references to member functions (or member data) that is defined in the templated base class must be preceded by "this->" when the reference is made in the derived class. Allegedly, this is necessary to avoid ambiguities, though it is not entirely clear what this ambiguity is supposed to be... Here is a driver code that illustrates the problem.
If you compile this with sufficiently recent versions of the gcc compilers, using the flag -DUSE_BROKEN_VERSION
, the compilation will fail with the following error:
You may not only stumble across this problem in one of your own codes but it is also possible that some code in the library itself still violates this rule. This is because templated classes are only built when needed and it is conceivable that oomph-lib's
suite of self-tests do not instantiate all templated classes that exist in the library. If you encounter any such problems, check if putting a "this->" in front of the function call fixes the problem. If it does, let us know!
When linking, some versions of the gcc compiler produce warnings about references to "discarded sections" being referenced. Here's an example:
We admit to being slightly baffled by this. Other libraries seem to suffer from the same problem (google for .rodata
discarded
, say), but as far as we can tell no solution has ever been suggested, nor does one seem to be required. The executable works fine. Upgrade to a newer version of gcc?
Suggestions:
Problem::self_test()
before solving the problem. This function performs a large number of sanity checks and reports any inconsistencies in the data structure. oomph-lib
are Vectors
(oomph-lib's
wrapper to the STL vector class, with optional range checking) they can easily be detected. Make sure to re-compile again with RANGE_CHECKING switched off before you start any production runs – the run-time overheads incurred by range-checking are significant! gdb
or its GUI-based equivalent ddd) to (try to!) find out where the segmentation fault occurred. [Careful: If the segmentation fault is caused by a pointer problem, this naive inspection can be quite misleading – tell-tale signs are that the traceback displays a non-sensical call stack, e.g. a function being called "out of nowhere"; variables that have just been given values not existing; etc.] Suggestions:
Node::is_pinned(...)
. oomph-lib's
Poisson elements solve the Laplace equation unless a function pointer to the source function is specified. oomph-lib's
timestepping procedures in the context of the unsteady heat equation for details. Problem::actions_before_implicit_timestep()
to update any time-dependent boundary conditions?Suggestions:
oomph-lib's
default solver Problem::newton_solve(...)
will converge quadratically, provided oomph-lib
also provides automatic continuation methods, based on Keller's arclength continuation, but at the moment, no tutorials exist for these. get_jacobian(...)
or fill_in_contribution_to_jacobian(...)
. oomph-lib
will then use the default implementation of these functions in the GeneralisedElement
base class to compute the Jacobian matrices by finite-differencing. The executable is likely to run more slowly since the finite-difference-based computation is unlikely to be as efficient as the customised implementation for your specific element, but if the Newton method then converges, you know where to look for your bug! You may also want to check for any un-initialised variables. They are the most likely culprits if your code behaves differently at different levels of optimisation as more aggressive optimisation may suppress any default initialisations of data – in fact, you should never rely on that anyway! AlgebraicNodes
, SpineNodes
or nodes whose position is updated by a MacroElement/Domain
- based procedure), the position of the nodes in the "bulk" mesh must be updated whenever the Newton method updates the unknowns. This is most easily done by calling Mesh::node_update()
in Problem::actions_before_newton_convergence_check()
.
oomph-lib's
high-level post-processing routines output the results of the computations in a form that is suitable for display with tecplot, a powerful commercial plotting package. Purists may find it odd that an open-source library should choose an output format that is customised for a commercial software package. We tend to agree... Our only excuse is that tecplot is very very good, and without it we would have found it extremely difficult to create many of the plots shown in the tutorials. [If you know of any open-source plotting package whose capabilities are comparable to those of tecplot, let us know!]
Angelo Simone has written a python script that converts oomph-lib's
output to the vtu format that can be read by paraview, an open-source 3D plotting package. The conversion script can currently deal with output from meshes that are composed of 2D quad elements – the extension to 3D is work in progress. Use of the conversion script is documented in another tutorial.
It is possible to display oomph-lib's
default output (in more elementary form, obviously) with gnuplot. The trick is to specify the using
option in gnuplot's plot commands – in this mode gnuplot ignores tecplot's "ZONE" commands. For instance, trying to plot the x-y data created by the demo code for the solution of the 1D Poisson equation with
will fail because gnuplot gets confused by the ZONE
specifications required by tecplot. However,
works.
If the data is too complex to be displayed by gnuplot, you may wish to customise the output for your preferred plotting package. This is easily done as oomph-lib
creates its output element-by-element. The elements' various output(...)
functions are virtual functions that can easily be overloaded in a user-defined wrapper class.
Here is an example driver code that illustrates how to change the output from oomph-lib's
QPoissonElement
family of 1D-line/2D-quad/3D-brick Poisson elements so that they output the string "Hello world".
We include oomph-lib's
generic
and poisson
library headers:
and then create a customised version of the Poisson elements in which we overload the tecplot-based QPoissonElement<DIM,NNODE_1D>::output(...)
function, defined in the poisson
library:
If we now call the output function, the version defined in the customised element is used. The remaining implementation of the Poisson element remains unchanged.
Many of oomph-lib's
equations classes (or elements) are implemented in great generality. For instance, our discretisation of the Navier-Stokes equations includes a source term in the continuity equation, and body force terms in the momentum equations; it allows switching between the stress-divergence and simplified forms of the viscous terms; it includes the mesh velocity into the ALE formulation of the time-derivatives; etc. This makes the elements very versatile and robust. However, the generality/robustness comes at a price: Even though we provide default values for most functions (e.g. the body force terms default to zero), their evaluation requires a finite amount of CPU time. If you wish to use the elements in a simple application in which the Navier-Stokes equations are solved in a fixed domain, without any body forces or other source terms, say, you may wish to disable the additional functionality.
This is easily done: After all, oomph-lib
is open-source software and you can therefore change anything you want! In principle, you could edit the source code in the src/navier_stokes
directory and delete (or at least comment out) all the functionality that you do not require. However, this is probably a risky step as it will break all demo codes (used during oomph-lib's
self-test procedure) that use some of the features that you are not interested in. We therefore recommend copying the content of the directory src/navier_stokes
into a new directory, e.g. src/my_navier_stokes
and to edit the copied sources. Follow the instructions in the oomph-lib
GitHub repository to turn these sources into a separate library against which you can link.
Yes, oomph-lib
does contain a lot of code and a lot of documentation. How to get started obviously depends on your background: Are you familiar with the finite element method? How good is your knowledge of C++? Etc.
Here are some possible "routemaps" around the library:
oomph-lib's
capabilities. Pick a problem that interests you and study the associated tutorial. Copy the driver code into your own directory and play with it. oomph-lib's
overall data structure, or find out how to optimise the library for your particular application. oomph-lib
. oomph-lib
objects for your problem: Problems
, Meshes
, FiniteElements
, etc. oomph-lib
. You should at least understand:
Assume you have studied one of the example codes and wish to find out more about the implementation of a particular class or function that is used there. How do you find its source code and/or its full documentation?
Generally, a class/function that is used in a demo code can only be defined in one of two places:
oomph-lib's
tutorials tend to provide a fairly complete annotated listing of the relevant driver codes; if the function you are interested in is not mentioned explicitly in the tutorial, it is most likely to be defined in an include file. You can inspect the driver code in its entirety by following the link at the end of the tutorials. If you cannot find the class/function there, it must be defined in one of the include files listed at the beginning of the source code.
The included files themselves can either be located in the same directory as the demo driver (the directory also tends to be mentioned at the end of the tutorial) or in one of oomph-lib's
sub-libraries. The source code for these is located in the sub-directories of the src
directory. Often the class/function is defined in a source file with an "obvious" name; if not, use grep
to find it. This can, of course, be done recursively. For instance, the command
issued in oomph-lib's
top-level directory will search through the entire distribution to locate files that contain the string "FiniteElement".
You can also use the html-based representation of oomph-lib's
data structure, created by doxygen, in the "bottom-up" discussion of the data structure. (Note that the search menu may not work on your browser.)
If all else fails and you think you have found a bug in the library, make sure you follow these steps:
oomph-lib
's GitHub repository and the other FAQs listed here.RANGE_CHECKING
and PARANOID
flags are set? A pdf version of this document is available. \