Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
amdis
amdis-core
Commits
4888fda1
Commit
4888fda1
authored
Sep 19, 2016
by
Praetorius, Simon
Browse files
output changed from macros to variadic functions
parent
ee990734
Changes
49
Show whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
4888fda1
cmake_minimum_required
(
VERSION 3.0
)
project
(
dune-amdis CXX
)
set
(
ALBERTA_ROOT /opt/software/alberta
)
set
(
ALBERTA_INCLUDE_DIR /opt/software/alberta/include
)
#
set(ALBERTA_ROOT /opt/software/alberta)
#
set(ALBERTA_INCLUDE_DIR /opt/software/alberta/include)
# set(CMAKE_PREFIX_PATH /opt/software/dune/lib/cmake)
# set(UG_DIR /opt/software/dune/lib/cmake/ug)
# set(Vc_DIR /opt/software/dune/lib/cmake/Vc)
set
(
MTL_DIR
${
CMAKE_SOURCE_DIR
}
/install/MTL/share/mtl
)
#
set(MTL_DIR ${CMAKE_SOURCE_DIR}/install/MTL/share/mtl)
if
(
NOT
(
dune-common_DIR OR dune-common_ROOT OR
"
${
CMAKE_PREFIX_PATH
}
"
MATCHES
".*dune-common.*"
))
...
...
@@ -30,6 +30,7 @@ add_subdirectory("src")
add_subdirectory
(
"dune"
)
add_subdirectory
(
"doc"
)
add_subdirectory
(
"cmake/modules"
)
add_subdirectory
(
"projects"
)
# finalize the dune project, e.g. generating config.h etc.
finalize_dune_project
(
GENERATE_CONFIG_H_CMAKE
)
dune/amdis/AMDiS.cpp
View file @
4888fda1
...
...
@@ -6,8 +6,8 @@
#include
<boost/program_options.hpp>
// AMDiS includes
#include
"
Initfile.hpp
"
#include
"Log
.hpp
"
#include
<dune/amdis/
Initfile.hpp
>
#include
<dune/amdis/Output
.hpp
>
namespace
AMDiS
{
...
...
@@ -63,9 +63,7 @@ namespace AMDiS
if
(
vm
.
count
(
"init-file"
))
Parameters
::
init
(
vm
[
"init-file"
].
as
<
std
::
string
>
());
else
{
AMDIS_ERROR_EXIT
(
"No init file specified!
\n
"
);
}
error_exit
(
"No init file specified!
\n
"
);
}
else
{
...
...
dune/amdis/AdaptInfo.cpp
View file @
4888fda1
...
...
@@ -4,7 +4,7 @@
#include
<string>
#include
<iostream>
#include
"
Initfile.hpp
"
#include
<dune/amdis/
Initfile.hpp
>
namespace
AMDiS
{
...
...
dune/amdis/AdaptInfo.hpp
View file @
4888fda1
...
...
@@ -6,7 +6,7 @@
#include
<vector>
// AMDiS includes
#include
<dune/amdis/
Log
.hpp>
#include
<dune/amdis/
Output
.hpp>
#include
<dune/amdis/Math.hpp>
namespace
AMDiS
...
...
@@ -304,7 +304,7 @@ namespace AMDiS
double
getEstSum
(
int
index
)
const
{
AMDIS_FUNCNAME_DBG
(
"AdaptInfo::getEstSum()"
);
AMDIS_TEST_EXIT_DBG
(
static_cast
<
size_t
>
(
index
)
<
scalContents
.
size
(),
test_exit_dbg
(
static_cast
<
size_t
>
(
index
)
<
scalContents
.
size
(),
"Wrong index for adaptInfo!
\n
"
);
return
scalContents
[
index
]
->
est_sum
;
...
...
@@ -320,7 +320,7 @@ namespace AMDiS
double
getEstMax
(
int
index
)
const
{
AMDIS_FUNCNAME_DBG
(
"AdaptInfo::getEstSum()"
);
AMDIS_TEST_EXIT_DBG
(
static_cast
<
size_t
>
(
index
)
<
scalContents
.
size
(),
test_exit_dbg
(
static_cast
<
size_t
>
(
index
)
<
scalContents
.
size
(),
"Wrong index for adaptInfo!
\n
"
);
return
scalContents
[
index
]
->
est_max
;
...
...
dune/amdis/AdaptInstationary.cpp
View file @
4888fda1
#include
"AdaptInstationary.hpp"
// AMDiS includes
#include
"
AdaptInfo.hpp
"
#include
"
Flag.hpp
"
#include
"
Initfile.hpp
"
#include
"Log
.hpp
"
#include
"
ProblemIterationInterface.hpp
"
#include
"
ProblemTimeInterface.hpp
"
#include
<dune/amdis/
AdaptInfo.hpp
>
#include
<dune/amdis/
Flag.hpp
>
#include
<dune/amdis/
Initfile.hpp
>
#include
<dune/amdis/Output
.hpp
>
#include
<dune/amdis/
ProblemIterationInterface.hpp
>
#include
<dune/amdis/
ProblemTimeInterface.hpp
>
namespace
AMDiS
{
...
...
@@ -46,8 +46,7 @@ namespace AMDiS
problemTime
->
setTime
(
adaptInfo
);
AMDIS_MSG
(
"time = "
<<
adaptInfo
.
getTime
()
<<
", timestep = "
<<
adaptInfo
.
getTimestep
());
msg
(
"time = "
,
adaptInfo
.
getTime
(),
", timestep = "
,
adaptInfo
.
getTimestep
());
adaptInfo
.
setSpaceIteration
(
0
);
...
...
@@ -68,8 +67,7 @@ namespace AMDiS
adaptInfo
.
setTime
(
adaptInfo
.
getTime
()
+
adaptInfo
.
getTimestep
());
problemTime
->
setTime
(
adaptInfo
);
AMDIS_MSG
(
"time = "
<<
adaptInfo
.
getTime
()
<<
", timestep = "
<<
adaptInfo
.
getTimestep
());
msg
(
"time = "
,
adaptInfo
.
getTime
(),
", timestep = "
,
adaptInfo
.
getTimestep
());
problemIteration
->
oneIteration
(
adaptInfo
,
NO_ADAPTION
);
...
...
@@ -160,8 +158,7 @@ namespace AMDiS
adaptInfo
.
setTime
(
adaptInfo
.
getTime
()
+
adaptInfo
.
getTimestep
());
problemTime
->
setTime
(
adaptInfo
);
AMDIS_MSG
(
"time = "
<<
adaptInfo
.
getTime
()
<<
", timestep = "
<<
adaptInfo
.
getTimestep
());
msg
(
"time = "
,
adaptInfo
.
getTime
(),
", timestep = "
,
adaptInfo
.
getTimestep
());
problemIteration
->
oneIteration
(
adaptInfo
,
FULL_ITERATION
);
...
...
@@ -197,7 +194,7 @@ namespace AMDiS
simpleAdaptiveTimeStrategy
();
break
;
default:
AMDIS_ERROR_EXIT
(
"Unknown strategy = "
<<
strategy
);
error_exit
(
"Unknown strategy = "
,
strategy
);
}
adaptInfo
.
incTimestepNumber
();
...
...
@@ -209,12 +206,12 @@ namespace AMDiS
AMDIS_FUNCNAME
(
"AdaptInstationary::adapt()"
);
int
errorCode
=
0
;
AMDIS_TEST_EXIT
(
adaptInfo
.
getTimestep
()
>=
adaptInfo
.
getMinTimestep
(),
test_exit
(
adaptInfo
.
getTimestep
()
>=
adaptInfo
.
getMinTimestep
(),
"timestep < min timestep"
);
AMDIS_TEST_EXIT
(
adaptInfo
.
getTimestep
()
<=
adaptInfo
.
getMaxTimestep
(),
test_exit
(
adaptInfo
.
getTimestep
()
<=
adaptInfo
.
getMaxTimestep
(),
"timestep > max timestep"
);
AMDIS_TEST_EXIT
(
adaptInfo
.
getTimestep
()
>
0
,
"timestep <= 0!"
);
test_exit
(
adaptInfo
.
getTimestep
()
>
0
,
"timestep <= 0!"
);
if
(
adaptInfo
.
getTimestepNumber
()
==
0
)
{
...
...
dune/amdis/CMakeLists.txt
View file @
4888fda1
...
...
@@ -24,7 +24,6 @@ set(BOOST_LIBS_REQUIRED system program_options)
if
(
NOT BUILD_SHARED_LIBS
)
set
(
Boost_USE_STATIC_LIBS ON
)
endif
(
NOT BUILD_SHARED_LIBS
)
set
(
Boost_NO_SYSTEM_PATHS ON
)
find_package
(
Boost
${
BOOST_VERSION
}
REQUIRED
${
BOOST_LIBS_REQUIRED
}
)
if
(
Boost_FOUND
)
add_library
(
boost INTERFACE
)
...
...
dune/amdis/CreatorInterface.hpp
View file @
4888fda1
...
...
@@ -4,7 +4,7 @@
#include
<string>
#include
<dune/amdis/common/Utility.hpp>
#include
<dune/amdis/
Log
.hpp>
#include
<dune/amdis/
Output
.hpp>
namespace
AMDiS
{
...
...
@@ -47,7 +47,7 @@ namespace AMDiS
virtual
shared_ptr
<
BaseClass
>
create
()
override
{
AMDIS_ERROR_EXIT
(
"Should not be called. Call create(string) instead!"
);
error_exit
(
"Should not be called. Call create(string) instead!"
);
return
{};
};
...
...
@@ -65,7 +65,7 @@ namespace AMDiS
inline
CreatorInterfaceName
<
BaseClass
>*
named
(
CreatorInterface
<
BaseClass
>*
ptr
)
{
auto
result
=
dynamic_cast
<
CreatorInterfaceName
<
BaseClass
>*>
(
ptr
);
AMDIS_TEST_EXIT_DBG
(
result
,
"Can not cast CreatorInterface to CreatorInterfaceName!"
);
test_exit_dbg
(
result
,
"Can not cast CreatorInterface to CreatorInterfaceName!"
);
return
result
;
}
...
...
dune/amdis/CreatorMap.hpp
View file @
4888fda1
...
...
@@ -35,8 +35,8 @@ namespace AMDiS
static
void
addCreator
(
std
::
string
key
,
CreatorInterface
<
BaseClass
>*
creator
)
{
init
();
AMDIS_TEST_EXIT
(
!
creatorMap
[
key
],
"There is already a creator for key "
<<
key
);
test_exit
(
!
creatorMap
[
key
],
"There is already a creator for key "
,
key
);
creatorMap
[
key
]
=
creator
;
}
...
...
@@ -50,8 +50,8 @@ namespace AMDiS
key
=
"default"
;
auto
creator
=
creatorMap
[
key
];
AMDIS_TEST_EXIT
(
creator
,
"No creator for key
\"
"
<<
key
<<
"
\"
defined in init file for parameter
\"
"
<<
initFileStr
<<
"
\"
"
);
test_exit
(
creator
,
"No creator for key
\"
"
,
key
,
"
\"
defined in init file for parameter
\"
"
,
initFileStr
,
"
\"
"
);
return
creator
;
}
...
...
dune/amdis/DirichletBC.hpp
View file @
4888fda1
...
...
@@ -6,7 +6,7 @@
#include
<dune/amdis/common/ConceptsBase.hpp>
#include
"Log
.hpp
"
#include
<dune/amdis/Output
.hpp
>
namespace
AMDiS
{
...
...
dune/amdis/DirichletBC.inc.hpp
View file @
4888fda1
...
...
@@ -30,7 +30,7 @@ namespace AMDiS
{
using
Dune
::
Functions
::
interpolate
;
AMDIS_TEST_EXIT
(
initialized
,
"Boundary condition not initialized!"
);
test_exit
(
initialized
,
"Boundary condition not initialized!"
);
matrix
.
clearDirichletRows
(
dirichletNodes
,
apply
);
if
(
apply
)
{
...
...
dune/amdis/Initfile.cpp
View file @
4888fda1
...
...
@@ -14,7 +14,7 @@
// a parser for arithmetic expressions
// #include <muParser.h>
#include
"Log
.hpp
"
#include
<dune/amdis/Output
.hpp
>
namespace
AMDiS
{
...
...
@@ -42,22 +42,19 @@ namespace AMDiS
// }
// }
Initfile
*
Initfile
::
singlett
=
NULL
;
/// initialize singleton object an global parameters
void
Initfile
::
init
(
std
::
string
in
)
{
initIntern
();
singlett
->
read
(
in
);
singlett
->
getInternalParameters
();
singlett
().
read
(
in
);
singlett
().
getInternalParameters
();
}
/// Fill an initfile from a file with filename fn
void
Initfile
::
read
(
std
::
string
fn
,
bool
/*force*/
)
{
AMDIS_TEST_EXIT
(
file_exists
(
fn
),
"init-file '"
<<
fn
<<
"' cannot be opened for reading"
);
test_exit
(
file_exists
(
fn
),
"init-file '"
,
fn
,
"' cannot be opened for reading"
);
using
namespace
boost
::
property_tree
;
json_parser
::
read_json
(
fn
,
pt
);
...
...
@@ -87,7 +84,6 @@ namespace AMDiS
/// print all parameters to std::cout
void
Initfile
::
printParameters
()
{
initIntern
();
// TODO: implement printing of all parameters
}
...
...
dune/amdis/Initfile.hpp
View file @
4888fda1
...
...
@@ -15,8 +15,8 @@
#include
<dune/common/fvector.hh>
#include
"Log
.hpp
"
#include
"
Math.hpp
"
#include
<dune/amdis/Output
.hpp
>
#include
<dune/amdis/
Math.hpp
>
namespace
AMDiS
{
...
...
@@ -52,7 +52,7 @@ namespace AMDiS
// try {
// value = numeric_cast< T >(mu_parser_eval(valStr));
// } catch(...) {
//
AMDIS_ERROR
("Could not parse '"
<<
valStr
<<
"' to '"
<<
typeid(T).name()
<<
"'\n");
//
error_exit
("Could not parse '"
,
valStr
,
"' to '"
,
typeid(T).name()
,
"'\n");
// }
// }
// };
...
...
@@ -81,7 +81,7 @@ namespace AMDiS
int
i
=
0
;
for
(
auto
token
:
tokens
)
{
AMDIS_TEST_EXIT
(
i
<
dim
,
"Vector data exceeds field-vector dimension!"
);
test_exit
(
i
<
dim
,
"Vector data exceeds field-vector dimension!"
);
value_type
v
;
Convert
<
value_type
>::
eval
(
token
,
v
);
...
...
@@ -105,7 +105,7 @@ namespace AMDiS
size_t
i
=
0
;
for
(
auto
token
:
tokens
)
{
AMDIS_TEST_EXIT
(
i
<
dim
,
"Vector data exceeds array dimension!"
);
test_exit
(
i
<
dim
,
"Vector data exceeds array dimension!"
);
value_type
v
;
Convert
<
value_type
>::
eval
(
token
,
v
);
...
...
@@ -201,14 +201,13 @@ namespace AMDiS
template
<
class
T
>
static
void
get
(
std
::
string
tag
,
T
&
value
,
int
debugInfo
=
-
1
)
{
initIntern
();
if
(
debugInfo
==
-
1
)
debugInfo
=
singlett
->
getMsgInfo
();
debugInfo
=
singlett
().
getMsgInfo
();
else
{
int
swap
(
debugInfo
);
debugInfo
=
singlett
->
getMsgInfo
();
singlett
->
msgInfo
=
swap
;
debugInfo
=
singlett
().
getMsgInfo
();
singlett
().
msgInfo
=
swap
;
}
using
path
=
boost
::
property_tree
::
ptree
::
path_type
;
...
...
@@ -218,7 +217,7 @@ namespace AMDiS
// TODO: use boost::optional instead
// TODO: use convert method from above
std
::
string
valueStr
=
"-"
;
valueStr
=
singlett
->
pt
.
get
(
tagPath
,
valueStr
);
valueStr
=
singlett
().
pt
.
get
(
tagPath
,
valueStr
);
if
(
valueStr
!=
"-"
)
detail
::
Convert
<
T
>::
eval
(
valueStr
,
value
);
...
...
@@ -228,7 +227,7 @@ namespace AMDiS
// std::cout << "Parameter '" << tag << "'"
// << " initialized with: " << value << std::endl;
// }
singlett
->
msgInfo
=
debugInfo
;
singlett
().
msgInfo
=
debugInfo
;
}
...
...
@@ -254,17 +253,16 @@ namespace AMDiS
template
<
class
T
>
static
void
set
(
std
::
string
tag
,
T
&
value
,
int
debugInfo
=
-
1
)
{
initIntern
();
if
(
debugInfo
==
-
1
)
debugInfo
=
singlett
->
getMsgInfo
();
debugInfo
=
singlett
().
getMsgInfo
();
using
path
=
boost
::
property_tree
::
ptree
::
path_type
;
replaceAll
(
tag
,
"->"
,
">"
);
auto
tagPath
=
path
(
tag
,
'>'
);
singlett
->
pt
.
put
(
tagPath
,
value
);
singlett
().
pt
.
put
(
tagPath
,
value
);
// update msg parameters msgInfo, msgWait, paramInfo
singlett
->
getInternalParameters
();
singlett
().
getInternalParameters
();
// if (debugInfo == 2)
// std::cout << "Parameter '" << tag << "'"
// << " set to: " << value << std::endl;
...
...
@@ -281,21 +279,7 @@ namespace AMDiS
/// Returns specified info level
static
int
getMsgInfo
()
{
return
(
singlett
!=
NULL
)
?
singlett
->
msgInfo
:
0
;
}
/// Checks whether parameters are initialized. if not, call init()
static
bool
initialized
()
{
return
(
singlett
!=
NULL
);
}
/// return pointer to singleton
static
Initfile
*
getSingleton
()
{
return
singlett
;
return
singlett
().
msgInfo
;
}
...
...
@@ -306,8 +290,7 @@ namespace AMDiS
/// clear data in singleton
static
void
clearData
()
{
initIntern
();
// singlett->clear();
// singlett().clear();
}
...
...
@@ -315,22 +298,19 @@ namespace AMDiS
static
void
save
(
std
::
string
/*fn*/
)
{
using
namespace
boost
::
property_tree
;
initIntern
();
// json_parser::write_jason(fn, singlett->pt);
// json_parser::write_jason(fn, singlett().pt);
}
protected:
Initfile
()
=
default
;
static
void
initIntern
()
/// return the singleton that contains the data
static
Initfile
&
singlett
()
{
if
(
singlett
==
NULL
)
singlett
=
new
I
nitfile
;
static
Initfile
initfile
;
return
i
nitfile
;
}
/// pointer to the singleton that contains the data
static
Initfile
*
singlett
;
/** Fill the initfile from an input stream.
* @param in: the stream to fill the data from.
* Current dataformat: tag:value
...
...
dune/amdis/Mesh.hpp
View file @
4888fda1
...
...
@@ -17,7 +17,7 @@
#include
<dune/grid/io/file/gmshreader.hh>
#include
<dune/amdis/Initfile.hpp>
#include
<dune/amdis/
Log
.hpp>
#include
<dune/amdis/
Output
.hpp>
#include
<dune/amdis/common/Filesystem.hpp>
namespace
AMDiS
...
...
@@ -74,7 +74,7 @@ namespace AMDiS
{
static
unique_ptr
<
Grid
>
create
(
std
::
string
meshName
)
{
AMDIS_ERROR_EXIT
(
"Creator not yet implemented for this mesh type."
);
error_exit
(
"Creator not yet implemented for this mesh type."
);
}
};
...
...
@@ -127,10 +127,10 @@ namespace AMDiS
return
unique_ptr
<
Grid
>
{
reader
.
read
(
filename
)};
}
}
else
{
AMDIS_ERROR_EXIT
(
"Construction of UGGrid without filename not yet implemented!"
);
error_exit
(
"Construction of UGGrid without filename not yet implemented!"
);
}
AMDIS_ERROR_EXIT
(
"No way to construct UG-Grid found"
);
error_exit
(
"No way to construct UG-Grid found"
);
return
{};
}
};
...
...
@@ -146,7 +146,7 @@ namespace AMDiS
Dune
::
FieldVector
<
double
,
dim
>
L
;
L
=
1.0
;
// extension of the domain
Parameters
::
get
(
meshName
+
"->dimension"
,
L
);
AMDIS_MSG
(
"L = "
<<
L
);
msg
(
"L = "
,
L
);
std
::
array
<
int
,
dim
>
s
;
// number of cells on coarse mesh in each direction
Parameters
::
get
(
meshName
+
"->num cells"
,
s
);
...
...
dune/amdis/Operator.inc.hpp
View file @
4888fda1
...
...
@@ -131,7 +131,7 @@ namespace AMDiS
if
(
fac
==
0.0
)
return
false
;
AMDIS_TEST_EXIT
(
firstOrderGrdPhi
.
empty
()
&&
secondOrder
.
empty
(),
test_exit
(
firstOrderGrdPhi
.
empty
()
&&
secondOrder
.
empty
(),
"Derivatives on ansatz-functions not allowed on the vector-side!"
);
const
auto
nRows
=
rowView
.
tree
().
finiteElement
().
size
();
...
...
dune/amdis/Output.hpp
0 → 100644
View file @
4888fda1
#pragma once
#include
<iomanip>
#include
<iostream>
#include
<sstream>
#include
<string>
/**
* \def AMDIS_NO_THROW
* \brief The preprocessor constant sets whether to use c-asserts (if defined) or
* to throw an exception in case of an error (if not defined).
**/
#ifdef AMDIS_NO_THROW
#include
<cassert>
#else
#include
<stdexcept>
#endif
#ifdef AMDIS_HAS_MPI
#include
<mpi.h>
#endif
/**
* \def AMDIS_ENABLE_MSG_DBG
* \brief The preprocessor constant enables the functions \ref AMDiS::MSG_DBG
* and \ref AMDiS::TEST_EXIT_DBG.
*
* If the value is set to 1 the functions \ref AMDiS::MSG_DBG and \ref AMDiS::TEST_EXIT_DBG
* are implemented, otherwise empty. Default is value 0 if \ref NDEBUG is not
* defined, otherwise value 1.
**/
#ifndef AMDIS_ENABLE_MSG_DBG
#ifndef NDEBUG
#define AMDIS_ENABLE_MSG_DBG 1
#else
#define AMDIS_ENABLE_MSG_DBG 0
#endif
#endif
#define AMDIS_STATIC_ASSERT(...) \
static_assert(__VA_ARGS__, #__VA_ARGS__)
#define AMDIS_UNUSED(var) __attribute__((unused)) var
#define AMDIS_FUNCNAME(nn) AMDIS_UNUSED(const char *funcName); funcName = nn;
#ifdef NDEBUG
#define AMDIS_FUNCNAME_DBG(nn)
#define AMDIS_DBG_VAR(var)
#else
#define AMDIS_FUNCNAME_DBG(nn) AMDIS_UNUSED(const char *funcName); funcName = nn;
#define AMDIS_DBG_VAR(var) var
#endif
namespace
AMDiS
{
namespace
Impl
{
template
<
class
OStream
>
OStream
&
concat
(
OStream
&
out
)
{
return
out
;
}
template
<
class
OStream
,
class
Arg0
,
class
...
Args
>
OStream
&
concat
(
OStream
&
out
,
Arg0
&&
arg0
,
Args
&&
...
args
)
{
out
<<
arg0
;
concat
(
out
,
std
::
forward
<
Args
>
(
args
)...);
return
out
;
}
template
<
class
...
Args
>
std
::
string
to_string
(
Args
&&
...
args
)
{
std
::
stringstream
ss
;
concat
(
ss
,
std
::
forward
<
Args
>
(
args
)...);
return
ss
.
str
();
}
template
<
class
OStream
,
class
...
Args
>
OStream
&
msg
(
OStream
&
out
,
Args
&&
...
args
)
{
#ifdef AMDIS_HAS_MPI
int
rank
=
-
1
;
int
num_ranks
=
-
1
;
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
num_ranks
);
if
(
num_ranks
>
1
&&
rank
==
0
)
{
concat
(
out
,
"[0] "
,
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
num_ranks
==
1
)
{
concat
(
out
,
std
::
forward
<
Args
>
(
args
)...);
}
#else
concat
(
out
,
std
::
forward
<
Args
>
(
args
)...);
#endif
return
out
;
}
}
// end namespace Impl
/// \brief print a message
/**
* Example:
* ```
* msg("Hello ", "World: ", 123); // prints "Hello World: 123\n"
* ```
**/
template
<
class
...
Args
>
void
msg
(
Args
&&
...
args
)
{
Impl
::
msg
(
std
::
cout
,
std
::
forward
<
Args
>
(
args
)...,
"
\n
"
);
}
/// \brief print a message (without appended newline)
/**
* Example:
* ```
* msg("Hello ", "World: ", 123); // prints "Hello World: 123"
* ```
**/
template
<
class
...
Args
>
void
msg_
(
Args
&&
...
args
)
{
Impl
::
msg
(
std
::
cout
,
std
::
forward
<
Args
>
(
args
)...);
}
/// \brief print a message and exit
/**
* If the preprocessor constant \ref AMDIS_NO_THROW is defined,
* the c-assert macro is called, otherwise an exception of
* type \ref std::runtime_Error is thrown.
**/
template
<
class
...
Args
>
void
error_exit
(
Args
&&
...
args
)
{
#ifdef AMDIS_NO_THROW
Impl
::
msg
(
std
::
cerr
,
"ERROR: "
,
std
::
forward
<
Args
>
(
args
)...,
"
\n
"
);
#ifndef NDEBUG
assert
(
false
);
#else
std
::
exit
(
EXIT_FAILURE
);
#endif
#else
throw
std
::
runtime_error
(
Impl
::
to_string
(
"ERROR: "
,
std
::
forward
<
Args
>
(
args
)...)
);
#endif
}
/// \brief test for condition and in case of failure print message and exit
/**
* This function is equivalent to
* ```