DOLFIN User Manual - FEniCS Project

DOLFIN User Manual - FEniCS Project DOLFIN User Manual - FEniCS Project

fenicsproject.org
from fenicsproject.org More from this publisher
12.07.2015 Views

DOLFIN User ManualHoffman, Jansson, Logg, Wellsdolfin assert(check);This macro accepts a boolean expression and if the expression evaluates tofalse, an error message is displayed, including the file, function name andline number of the assertion, and a segmentation fault is raised (to enableeasy attachment to a debugger). The following examples illustrate the useof dolfin assert():dolfin_assert(i >= 0);dolfin_assert(i < n);dolfin_assert(cell.type() == Cell::triangle);dolfin_assert(cell.type() == Cell::tetrahedron);Note that assertions are only active when compiling DOLFIN and yourprogram with DEBUG defined (configure option --enable-debug or compilerflag -DDEBUG). Otherwise, the macro dolfin assert() expands to nothing,meaning that liberal use of assertions does not affect performance, since assertionsare only present during development and debugging.10.4 Task notificationThe two functions dolfin begin() and dolfin end() available in the dolfinname space can be used to notify the DOLFIN log system about the beginningand end of a task:void dolfin_begin();void dolfin_end();Alternatively, a string message (or a formatting string with optional arguments)can be supplied:68

DOLFIN User ManualHoffman, Jansson, Logg, Wellsvoid dolfin_begin(const char* message, ...);void dolfin_end(const char* message, ...);These functions enable the DOLFIN log system to display messages, warningsand errors hierarchically, by automatically indenting the output producedbetween calls to dolfin begin() and dolfin end(). A program maycontain an arbitrary number of nested tasks.10.5 Progress barsThe DOLFIN log system provides the class Progress for simple creation ofprogress sessions. A progress session automatically displays the progress ofa computation using a progress bar.If the number of steps of a computation is known, a progress session shouldbe defined in terms of the number of steps and updated in each step of thecomputation as illustrated by the following example:Progress p(‘‘Assembling’’, mesh.noCells());for (CellIterator c(mesh); !c.end(); ++c){...p++;}It is also possible to specify the step number explicitly by assigning an integerto the progress session:Progress p(‘‘Iterating over vector’’, x.size())for (uint i = 0; i < x.size(); i++){...69

<strong>DOLFIN</strong> <strong>User</strong> <strong>Manual</strong>Hoffman, Jansson, Logg, Wellsvoid dolfin_begin(const char* message, ...);void dolfin_end(const char* message, ...);These functions enable the <strong>DOLFIN</strong> log system to display messages, warningsand errors hierarchically, by automatically indenting the output producedbetween calls to dolfin begin() and dolfin end(). A program maycontain an arbitrary number of nested tasks.10.5 Progress barsThe <strong>DOLFIN</strong> log system provides the class Progress for simple creation ofprogress sessions. A progress session automatically displays the progress ofa computation using a progress bar.If the number of steps of a computation is known, a progress session shouldbe defined in terms of the number of steps and updated in each step of thecomputation as illustrated by the following example:Progress p(‘‘Assembling’’, mesh.noCells());for (CellIterator c(mesh); !c.end(); ++c){...p++;}It is also possible to specify the step number explicitly by assigning an integerto the progress session:Progress p(‘‘Iterating over vector’’, x.size())for (uint i = 0; i < x.size(); i++){...69

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!