Skip to content
Snippets Groups Projects
Commit ea693f3d authored by Christian Engwer's avatar Christian Engwer
Browse files

Merge branch 'master' into feature/FS1322-initialize-fieldvector

parents b4328de2 2bf792d8
No related branches found
No related tags found
No related merge requests found
Showing
with 234 additions and 503 deletions
...@@ -3,10 +3,10 @@ project("dune-common" C CXX) ...@@ -3,10 +3,10 @@ project("dune-common" C CXX)
# general stuff # general stuff
cmake_minimum_required(VERSION 2.8.6) cmake_minimum_required(VERSION 2.8.6)
message("CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}|")
# make sure our own modules are found # make sure our own modules are found
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/modules") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/modules")
message("CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
# set the script dir for the macros. # set the script dir for the macros.
set(DUNE_COMMON_SCRIPT_DIR "${PROJECT_SOURCE_DIR}/cmake/scripts") set(DUNE_COMMON_SCRIPT_DIR "${PROJECT_SOURCE_DIR}/cmake/scripts")
......
...@@ -163,14 +163,33 @@ load_opts() { ...@@ -163,14 +163,33 @@ load_opts() {
local COMMAND=$(echo $command | tr '[:lower:]' '[:upper:]') local COMMAND=$(echo $command | tr '[:lower:]' '[:upper:]')
CMD_FLAGS="$(eval echo \$${COMMAND}_FLAGS)" CMD_FLAGS="$(eval echo \$${COMMAND}_FLAGS)"
local CMD_FLAGS_FROM_FILE="" local CMD_FLAGS_FROM_FILE=""
BUILDDIR=$DUNE_BUILDDIR if test "$command" = "NONE"; then
BUILDDIR=$DUNE_BUILDDIR
USE_CMAKE=$DUNE_USE_CMAKE
if test "x$DUNE_OPTS_FILE" != "x"; then
if test -z "$BUILDDIR"; then
# no builddir set yet, use build dir from opts file if set
# Note: if --use-buiddir is used BUILDDIR will be set already
OPTS_FILE_BUILDDIR="$(eval BUILDDIR=""; . $DUNE_OPTS_FILE; eval echo \$BUILDDIR)"
if test -n "$OPTS_FILE_BUILDDIR"; then
BUILDDIR="$OPTS_FILE_BUILDDIR"
fi
fi
if test -z "$USE_CMAKE"; then
# no USE_CMAKE set yet, use USE_CMAKE from opts file if set
# Note: if --use-cmake is used USE_CMAKE will be set already
OPTS_FILE_USE_CMAKE="$(eval USE_CMAKE=""; . $DUNE_OPTS_FILE; eval echo \$USE_CMAKE)"
if test -n "$OPTS_FILE_USE_CMAKE"; then
USE_CMAKE="$OPTS_FILE_USE_CMAKE"
fi
fi
fi
fi
if test "x$DUNE_OPTS_FILE" != "x"; then if test "x$DUNE_OPTS_FILE" != "x"; then
# use build dir from opts file if set if test "$command" = "configure"; then
OPTS_FILE_BUILDDIR="$(eval BUILDDIR=""; . $DUNE_OPTS_FILE; eval echo \$BUILDDIR)" CMAKE_FLAGS="$(. $DUNE_OPTS_FILE; eval echo \$CMAKE_FLAGS)"
if test -n "$OPTS_FILE_BUILDDIR"; then
BUILDDIR="$OPTS_FILE_BUILDDIR"
fi fi
CMAKE_FLAGS="$(. $DUNE_OPTS_FILE; eval echo \$CMAKE_FLAGS)"
CMD_FLAGS_FROM_FILE="$(eval ${COMMAND}_FLAGS=""; . $DUNE_OPTS_FILE; eval echo \$${COMMAND}_FLAGS)" CMD_FLAGS_FROM_FILE="$(eval ${COMMAND}_FLAGS=""; . $DUNE_OPTS_FILE; eval echo \$${COMMAND}_FLAGS)"
fi fi
if test -n "$CMD_FLAGS_FROM_FILE"; then if test -n "$CMD_FLAGS_FROM_FILE"; then
...@@ -179,6 +198,13 @@ load_opts() { ...@@ -179,6 +198,13 @@ load_opts() {
elif test -n "$CMD_FLAGS"; then elif test -n "$CMD_FLAGS"; then
echo "----- using default flags \$${COMMAND}_FLAGS from environment -----" echo "----- using default flags \$${COMMAND}_FLAGS from environment -----"
fi fi
if test "x$USE_CMAKE" = "xyes"; then
if test -z "$BUILDDIR"; then
echo "No build directory provided. Defaulting to the sub directory build-cmake"
export BUILDDIR=build-cmake
fi
fi
} }
############################################### ###############################################
...@@ -409,9 +435,12 @@ run_default_vcsetup() { ...@@ -409,9 +435,12 @@ run_default_vcsetup() {
echo -n "--> Setting Git configuration entries... " echo -n "--> Setting Git configuration entries... "
cat .vcsetup/config | while read; do cat .vcsetup/config | while read; do
# Filter out comments # Filter out comments
COMMENT="$(echo $REPLY | $GREP '^#')" local COMMENT="$(echo $REPLY | $GREP '^#')"
if [ ! "x$COMMENT" = "x$REPLY" ]; then if [ ! "x$COMMENT" = "x$REPLY" ]; then
git config $REPLY # parse line into an array first to catch obvious syntax errors
# like 'option value; rm -rf /'
eval local GIT_ARGS=($REPLY)
git config "${GIT_ARGS[@]}"
fi fi
done done
echo "done" echo "done"
...@@ -423,9 +452,12 @@ run_default_vcsetup() { ...@@ -423,9 +452,12 @@ run_default_vcsetup() {
echo -n "--> Setting custom Git configuration entries from '$GIT_CONFIG_FILE'... " echo -n "--> Setting custom Git configuration entries from '$GIT_CONFIG_FILE'... "
cat "$GIT_CONFIG_FILE" | while read; do cat "$GIT_CONFIG_FILE" | while read; do
# Filter out comments # Filter out comments
COMMENT="$(echo $REPLY | $GREP '^#')" local COMMENT="$(echo $REPLY | $GREP '^#')"
if [ ! "x$COMMENT" = "x$REPLY" ]; then if [ ! "x$COMMENT" = "x$REPLY" ]; then
git config $REPLY # parse line into an array first to catch obvious syntax errors
# like 'option value; rm -rf /'
eval local GIT_ARGS=($REPLY)
git config "${GIT_ARGS[@]}"
fi fi
done done
echo "done" echo "done"
...@@ -518,7 +550,7 @@ run_default_configure () { ...@@ -518,7 +550,7 @@ run_default_configure () {
else else
LOCAL_USE_CMAKE=no LOCAL_USE_CMAKE=no
fi fi
echo "LOCAL_USE_CMAKE=$LOCAL_USE_CMAKE $(eval "echo \$PATH_$module")/CMakeLists.txt"
if test -x configure || test "x$LOCAL_USE_CMAKE" = "xyes" ; then if test -x configure || test "x$LOCAL_USE_CMAKE" = "xyes" ; then
ACLOCAL_FLAGS="-I ." ACLOCAL_FLAGS="-I ."
if test -d "m4"; then if test -d "m4"; then
...@@ -534,7 +566,6 @@ run_default_configure () { ...@@ -534,7 +566,6 @@ run_default_configure () {
# Translate the configure PARMS to cmake # Translate the configure PARMS to cmake
export PARAMS export PARAMS
export CMAKE_PARAMS export CMAKE_PARAMS
echo module_translate_options_am2cmake $m $path/lib
module_translate_options_am2cmake $m $path/lib module_translate_options_am2cmake $m $path/lib
fi fi
if test x$module = x$m; then continue; fi # skip myself if test x$module = x$m; then continue; fi # skip myself
...@@ -577,16 +608,16 @@ run_default_configure () { ...@@ -577,16 +608,16 @@ run_default_configure () {
PREPARAMS="$PREPARAMS $cflags" PREPARAMS="$PREPARAMS $cflags"
fi fi
done done
# create build directory if requested
test -d "$BUILDDIR" || mkdir "$BUILDDIR" test -d "$BUILDDIR" || mkdir "$BUILDDIR"
SRCDIR="$PWD" SRCDIR="$PWD"
cd "$BUILDDIR" cd "$BUILDDIR"
echo `pwd`
echo "$PREPARAMS cmake -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_MODULE_PATH=\"$CMAKE_MODULE_PATH\" $CMAKE_PARAMS $CMAKE_FLAGS $SRCDIR" echo "$PREPARAMS cmake -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_MODULE_PATH=\"$CMAKE_MODULE_PATH\" $CMAKE_PARAMS $CMAKE_FLAGS $SRCDIR"
eval $PREPARAMS cmake "-DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_MODULE_PATH=\"$CMAKE_MODULE_PATH\" $CMAKE_PARAMS $CMAKE_FLAGS $SRCDIR" || exit 1 eval $PREPARAMS cmake "-DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_MODULE_PATH=\"$CMAKE_MODULE_PATH\" $CMAKE_PARAMS $CMAKE_FLAGS $SRCDIR" || exit 1
else else
PARAMS="$PARAMS ACLOCAL_AMFLAGS=\"$ACLOCAL_FLAGS\"" PARAMS="$PARAMS ACLOCAL_AMFLAGS=\"$ACLOCAL_FLAGS\""
echo ./configure "$PARAMS" echo ./configure "$PARAMS"
# create build directory of requested # create build directory if requested
if test -n "$BUILDDIR"; then if test -n "$BUILDDIR"; then
test -d "$BUILDDIR" || mkdir "$BUILDDIR" test -d "$BUILDDIR" || mkdir "$BUILDDIR"
SRCDIR="$PWD" SRCDIR="$PWD"
...@@ -752,7 +783,6 @@ export ONLY="" ...@@ -752,7 +783,6 @@ export ONLY=""
export RESUME_FLAG=no export RESUME_FLAG=no
export REVERSE_FLAG=no export REVERSE_FLAG=no
export SKIPFIRST=no export SKIPFIRST=no
export USE_CMAKE=no
# parse commandline parameters # parse commandline parameters
while test $# -gt 0; do while test $# -gt 0; do
...@@ -862,7 +892,7 @@ while test $# -gt 0; do ...@@ -862,7 +892,7 @@ while test $# -gt 0; do
export SKIPFIRST=yes export SKIPFIRST=yes
;; ;;
--use-cmake) --use-cmake)
export USE_CMAKE=yes export DUNE_USE_CMAKE=yes
;; ;;
--debug) true ;; # ignore this option, it is handled right at the beginning --debug) true ;; # ignore this option, it is handled right at the beginning
--*) --*)
...@@ -879,15 +909,6 @@ while test $# -gt 0; do ...@@ -879,15 +909,6 @@ while test $# -gt 0; do
shift shift
done done
if test "x$USE_CMAKE" = "xyes"; then
# load general options. DUNE_BUILDDIR might be overwritten in the opts file
load_opts NONE
if test -z "$DUNE_BUILDDIR"; then
echo "No build directory provided. Defaulting to the sub directory build-cmake"
export DUNE_BUILDDIR=build-cmake
fi
fi
echo "USE_CMAKE=$USE_CMAKE DUNE_BUILDDIR=$DUNE_BUILDDIR"
# we assume there should be a command... # we assume there should be a command...
if test "x$command" = "x"; then if test "x$command" = "x"; then
usage usage
......
...@@ -10,6 +10,7 @@ set(modules DuneBoost.cmake ...@@ -10,6 +10,7 @@ set(modules DuneBoost.cmake
DuneTestMacros.cmake DuneTestMacros.cmake
DuneTests.cmake DuneTests.cmake
FindBoostFusion.cmake FindBoostFusion.cmake
FindCXX11Conditional.cmake
FindCXX11Features.cmake FindCXX11Features.cmake
FindGMP.cmake FindGMP.cmake
FindInkscape.cmake FindInkscape.cmake
......
...@@ -83,7 +83,6 @@ MACRO(dune_add_latex_document tex_file) ...@@ -83,7 +83,6 @@ MACRO(dune_add_latex_document tex_file)
string(REGEX REPLACE "/" "_" "${CMAKE_CURRENT_SOURCE_DIR}/${file}" filevar ${file}) string(REGEX REPLACE "/" "_" "${CMAKE_CURRENT_SOURCE_DIR}/${file}" filevar ${file})
set(filevar "filevar-NOTFOUND") set(filevar "filevar-NOTFOUND")
find_file(filevar ${tex_file} ${CMAKE_CURRENT_SOURCE_DIR}) find_file(filevar ${tex_file} ${CMAKE_CURRENT_SOURCE_DIR})
message(filevar=${filevar} tex_file=${tex_file} CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR})
if(filevar) if(filevar)
if(LATEX_USABLE) if(LATEX_USABLE)
# add rule to create latex document # add rule to create latex document
......
...@@ -419,6 +419,7 @@ macro(dune_project) ...@@ -419,6 +419,7 @@ macro(dune_project)
# set required compiler flags for C++11 (former C++0x) # set required compiler flags for C++11 (former C++0x)
find_package(CXX11Features) find_package(CXX11Features)
find_package(CXX11Conditional)
include(DuneCxaDemangle) include(DuneCxaDemangle)
...@@ -435,7 +436,7 @@ macro(dune_project) ...@@ -435,7 +436,7 @@ macro(dune_project)
include_directories("${CMAKE_SOURCE_DIR}") include_directories("${CMAKE_SOURCE_DIR}")
link_directories("${CMAKE_SOURCE_DIR}/lib") link_directories("${CMAKE_SOURCE_DIR}/lib")
include_directories("${CMAKE_CURRENT_BINARY_DIR}") include_directories("${CMAKE_CURRENT_BINARY_DIR}")
include_directories("/\${CMAKE_CURRENT_SOURCE_DIR}") include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
add_definitions(-DHAVE_CONFIG_H) add_definitions(-DHAVE_CONFIG_H)
# Search for MPI and set the relevant variables. # Search for MPI and set the relevant variables.
...@@ -489,8 +490,11 @@ macro(dune_project) ...@@ -489,8 +490,11 @@ macro(dune_project)
include(GNUInstallDirs) include(GNUInstallDirs)
# Set variable where the cmake modules will be installed. # Set variable where the cmake modules will be installed.
# Thus the user can override it and for example install # Thus the user can override it and for example install
# directly into the CMake installation. This has to be an # directly into the CMake installation. We use a cache variable
# absolute path. Default: ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/cmake/modules # that is overridden by a local variable of the same name if
# the user does not explicitely set a value for it. Thus the value
# will automatically change if the user changes CMAKE_INSTALL_DATAROOTDIR
# or CMAKE_INSTALL_PREFIX
if(NOT DUNE_INSTALL_MODULEDIR) if(NOT DUNE_INSTALL_MODULEDIR)
set(DUNE_INSTALL_MODULEDIR "" set(DUNE_INSTALL_MODULEDIR ""
CACHE PATH CACHE PATH
......
...@@ -15,7 +15,18 @@ set(VERSION ${DUNE_MOD_VERSION}) ...@@ -15,7 +15,18 @@ set(VERSION ${DUNE_MOD_VERSION})
set(CC ${CMAKE_C_COMPILER}) set(CC ${CMAKE_C_COMPILER})
set(CXX "${CMAKE_CXX_COMPILER} ${CXX_STD11_FLAGS}") set(CXX "${CMAKE_CXX_COMPILER} ${CXX_STD11_FLAGS}")
set(REQUIRES ${DUNE_DEPENDS}) if(DUNE_DEPENDS)
foreach(_DUNE_DEPEND ${DUNE_DEPENDS})
string(REGEX REPLACE "\\(" "" REQF1 ${_DUNE_DEPEND})
string(REGEX REPLACE "\\)" "" LR ${REQF1})
if(REQUIRES)
set(REQUIRES "${REQUIRES} ${LR}")
else()
set(REQUIRES ${LR})
endif(REQUIRES)
endforeach(_DUNE_DEPEND ${DUNE_DEPENDS})
endif(DUNE_DEPENDS)
#create pkg-config file #create pkg-config file
configure_file( configure_file(
${PROJECT_SOURCE_DIR}/${DUNE_MOD_NAME}.pc.in ${PROJECT_SOURCE_DIR}/${DUNE_MOD_NAME}.pc.in
...@@ -24,7 +35,7 @@ configure_file( ...@@ -24,7 +35,7 @@ configure_file(
) )
# install pkgconfig file # install pkgconfig file
if(PKG_CONFIG_FOUND ) if(PKG_CONFIG_FOUND)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DUNE_MOD_NAME}.pc install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DUNE_MOD_NAME}.pc
DESTINATION lib/pkgconfig) DESTINATION lib/pkgconfig)
endif(PKG_CONFIG_FOUND) endif(PKG_CONFIG_FOUND)
# Module that checks whether the compiler supports
# C++11 std::conditional.
#
# Sets the following variable:
# HAVE_STD_CONDITIONAL
#
# perform tests
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <type_traits>
int main(void){
return std::conditional<true,std::integral_constant<int,0>,void>::type::value;
}"
HAVE_STD_CONDITIONAL)
...@@ -5,11 +5,9 @@ ...@@ -5,11 +5,9 @@
# HAVE_SYS_MMAN_H # HAVE_SYS_MMAN_H
# HAVE_MPROTECT # HAVE_MPROTECT
check_include_file("sys/mman.h" HAVE_SYS_MMAN_H) check_include_file("sys/mman.h" HAVE_SYS_MMAN_H)
message(STATUS HAVE_SYS_MMAN_H=${HAVE_SYS_MMAN_H})
include(CheckCSourceCompiles) include(CheckCSourceCompiles)
check_c_source_compiles(" check_c_source_compiles("
#include <sys/mman.h> #include <sys/mman.h>
int main(void){ int main(void){
mprotect(0,0,PROT_NONE); mprotect(0,0,PROT_NONE);
}" HAVE_MPROTECT) }" HAVE_MPROTECT)
message(STATUS HAVE_MPROTECT=${HAVE_MPROTECT})
...@@ -10,6 +10,7 @@ MODULES = DuneBoost.cmake \ ...@@ -10,6 +10,7 @@ MODULES = DuneBoost.cmake \
DuneTestMacros.cmake \ DuneTestMacros.cmake \
DuneTests.cmake \ DuneTests.cmake \
FindBoostFusion.cmake \ FindBoostFusion.cmake \
FindCXX11Conditional.cmake \
FindCXX11Features.cmake \ FindCXX11Features.cmake \
FindGMP.cmake \ FindGMP.cmake \
FindInkscape.cmake \ FindInkscape.cmake \
......
MACRO(get_directory_test_target _target _dir) MACRO(get_directory_test_target _target _dir)
message("$_dir")
string(REPLACE "@CMAKE_BINARY_DIR@" "" _relative_dir "${_dir}") string(REPLACE "@CMAKE_BINARY_DIR@" "" _relative_dir "${_dir}")
message("$_relative_dir")
string(REPLACE "/" "_" ${_target} "${_relative_dir}") string(REPLACE "/" "_" ${_target} "${_relative_dir}")
message("target=${${_target}}")
ENDMACRO(get_directory_test_target _target _dir) ENDMACRO(get_directory_test_target _target _dir)
get_directory_test_target(_build_test_target "@CMAKE_CURRENT_BINARY_DIR@") get_directory_test_target(_build_test_target "@CMAKE_CURRENT_BINARY_DIR@")
message("binary_dir=@CMAKE_CURRENT_BINARY_DIR@") message("binary_dir=@CMAKE_CURRENT_BINARY_DIR@")
execute_process(COMMAND @CMAKE_COMMAND@ --build @CMAKE_BINARY_DIR@ execute_process(COMMAND @CMAKE_COMMAND@ --build @CMAKE_BINARY_DIR@
--target ${_build_test_target}) --target ${_build_test_target})
\ No newline at end of file
...@@ -108,6 +108,9 @@ ...@@ -108,6 +108,9 @@
/* Define to 1 if you have the <type_traits> header file. */ /* Define to 1 if you have the <type_traits> header file. */
#cmakedefine HAVE_TYPE_TRAITS 1 #cmakedefine HAVE_TYPE_TRAITS 1
/* Define to 1 if you have the <type_traits> header file. */
#cmakedefine HAVE_STD_CONDITIONAL 1
/* Define to 1 if the MPI2 Standard is supported */ /* Define to 1 if the MPI2 Standard is supported */
#cmakedefine MPI_2 1 #cmakedefine MPI_2 1
......
...@@ -107,8 +107,6 @@ INTERNAL_DOCS = YES ...@@ -107,8 +107,6 @@ INTERNAL_DOCS = YES
# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
# in the documentation. The default is NO. # in the documentation. The default is NO.
SHOW_DIRECTORIES = YES
REFERENCED_BY_RELATION = YES REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES REFERENCES_RELATION = YES
ALPHABETICAL_INDEX = YES ALPHABETICAL_INDEX = YES
...@@ -207,7 +205,6 @@ GENERATE_BUGLIST = YES ...@@ -207,7 +205,6 @@ GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS = ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30 MAX_INITIALIZER_LINES = 30
SHOW_DIRECTORIES = YES
SHOW_FILES = YES SHOW_FILES = YES
SHOW_NAMESPACES = YES SHOW_NAMESPACES = YES
FILE_VERSION_FILTER = FILE_VERSION_FILTER =
......
...@@ -7,8 +7,8 @@ noinst_LTLIBRARIES = libcommon.la ...@@ -7,8 +7,8 @@ noinst_LTLIBRARIES = libcommon.la
libcommon_la_SOURCES = \ libcommon_la_SOURCES = \
debugallocator.cc \ debugallocator.cc \
fmatrixev.cc \ fmatrixev.cc \
dynmatrixev.cc \ dynmatrixev.cc \
ios_state.cc \ ios_state.cc \
parametertree.cc \ parametertree.cc \
parametertreeparser.cc \ parametertreeparser.cc \
...@@ -60,9 +60,9 @@ commoninclude_HEADERS = \ ...@@ -60,9 +60,9 @@ commoninclude_HEADERS = \
iteratorfacades.hh \ iteratorfacades.hh \
lcm.hh \ lcm.hh \
lru.hh \ lru.hh \
mallocallocator.hh \ mallocallocator.hh \
math.hh \ math.hh \
matvectraits.hh \ matvectraits.hh \
misc.hh \ misc.hh \
mpicollectivecommunication.hh \ mpicollectivecommunication.hh \
mpiguard.hh \ mpiguard.hh \
......
...@@ -39,7 +39,7 @@ namespace Dune { ...@@ -39,7 +39,7 @@ namespace Dune {
/** /**
@brief LRU Cache Container @brief LRU Cache Container
Implementatation of an LRU (least recently used) cache Implementation of an LRU (least recently used) cache
container. This implementation follows the approach presented in container. This implementation follows the approach presented in
http://aim.adc.rmit.edu.au/phd/sgreuter/papers/graphite2003.pdf http://aim.adc.rmit.edu.au/phd/sgreuter/papers/graphite2003.pdf
*/ */
...@@ -175,26 +175,26 @@ namespace Dune { ...@@ -175,26 +175,26 @@ namespace Dune {
} }
/** /**
* @brief mark data associateed with key as most recent * @brief mark data associated with key as most recent
* *
* @return reference of stored data * @return reference of stored data
*/ */
reference touch (const key_type & key) reference touch (const key_type & key)
{ {
/* query _index for iterator */ /* query _index for iterator */
iterator it = _index[key]; map_iterator it = _index.find(key);
if (it == _index.end()) if (it == _index.end())
DUNE_THROW(Dune::RangeError, DUNE_THROW(Dune::RangeError,
"Failed to touch key " << key << ", it is not in the lru container"); "Failed to touch key " << key << ", it is not in the lru container");
/* update _data /* update _data
move it to the front move it to the front
*/ */
_data.splice(_data.begin(), _data, it); _data.splice(_data.begin(), _data, it->second);
return it->second; return it->second->second;
} }
/** /**
* @brief retief number of entries in the container * @brief Retrieve number of entries in the container
*/ */
size_type size() const size_type size() const
{ {
...@@ -203,6 +203,7 @@ namespace Dune { ...@@ -203,6 +203,7 @@ namespace Dune {
/** /**
* @brief ensure a maximum size of the container * @brief ensure a maximum size of the container
*
* If new_size is smaller than size the oldest elements are * If new_size is smaller than size the oldest elements are
* dropped. Otherwise nothing happens. * dropped. Otherwise nothing happens.
*/ */
......
# Stuff from the build system
Makefile Makefile
Makefile.in Makefile.in
.deps .deps
.libs .libs
*.gcda
*.gcno
*.log
*.trs
gmon.out
semantic.cache semantic.cache
diagonalmatrixtest
dynvectortest # The test binaries (in alphabetical order)
fvectortest
mpicollectivecommunication
lrutest
arraylisttest arraylisttest
shared_ptrtest arraytest
testfloatcmp bigunsignedinttest
bitsetvectortest bitsetvectortest
iteratorfacadetest blockbitfieldtest
sllisttest check_fvector_size
tuplestest conversiontest
tupleutilitytest diagonalmatrixtest
dynmatrixtest
dynvectortest
eigenvaluestest
enumsettest enumsettest
fassigntest
fmatrixtest fmatrixtest
dynmatrixtest fvectortest
poolallocatortest
*.gcda
*.gcno
gmon.out
gcdlcmtest gcdlcmtest
streamtest iteratorfacadetest
exprtmpl iteratorfacadetest2
timing_xpr lrutest
timing_old mpicollectivecommunication
timing_flt
bigunsignedinttest
mpiguardtest mpiguardtest
mpihelpertest mpihelpertest
mpihelpertest2
nullptr-test
parametertreetest
pathtest
poolallocatortest
shared_ptrtest
singletontest singletontest
utilitytest shared_ptrtest_config
shared_ptrtest_dune
sllisttest
static_assert_test
streamtest
testdebugallocator
testdebugallocator_fail1
testdebugallocator_fail2
testdebugallocator_fail3
testdebugallocator_fail4
testdebugallocator_fail5
testfassign_fail1 testfassign_fail1
testfassign_fail2 testfassign_fail2
testfassign_fail3 testfassign_fail3
...@@ -44,31 +61,19 @@ testfassign1 ...@@ -44,31 +61,19 @@ testfassign1
testfassign2 testfassign2
testfassign3 testfassign3
testfassign4 testfassign4
conversiontest testfloatcmp
nullptr-test
blockbitfieldtest
fassigntest
iteratorfacadetest2
static_assert_test
parametertreetest
tags
pathtest
TAGS
mpihelpertest2
testfconstruct testfconstruct
arraytest timing_xpr
shared_ptrtest_config timing_old
shared_ptrtest_dune timing_flt
tuplestest
tuplestest_dune tuplestest_dune
tuplestest_std tuplestest_std
tuplestest_tr1 tuplestest_tr1
check_fvector_size tupleutilitytest
testdebugallocator typetraitstest
testdebugallocator_fail1 utilitytest
testdebugallocator_fail2
testdebugallocator_fail3 tags
testdebugallocator_fail4 TAGS
testdebugallocator_fail5
eigenvaluestest
*.log
*.trs
...@@ -55,6 +55,7 @@ TESTPROGS = \ ...@@ -55,6 +55,7 @@ TESTPROGS = \
tuplestest_std \ tuplestest_std \
tuplestest_tr1 \ tuplestest_tr1 \
tupleutilitytest \ tupleutilitytest \
typetraitstest \
utilitytest utilitytest
# which tests to run # which tests to run
...@@ -104,60 +105,27 @@ noinst_HEADERS = dummyiterator.hh iteratorfacadetest.hh ...@@ -104,60 +105,27 @@ noinst_HEADERS = dummyiterator.hh iteratorfacadetest.hh
testincludedir = $(includedir)/dune/common/test testincludedir = $(includedir)/dune/common/test
testinclude_HEADERS = checkmatrixinterface.hh iteratortest.hh testinclude_HEADERS = checkmatrixinterface.hh iteratortest.hh
# define the programs # define the programs (in alphabetical order)
pathtest_SOURCES = pathtest.cc
parametertreetest_SOURCES = parametertreetest.cc
bitsetvectortest_SOURCES = bitsetvectortest.cc
diagonalmatrixtest_SOURCES = diagonalmatrixtest.cc
nullptr_test_SOURCES = nullptr-test.cc nullptr-test2.cc
nullptr_test_fail_SOURCES = nullptr-test.cc
nullptr_test_fail_CPPFLAGS = $(AM_CPPFLAGS) -DFAIL
static_assert_test_SOURCES = static_assert_test.cc
static_assert_test_fail_SOURCES = static_assert_test_fail.cc
fassigntest_SOURCES = fassigntest.cc
bigunsignedinttest_SOURCES=bigunsignedinttest.cc
bigunsignedinttest_CPPFLAGS = $(AM_CPPFLAGS) $(BOOST_CPPFLAGS)
lrutest_SOURCES = lrutest.cc
sllisttest_SOURCES = sllisttest.cc
arraylisttest_SOURCES = arraylisttest.cc arraylisttest_SOURCES = arraylisttest.cc
arraytest_SOURCES = arraytest.cc arraytest_SOURCES = arraytest.cc
shared_ptrtest_config_SOURCES = shared_ptrtest.cc bigunsignedinttest_SOURCES=bigunsignedinttest.cc
bigunsignedinttest_CPPFLAGS = $(AM_CPPFLAGS) $(BOOST_CPPFLAGS)
shared_ptrtest_dune_SOURCES = shared_ptrtest.cc
shared_ptrtest_dune_CPPFLAGS = $(AM_CPPFLAGS) \
-DDISABLE_CONFIGURED_SHARED_PTR
tuplestest_dune_SOURCES = tuplestest.cc
tuplestest_dune_CPPFLAGS = $(AM_CPPFLAGS) \
-DDISABLE_TR1_TUPLE -DDISABLE_STD_TUPLE
tuplestest_std_SOURCES = tuplestest.cc bitsetvectortest_SOURCES = bitsetvectortest.cc
tuplestest_tr1_SOURCES = tuplestest.cc check_fvector_size_fail1_SOURCES = check_fvector_size_fail.cc
tuplestest_tr1_CPPFLAGS = $(AM_CPPFLAGS) \ check_fvector_size_fail1_CPPFLAGS = $(AM_CPPFLAGS) -DDIM=1
-DDISABLE_STD_TUPLE
tupleutilitytest_SOURCES = tupleutilitytest.cc check_fvector_size_fail2_SOURCES = check_fvector_size_fail.cc
check_fvector_size_fail2_CPPFLAGS = $(AM_CPPFLAGS) -DDIM=3
streamtest_SOURCES = streamtest.cc check_fvector_size_SOURCES = check_fvector_size.cc
# mention headers so that they are distributed too conversiontest_SOURCES = conversiontest.cc
iteratorfacadetest_SOURCES = iteratorfacadetest.cc iteratorfacadetest.hh \
iteratortest.hh
iteratorfacadetest2_SOURCES = iteratorfacadetest2.cc diagonalmatrixtest_SOURCES = diagonalmatrixtest.cc
dynmatrixtest_SOURCES = dynmatrixtest.cc dynmatrixtest_SOURCES = dynmatrixtest.cc
...@@ -166,24 +134,36 @@ dynvectortest_SOURCES = dynvectortest.cc ...@@ -166,24 +134,36 @@ dynvectortest_SOURCES = dynvectortest.cc
eigenvaluestest_SOURCES = eigenvaluestest.cc eigenvaluestest_SOURCES = eigenvaluestest.cc
eigenvaluestest_LDADD = $(LAPACK_LIBS) $(LDADD) $(BLAS_LIBS) $(LIBS) $(FLIBS) eigenvaluestest_LDADD = $(LAPACK_LIBS) $(LDADD) $(BLAS_LIBS) $(LIBS) $(FLIBS)
enumsettest_SOURCES = enumsettest.cc
fassigntest_SOURCES = fassigntest.cc
fmatrixtest_SOURCES = fmatrixtest.cc fmatrixtest_SOURCES = fmatrixtest.cc
fmatrixtest_LDADD = $(LAPACK_LIBS) $(LDADD) $(BLAS_LIBS) $(LIBS) $(FLIBS) fmatrixtest_LDADD = $(LAPACK_LIBS) $(LDADD) $(BLAS_LIBS) $(LIBS) $(FLIBS)
fvectortest_SOURCES = fvectortest.cc fvectortest_SOURCES = fvectortest.cc
check_fvector_size_fail1_SOURCES = check_fvector_size_fail.cc gcdlcmtest_SOURCES = gcdlcmtest.cc
check_fvector_size_fail1_CPPFLAGS = $(AM_CPPFLAGS) -DDIM=1
check_fvector_size_fail2_SOURCES = check_fvector_size_fail.cc genericiterator_compile_fail_SOURCES = genericiterator_compile_fail.cc
check_fvector_size_fail2_CPPFLAGS = $(AM_CPPFLAGS) -DDIM=3
check_fvector_size_SOURCES = check_fvector_size.cc # mention headers so that they are distributed too
iteratorfacadetest_SOURCES = iteratorfacadetest.cc iteratorfacadetest.hh \
iteratortest.hh
poolallocatortest_SOURCES = poolallocatortest.cc iteratorfacadetest2_SOURCES = iteratorfacadetest2.cc
enumsettest_SOURCES=enumsettest.cc lrutest_SOURCES = lrutest.cc
gcdlcmtest_SOURCES = gcdlcmtest.cc mpicollectivecommunication_SOURCES = mpicollectivecommunication.cc
mpicollectivecommunication_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS)
mpicollectivecommunication_LDADD = $(DUNEMPILIBS) $(LDADD)
mpicollectivecommunication_LDFLAGS = $(AM_LDFLAGS) $(DUNEMPILDFLAGS)
mpiguardtest_SOURCES = mpiguardtest.cc
mpiguardtest_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS)
mpiguardtest_LDADD = $(DUNEMPILIBS) $(LDADD)
mpiguardtest_LDFLAGS = $(AM_LDFLAGS) $(DUNEMPILDFLAGS)
mpihelpertest_SOURCES = mpihelpertest.cc mpihelpertest_SOURCES = mpihelpertest.cc
mpihelpertest_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS) mpihelpertest_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS)
...@@ -195,19 +175,32 @@ mpihelpertest2_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS) -DMPIHELPER_PREINITI ...@@ -195,19 +175,32 @@ mpihelpertest2_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS) -DMPIHELPER_PREINITI
mpihelpertest2_LDADD = $(DUNEMPILIBS) $(LDADD) mpihelpertest2_LDADD = $(DUNEMPILIBS) $(LDADD)
mpihelpertest2_LDFLAGS = $(AM_LDFLAGS) $(DUNEMPILDFLAGS) mpihelpertest2_LDFLAGS = $(AM_LDFLAGS) $(DUNEMPILDFLAGS)
mpicollectivecommunication_SOURCES = mpicollectivecommunication.cc nullptr_test_SOURCES = nullptr-test.cc nullptr-test2.cc
mpicollectivecommunication_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS) nullptr_test_fail_SOURCES = nullptr-test.cc
mpicollectivecommunication_LDADD = $(DUNEMPILIBS) $(LDADD) nullptr_test_fail_CPPFLAGS = $(AM_CPPFLAGS) -DFAIL
mpicollectivecommunication_LDFLAGS = $(AM_LDFLAGS) $(DUNEMPILDFLAGS)
mpiguardtest_SOURCES = mpiguardtest.cc parametertreetest_SOURCES = parametertreetest.cc
mpiguardtest_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS)
mpiguardtest_LDADD = $(DUNEMPILIBS) $(LDADD) pathtest_SOURCES = pathtest.cc
mpiguardtest_LDFLAGS = $(AM_LDFLAGS) $(DUNEMPILDFLAGS)
poolallocatortest_SOURCES = poolallocatortest.cc
shared_ptrtest_config_SOURCES = shared_ptrtest.cc
shared_ptrtest_dune_SOURCES = shared_ptrtest.cc
shared_ptrtest_dune_CPPFLAGS = $(AM_CPPFLAGS) \
-DDISABLE_CONFIGURED_SHARED_PTR
singletontest_SOURCES = singletontest.cc singletontest_SOURCES = singletontest.cc
utilitytest_SOURCES = utilitytest.cc sllisttest_SOURCES = sllisttest.cc
sourcescheck_NOSOURCES = timing.cc
static_assert_test_SOURCES = static_assert_test.cc
static_assert_test_fail_SOURCES = static_assert_test_fail.cc
streamtest_SOURCES = streamtest.cc
testdebugallocator_SOURCES = testdebugallocator.cc testdebugallocator_SOURCES = testdebugallocator.cc
testdebugallocator_CPPFLAGS = $(AM_CPPFLAGS) testdebugallocator_CPPFLAGS = $(AM_CPPFLAGS)
...@@ -266,13 +259,25 @@ testfconstruct_fail1_CPPFLAGS = $(AM_CPPFLAGS) -DFVSIZE=2 ...@@ -266,13 +259,25 @@ testfconstruct_fail1_CPPFLAGS = $(AM_CPPFLAGS) -DFVSIZE=2
testfconstruct_fail2_SOURCES = testfconstruct.cc testfconstruct_fail2_SOURCES = testfconstruct.cc
testfconstruct_fail2_CPPFLAGS = $(AM_CPPFLAGS) -DFVSIZE=5 testfconstruct_fail2_CPPFLAGS = $(AM_CPPFLAGS) -DFVSIZE=5
conversiontest_SOURCES = conversiontest.cc testfloatcmp_SOURCES = testfloatcmp.cc
sourcescheck_NOSOURCES = exprtmpl.cc timing.cc tuplestest_dune_SOURCES = tuplestest.cc
tuplestest_dune_CPPFLAGS = $(AM_CPPFLAGS) \
-DDISABLE_TR1_TUPLE -DDISABLE_STD_TUPLE
tuplestest_std_SOURCES = tuplestest.cc
tuplestest_tr1_SOURCES = tuplestest.cc
tuplestest_tr1_CPPFLAGS = $(AM_CPPFLAGS) \
-DDISABLE_STD_TUPLE
tupleutilitytest_SOURCES = tupleutilitytest.cc
typetraitstest_SOURCES = typetraitstest.cc
utilitytest_SOURCES = utilitytest.cc
testfloatcmp_SOURCES = testfloatcmp.cc
genericiterator_compile_fail_SOURCES = genericiterator_compile_fail.cc
include $(top_srcdir)/am/global-rules include $(top_srcdir)/am/global-rules
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2: // vi: set et ts=4 sw=2 sts=2:
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <iostream> #include <iostream>
#include <dune/common/typetraits.hh> #include <dune/common/typetraits.hh>
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2: // vi: set et ts=4 sw=2 sts=2:
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
//============================================================================== //==============================================================================
//! //!
//! \file shapefunctions.hpp
//!
//! \date Nov 9 2011 //! \date Nov 9 2011
//! //!
//! \author Arne Morten Kvarving / SINTEF //! \author Arne Morten Kvarving / SINTEF
//! //!
//! \brief Classes for shape functions. Loosely based on code in dune-grid-howto
//!
//============================================================================== //==============================================================================
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
/*
TODO:
- test deeper Matrix nesting
- get rid of
int *M;
- fix RowBlock::N()
- remove second template parameter of FlatColIterator
- vectorentry -> exrpressionentry
- FlatColIterator<Matrix> does not work if Matrix is mutable
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <iostream>
#include <fstream>
#include <dune/common/fvector.hh>
#include <dune/common/timer.hh>
//#include <dune/istl/bvector.hh>
//#include <dune/istl/io.hh>
#include <dune/common/iteratorfacades.hh>
Indent INDENT;
void test_fvector()
{
typedef Dune::FieldVector<double,2> VB;
VB v1(1);
VB v2(2);
typedef Dune::ExprTmpl::ConstRef<VB> RVB;
VB v = 0.5 * (v1 + v2 * 2) + 3 * v1 - v2;
std::cout << " 0.5 * ( " << v1 << " + " << v2 << " * 2) + 3 * " << v1 << " - " << v2 << std::endl;
}
void test_blockvector()
{
Dune::FieldVector<double,2> v(10);
typedef Dune::FieldVector<double,2> VB;
typedef Dune::BlockVector<VB> BV;
const int sz = 3;
BV bv1(sz), bv2(sz);
bv1 = 1;
bv2 = 0;
bv2[1][0]=1;
bv2[1][1]=2;
BV bv(sz);
bv = -17;
printvector (std::cout, bv, "bv", "r");
// bv.emptyClone(bv1);
std::cout << "Assingn from ConstRef\n";
bv = 2 * (bv1 + bv2);
bv -= 1;
printvector (std::cout, bv1, "bv1", "r");
printvector (std::cout, bv2, "bv2", "r");
printvector (std::cout, bv, "bv", "r");
}
void test_blockblockvector()
{
const int bs = 2;
const int sz = 3;
typedef Dune::FieldVector<double,bs> VB;
typedef Dune::BlockVector<VB> BV;
typedef Dune::BlockVector<BV> BBV;
typedef Dune::ExprTmpl::ConstRef<BV> RBV;
BV bv1(sz), bv2(sz);
bv1 = 1;
bv2 = 0;
bv2[1][0]=1;
bv2[1][1]=2;
Dune::ExprTmpl::ConstRef<BV> rbv1(bv1);
Dune::ExprTmpl::ConstRef<BV> rbv2(bv2);
BBV bbv(2);
bbv[0].resize(bv1.N());
bbv[0] = Dune::ExprTmpl::Expression<RBV>(rbv1);
bbv[1].resize(bv2.N());
bbv[1] = Dune::ExprTmpl::Expression<RBV>(rbv2);
Dune::Timer stopwatch;
stopwatch.reset();
for (int i=0; i<10; i++) bbv *= 2;
std::cout << "Time bbv*2: " << stopwatch.elapsed() << std::endl;
#ifndef NOPRINT
// Dune::FlatIterator<BBV> fit(bbv.begin());
// Dune::FlatIterator<BBV> fend(bbv.end());
// int index = 0;
// for(;fit!=fend;++fit)
// {
// BBV::field_type x;
// x = *fit;
// std::cout << index << "\t" << x << std::endl;
// index++;
// }
printvector (std::cout, bv1, "bv1", "r");
printvector (std::cout, bv2, "bv1", "r");
printvector (std::cout, bbv, "bbv", "r");
#endif
std::cout << "infinity_norm(bbv)=" << infinity_norm(bbv) << std::endl;
std::cout << "two_norm(bbv)=" << two_norm(bbv) << std::endl;
std::cout << "bbv.two_norm()=" << bbv.two_norm() << std::endl;
std::cout << "two_norm2(bbv)=" << two_norm2(bbv) << std::endl;
std::cout << "one_norm(bbv)=" << one_norm(bbv) << std::endl;
}
// namespace Dune {
// namespace ExprTmpl {
// template <class K, int iN, int iM>
// class MatrixMulVector< FieldMatrix<K,iN,iM>,
// BCRSMatrix< FieldMatrix<K,iN,iM> >,
// BlockVector< FieldVector<K,iM> > >
// {
// public:
// typedef BCRSMatrix< FieldMatrix<K,iN,iM> > Mat;
// typedef BlockVector< FieldVector<K,iM> > Vec;
// typedef typename
// BlockTypeN<MatrixMulVector<Mat,Mat,Vec>,
// MyDepth<FieldMatrix<K,iN,iM>,Mat>::value-1>::type
// ParentBlockType;
// /* constructor */
// MatrixMulVector(const Mat & _A, const Vec & _v, int* _DUNE_TEST_M,
// const ParentBlockType & _parent) :
// parent(_parent), M(_DUNE_TEST_M), A(_A), v(_v )
// {
// int parent_i = M[0];
// typename Mat::ConstColIterator it = A[parent_i].begin();
// typename Mat::ConstColIterator end = A[parent_i].end();
// tmp = 0;
// for (; it!=end; ++it)
// {
// it->umv(tmp,v[it.index()]);
// }
// };
// K operator[] (int i) const {
// return tmp[i];
// }
// int N() const { iN; };
// const ParentBlockType & parent;
// private:
// FieldVector<K,iN> tmp;
// mutable int* M;
// const Mat & A;
// const Vec & v;
// };
// } // NS ExpreTmpl
// } // NS Dune
//template<int BlockSize, int N, int M>
template<int BN, int BM, int N, int M>
void test_matrix()
{
std::cout << "test_matrix<" << BN << ", " << BM << ", "
<< N << ", " << M << ">\n";
typedef double matvec_t;
typedef Dune::FieldVector<matvec_t,BN> LVB;
typedef Dune::FieldVector<matvec_t,BM> VB;
typedef Dune::FieldMatrix<matvec_t,BN,BM> MB;
typedef Dune::BlockVector<LVB> LeftVector;
typedef Dune::BlockVector<VB> Vector;
typedef Dune::BCRSMatrix<MB> Matrix;
LVB a(0);
VB b(2);
MB _DUNE_TEST_M(1);
_DUNE_TEST_M[1][1] = 3;
// a += M * b
_DUNE_TEST_M.umv(b,a);
#ifndef NOPRINT
printmatrix (std::cout, _DUNE_TEST_M, "Matrix", "r");
printvector (std::cout, a, "Vector", "r");
#endif
// a = M * b
#if 0
a = _DUNE_TEST_M*b;
#endif
#ifndef NOPRINT
printvector (std::cout, a, "Vector", "r");
#endif
Matrix A(N,M,Matrix::row_wise);
typename Matrix::CreateIterator i=A.createbegin();
typename Matrix::CreateIterator end=A.createend();
std::cout << "Building matrix structure\n";
// build up the matrix structure
int c=0;
for (; i!=end; ++i)
{
// insert a non zero entry for myself
i.insert(c);
// insert index M-1
i.insert(M-1);
c++;
}
std::cout << "...done\n";
#ifndef NOPRINT
std::cout << "Matrix coldim=" << A.coldim() << std::endl;
std::cout << "Matrix rowdim=" << A.rowdim() << std::endl;
std::cout << "Matrix N=" << A.M() << std::endl;
std::cout << "Matrix M=" << A.N() << std::endl;
std::cout << "Assembling matrix\n";
typename Matrix::Iterator rit=A.begin();
typename Matrix::Iterator rend=A.end();
for (; rit!=rend; ++rit)
{
typename Matrix::ColIterator cit=rit->begin();
typename Matrix::ColIterator cend=rit->end();
for (; cit!=cend; ++cit)
{
// *rit = rit.index();
*cit = 10*cit.index()+rit.index();
}
}
std::cout << "...done\n";
printmatrix (std::cout, A, "Matrix", "r");
#endif
LeftVector v(N);
LeftVector v2(N);
v = 0;
Vector x(M);
x = 1;
Dune::FlatIterator<Vector> fit = x.begin();
Dune::FlatIterator<Vector> fend = x.end();
c = 0;
for (; fit!=fend; ++fit)
*fit=c++;
Dune::Timer stopwatch;
stopwatch.reset();
A.umv(x,v);
std::cout << "Time umv: " << stopwatch.elapsed() << std::endl;
using namespace Dune;
#ifndef NOPRINT
printvector (std::cout, x, "Vector X", "r");
printvector (std::cout, v, "Vector", "r");
#endif
v2 = 0;
stopwatch.reset();
v2 += A * x;
std::cout << "Time v2+=A*x: " << stopwatch.elapsed() << std::endl;
#ifndef NOPRINT
printvector (std::cout, v2, "Vector2", "r");
#endif
#ifndef NOPRINT
// int rowIndex[]={1};
// FlatColIterator<const Matrix> it(A[2].begin(),rowIndex);
// for (int i=0; i<5; i++)
// {
// std::cout << *it << " ";
// ++it;
// }
// std::cout << std::endl;
#endif
std::cout << std::endl;
}
void test_norm()
{
Dune::FieldVector<double,3> a,b;
double c;
c = (a-b).two_norm();
c = two_norm(a-b);
}
void test_sproduct()
{
Dune::FieldVector<double,2> v(10);
typedef Dune::FieldVector<double,2> VB;
typedef Dune::BlockVector<VB> BV;
const int sz = 3;
BV bv1(sz), bv2(sz);
bv1 = 1;
bv2 = 0;
bv2[1][0]=1;
bv2[1][1]=2;
double x;
x = bv1[0] * bv2[0];
x = bv1 * bv2;
}
int main()
{
// Dune::dvverb.attach(std::cout);
try
{
// test_fvector();
// test_blockvector();
test_norm();
test_sproduct();
test_blockblockvector();
test_matrix<2,3,3,4>();
#ifdef NOPRINT
test_matrix<3,6,400000,500000>();
test_matrix<6,3,400000,500000>();
test_matrix<30,60,4000,5000>();
test_matrix<150,150,500,4000>();
test_matrix<150,150,1000,2000>();
#endif
// test_matrix<150,150,2000,1000>(); // fails in fmeta_something
// test_matrix<150,150,4000,500>(); // fails in fmeta_something
}
catch (Dune::Exception & e)
{
std::cout << e << std::endl;
}
return (0);
}
...@@ -99,7 +99,7 @@ struct DivisorAccumulator ...@@ -99,7 +99,7 @@ struct DivisorAccumulator
typedef typename Data::second_type OldTuple; typedef typename Data::second_type OldTuple;
typedef typename Dune::PushBackTuple<OldTuple, PotentialDivisor>::type ExtendedTuple; typedef typename Dune::PushBackTuple<OldTuple, PotentialDivisor>::type ExtendedTuple;
typedef typename Dune::SelectType<isDivisor, ExtendedTuple, OldTuple>::Type NewTuple; typedef typename Dune::conditional<isDivisor, ExtendedTuple, OldTuple>::type NewTuple;
typedef typename std::pair<typename Data::first_type, NewTuple> type; typedef typename std::pair<typename Data::first_type, NewTuple> type;
}; };
...@@ -123,7 +123,7 @@ struct PrimeAccumulator ...@@ -123,7 +123,7 @@ struct PrimeAccumulator
{ {
enum {isPrime = (Divisors<N::value>::value==2)}; enum {isPrime = (Divisors<N::value>::value==2)};
typedef typename Dune::SelectType<isPrime, typename Dune::PushBackTuple<Data, N>::type, Data>::Type type; typedef typename Dune::conditional<isPrime, typename Dune::PushBackTuple<Data, N>::type, Data>::type type;
}; };
// Construct list primes // Construct list primes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment