Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • iwr/amdis
  • backofen/amdis
  • aland/amdis
3 results
Show changes
Commits on Source (22)
Showing
with 225 additions and 154 deletions
......@@ -17,8 +17,6 @@ build:9-debug-gcc:
- install/
name: "$CI_BUILD_NAME"
expire_in: 6 hrs
only:
- master
build:9-release-gcc:
stage: build
......@@ -29,8 +27,6 @@ build:9-release-gcc:
- install/
name: "$CI_BUILD_NAME"
expire_in: 6 hrs
only:
- master
build:9-parallel-debug-gcc:
stage: build
......@@ -41,8 +37,6 @@ build:9-parallel-debug-gcc:
- install/
name: "$CI_BUILD_NAME"
expire_in: 6 hrs
only:
- master
build:9-parallel-release-gcc:
stage: build
......@@ -53,8 +47,6 @@ build:9-parallel-release-gcc:
- install/
name: "$CI_BUILD_NAME"
expire_in: 6 hrs
only:
- master
# compile the demos
......@@ -64,8 +56,6 @@ demo:9-debug-gcc:
- tools/build_amdis.sh --stage demo --config Debug
dependencies:
- build:9-debug-gcc
only:
- master
demo:9-release-gcc:
stage: demo
......@@ -73,8 +63,6 @@ demo:9-release-gcc:
- tools/build_amdis.sh --stage demo --config Release
dependencies:
- build:9-release-gcc
only:
- master
demo:9-parallel-debug-gcc:
stage: demo
......@@ -82,8 +70,6 @@ demo:9-parallel-debug-gcc:
- tools/build_amdis.sh --stage demo --config Debug --parallel
dependencies:
- build:9-parallel-debug-gcc
only:
- master
demo:9-parallel-release-gcc:
stage: demo
......@@ -91,8 +77,6 @@ demo:9-parallel-release-gcc:
- tools/build_amdis.sh --stage demo --config Release --parallel
dependencies:
- build:9-parallel-release-gcc
only:
- master
# compiel and run the tests
......@@ -102,8 +86,6 @@ test:9-debug-gcc:
- tools/build_amdis.sh --stage test --config Debug
dependencies:
- build:9-debug-gcc
only:
- master
test:9-release-gcc:
stage: test
......@@ -111,8 +93,6 @@ test:9-release-gcc:
- tools/build_amdis.sh --stage test --config Release
dependencies:
- build:9-release-gcc
only:
- master
test:9-parallel-debug-gcc:
stage: test
......@@ -120,8 +100,6 @@ test:9-parallel-debug-gcc:
- tools/build_amdis.sh --stage test --config Debug --parallel
dependencies:
- build:9-parallel-debug-gcc
only:
- master
test:9-parallel-release-gcc:
stage: test
......@@ -129,5 +107,3 @@ test:9-parallel-release-gcc:
- tools/build_amdis.sh --stage test --config Release --parallel
dependencies:
- build:9-parallel-release-gcc
only:
- master
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
project(AMDiS)
set(AMDiS_VERSION "1.1.0")
set(AMDiS_VERSION "1.2.0")
set(BASE_DIR ${AMDiS_SOURCE_DIR})
set(SOURCE_DIR ${BASE_DIR}/src)
......@@ -69,7 +69,7 @@ endif (MSVC)
# parallel of sequential version
if (ENABLE_PARALLEL_DOMAIN)
set(ENABLE_MPI CACHE BOOL "Compile with MPI compiler and library" FORCE)
set(ENABLE_MPI 1 CACHE BOOL "Compile with MPI compiler and library" FORCE)
set(POSTFIX "-p")
else ()
set(POSTFIX "-s")
......
......@@ -182,6 +182,11 @@ list(APPEND AMDIS_SRC
${SOURCE_DIR}/ProblemStatDbg.cc
)
if (ENABLE_MPI)
enable_mpi(COMPILEFLAGS AMDIS_INCLUDE_DIRS _)
list(APPEND COMPILEFLAGS "-DHAVE_MPI=1")
endif (ENABLE_MPI)
include(amdis_parallel)
include(muparser)
......
......@@ -20,7 +20,6 @@ if (ENABLE_PARALLEL_DOMAIN)
list(APPEND COMPILEFLAGS "-DHAVE_PARALLEL_DOMAIN_AMDIS=1")
enable_mpi(COMPILEFLAGS AMDIS_INCLUDE_DIRS _)
enable_petsc(COMPILEFLAGS AMDIS_INCLUDE_DIRS _)
# add support for the zoltan library
......
......@@ -78,8 +78,7 @@ target_enable_boost(amdis_base INTERFACE ON)
# --------------------
if (AMDIS_NEED_UMFPACK)
set(AMDIS_SuiteSparse_DIR @SuiteSparse_DIR@)
set(AMDIS_UMFPACK_INCLUDE_DIR @UMFPACK_INCLUDE_DIRS@)
set(AMDIS_UMFPACK_LIB_DIR ${AMDIS_UMFPACK_INCLUDE_DIR}/../include)
set(AMDIS_UMFPACK_ROOT_DIR @UMFPACK_ROOT_DIR@)
target_enable_umfpack(amdis_base INTERFACE ON)
endif (AMDIS_NEED_UMFPACK)
......
......@@ -22,7 +22,6 @@ if (ENABLE_PARALLEL_DOMAIN)
target_compile_definitions(amdis_parallel INTERFACE
HAVE_PARALLEL_DOMAIN_AMDIS=1)
target_enable_mpi(amdis_parallel INTERFACE)
target_enable_petsc(amdis_parallel INTERFACE)
# add support for the zoltan library
......
......@@ -19,7 +19,7 @@ macro(target_enable_bddcml _TARGET_ _SCOPE_)
message(FATAL_ERROR "Could not find BDDCML headers.")
endif()
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
find_library(BDDCML_LIB bddcml
HINTS ENV LIBRARY_PATH
DOC "BDDCML library")
......@@ -29,7 +29,7 @@ macro(target_enable_bddcml _TARGET_ _SCOPE_)
else()
message(FATAL_ERROR "Could not find the BDDCML library")
endif()
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
target_compile_definitions(${_TARGET_} ${_SCOPE_} HAVE_BDDCML=1)
endmacro(target_enable_bddcml)
......@@ -28,9 +28,9 @@ macro(target_enable_boost _TARGET_ _SCOPE_)
find_package(Boost ${BOOST_VERSION} REQUIRED ${BOOST_LIBS_REQUIRED})
target_include_directories(${_TARGET_} ${_SCOPE_} ${Boost_INCLUDE_DIR})
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
target_link_libraries(${_TARGET_} ${_SCOPE_} ${Boost_LIBRARIES})
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
if (MSVC_SHARED_LIBS AND LINK_EXECUTABLE)
link_directories(${Boost_LIBRARY_DIRS})
......
......@@ -21,7 +21,7 @@ macro(target_enable_hypre _TARGET_ _SCOPE_)
target_include_directories(${_TARGET_} ${_SCOPE_} ${HYPRE_INCLUDE_DIRECTORIES})
endif (_HYPRE_H)
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
find_library(_HYPRE_LIB HYPRE
HINTS ${PETSC_LIBRARY_DIRS})
......@@ -41,10 +41,10 @@ macro(target_enable_hypre _TARGET_ _SCOPE_)
find_package(LAPACK REQUIRED)
endif (LAPACK_LIB)
target_link_libraries(${_TARGET_} ${_SCOPE_} ${LAPACK_LIBRARIES})
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
if (_HYPRE_H AND (NOT LINK_EXECUTABLE OR _HYPRE_LIB))
if (_HYPRE_H AND (NOT LINK_EXECUTABLE OR _HYPRE_LIB OR APPLE))
set(HAVE_HYPRE ON)
target_compile_definitions(${_TARGET_} ${_SCOPE_} MTL_HAS_HYPRE)
else ()
......
......@@ -13,7 +13,7 @@ macro(target_enable_mpi _TARGET_ _SCOPE_)
target_compile_options(${_TARGET_} ${_SCOPE_}
${MPI_CXX_COMPILE_FLAGS})
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
# the parameter --enable-new-dtags causes a linker problem, i.e. some libraries are
# linked without an rpath (or any other path information) and can not be found while
# running the executable. The hack below removes this flag manually from the linker flags.
......@@ -21,7 +21,7 @@ macro(target_enable_mpi _TARGET_ _SCOPE_)
string(STRIP "${MY_MPI_CXX_LINK_FLAGS}" MY_MPI_CXX_LINK_FLAGS)
target_link_libraries(${_TARGET_} ${_SCOPE_} ${MPI_CXX_LIBRARIES} ${MY_MPI_CXX_LINK_FLAGS})
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
endmacro(target_enable_mpi)
macro(target_enable_petsc _TARGET_ _SCOPE_)
......@@ -39,7 +39,8 @@ macro(target_enable_petsc _TARGET_ _SCOPE_)
$ENV{PETSC_ROOT}/lib/pkgconfig
/usr/lib/petsc/lib/pkgconfig
/usr/lib/petsc/linux-gnu-cxx-opt/lib/pkgconfig
/usr/lib/petsc/linux-gnu-c-opt/lib/pkgconfig)
/usr/lib/petsc/linux-gnu-c-opt/lib/pkgconfig
PATHS $ENV{PKG_CONFIG_PATH})
if (PETSC_PKG_CONFIG)
get_filename_component(PETSC_PKG_CONFIG_PATH "${PETSC_PKG_CONFIG}" PATH CACHE)
set(ENV{PKG_CONFIG_PATH} ${PETSC_PKG_CONFIG_PATH})
......@@ -74,7 +75,7 @@ macro(target_enable_petsc _TARGET_ _SCOPE_)
PETSC_VERSION=${PETSC_VERSION})
target_compile_options(${_TARGET_} ${_SCOPE_} ${PETSC_DEFINITIONS})
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
set(PETSC_LINK_LIBRARIES "")
foreach (_PETSC_LIB ${PETSC_LIBRARIES})
find_library(_PETSC_LINK_LIB ${_PETSC_LIB} PATHS ${PETSC_LIBRARY_DIRS} NO_DEFAULT_PATH)
......@@ -82,7 +83,7 @@ macro(target_enable_petsc _TARGET_ _SCOPE_)
endforeach()
message(STATUS " Found PETSc library ${PETSC_LINK_LIBRARIES}")
target_link_libraries(${_TARGET_} ${_SCOPE_} ${PETSC_LINK_LIBRARIES})
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
# parmetis is required
......@@ -104,7 +105,7 @@ macro(target_enable_petsc _TARGET_ _SCOPE_)
message(FATAL_ERROR "Could not find ParMetis header file 'parmetis.h'!")
endif (PARMETIS_HEADER_FILE)
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
find_library(PARMETIS_LIB parmetis
HINTS ${PARMETIS_DIR}/lib ${PETSC_LIBRARY_DIRS})
if (NOT PARMETIS_LIB)
......@@ -112,7 +113,7 @@ macro(target_enable_petsc _TARGET_ _SCOPE_)
endif (NOT PARMETIS_LIB)
message(STATUS " Found ParMetis library ${PARMETIS_LIB}")
target_link_libraries(${_TARGET_} ${_SCOPE_} ${PARMETIS_LIB})
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
# metis is required
......@@ -125,7 +126,7 @@ macro(target_enable_petsc _TARGET_ _SCOPE_)
message(FATAL_ERROR "Could not find Metis header file 'metis.h'!")
endif (METIS_HEADER_FILE)
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
find_library(METIS_LIB metis
HINTS ${METIS_DIR}/lib ${PETSC_LIBRARY_DIRS})
if (NOT METIS_LIB)
......@@ -133,11 +134,11 @@ macro(target_enable_petsc _TARGET_ _SCOPE_)
endif (NOT METIS_LIB)
message(STATUS " Found Metis library ${METIS_LIB}")
target_link_libraries(${_TARGET_} ${_SCOPE_} ${METIS_LIB})
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
# blas library is required
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
find_library(BLAS_LIB
NAMES blas fblas openblas
HINTS ${BLAS_DIR}/lib ${PETSC_LIBRARY_DIRS} /usr/lib/openblas-base /usr/lib/atlas-base)
......@@ -147,11 +148,11 @@ macro(target_enable_petsc _TARGET_ _SCOPE_)
find_package(BLAS REQUIRED)
endif (BLAS_LIB)
target_link_libraries(${_TARGET_} ${_SCOPE_} ${BLAS_LIBRARIES})
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
# lapack library is required
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
find_library(LAPACK_LIB
NAMES lapack flapack
HINTS ${LAPACK_DIR}/lib ${PETSC_LIBRARY_DIRS} ${PETSC_DIR}/lib)
......@@ -161,5 +162,5 @@ macro(target_enable_petsc _TARGET_ _SCOPE_)
find_package(LAPACK REQUIRED)
endif (LAPACK_LIB)
target_link_libraries(${_TARGET_} ${_SCOPE_} ${LAPACK_LIBRARIES})
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
endmacro(target_enable_petsc)
......@@ -25,7 +25,7 @@ macro(target_enable_png _TARGET_ _SCOPE_)
get_filename_component(PNG_PATH ${_PNG_H} PATH)
target_include_directories(${_TARGET_} ${_SCOPE_} ${PNG_PATH})
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
find_library(_PNG_LIB png
HINTS ENV LIBRARY_PATH
DOC "The PNG library")
......@@ -34,7 +34,7 @@ macro(target_enable_png _TARGET_ _SCOPE_)
else()
message(FATAL_ERROR "Could not find the PNG library")
endif()
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
target_compile_definitions(${_TARGET_} ${_SCOPE_} HAVE_PNG=1)
endmacro(target_enable_png)
......@@ -18,19 +18,22 @@ macro(target_enable_umfpack _TARGET_ _SCOPE_)
if (SuiteSparse_FOUND)
message(STATUS "Found SuiteSparse CMake-library")
include(${USE_SuiteSparse})
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
target_link_libraries(${_TARGET_} ${_SCOPE_} ${SuiteSparse_LIBRARIES})
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
target_include_directories(${_TARGET_} ${_SCOPE_} ${SuiteSparse_INCLUDE_DIR} ${SuiteSparse_METIS_INCLUDE_DIR})
set(FOUND_SUITESPARSE_LIBS ${SuiteSparse_LIBRARIES})
else (SuiteSparse_FOUND)
# find umfpack manually by searching for umfpack.h header file
find_library(UMFPACK_LIBRARY umfpack
HINTS ${AMDIS_UMFPACK_LIB_DIR} ${SUITESPARSE_LIB} $ENV{SUITESPARSE_LIB}
DOC "Library file for UMFPACK")
HINTS ${AMDIS_UMFPACK_ROOT_DIR}
PATHS $ENV{EBROOTSUITESPARSE}
PATH_SUFFIXES lib/ lib64/
DOC "Library file for UMFPACK")
find_file(UMFPACK_H umfpack.h
HINTS ${AMDIS_UMFPACK_INCLUDE_DIR} ${SUITESPARSE_INC} $ENV{SUITESPARSE_INC} ENV CPATH /usr/include /usr/include/suitesparse /usr/include/ufsparse
DOC "Headerfile umfpack.h for UMFPACK")
HINTS ${AMDIS_UMFPACK_ROOT_DIR}/include
PATHS /usr/include/suitesparse /usr/include/ufsparse $ENV{EBROOTSUITESPARSE}/include
DOC "Headerfile umfpack.h for UMFPACK")
if (UMFPACK_H AND UMFPACK_LIBRARY)
get_filename_component(UMFPACK_PATH ${UMFPACK_H} PATH)
......@@ -39,7 +42,13 @@ macro(target_enable_umfpack _TARGET_ _SCOPE_)
get_filename_component(UMFPACK_LIB_PATH ${UMFPACK_LIBRARY} PATH)
set(FOUND_SUITESPARSE_LIBS ${UMFPACK_LIBRARY})
if (LINK_EXECUTABLE)
# extract root directory from umfpack lib dir
set (UMFPACK_ROOT_DIR ${UMFPACK_LIB_PATH}/..)
if (NOT EXISTS ${UMFPACK_ROOT_DIR}/include)
message(WARNING "directory ${UMFPACK_ROOT_DIR} is not a valid root dir of an umfpack installation.")
endif ()
if (LINK_EXECUTABLE OR APPLE)
# find all connected libraries
find_library(AMD_LIBRARY amd HINTS ${UMFPACK_LIB_PATH})
......@@ -70,15 +79,20 @@ macro(target_enable_umfpack _TARGET_ _SCOPE_)
endif (SUITESPARSECONFIG_LIBRARY)
target_link_libraries(${_TARGET_} ${_SCOPE_} ${FOUND_SUITESPARSE_LIBS})
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
else()
message(FATAL_ERROR "Could not find the UMFPACK header umfpack.h.")
if (NOT UMFPACK_H)
message(FATAL_ERROR "Could not find the UMFPACK header umfpack.h.")
endif ()
if (NOT UMFPACK_LIBRARY)
message(FATAL_ERROR "Could not find the UMFPACK library libumfpack.so")
endif ()
endif (UMFPACK_H AND UMFPACK_LIBRARY)
endif (SuiteSparse_FOUND)
# Check for clock_gettime in librt
if (NOT WIN32 AND LINK_EXECUTABLE)
if (NOT WIN32 AND (LINK_EXECUTABLE OR APPLE))
include(CheckLibraryExists)
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
if (HAVE_CLOCK_GETTIME)
......@@ -86,7 +100,7 @@ macro(target_enable_umfpack _TARGET_ _SCOPE_)
else ()
check_library_exists(c clock_gettime "" HAVE_CLOCK_GETTIME)
endif (HAVE_CLOCK_GETTIME)
endif (NOT WIN32 AND LINK_EXECUTABLE)
endif (NOT WIN32 AND (LINK_EXECUTABLE OR APPLE))
# collect informations about umfpack version and found libraries
......@@ -98,12 +112,12 @@ macro(target_enable_umfpack _TARGET_ _SCOPE_)
unset(_UMFPACK_H CACHE)
message(STATUS "UMFPACK version: ${UMFPACK_VERSION}")
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
message(STATUS "Found the following SuiteSparse libraries:")
foreach (lib ${FOUND_SUITESPARSE_LIBS})
message(STATUS " ${lib}")
endforeach ()
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
endif (FOUND_SUITESPARSE_LIBS)
target_compile_definitions(${_TARGET_} ${_SCOPE_}
......
......@@ -11,7 +11,7 @@ macro(target_enable_zoltan _TARGET_ _SCOPE_)
find_file(ZOLTAN_HEADER_FILE "zoltan.h" PATHS ${Zoltan_INCLUDE_DIRS})
target_include_directories(${_TARGET_} ${_SCOPE_} ${Zoltan_INCLUDE_DIRS})
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
foreach (LIB_NAME ${Zoltan_LIBRARIES})
find_library(_ZOLTAN_LIB ${LIB_NAME} HINTS ${Zoltan_LIBRARY_DIRS})
if (NOT _ZOLTAN_LIB)
......@@ -21,7 +21,7 @@ macro(target_enable_zoltan _TARGET_ _SCOPE_)
endif ()
unset(_ZOLTAN_LIB CACHE)
endforeach(LIB_NAME)
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
else (Zoltan_FOUND)
find_file(ZOLTAN_HEADER_FILE "zoltan.h" HINTS ${ZOLTAN_DIR}/include ${PETSC_INCLUDE_DIRS})
if (ZOLTAN_HEADER_FILE)
......@@ -31,7 +31,7 @@ macro(target_enable_zoltan _TARGET_ _SCOPE_)
message(FATAL_ERROR "Could not find Zoltan include file 'zoltan.h'!")
endif(ZOLTAN_HEADER_FILE)
if (LINK_EXECUTABLE)
if (LINK_EXECUTABLE OR APPLE)
find_library(ZOLTAN_LIB zoltan
HINTS ${Zoltan_INCLUDE_DIR}/../lib DOC "Full path to the zoltan library")
if (NOT ZOLTAN_LIB)
......@@ -45,7 +45,7 @@ macro(target_enable_zoltan _TARGET_ _SCOPE_)
else ()
message(WARNING "Zoltan configuration file Makefile.export.zoltan not found!")
endif ()
endif (LINK_EXECUTABLE)
endif (LINK_EXECUTABLE OR APPLE)
target_compile_definitions(${_TARGET_} ${_SCOPE_} HAVE_ZOLTAN=1)
endif (Zoltan_FOUND)
......
......@@ -76,13 +76,11 @@ namespace AMDiS {
class NullCreator : public CreatorInterface<BaseClass>
{
/// Creates no object.
BaseClass* create()
virtual BaseClass* create() override
{
return NULL;
}
virtual ~NullCreator() {}
/// Implementation of \ref CreatorInterface::isNullCreator()
virtual bool isNullCreator() override
{
......@@ -101,8 +99,6 @@ namespace AMDiS {
class CreatorInterfaceName : public CreatorInterface<BaseClass>
{
public:
virtual ~CreatorInterfaceName() {}
/// Sets \ref name
void setName(std::string str)
{
......
......@@ -7,34 +7,38 @@
#include "Traverse.h"
namespace AMDiS
{
// satre values of DOFVector on all macro elements to internal container
{
// store values of DOFVector on all macro elements to internal container
void DOFSerializer::gather(DOFVector<double> const* vec, std::vector<double>& values)
{
std::fill(visited_.begin(), visited_.end(), false);
values.clear();
values.reserve(numValues_);
for (auto* macroEl : mesh_->getMacroElements())
gather(macroEl->getIndex(), vec, values, false);
numValues_ = values.size();
}
// satre values of DOFVector on macro element `macroIndex` to internal container
// store values of DOFVector on macro element `macroIndex` to internal container
void DOFSerializer::gather(int macroIndex, DOFVector<double> const* vec, std::vector<double>& values, bool reset)
{
FUNCNAME("DOFSerializer::gather()");
TEST_EXIT(mesh_ == vec->getFeSpace()->getMesh())("Incompatible meshes!\n");
if (reset) {
std::fill(visited_.begin(), visited_.end(), false);
values.clear();
}
TEST_EXIT(mesh_ == vec->getFeSpace()->getMesh())("Incompatible meshes!\n");
TraverseStack stack;
ElInfo *elInfo = stack.traverseFirstOneMacro(mesh_, macroIndex, -1, Mesh::CALL_EVERY_EL_PREORDER);
while (elInfo) {
Element *el = elInfo->getElement();
if (el->isLeaf()) {
gather(VERTEX, elInfo, vec, values);
if (mesh_->getDim() > 1)
......@@ -43,14 +47,15 @@ void DOFSerializer::gather(int macroIndex, DOFVector<double> const* vec, std::ve
gather(FACE, elInfo, vec, values);
gather(CENTER, elInfo, vec, values);
}
elInfo = stack.traverseNext(elInfo);
}
}
void DOFSerializer::gather(GeoIndex geo, ElInfo* elInfo, DOFVector<double> const* vec, std::vector<double>& values)
void DOFSerializer::gather(GeoIndex geo, ElInfo* elInfo, DOFVector<double> const* vec, std::vector<double>& values)
{
FUNCNAME_DBG("DOFSerializer::gather()");
int nd;
if ((nd = admin_->getNumberOfDofs(geo))) {
int entities = mesh_->getGeo(geo);
......@@ -59,7 +64,7 @@ void DOFSerializer::gather(GeoIndex geo, ElInfo* elInfo, DOFVector<double> const
for (int n = 0; n < entities; n++) {
for(int d = 0; d < nd; d++) {
DegreeOfFreedom globalDof = elInfo->getElement()->getDof(n0 + n, nd0 + d);
TEST_EXIT(globalDof < visited_.size())("visited container not large enough!\n");
TEST_EXIT_DBG(globalDof < visited_.size())("visited container not large enough!\n");
if (!visited_[globalDof]) {
visited_[globalDof] = true;
values.push_back((*vec)[globalDof]);
......@@ -75,7 +80,7 @@ void DOFSerializer::scatter(std::vector<double> const& values, DOFVector<double>
{
std::fill(visited_.begin(), visited_.end(), false);
counter_ = 0u;
for (auto* macroEl : mesh_->getMacroElements())
scatter(macroEl->getIndex(), values, vec, false);
}
......@@ -83,19 +88,20 @@ void DOFSerializer::scatter(std::vector<double> const& values, DOFVector<double>
// assign stored values to DOFVector, on macroElement with index `macroIndex`
void DOFSerializer::scatter(int macroIndex, std::vector<double> const& values, DOFVector<double>* vec, bool reset) const
{
{
FUNCNAME("DOFSerializer::scatter()");
TEST_EXIT(mesh_ == vec->getFeSpace()->getMesh())("Incompatible meshes!\n");
if (reset) {
std::fill(visited_.begin(), visited_.end(), false);
counter_ = 0u;
}
TEST_EXIT(mesh_ == vec->getFeSpace()->getMesh())("Incompatible meshes!\n");
TraverseStack stack;
ElInfo *elInfo = stack.traverseFirstOneMacro(mesh_, macroIndex, -1, Mesh::CALL_EVERY_EL_PREORDER);
while (elInfo) {
Element *el = elInfo->getElement();
if (el->isLeaf()) {
scatter(VERTEX, elInfo, values, vec);
if (mesh_->getDim() > 1)
......@@ -104,7 +110,7 @@ void DOFSerializer::scatter(int macroIndex, std::vector<double> const& values, D
scatter(FACE, elInfo, values, vec);
scatter(CENTER, elInfo, values, vec);
}
elInfo = stack.traverseNext(elInfo);
}
}
......@@ -112,6 +118,7 @@ void DOFSerializer::scatter(int macroIndex, std::vector<double> const& values, D
void DOFSerializer::scatter(GeoIndex geo, ElInfo* elInfo, std::vector<double> const& values, DOFVector<double>* vec) const
{
FUNCNAME("DOFSerializer::scatter()");
int nd;
if ((nd = admin_->getNumberOfDofs(geo))) {
int entities = mesh_->getGeo(geo);
......@@ -120,7 +127,7 @@ void DOFSerializer::scatter(GeoIndex geo, ElInfo* elInfo, std::vector<double> co
for (int n = 0; n < entities; n++) {
for(int d = 0; d < nd; d++) {
DegreeOfFreedom globalDof = elInfo->getElement()->getDof(n0 + n, nd0 + d);
TEST_EXIT(globalDof < visited_.size())("visited container not large enough!\n");
TEST_EXIT_DBG(globalDof < visited_.size())("visited container not large enough!\n");
if (!visited_[globalDof]) {
visited_[globalDof] = true;
TEST_EXIT(counter_ < values.size())("Not enough values in value-container!\n");
......
......@@ -41,47 +41,51 @@ namespace AMDiS
class DOFSerializer
{
public:
/// Constructor, stores a pointer to the DOFAdmin. If the number of values to store can be estimated,
/// pass a second argument `numValues`
DOFSerializer(DOFAdmin* admin, std::size_t numValues = 0)
DOFSerializer(DOFAdmin* admin, std::size_t numValues = 0u)
: admin_(admin)
, mesh_(admin->getMesh())
, visited_(admin->getUsedSize(), false)
, numValues_(numValues)
{}
// satre values of DOFVector on all macro elements to internal container
// store values of DOFVector on all macro elements to internal container
void gather(DOFVector<double> const* vec, std::vector<double>& values);
// satre values of DOFVector on macro element `macroIndex` to internal container
// store values of DOFVector on macro element `macroIndex` to internal container
void gather(int macroIndex, DOFVector<double> const* vec, std::vector<double>& values, bool reset = true);
// assign stored values to DOFVector, for all macro elements
void scatter(std::vector<double> const& values, DOFVector<double>* vec) const;
// assign stored values to DOFVector, on macroElement with index `macroIndex`
void scatter(int macroIndex, std::vector<double> const& values, DOFVector<double>* vec, bool reset = true) const;
protected:
// collect values of one geometry-type
void gather(GeoIndex geo, ElInfo* elInfo, DOFVector<double> const* vec, std::vector<double>& values);
// assign values of one geometry type
void scatter(GeoIndex geo, ElInfo* elInfo, std::vector<double> const& values, DOFVector<double>* vec) const;
protected:
DOFAdmin* admin_;
Mesh* mesh_;
// stored which DOFs were already visited during traversal
mutable std::vector<bool> visited_;
// estimated number of values
std::size_t numValues_ = 0u;
// a counter used during assignment of values. To guarantee the same order as during gather
mutable std::size_t counter_ = 0u;
};
......
......@@ -124,10 +124,10 @@ namespace AMDiS {
{
this->name = n;
this->feSpace = f;
if (this->feSpace && this->feSpace->getAdmin())
(this->feSpace->getAdmin())->addDOFIndexed(this);
this->boundaryManager = new BoundaryManager(f);
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
if (addToSynch && Parallel::MeshDistributor::globalMeshDistributor != NULL)
......@@ -142,7 +142,7 @@ namespace AMDiS {
if ( Parallel::MeshDistributor::globalMeshDistributor != NULL)
Parallel::MeshDistributor::globalMeshDistributor->removeInterchangeVector(this);
#endif
#ifdef _OPENMP
#pragma omp critical
#endif
......@@ -1090,7 +1090,7 @@ namespace AMDiS {
ElInfo *elInfo = mesh->createNewElInfo();
double value = 0.0;
bool inside = false;
unsigned short inside = 0;
if (oldElInfo && oldElInfo->getMacroElement()) {
inside = mesh->findElInfoAtPoint(p, elInfo, lambda, oldElInfo->getMacroElement(), NULL, NULL);
......@@ -1101,28 +1101,24 @@ namespace AMDiS {
if (oldElInfo)
oldElInfo = elInfo;
if (inside) {
if (inside > 0) {
basFcts->getLocalIndices(elInfo->getElement(), this->feSpace->getAdmin(), localIndices);
ElementVector uh(nBasFcts);
for (int i = 0; i < nBasFcts; i++)
uh[i] = operator[](localIndices[i]);
value = basFcts->evalUh(lambda, uh);
} else {
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
value = 0.0;
#else
ERROR_EXIT("Can not eval DOFVector at point p, because point is outside geometry.");
#endif
}
if (oldElInfo == NULL)
delete elInfo;
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
Parallel::mpi::globalAdd(value);
Parallel::mpi::globalAdd(inside);
#endif
return value;
TEST_EXIT(inside > 0)("Can not eval DOFVector at point p, because point is outside geometry.");
return value/inside;
}
......@@ -1140,7 +1136,7 @@ namespace AMDiS {
DimVec<double> lambda(dim, NO_INIT);
ElInfo *elInfo = mesh->createNewElInfo();
WorldVector<double> value(DEFAULT_VALUE, 0.0);
bool inside = false;
unsigned short inside = 0;
if (oldElInfo && oldElInfo->getMacroElement()) {
inside = mesh->findElInfoAtPoint(p, elInfo, lambda, oldElInfo->getMacroElement(), NULL, NULL);
......@@ -1151,19 +1147,24 @@ namespace AMDiS {
if (oldElInfo)
oldElInfo = elInfo;
if (inside) {
if (inside > 0) {
basFcts->getLocalIndices(elInfo->getElement(), this->feSpace->getAdmin(), localIndices);
mtl::dense_vector<WorldVector<double> > uh(nBasFcts);
for (int i = 0; i < nBasFcts; i++)
uh[i] = operator[](localIndices[i]);
value = basFcts->evalUh(lambda, uh);
} else {
ERROR_EXIT("Can not eval DOFVector at point p, because point is outside geometry.");
}
if (oldElInfo == NULL)
delete elInfo;
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
Parallel::mpi::globalAdd(value);
Parallel::mpi::globalAdd(inside);
#endif
TEST_EXIT(inside > 0)("Can not eval DOFVector at point p, because point is outside geometry.");
value *= 1.0/inside;
return value;
}
......
......@@ -37,7 +37,6 @@
#include <boost/lexical_cast.hpp>
#include <boost/numeric/conversion/cast.hpp>
#include <boost/thread/shared_mutex.hpp> // requires c++14
#include <boost/type_traits.hpp>
......@@ -423,8 +422,6 @@ namespace AMDiS {
template<typename T>
static void get(const std::string tag, T& value, int debugInfo = -1)
{
// boost::shared_lock<boost::shared_mutex> lock(singlett().mutex_);
if (debugInfo == -1)
debugInfo = singlett().getMsgInfo();
else {
......@@ -498,8 +495,6 @@ namespace AMDiS {
/// return InitEntry object for tag tag
static InitEntry get(const std::string tag)
{
// boost::shared_lock<boost::shared_mutex> lock(singlett().mutex_);
InitEntry result;
std::string valStr;
......@@ -527,8 +522,6 @@ else if(error_code == TAG_NOT_FOUND_BREAK)
template<typename T>
static void set(const std::string tag, T const& value, int debugInfo= -1)
{
// boost::unique_lock<boost::shared_mutex> lock(singlett().mutex_);
if (debugInfo == -1)
debugInfo = singlett().getMsgInfo();
......@@ -578,14 +571,14 @@ else if(error_code == TAG_NOT_FOUND_BREAK)
{
singlett().clear();
}
/// save singlett-data to file with filename fn
static void save(std::string fn)
{
singlett().write(fn);
}
// list of included filenames
static std::set< std::string >& getIncludeList()
......@@ -593,7 +586,7 @@ else if(error_code == TAG_NOT_FOUND_BREAK)
static std::set< std::string > include_list;
return include_list;
}
protected:
Initfile()
: msgInfo(0),
......@@ -656,8 +649,6 @@ protected:
void getInternalParameters();
int msgInfo, msgWait, paramInfo, breakOnMissingTag;
// mutable boost::shared_mutex mutex_;
};
typedef Initfile Parameters;
......
......@@ -280,25 +280,25 @@ namespace AMDiS {
bool cont = true;
while (cont) {
bool cont1;
// #ifndef NDEBUG
#ifndef NDEBUG
bool cont2;
// #endif
#endif
if (structure1->isLeafElement() == structure2->isLeafElement()) {
cont1 = structure1->nextElement(result);
// #ifndef NDEBUG
#ifndef NDEBUG
cont2 = structure2->nextElement();
// #endif
#endif
} else {
if (structure1->isLeafElement()) {
cont1 = structure1->nextElement();
// #ifndef NDEBUG
#ifndef NDEBUG
cont2 = structure2->skipBranch(result);
// #endif
#endif
} else {
cont1 = structure1->skipBranch(result);
// #ifndef NDEBUG
#ifndef NDEBUG
cont2 = structure2->nextElement();
// #endif
#endif
}
}
TEST_EXIT_DBG(cont1 == cont2)("Structures don't match!\n");
......@@ -504,7 +504,7 @@ namespace AMDiS {
elInfo = stack.traverseNext(elInfo);
}
}
void MeshStructure::setMeshStructureValues(int macroElIndex,
DOFVector<double>* vec,
......@@ -519,7 +519,7 @@ namespace AMDiS {
Mesh *mesh = feSpace->getMesh();
bool feSpaceHasNonVertexDofs = (feSpace->getBasisFcts()->getDegree() > 1);
int nVertexPreDofs = feSpace->getAdmin()->getNumberOfPreDofs(VERTEX);
std::size_t counter = 0;
if (withElIndex) {
TEST_EXIT(static_cast<int>(values[0]) == macroElIndex)
......
......@@ -490,7 +490,7 @@ namespace AMDiS
int getDegree() const
{
return std::max(super::term1.getDegree(), super::term2.getDegree());
return std::max(super::term1.getDegree(), super::term2.getDegree())+2;
}
inline value_type operator()(const int& iq) const
......@@ -514,7 +514,7 @@ namespace AMDiS
int getDegree() const
{
return std::max(super::term1.getDegree(), super::term2.getDegree());
return std::max(super::term1.getDegree(), super::term2.getDegree())+2;
}
inline value_type operator()(const int& iq) const
......@@ -525,6 +525,69 @@ namespace AMDiS
std::string str() const { return std::string("min(") + super::term1.str() + ", " + super::term2.str() + ")"; }
};
template<typename Term1>
struct Clamp : public LazyOperatorTerm1<Term1>
{
typedef LazyOperatorTerm1<Term1> super;
typedef typename Term1::value_type value_type;
Clamp(const Term1& term1_, value_type const& lo = 0.0, value_type const& hi = 1.0)
: super(term1_)
, lo(lo)
, hi(hi)
{
assert( !(hi < lo) );
}
int getDegree() const
{
return super::term.getDegree()+2;
}
inline value_type operator()(const int& iq) const
{
value_type v = super::term(iq);
return v < lo ? lo : hi < v ? hi : v;
}
std::string str() const { return std::string("clamp(") + super::term.str() + ", " + lo + ", " << hi << ")"; }
value_type lo, hi;
};
// derivative of clamp
template<typename Term1>
struct DClamp : public LazyOperatorTerm1<Term1>
{
typedef LazyOperatorTerm1<Term1> super;
typedef typename Term1::value_type value_type;
DClamp(const Term1& term1_, value_type const& lo = 0.0, value_type const& hi = 1.0)
: super(term1_)
, lo(lo)
, hi(hi)
{
assert( !(hi < lo) );
}
int getDegree() const
{
return 2;
}
inline value_type operator()(const int& iq) const
{
value_type v = super::term(iq);
return v < lo ? value_type(0) : hi < v ? value_type(0) : value_type(1);
}
std::string str() const { return std::string("dclamp(") + super::term.str() + ", " + lo + ", " << hi << ")"; }
value_type lo, hi;
};
} // end namespace expressions
......@@ -742,6 +805,22 @@ namespace AMDiS
expressions::Atanh<Term> >::type
atanh(const Term& t) { return expressions::Atanh<Term>(t); }
//______________________________________________________________________________
// clamp between lo and hi
template<typename Term, typename T = typename Term::value_type>
inline typename boost::enable_if<
typename traits::is_expr<Term>::type,
expressions::Clamp<Term> >::type
clamp(const Term& t, T const& lo, T const& hi) { return expressions::Clamp<Term>(t, lo, hi); }
// derivative of clamp between lo and hi
template<typename Term, typename T = typename Term::value_type>
inline typename boost::enable_if<
typename traits::is_expr<Term>::type,
expressions::DClamp<Term> >::type
dclamp(const Term& t, T const& lo, T const& hi) { return expressions::DClamp<Term>(t, lo, hi); }
} // end namespace AMDiS
#endif // AMDIS_CMATH_EXPRESSION_HPP