Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
iwr
amdis
Commits
68712ed4
Commit
68712ed4
authored
Jun 06, 2011
by
Praetorius, Simon
Browse files
Initfiles with arithmetic expressions
parent
c514d77b
Changes
4
Hide whitespace changes
Inline
Side-by-side
AMDiS/AMDiSConfig.cmake.in
View file @
68712ed4
...
...
@@ -41,7 +41,7 @@ find_library(_AMDIS_LIB amdis PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/
if(_AMDIS_LIB)
get_filename_component(AMDIS_LIBRARY_DIR ${_AMDIS_LIB} PATH CACHE)
set(AMDIS_LIBRARY_DIRS ${AMDIS_LIBRARY_DIR})
set(AMDIS_LIBRARIES "${_AMDIS_LIB};${AMDIS_LIBRARY_DIR}/libcompositeFEM.so;${AMDIS_LIBRARY_DIR}/libreinit.so" CACHE STRING "amdis libraries")
set(AMDIS_LIBRARIES "${_AMDIS_LIB};${AMDIS_LIBRARY_DIR}/libcompositeFEM.so;${AMDIS_LIBRARY_DIR}/libreinit.so
;${AMDIS_LIBRARY_DIR}/libmuparser.so
" CACHE STRING "amdis libraries")
else()
message(ERROR "could not detect the AMDiS library directory. Please set the variable AMDIS_LIBRARY_DIR to the directory containg the AMDiS library")
endif()
...
...
@@ -129,6 +129,7 @@ endif(AMDiS_NEED_UMFPACK)
#add directories for reinit
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/reinit)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/compositeFEM)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/muparser)
if(${AMDIS_FIND_COMPONENTS} MATCHES umfpack )
if( NOT AMDiS_NEED_UMFPACK )
...
...
AMDiS/CMakeLists.txt
View file @
68712ed4
...
...
@@ -336,6 +336,12 @@ set(REINIT_SOURCE_DIR ${SOURCE_DIR}/reinit)
file
(
GLOB REINIT_SRC
${
REINIT_SOURCE_DIR
}
/*.cc
)
include_directories
(
${
REINIT_SOURCE_DIR
}
)
#muparser includes
set
(
MUPARSER_SOURCE_DIR
${
AMDiS_SOURCE_DIR
}
/lib/muparser_v134
)
file
(
GLOB MUPARSER_SRC
${
MUPARSER_SOURCE_DIR
}
/src/*.cpp
)
list
(
APPEND AMDiS_INCLUDE_DIRS
${
MUPARSER_SOURCE_DIR
}
/include
)
#mtl4 includes
list
(
APPEND AMDiS_INCLUDE_DIRS
${
MTL_INCLUDE_DIR
}
)
#include_directories(${MTL_INCLUDE_DIR})
...
...
@@ -346,6 +352,7 @@ include_directories(${AMDiS_INCLUDE_DIRS})
add_library
(
amdis SHARED
${
AMDIS_SRC
}
${
PARALLEL_DOMAIN_AMDIS_SRC
}
)
add_library
(
compositeFEM SHARED
${
COMPOSITE_FEM_SRC
}
)
add_library
(
reinit SHARED
${
REINIT_SRC
}
)
add_library
(
muparser SHARED
${
MUPARSER_SRC
}
)
#target_link_libraries(compositeFEM amdis)
#target_link_libraries(reinit amdis)
list
(
APPEND AMDiS_LIBS amdis
${
Boost_LIBRARIES
}
)
...
...
@@ -406,8 +413,13 @@ INSTALL(FILES ${HEADERS}
DESTINATION include/amdis/compositeFEM
)
list
(
APPEND deb_add_dirs
"include/amdis/compositeFEM"
)
FILE
(
GLOB HEADERS
"
${
MUPARSER_SOURCE_DIR
}
/include/*.h"
)
INSTALL
(
FILES
${
HEADERS
}
DESTINATION include/amdis/muparser
)
list
(
APPEND deb_add_dirs
"include/amdis/muparser"
)
list
(
APPEND deb_add_dirs
"lib/amdis"
)
install
(
TARGETS amdis compositeFEM reinit
install
(
TARGETS amdis compositeFEM reinit
muparser
LIBRARY DESTINATION lib/amdis/
)
configure_file
(
${
AMDiS_SOURCE_DIR
}
/AMDiSConfig.cmake.in
...
...
AMDiS/src/Initfile.h
View file @
68712ed4
...
...
@@ -15,8 +15,12 @@
#include
<boost/algorithm/string/trim.hpp>
#include
<boost/lexical_cast.hpp>
#include
<boost/numeric/conversion/cast.hpp>
#include
<boost/type_traits.hpp>
// a parser for arithmetic expressions
#include
"muParser.h"
namespace
AMDiS
{
...
...
@@ -43,7 +47,18 @@ namespace AMDiS {
WrongValueFormat
(
std
::
string
value
)
:
std
::
runtime_error
(
std
::
string
(
"cannot convert '"
)
+
value
+
std
::
string
(
"' into <"
)
+
name
(
T
())
+
">"
)
{}
};
template
<
typename
T
>
struct
BadArithmeticExpression
:
std
::
runtime_error
{
static
std
::
string
name
(
int
)
{
return
"int"
;
}
static
std
::
string
name
(
bool
)
{
return
"bool"
;
}
static
std
::
string
name
(
double
)
{
return
"double"
;
}
static
std
::
string
name
(
unsigned
int
)
{
return
"unsigned int"
;
}
template
<
typename
G
>
static
std
::
string
name
(
G
)
{
return
std
::
string
(
typeid
(
G
).
name
());
}
BadArithmeticExpression
(
std
::
string
m
,
std
::
string
value
)
:
std
::
runtime_error
(
std
::
string
(
"cannot evaluate expression '"
)
+
value
+
std
::
string
(
"' into <"
)
+
name
(
T
())
+
">
\n
Parser message: '"
+
m
+
"'"
)
{}
};
/// trim std::string
...
...
@@ -125,11 +140,22 @@ namespace AMDiS {
typename
boost
::
disable_if
<
boost
::
is_enum
<
T
>
>::
type
*
p2
=
NULL
)
{
using
boost
::
lexical_cast
;
using
boost
::
numeric_cast
;
mu
::
Parser
parser
;
parser
.
DefineConst
(
_T
(
"M_PI"
),
m_pi
);
parser
.
DefineConst
(
_T
(
"M_E"
),
m_e
);
try
{
value
=
lexical_cast
<
T
>
(
trim
(
valStr
));
}
catch
(
boost
::
bad_lexical_cast
e
)
{
parser
.
SetExpr
(
valStr
);
// value = lexical_cast< T >(trim(valStr));
value
=
numeric_cast
<
T
>
(
parser
.
Eval
());
}
catch
(
boost
::
bad_lexical_cast
e
)
{
throw
WrongValueFormat
<
T
>
(
valStr
);
}
catch
(
boost
::
bad_numeric_cast
e
)
{
throw
WrongValueFormat
<
T
>
(
valStr
);
}
catch
(
mu
::
Parser
::
exception_type
&
e
)
{
throw
BadArithmeticExpression
<
T
>
(
e
.
GetMsg
(),
valStr
);
}
}
...
...
demo/CMakeLists.txt
View file @
68712ed4
project
(
"amdis_demo"
)
cmake_minimum_required
(
VERSION 2.8
)
set
(
AMDIS_DIR /u/spraetor/amdis-trunk/AMDiS_seq/share/amdis
)
#find_package(AMDIS REQUIRED COMPONENTS umfpack )
find_package
(
AMDIS REQUIRED
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment