Liebe Gitlab-Nutzer, lieber Gitlab-Nutzer, es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Ein Anmelden über dieses erzeugt ein neues Konto. Das alte Konto ist über den Reiter "Standard" erreichbar. Die Administratoren

Dear Gitlab user, it is now possible to log in to our service using the ZIH login/LDAP. Logging in via this will create a new account. The old account can be accessed via the "Standard" tab. The administrators

Commit 68712ed4 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Initfiles with arithmetic expressions

parent c514d77b
......@@ -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 )
......
......@@ -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
......
......@@ -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())+">\nParser 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);
}
}
......
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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment