LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Classes | Typedefs | Enumerations | Functions | Variables
lf::base Namespace Reference

Contains basic functionality that is used by other parts of LehrFEM++. More...

Classes

class  AutoTimer
 Measures execution time between construction and destruction. AutoTimer can output either to a std::ostream or to a spdlog::logger More...
 
class  InvalidTypeException
 Thrown to signal that an argument passed to a function had the wrong (polymorphic) type. More...
 
struct  IsScalar
 Base Traits class which can be used to determine if a type T is a scalar value. More...
 
struct  IsScalar< std::complex< T >, std::enable_if_t< std::is_arithmetic_v< T > > >
 Also std::complex is a "scalar" type if the underlying type is a std::is_arithmetic type. More...
 
struct  IsScalar< T, std::enable_if_t< std::is_arithmetic_v< T > > >
 any type that is a std::is_arithmetic is also a scalar type. More...
 
class  LehrFemInfo
 Provides extra information about this version of LehrFEM++, in particular licensing information. More...
 
class  LfException
 A simple, general purpose exception class that is thrown by LehrFEM++ if something is wrong. More...
 
class  LineFeedFormatter
 A spdlog formatter which wraps another formatter and makes sure that if there are new lines (\n) in the log message, that the log message is still properly indented. More...
 
class  PredicateTrue
 A Function Object that can be invoked with any arguments and that always returns the value true. More...
 
class  RefEl
 Represents a reference element with all its properties. More...
 
class  Timer
 Timer class to measure time. More...
 

Typedefs

using size_type = unsigned int
 general type for variables related to size of arrays More...
 
using glb_idx_t = unsigned int
 type for global index of mesh entities (nodes, edges, cells) More...
 
using sub_idx_t = unsigned int
 type for local indices of sub-entities More...
 
using dim_t = unsigned int
 type for dimensions and co-dimensions and numbers derived from them More...
 

Enumerations

enum class  RefElType : unsigned char { kPoint = 1 , kSegment = 2 , kTria = 3 , kQuad = 4 }
 An enum that defines all possible RefEl types. More...
 

Functions

void AssertionFailed (const std::string &expr, const std::string &file, long line, const std::string &msg)
 
void PrintInfo (std::ostream &o, const RefEl &ref_el, int output_ctrl)
 
std::ostream & operator<< (std::ostream &stream, const RefEl &ref_el)
 Operator overload to print a RefEl to a stream, such as std::cout More...
 
std::shared_ptr< spdlog::logger > InitLogger (const std::string &name)
 Create a spdlog logger, register it in the spdlog registry and initialize it with LehrFEM++ specific settings. More...
 

Variables

const unsigned int kIdxNil = static_cast<unsigned int>(-1)
 Index flagged as invalid. More...
 
constexpr double kPi = 3.14159265358979323846
 
template<class T >
constexpr bool is_eigen_matrix
 Check if a given type T is an Eigen::Matrix. More...
 
template<class T >
constexpr bool is_eigen_array
 Check if a given type T is an Eigen::Array. More...
 
template<class T >
constexpr bool is_scalar = IsScalar<T>::value
 Variable template that determines if a type T is a scalar type, i.e. if it is a "field" in the mathematical sense. More...
 

Detailed Description

Contains basic functionality that is used by other parts of LehrFEM++.

Enumeration Type Documentation

◆ RefElType

enum class lf::base::RefElType : unsigned char
strong

An enum that defines all possible RefEl types.

This enum is only rarely used direcly because there is a one-to-one relation between every enum value and an instance of the lf::base::RefEl class:

static constexpr RefEl kSegment()
Returns the (1-dimensional) reference segment.
Definition: ref_el.h:150
static constexpr RefEl kPoint()
Returns the (0-dimensional) reference point.
Definition: ref_el.h:141
static constexpr RefEl kTria()
Returns the reference triangle.
Definition: ref_el.h:158
static constexpr RefEl kQuad()
Returns the reference quadrilateral.
Definition: ref_el.h:166
@ kSegment
Returns the (1-dimensional) reference segment.
@ kPoint
Returns the (0-dimensional) reference point.
@ kTria
Returns the reference triangle.
@ kQuad
Returns the reference quadrilateral.

Also the enum representation is convertible into a lf::base::RefEl instance and back:

auto segment = RefEl(RefElType::kSegment);
Represents a reference element with all its properties.
Definition: ref_el.h:106
RefElType
An enum that defines all possible RefEl types.
Definition: ref_el.h:28
Enumerator
kPoint 

Returns the (0-dimensional) reference point.

kSegment 

Returns the (1-dimensional) reference segment.

Node numbering with (1D) node coordinates

kTria 

Returns the reference triangle.

Node numbering with (2D) node coordinates and segment orientation.

kQuad 

Returns the reference quadrilateral.

Node numbering with (2D) node coordinates and segment orientation

Definition at line 28 of file ref_el.h.

Function Documentation

◆ AssertionFailed()

void lf::base::AssertionFailed ( const std::string &  expr,
const std::string &  file,
long  line,
const std::string &  msg 
)

Definition at line 11 of file lf_assert.cc.

◆ InitLogger()

std::shared_ptr< spdlog::logger > lf::base::InitLogger ( const std::string &  name)

Create a spdlog logger, register it in the spdlog registry and initialize it with LehrFEM++ specific settings.

Parameters
nameThe name of the logger, is usually equal to the fully-scoped variable name, e.g. lf::mesh::hybrid2d::Mesh::Logger or lf::assemble::AssembleMatrixLogger
Returns
The initialized logger

LehrFEM++ uses spdlog loggers to provide the user with additional information about long running operations. These loggers are either associated with a class, in which case they are static, public member functions of this class (e.g. lf::mesh::hybrid2d::Mesh::Logger()) or they are associated with a free function in which case they are retrieved through a global free function lying in the same namespace as the free function (e.g. lf::assemble::AssembleMatrixLogger()).

You should use InitLogger() to initialize these loggers. In this way, we can set some sensible defaults for all LehrFEM++ loggers at one central location.

Note
So far a call to this method is essentially forwarded to spdlog::stdout_color_mt() and the formatter is set to a LineFeedFormatter.

Definition at line 16 of file spdlog_utils.cc.

Referenced by lf::assemble::AssembleMatrixLogger(), lf::uscalfe::LinearFeLocalLoadVectorLogger(), lf::mesh::hybrid2d::Mesh::Logger(), lf::mesh::hybrid2d::MeshFactory::Logger(), lf::mesh::utils::TorusMeshBuilder::Logger(), lf::mesh::utils::TPQuadMeshBuilder::Logger(), lf::mesh::utils::TPTriagMeshBuilder::Logger(), lf::refinement::MeshHierarchy::Logger(), lf::uscalfe::LinearFELaplaceElementMatrix::Logger(), lf::uscalfe::MassEdgeMatrixProviderLogger(), lf::uscalfe::ReactionDiffusionElementMatrixProviderLogger(), lf::uscalfe::ScalarLoadEdgeVectorProviderLogger(), lf::uscalfe::ScalarLoadElementVectorProviderLogger(), and lf::mesh::test_utils::WatertightLogger().

◆ operator<<()

std::ostream & lf::base::operator<< ( std::ostream &  stream,
const RefEl ref_el 
)
inline

Operator overload to print a RefEl to a stream, such as std::cout

Parameters
streamThe stream to which this function should output
ref_elThe reference element to write to stream.
Returns
The stream itself.
Note
This function directly calls RefEl::ToString().

Usage example

std::cout << RefEl::kSegment(); // prints "kSegment"

Definition at line 532 of file ref_el.h.

References lf::base::RefEl::ToString().

◆ PrintInfo()

void lf::base::PrintInfo ( std::ostream &  o,
const RefEl ref_el,
int  output_ctrl 
)
related

Definition at line 17 of file ref_el.cc.

Variable Documentation

◆ is_eigen_array

template<class T >
constexpr bool lf::base::is_eigen_array
inlineconstexpr
Initial value:
= std::is_same_v<
decltype(internal::IsEigenArrayTester::Test(std::declval<T>(), 0)), bool>

Check if a given type T is an Eigen::Array.

Definition at line 58 of file eigen_tools.h.

◆ is_eigen_matrix

template<class T >
constexpr bool lf::base::is_eigen_matrix
inlineconstexpr
Initial value:
= std::is_same_v<
decltype(internal::IsEigenMatrixTester::Test(std::declval<T>(), 0)), bool>

Check if a given type T is an Eigen::Matrix.

Definition at line 51 of file eigen_tools.h.

◆ is_scalar

template<class T >
constexpr bool lf::base::is_scalar = IsScalar<T>::value
inlineconstexpr

Variable template that determines if a type T is a scalar type, i.e. if it is a "field" in the mathematical sense.

Template Parameters
TThe type that should be tested.
Note
This method is e.g. used to determine if a given type can be multiplied to a Eigen::Matrix.

Definition at line 56 of file scalar_traits.h.

◆ kPi

constexpr double lf::base::kPi = 3.14159265358979323846
constexpr

Definition at line 43 of file base.h.