Example codes
and tutorials
The (Not-so) Quick Guide
List of tutorials/demo codes
Single-Physics Problems
Poisson
Adaptivity illustrated for Poisson
Advection-Diffusion
Unsteady heat equation
Linear wave equation
The Young-Laplace equation
Navier-Stokes
Free-surface Navier-Stokes
Axisymmetric Navier-Stokes
Solid mechanics
Beam structures
Shell structures
Multi-physics Problems
Fluid-structure interaction
Boussinesq convection
Steady thermoelasticity
Methods-based example codes and tutorials
Mesh generation
Linear solvers and preconditioners
Visualisation of the results
Parallel processing
How to write a new element
How to write a new refineable element
Default nonlinear solvers -- the sequence of action functions
...
Documentation
FE theory and top-down discussion of the data structure
The (Not-so) Quick Guide
Comprehensive bottom-up discussion of the data structure
List of available structured and unstructured meshes
Linear solvers and preconditioners
Visualisation of the results
Parallel processing
Coding conventions and C++ style
Creating documentation
Optimisation - robustness vs. "raw speed"
Linear vs. nonlinear problems
Storing shape functions
Changing the default "full" integration scheme
Disabling the ALE formulation of unsteady equations
C vs. C++ output
Different sparse assembly techniques and the STL memory pool
Publications
Publications
Talks
Journal publications
Theses
Picture show
Download
Copyright
Download/installation instructions
Download page
FAQ & Contact
FAQ
Change log
Bugs and other known problems
Completeness of the library & our "To-Do List"
Contact the developers
Get involved

 


Beta release!

Please note that the library has not been "officially" released. While we continue to work on the documentation, these web pages are likely to contain broken links and documents in draft form. Please send an email to

oomph-lib AT maths DOT man DOT ac DOT uk

if you wish to be informed of the library's "official" release.

oomph_definitions.h

