Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Praetorius, Simon
dune-amdis
Commits
4888fda1
Commit
4888fda1
authored
Sep 19, 2016
by
Praetorius, Simon
Browse files
output changed from macros to variadic functions
parent
ee990734
Changes
49
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
49 changed files
with
1645 additions
and
1291 deletions
+1645
-1291
CMakeLists.txt
CMakeLists.txt
+4
-3
dune/amdis/AMDiS.cpp
dune/amdis/AMDiS.cpp
+5
-7
dune/amdis/AdaptInfo.cpp
dune/amdis/AdaptInfo.cpp
+1
-1
dune/amdis/AdaptInfo.hpp
dune/amdis/AdaptInfo.hpp
+5
-5
dune/amdis/AdaptInstationary.cpp
dune/amdis/AdaptInstationary.cpp
+15
-18
dune/amdis/CMakeLists.txt
dune/amdis/CMakeLists.txt
+2
-3
dune/amdis/CreatorInterface.hpp
dune/amdis/CreatorInterface.hpp
+11
-11
dune/amdis/CreatorMap.hpp
dune/amdis/CreatorMap.hpp
+11
-11
dune/amdis/DirichletBC.hpp
dune/amdis/DirichletBC.hpp
+20
-20
dune/amdis/DirichletBC.inc.hpp
dune/amdis/DirichletBC.inc.hpp
+10
-10
dune/amdis/Initfile.cpp
dune/amdis/Initfile.cpp
+6
-10
dune/amdis/Initfile.hpp
dune/amdis/Initfile.hpp
+22
-42
dune/amdis/Mesh.hpp
dune/amdis/Mesh.hpp
+37
-37
dune/amdis/Operator.inc.hpp
dune/amdis/Operator.inc.hpp
+113
-113
dune/amdis/Output.hpp
dune/amdis/Output.hpp
+214
-0
dune/amdis/ProblemInstat.inc.hpp
dune/amdis/ProblemInstat.inc.hpp
+7
-7
dune/amdis/ProblemStat.hpp
dune/amdis/ProblemStat.hpp
+140
-140
dune/amdis/ProblemStat.inc.hpp
dune/amdis/ProblemStat.inc.hpp
+119
-119
dune/amdis/StandardProblemIteration.cpp
dune/amdis/StandardProblemIteration.cpp
+12
-12
dune/amdis/Terms.hpp
dune/amdis/Terms.hpp
+1
-0
dune/amdis/linear_algebra/PreconditionerInterface.hpp
dune/amdis/linear_algebra/PreconditionerInterface.hpp
+4
-4
dune/amdis/linear_algebra/RunnerInterface.hpp
dune/amdis/linear_algebra/RunnerInterface.hpp
+5
-5
dune/amdis/linear_algebra/istl/DOFMatrix.hpp
dune/amdis/linear_algebra/istl/DOFMatrix.hpp
+35
-35
dune/amdis/linear_algebra/istl/DOFVector.hpp
dune/amdis/linear_algebra/istl/DOFVector.hpp
+25
-25
dune/amdis/linear_algebra/istl/ISTL_Preconditioner.hpp
dune/amdis/linear_algebra/istl/ISTL_Preconditioner.hpp
+12
-12
dune/amdis/linear_algebra/istl/ISTL_Solver.hpp
dune/amdis/linear_algebra/istl/ISTL_Solver.hpp
+21
-21
dune/amdis/linear_algebra/istl/LinearSolver.hpp
dune/amdis/linear_algebra/istl/LinearSolver.hpp
+15
-15
dune/amdis/linear_algebra/istl/SystemMatrix.hpp
dune/amdis/linear_algebra/istl/SystemMatrix.hpp
+77
-77
dune/amdis/linear_algebra/istl/SystemVector.hpp
dune/amdis/linear_algebra/istl/SystemVector.hpp
+68
-68
dune/amdis/linear_algebra/mtl/BlockMTLMatrix.hpp
dune/amdis/linear_algebra/mtl/BlockMTLMatrix.hpp
+25
-25
dune/amdis/linear_algebra/mtl/BlockMTLVector.hpp
dune/amdis/linear_algebra/mtl/BlockMTLVector.hpp
+49
-49
dune/amdis/linear_algebra/mtl/DOFMatrix.hpp
dune/amdis/linear_algebra/mtl/DOFMatrix.hpp
+49
-49
dune/amdis/linear_algebra/mtl/DOFVector.hpp
dune/amdis/linear_algebra/mtl/DOFVector.hpp
+32
-32
dune/amdis/linear_algebra/mtl/KrylovRunner.hpp
dune/amdis/linear_algebra/mtl/KrylovRunner.hpp
+19
-19
dune/amdis/linear_algebra/mtl/LinearSolver.hpp
dune/amdis/linear_algebra/mtl/LinearSolver.hpp
+12
-12
dune/amdis/linear_algebra/mtl/MTLDenseVector.hpp
dune/amdis/linear_algebra/mtl/MTLDenseVector.hpp
+11
-11
dune/amdis/linear_algebra/mtl/Mapper.hpp
dune/amdis/linear_algebra/mtl/Mapper.hpp
+42
-42
dune/amdis/linear_algebra/mtl/Preconditioner.hpp
dune/amdis/linear_algebra/mtl/Preconditioner.hpp
+7
-7
dune/amdis/linear_algebra/mtl/SystemMatrix.hpp
dune/amdis/linear_algebra/mtl/SystemMatrix.hpp
+46
-46
dune/amdis/linear_algebra/mtl/SystemVector.hpp
dune/amdis/linear_algebra/mtl/SystemVector.hpp
+43
-43
dune/amdis/linear_algebra/mtl/UmfpackRunner.hpp
dune/amdis/linear_algebra/mtl/UmfpackRunner.hpp
+28
-28
dune/amdis/terms/FunctorTerm.hpp
dune/amdis/terms/FunctorTerm.hpp
+84
-0
dune/amdis/test/test1.cc
dune/amdis/test/test1.cc
+35
-35
projects/CMakeLists.txt
projects/CMakeLists.txt
+1
-0
projects/director_field/CMakeLists.txt
projects/director_field/CMakeLists.txt
+5
-0
projects/director_field/director.cc
projects/director_field/director.cc
+78
-0
src/BlockPreconditioner.hpp
src/BlockPreconditioner.hpp
+21
-21
src/MTLPfcPrecon.inc.hpp
src/MTLPfcPrecon.inc.hpp
+14
-14
src/pfc.cc
src/pfc.cc
+27
-27
No files found.
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
{
...
...
@@ -17,7 +17,7 @@ namespace AMDiS
{
// Maybe initialize MPI
Dune
::
MPIHelper
&
mpiHelper
=
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
Parameters
::
clearData
();
// read commandline arguments
...
...
@@ -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
{
...
...
@@ -78,7 +76,7 @@ namespace AMDiS
// if (vm.count("parameters") && !ignoreCommandline)
// Parameters::readArgv(vm["parameters"].as<std::string>(),0);
// TODO: add command-line arguments again.
return
mpiHelper
;
}
...
...
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,8 +304,8 @@ namespace AMDiS
double
getEstSum
(
int
index
)
const
{
AMDIS_FUNCNAME_DBG
(
"AdaptInfo::getEstSum()"
);
AMDIS_TEST_EXIT_DBG
(
static_cast
<
size_t
>
(
index
)
<
scalContents
.
size
(),
"Wrong index for adaptInfo!
\n
"
);
test_exit_dbg
(
static_cast
<
size_t
>
(
index
)
<
scalContents
.
size
(),
"Wrong index for adaptInfo!
\n
"
);
return
scalContents
[
index
]
->
est_sum
;
}
...
...
@@ -320,8 +320,8 @@ namespace AMDiS
double
getEstMax
(
int
index
)
const
{
AMDIS_FUNCNAME_DBG
(
"AdaptInfo::getEstSum()"
);
AMDIS_TEST_EXIT_DBG
(
static_cast
<
size_t
>
(
index
)
<
scalContents
.
size
(),
"Wrong index for adaptInfo!
\n
"
);
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
(),
"timestep < min timestep"
);
AMDIS_TEST_EXIT
(
adaptInfo
.
getTimestep
()
<=
adaptInfo
.
getMaxTimestep
(),
"timestep > max timestep"
);
test_exit
(
adaptInfo
.
getTimestep
()
>=
adaptInfo
.
getMinTimestep
(),
"timestep < min timestep"
);
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
)
...
...
@@ -49,14 +48,14 @@ if (MTL_FOUND)
foreach
(
feature
${
CXX_ELEVEN_FEATURE_LIST
}
)
target_compile_definitions
(
"duneamdis"
PUBLIC MTL_WITH_
${
feature
}
)
endforeach
()
if
(
HAVE_UMFPACK OR ENABLE_SUITESPARSE OR SuiteSparse_FOUND
)
target_compile_definitions
(
"duneamdis"
PUBLIC MTL_HAS_UMFPACK
)
endif
()
endif
(
MTL_FOUND
)
install
(
FILES
install
(
FILES
AdaptBase.hpp
AdaptInfo.hpp
AdaptInstationary.hpp
...
...
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
{
...
...
@@ -31,7 +31,7 @@ namespace AMDiS
* Must be implemented by sub classes of CreatorInterface.
* Creates a new instance of the sub class of BaseClass.
*/
virtual
shared_ptr
<
BaseClass
>
create
()
=
0
;
virtual
shared_ptr
<
BaseClass
>
create
()
=
0
;
};
/**
...
...
@@ -44,28 +44,28 @@ namespace AMDiS
class
CreatorInterfaceName
:
public
CreatorInterface
<
BaseClass
>
{
public:
virtual
shared_ptr
<
BaseClass
>
create
()
override
{
AMDIS_ERROR_EXIT
(
"Should not be called. Call create(string) instead!"
);
return
{};
{
error_exit
(
"Should not be called. Call create(string) instead!"
);
return
{};
};
/** \brief
* Must be implemented by sub classes of CreatorInterfaceName.
* Creates a new instance of the sub class of BaseClass by passing a
* Creates a new instance of the sub class of BaseClass by passing a
* string to the constructor.
*/
virtual
shared_ptr
<
BaseClass
>
create
(
std
::
string
)
=
0
;
};
/// cast a ptr of CreatorInterface to CreatorInterfaceName
template
<
class
BaseClass
>
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
...
...
@@ -7,14 +7,14 @@
#include <dune/amdis/CreatorInterface.hpp>
namespace
AMDiS
{
// forward declaration.
{
// forward declaration.
// All classes that need creators must specialize this class and implement
// a static void init() method.
template
<
class
BaseClass
>
struct
DefaultCreators
;
/** \ingroup Common
* \brief
* A CreatorMap is used to construct objects, which types depends on key words
...
...
@@ -26,7 +26,7 @@ namespace AMDiS
*/
template
<
class
BaseClass
>
class
CreatorMap
{
{
public:
using
CreatorMapType
=
std
::
map
<
std
::
string
,
CreatorInterface
<
BaseClass
>*
>
;
...
...
@@ -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
;
}
...
...
@@ -44,14 +44,14 @@ namespace AMDiS
static
CreatorInterface
<
BaseClass
>*
getCreator
(
std
::
string
key
,
std
::
string
initFileStr
)
{
init
();
auto
it
=
creatorMap
.
find
(
key
);
if
(
it
==
creatorMap
.
end
())
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,22 +6,22 @@
#include <dune/amdis/common/ConceptsBase.hpp>
#include
"Log
.hpp
"
#include
<dune/amdis/Output
.hpp
>
namespace
AMDiS
{
/// Implements a boundary condition of Dirichlet-type.
/**
* By calling the methods \ref init() and \ref finish before and after
* By calling the methods \ref init() and \ref finish before and after
* assembling the system-matrix, respectively, dirichlet boundary conditions
* can be applied to the matrix and system vector. Therefore a predicate
* can be applied to the matrix and system vector. Therefore a predicate
* functions indicates the DOFs where values should be enforced and a second
* functor provided in the constructor is responsible for determining the
* functor provided in the constructor is responsible for determining the
* values to be set at the DOFs.
*
* In the \ref finish method the matrix is called with \ref applyDirichletBC
* to erase the corresponding rows and columns for the DOF indices. This
* application of boundary conditions can be symmetric if the matrix does
*
* In the \ref finish method the matrix is called with \ref applyDirichletBC
* to erase the corresponding rows and columns for the DOF indices. This
* application of boundary conditions can be symmetric if the matrix does
* support this symmetric modification. As a result, this method returns a list
* of columns values, that should be subtracted from the rhs.
**/
...
...
@@ -36,25 +36,25 @@ namespace AMDiS
:
predicate
(
std
::
forward
<
Predicate
>
(
predicate
))
,
values
(
std
::
forward
<
Values
>
(
values
))
{}
template
<
class
Matrix
,
class
VectorX
,
class
VectorB
>
void
init
(
bool
apply
,
Matrix
&
matrix
,
VectorX
&
rhs
,
void
init
(
bool
apply
,
Matrix
&
matrix
,
VectorX
&
rhs
,
VectorB
&
solution
);
template
<
class
Matrix
,
class
VectorX
,
class
VectorB
>
void
finish
(
bool
apply
,
Matrix
&
matrix
,
VectorX
&
rhs
,
void
finish
(
bool
apply
,
Matrix
&
matrix
,
VectorX
&
rhs
,
VectorB
&
solution
);
private:
std
::
function
<
bool
(
WorldVector
)
>
predicate
;
std
::
function
<
double
(
WorldVector
)
>
values
;
bool
initialized
=
false
;
std
::
vector
<
char
>
dirichletNodes
;
};
...
...
dune/amdis/DirichletBC.inc.hpp
View file @
4888fda1
...
...
@@ -8,29 +8,29 @@ namespace AMDiS
template
<
class
WorldVector
>
template
<
class
Matrix
,
class
VectorX
,
class
VectorB
>
void
DirichletBC
<
WorldVector
>::
init
(
bool
apply
,
Matrix
&
matrix
,
VectorX
&
solution
,
Matrix
&
matrix
,
VectorX
&
solution
,
VectorB
&
rhs
)
{
using
Dune
::
Functions
::
interpolate
;
if
(
!
initialized
)
{
interpolate
(
matrix
.
getRowFeSpace
(),
dirichletNodes
,
predicate
);
initialized
=
true
;
}
}
template
<
class
WorldVector
>
template
<
class
Matrix
,
class
VectorX
,
class
VectorB
>
void
DirichletBC
<
WorldVector
>::
finish
(
bool
apply
,
Matrix
&
matrix
,
VectorX
&
solution
,
Matrix
&
matrix
,
VectorX
&
solution
,
VectorB
&
rhs
)
{
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
)
{
...
...
@@ -38,6 +38,6 @@ namespace AMDiS
interpolate
(
matrix
.
getColFeSpace
(),
wrapper
(
solution
.
getVector
()),
values
,
dirichletNodes
);
}
}
}
// end namespace AMDiS
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
{
...
...
@@ -36,28 +36,25 @@ namespace AMDiS
// mu::Parser parser;
// parser.DefineConst(_T("M_PI"), m_pi);
// parser.DefineConst(_T("M_E"), m_e);
//
//
// parser.SetExpr(valStr);
// return parser.Eval();
// }
// }
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,8 +81,8 @@ 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
);
values
[
i
++
]
=
v
;
...
...
@@ -105,8 +105,8 @@ 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
);
values
[
i
++
]
=
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);