Go to the documentation of this file.
00001 //LIC// ====================================================================
00002 //LIC// This file forms part of oomph-lib, the object-oriented, 
00003 //LIC// multi-physics finite-element library, available 
00004 //LIC// at http://www.oomph-lib.org.
00005 //LIC// 
00006 //LIC//           Version 0.90. August 3, 2009.
00007 //LIC// 
00008 //LIC// Copyright (C) 2006-2009 Matthias Heil and Andrew Hazel
00009 //LIC// 
00010 //LIC// This library is free software; you can redistribute it and/or
00011 //LIC// modify it under the terms of the GNU Lesser General Public
00012 //LIC// License as published by the Free Software Foundation; either
00013 //LIC// version 2.1 of the License, or (at your option) any later version.
00014 //LIC// 
00015 //LIC// This library is distributed in the hope that it will be useful,
00016 //LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 //LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 //LIC// Lesser General Public License for more details.
00019 //LIC// 
00020 //LIC// You should have received a copy of the GNU Lesser General Public
00021 //LIC// License along with this library; if not, write to the Free Software
00022 //LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00023 //LIC// 02110-1301  USA.
00024 //LIC// 
00025 //LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
00026 //LIC// 
00027 //LIC//====================================================================
00028 //A header containing the definition of the Oomph run-time
00029 //exception classes and our standard (info) output stream 
00030 //(essentially a wrapper to cout but it can be customised,
00031 // e.g. for mpi runs.
00032 
00033 //Include guard to prevent multiple inclusions of the header
00034 #ifndef OOMPH_DEFINITIONS_HEADER
00035 #define OOMPH_DEFINITIONS_HEADER
00036 
00037 // Config header generated by autoconfig
00038 #ifdef HAVE_CONFIG_H
00039   #include <oomph-lib-config.h>
00040 #endif
00041 
00042 //Standard libray headers
00043 #include<stdexcept>
00044 #include<iostream>
00045 #include<string>
00046 
00047 
00048 namespace oomph
00049 {
00050 
00051 //Pre-processor magic for error reporting
00052 //Macro that converts argument to string 
00053 #define OOMPH_MAKE_STRING(x) #x
00054 //Macro wrapper to MAKE_STRING, required because calling
00055 //OOMPH_MAKE_STRING(__LINE__) directly returns __LINE__
00056 //i.e. the conversion of __LINE__ into a number must be performed before
00057 //its conversion into a string
00058 #define OOMPH_TO_STRING(x) OOMPH_MAKE_STRING(x)
00059 //Combine the FILE and LINE built-in macros into a string that can
00060 //be used in erorr messages.
00061 #define OOMPH_EXCEPTION_LOCATION __FILE__ ":" OOMPH_TO_STRING(__LINE__)
00062 
00063 ///=====================================================================
00064 /// A Base class for oomph-lib run-time exception (error and warning) 
00065 /// handling.
00066 ///
00067 /// The class can only be instantiated by the derived classes 
00068 /// OomphLibError and OomphLibWarning. The (protected) constructor 
00069 /// combines its string arguments into a standard format 
00070 /// for uniform exception reports which are written to the specified 
00071 /// output stream.
00072 //======================================================================
00073 class OomphLibException : public std::runtime_error
00074 { 
00075  protected:
00076  
00077  ///\short Constructor takes the error description, function name
00078  ///and a location string provided by the OOMPH_EXCEPTION_LOCATION
00079  ///macro and combines them into a standard header. The exception type
00080  ///will be the string "WARNING" or "ERROR" and the message is written to
00081  ///the exception_stream, with a specified output_width
00082  OomphLibException(const std::string &error_description,
00083                    const std::string &function_name,
00084                    const char *location,
00085                    const std::string &exception_type,
00086                    std::ostream &exception_stream,
00087                    const unsigned &output_width);
00088  
00089   ///The destructor cannot throw an exception (C++ STL standard) 
00090   ~OomphLibException() throw() {}
00091 };
00092 
00093 //====================================================================
00094 /// An OomphLibError object which should be thrown when an run-time
00095 /// error is encountered. The error stream and stream width can be 
00096 /// specified. The default is cout with a width of 70 characters.
00097 //====================================================================
00098 class OomphLibError : public OomphLibException
00099 {
00100  ///Output stream that is used to write the errors
00101  static std::ostream *Stream_pt;
00102 
00103  ///Width in characters of the output report
00104  static unsigned Output_width;
00105 
00106   public:
00107 
00108  ///\short Constructor requires the error description and the function
00109  ///in which the error occured and the location provided by the 
00110  ///OOMPH_EXCEPTION_LOCATION macro
00111  OomphLibError(const std::string &error_description,
00112                const std::string &function_name,
00113                const char *location) :
00114   OomphLibException(error_description,function_name,location,"ERROR",
00115                     *Stream_pt,Output_width) { }
00116 
00117  /// \short Static member function used to specify the error stream,
00118  /// which must be passed as a pointer because streams cannot be copied.
00119  static inline void set_stream_pt(std::ostream* const &stream_pt)
00120   {Stream_pt = stream_pt;}
00121 
00122  /// \short Static member function used to specify the width (in characters)
00123  /// of the error stream
00124  static inline void set_output_width(const unsigned &output_width)
00125   {Output_width = output_width;}
00126 
00127 };
00128 
00129 //====================================================================
00130 /// An OomphLibWarning object which should be created as a temporary
00131 /// object to issue a warning. The warning stream and stream width can be 
00132 /// specified. The default is cout with a width of 70 characters.
00133 //====================================================================
00134 class OomphLibWarning : public OomphLibException
00135 {
00136  ///Output stream that is used to write the errors
00137  static std::ostream *Stream_pt;
00138 
00139  ///Width of output
00140  static unsigned Output_width;
00141 
00142   public:
00143  
00144  ///\short Constructor requires the warning description and the function
00145  ///in which the warning occurred. 
00146  OomphLibWarning(const std::string &warning_description,
00147                  const std::string &function_name,
00148                  const char* location) :
00149                  OomphLibException(warning_description,function_name,
00150                                    location,
00151                                    "WARNING",*Stream_pt,Output_width) { }
00152                  
00153  /// \short Static member function used to specify the error stream,
00154  /// which must be passed as a pointer because streams cannot be copied.
00155  static inline void set_stream_pt(std::ostream* const &stream_pt)
00156   {Stream_pt = stream_pt;}
00157 
00158  /// \short Static member function used to specify the width (in characters)
00159  /// of the error stream
00160  static inline void set_output_width(const unsigned &output_width)
00161   {Output_width = output_width;}
00162 };
00163 
00164 
00165 
00166 ////////////////////////////////////////////////////////////////////////
00167 ////////////////////////////////////////////////////////////////////////
00168 ////////////////////////////////////////////////////////////////////////
00169 
00170 
00171 
00172 //=====================================================================
00173 /// A small nullstream class that throws away everything sent to it.
00174 //=====================================================================
00175 class Nullstream : public std::ostream 
00176 {
00177 public:
00178  ///Constructor sets the buffer sizes to zero, suppressing all output
00179  Nullstream(): std::ios(0), std::ostream(0) {} 
00180 };
00181 
00182 
00183 
00184 
00185 //========================================================================
00186 /// Single (global) instantiation of the Nullstream
00187 //========================================================================
00188 extern Nullstream oomph_nullstream;
00189 
00190 
00191 
00192 
00193 ////////////////////////////////////////////////////////////////////////
00194 ////////////////////////////////////////////////////////////////////////
00195 ////////////////////////////////////////////////////////////////////////
00196 
00197 
00198 
00199 //========================================================================
00200 /// A base class that contains a single virtual member function: 
00201 /// The () operator that may be used to modify the output in 
00202 /// OomphOutput objects. The default implementation 
00203 ///=======================================================================
00204 class OutputModifier
00205 {
00206 
00207 public:
00208 
00209  ///Empty constructor
00210  OutputModifier() {}
00211 
00212  ///Empty virtual destructor
00213  virtual ~OutputModifier() {}
00214 
00215  /// \short Function that will be called before output from an 
00216  /// OomphOutput object. It returns a bool (true in this default
00217  /// implementation) to indicate that output should be continued.
00218  virtual bool operator()(std::ostream &stream) 
00219   {return true;}
00220 
00221 };
00222 
00223 
00224 
00225 
00226 //========================================================================
00227 /// Single global instatiation of the default output modifier.
00228 //========================================================================
00229  extern OutputModifier default_output_modifier;
00230 
00231 
00232 
00233 
00234 ////////////////////////////////////////////////////////////////////////
00235 ////////////////////////////////////////////////////////////////////////
00236 ////////////////////////////////////////////////////////////////////////
00237 
00238 
00239 
00240 
00241 //=======================================================================
00242 /// This class is a wrapper to a stream and an output modifier that is
00243 /// used to control the "info" output from OomphLib. Its instationiation
00244 /// can be used like std::cout.
00245 //=======================================================================
00246 class OomphInfo
00247 {
00248 
00249 private:
00250 
00251  ///Pointer to the output stream -- defaults to std::cout
00252  std::ostream *Stream_pt;
00253 
00254  ///Pointer to the output modifier object -- defaults to no modification 
00255  OutputModifier* Output_modifier_pt;
00256 
00257 public:
00258 
00259  ///\short Set default values for the output stream (cout) 
00260  ///and modifier (no modification)
00261  OomphInfo() : Stream_pt(&std::cout), 
00262                Output_modifier_pt(&default_output_modifier) {}
00263 
00264  ///\short Overload the << operator, writing output to the stream addressed by 
00265  ///Stream_pt and calling the function defined by the object addressed by
00266  ///Output_modifier_pt
00267  template<class _Tp>
00268  std::ostream &operator<<(_Tp argument)
00269   {
00270    //If the Output_modifer function returns true
00271    //echo the argument to the stream and return the (vanilla) stream
00272    if((*Output_modifier_pt)(*Stream_pt))
00273     {
00274      *Stream_pt << argument;
00275      return (*Stream_pt);
00276     }
00277    //Otherwise return the null stream (suppress all future output)
00278    return oomph_nullstream;
00279   }
00280 
00281  ///Access function for the stream pointer
00282  std::ostream* &stream_pt() {return Stream_pt;}
00283 
00284  ///Overload insertor to handle stream modifiers
00285  std::ostream &operator<<(std::ostream& (*f)(std::ostream &))
00286   {
00287    return f(*Stream_pt);
00288   } 
00289  
00290  ///Access function for the output modifier pointer
00291  OutputModifier* &output_modifier_pt() {return Output_modifier_pt;}
00292 
00293 };
00294 
00295 
00296 //========================================================================
00297 /// Single (global) instantiation of the OomphInfo object -- this
00298 /// is used throughout the library as a "replacement" for std::cout
00299 //========================================================================
00300 extern OomphInfo oomph_info;
00301 
00302 
00303 
00304 
00305 }
00306 
00307 #endif

Generated on Mon Aug 10 11:23:48 2009 by  doxygen 1.4.7