Skip to content
Snippets Groups Projects
Commit 5828d2a8 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Merge branch 'develop'

parents 4646e930 3efd88e3
No related branches found
No related tags found
No related merge requests found
Showing
with 1357 additions and 93 deletions
---
cache:
paths:
- install/
before_script:
- source ~/toolchain
- export CMAKE_FLAGS="-DCMAKE_C_COMPILER='$CC' -DCMAKE_CXX_COMPILER='$CXX'"
dune:git--gcc:
image: mathiwr/dune:latest
variables:
GIT_SUBMODULE_STRATEGY: recursive
debian:10 gcc-8-17:
image: registry.dune-project.org/docker/ci/dune:2.6-debian-10-gcc-8-17
script:
- dunecontrol --current all
- dunecontrol --current make build_tests
- dunecontrol --current make test
- dunecontrol --current make examples
debian:10 clang-6-libcpp-17:
image: registry.dune-project.org/docker/ci/dune:2.6-debian-10-clang-6-libcpp-17
script:
- duneci-standard-test
- dunecontrol --current make examples
debian:9 gcc-6-14:
image: registry.dune-project.org/docker/ci/dune:2.6-debian-9-gcc-6-14
script:
- dunecontrol --current all
- dunecontrol --current make build_tests
- dunecontrol --current make test
only:
- develop
- dunecontrol --current make examples
ubuntu:18.04 clang-6-17:
image: registry.dune-project.org/docker/ci/dune:2.6-ubuntu-18.04-clang-6-17
script:
- duneci-standard-test
- dunecontrol --current make examples
[submodule "externals/fmt"]
path = externals/fmt
url = https://github.com/fmtlib/fmt.git
......@@ -12,18 +12,22 @@ include(DuneMacros)
# start a dune project with information from dune.module
dune_project()
dune_enable_all_packages(MODULE_LIBRARIES amdis)
dune_enable_all_packages(MODULE_LIBRARIES amdis fmt)
add_subdirectory("bin")
add_subdirectory("cmake/modules")
add_subdirectory("doc")
add_subdirectory("externals")
add_subdirectory("src")
add_subdirectory("test")
add_subdirectory("examples" EXCLUDE_FROM_ALL)
add_subdirectory("doc")
add_subdirectory("cmake/modules")
target_include_directories(amdis PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>)
target_compile_definitions(amdis PUBLIC AMDIS_BACKEND_MTL=1)
target_compile_options(amdis PUBLIC -Wall -pedantic -Wno-unused-parameter) #-ftemplate-backtrace-limit=0
target_link_libraries(amdis fmt)
option(ENABLE_ALL_WARNINGS "enable all meaningful warnings" OFF)
if (ENABLE_ALL_WARNINGS)
target_compile_options(amdis PUBLIC "-Wall" "-Wextra" "-pedantic" "-Wnon-virtual-dtor" "-Wold-style-cast" "-Wcast-align" "-Woverloaded-virtual" "-Wpedantic" "-Wconversion")
endif (ENABLE_ALL_WARNINGS)
# finalize the dune project, e.g. generating config.h etc.
finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
The MIT License (MIT)
Copyright (c) 2016 Simon Praetorius
Copyright (c) 2016-2018 Simon Praetorius
2018 Felix Müller
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
#pragma once
#include <string>
#include "Flag.hpp"
namespace AMDiS
{
class AdaptInfo;
class ProblemStatBase;
const Flag BUILD = 1; // Assemble vectors and matrices
const Flag BUILD_RHS = 2; // Assemble rhs vectors only
const Flag ADAPT = 4; // Run adaption procedure
const Flag SOLVE = 8; // Solve system
const Flag SOLVE_RHS = 16; // Solve system, where only rhs vectors have changed
const Flag ESTIMATE = 32; // Estimate error
const Flag MARK = 64; // Mark elements
const Flag FULL_ITERATION = BUILD | ADAPT | SOLVE | ESTIMATE | MARK;
const Flag NO_ADAPTION = BUILD | SOLVE | ESTIMATE;
/** \brief
* Interface for master problems needed by the adaption loop. A master problem
* can handle one single or multiple coupled problems. In the latter case,
* the master problem can determine the execution order of the build, solve,
* estimate, and adapt steps of the single problems in \ref oneIteration().
*/
class ProblemIterationInterface
{
public:
virtual ~ProblemIterationInterface() = default;
/// Called before each adaption loop iteration.
virtual void beginIteration(AdaptInfo&) { /* by default, do nothing */ }
/** \brief
* Determines the execution order of the single adaption steps. If adapt is
* true, mesh adaption will be performed. This allows to avoid mesh adaption,
* e.g. in timestep adaption loops of timestep adaptive strategies.
*/
virtual Flag oneIteration(AdaptInfo& adaptInfo, Flag toDo = FULL_ITERATION) = 0;
/// Called after each adaption loop iteration.
virtual void endIteration(AdaptInfo&) { /* by default, do nothing */ }
/// Returns number of managed problems
virtual int numProblems() const = 0;
/** \brief
* Returns the problem with the given number. If only one problem
* is managed by this master problem, the number hasn't to be given.
*/
virtual ProblemStatBase& problem(int number = 0) = 0;
/// Returns the problem with the given name.
virtual ProblemStatBase& problem(std::string const& name) = 0;
/// Returns the name of the problem.
virtual std::string const& name() const = 0;
};
} // end namespace AMDiS
......@@ -18,6 +18,7 @@ The `dunecontrol` script searches for the required
- [dune-geometry](https://gitlab.dune-project.org/core/dune-geometry)
- [dune-grid](https://gitlab.dune-project.org/core/dune-grid)
- [dune-localfunctions](https://gitlab.dune-project.org/core/dune-localfunctions)
- [dune-istl](https://gitlab.dune-project.org/core/dune-istl)
- [dune-typetree](https://gitlab.dune-project.org/staging/dune-typetree)
- [dune-functions](https://gitlab.dune-project.org/staging/dune-functions)
......@@ -26,20 +27,21 @@ can be obtained from https://gitlab.dune-project.org and need to be found in a
subdirectory of `DUNE_CONTROL_PATH`. See also https://dune-project.org/doc/installation
for details about the installation of dune modules.
Additionally we require the following libraries to be found:
Additionally the following optional libraries can be used:
- [MTL4](https://gitlab.math.tu-dresden.de/spraetor/mtl4) (use this fork to get up-to-date changes)
- [SuiteSparse](http://faculty.cse.tamu.edu/davis/suitesparse.html) (optional)
- [Eigen3](http://eigen.tuxfamily.org) >= 3.3
- [SuiteSparse](http://faculty.cse.tamu.edu/davis/suitesparse.html)
- libalberta >= 3.0 (For Alberta-Grids)
And a compiler that supports the C++14 standard, e.g. g++ >= 5.0 and clang >= 3.6, and cmake >= 3.1.
By default, the `dune-istl` linear-algebra backend is used. To choose one of `ISTL`, `MTL`, or `EIGEN`, you can specify the cmake parameter `-DBACKEND=[ISTL,MTL,EIGEN]`.
If your MTL4 installation is not found by default, you have to specify the path,
where the file `MTLConfig.cmake` is found, here called `MTL_ROOT`. Then simply use
`dunecontrol` to configure and `cmake` to build:
```
CMAKE_FLAGS="-DMTL_DIR:PATH=[MTL_ROOT]" dunecontrol --current configure
CMAKE_FLAGS="-DBACKEND=MTL -DMTL_DIR:PATH=[MTL_ROOT]" dunecontrol --current configure
cmake --build build-cmake
```
This compiles the library and all examples in the `src/` directory.
install(PROGRAMS
amdisproject
DESTINATION ${CMAKE_INSTALL_BINDIR})
This diff is collapsed.
# Module that provides tools for adding executable with all required flags
#
# .. cmake_function:: add_amdis_executable
#
# .. cmake_brief::
#
# Adds an executable using the AMDiS library
#
# .. cmake_param:: NAME
# :single:
#
# The name of the test that should be added. If an executable
# is also added (by specifying SOURCES), the executable is also
# named accordingly. If omitted, the name will be deduced from
# the (single) sources parameter or from the given target. Note
# that this requires you to take care, that you only use a target
# or source file for but one such test.
#
# .. cmake_param:: SOURCES
# :multi:
#
# The source files that this test depends on. These are the
# sources that will be passed to :ref:`add_executable`.
#
# You *must* specify either :code:`SOURCES` or :code:`TARGET`.
#
# .. cmake_param:: DIM
# :single:
#
# Specify the grid dimension.
#
# .. cmake_param:: DOW
# :single:
#
# Specify the world dimension. If not specified it is assumed to be equal to DIM
#
# .. cmake_param:: ALU_GRID
# :option:
#
# Enables ALUGrid with specified grid dimension and world dimension.
#
# .. cmake_param:: ALBERTA_GRID
# :option:
#
# Enables AlbertaGrid with specified grid dimension and world dimension.
#
# This file defines the a function for adding executables to cmake and setting all required
# parameters for dependent modules.
#
function(add_amdis_executable)
include(CMakeParseArguments)
set(OPTIONS ALU_GRID ALBERTA_GRID)
set(SINGLEARGS NAME DIM DOW)
set(MULTIARGS SOURCES)
cmake_parse_arguments(ADDEXE "${OPTIONS}" "${SINGLEARGS}" "${MULTIARGS}" ${ARGN})
# Check whether the parser produced any errors
if(ADDTEST_UNPARSED_ARGUMENTS)
message(WARNING "Unrecognized arguments ('${ADDTEST_UNPARSED_ARGUMENTS}') for add_amdis_executable!")
endif()
# Check input for validity and apply defaults
if(NOT ADDEXE_SOURCES)
message(FATAL_ERROR "You need to specify the SOURCES option for add_amdis_executable!")
endif()
if(NOT ADDEXE_NAME)
# try deducing the executable name form the source name
if(ADDEXE_SOURCES)
# deducing a name is only possible with a single source argument
list(LENGTH ADDEXE_SOURCES len)
if(NOT len STREQUAL "1")
message(FATAL_ERROR "Cannot deduce executable name from multiple sources!")
endif()
# strip file extension
get_filename_component(ADDEXE_NAME ${ADDEXE_SOURCES} NAME_WE)
endif()
endif()
# Add the executable
add_executable(${ADDEXE_NAME} ${ADDEXE_SOURCES})
# add all flags to the target!
add_dune_all_flags(${ADDEXE_NAME})
target_link_dune_default_libraries(${ADDEXE_NAME})
target_link_libraries(${ADDEXE_NAME} amdis)
if(ADDEXE_DIM)
set(GRIDDIM ${ADDEXE_DIM})
endif(ADDEXE_DIM)
if(ADDEXE_DOW)
set(WORLDDIM ${ADDEXE_DOW})
else(ADDEXE_DOW)
set(WORLDDIM ${ADDEXE_DIM})
endif(ADDEXE_DOW)
# set dimension flag
if(GRIDDIM)
target_compile_definitions(${ADDEXE_NAME} PRIVATE "GRIDDIM=${GRIDDIM}")
endif(GRIDDIM)
if(WORLDDIM)
target_compile_definitions(${ADDEXE_NAME} PRIVATE "WORLDDIM=${WORLDDIM}")
endif(WORLDDIM)
# add flags for AlbertaGrid
if(ADDEXE_ALBERTA_GRID)
if(NOT ADDEXE_DIM)
message(FATAL_ERROR "You need to specify dimension for ALBERTA_GRID!")
endif()
if(NOT ADDEXE_DOW)
message(WARNING "dimensionworld not specified for ALBERTA_GRID. Setting DOW=DIM.")
endif()
add_dune_alberta_flags(GRIDDIM ${GRIDDIM} WORLDDIM ${WORLDDIM} ${ADDEXE_NAME})
endif(ADDEXE_ALBERTA_GRID)
# add flags for ALUGrid
if(ADDEXE_ALU_GRID)
# nothing special to do
endif(ADDEXE_ALU_GRID)
endfunction(add_amdis_executable)
\ No newline at end of file
#include(CheckIncludeFileCXX)
include(CheckCXXSourceCompiles)
#include(CheckCXXSymbolExists)
# fold expressions (a + ...)
check_cxx_source_compiles("
......@@ -13,7 +11,7 @@ check_cxx_source_compiles("
{
f(0,1,2,3,4,5);
}
" AMDIS_HAS_CXX_FOLD_EXPRESSION
" AMDIS_HAS_CXX_FOLD_EXPRESSIONS
)
check_cxx_source_compiles("
......@@ -30,4 +28,16 @@ check_cxx_source_compiles("
return f<1>();
}
" AMDIS_HAS_CXX_CONSTEXPR_IF
)
check_cxx_source_compiles("
#include <iostream>
#include <tuple>
int main()
{
auto tup = std::make_tuple(0, 'a', 3.14);
for... (auto elem : tup)
std::cout << elem << std::endl;
}
" AMDIS_HAS_EXPANSION_STATEMENTS
)
\ No newline at end of file
# File for module specific CMake tests.
include(AmdisCXXFeatures)
include(AddAmdisExecutable)
include(AMDiSCXXFeatures)
set(BACKEND "ISTL" CACHE STRING "LinearAlgebra backend. One of MTL, EIGEN, ISTL")
set_property(CACHE BACKEND PROPERTY STRINGS "MTL" "EIGEN" "ISTL")
# some additional packages and flags
find_package(MTL REQUIRED
PATHS /usr/local/lib/mtl4 /opt/sources/mtl4 /opt/development/mtl4)
if (BACKEND STREQUAL "MTL")
find_package(MTL
PATHS /usr/local/lib/mtl4 /opt/sources/mtl4 /opt/development/mtl4)
set(CXX_ELEVEN_FEATURE_LIST "MOVE" "AUTO" "RANGEDFOR" "INITLIST" "STATICASSERT" "DEFAULTIMPL")
set(MTL_COMPILE_DEFINITIONS "")
foreach(feature ${CXX_ELEVEN_FEATURE_LIST})
list(APPEND MTL_COMPILE_DEFINITIONS "MTL_WITH_${feature}")
endforeach()
if (MTL_FOUND)
set(CXX_ELEVEN_FEATURE_LIST "MOVE" "AUTO" "RANGEDFOR" "INITLIST" "STATICASSERT" "DEFAULTIMPL")
set(MTL_COMPILE_DEFINITIONS "")
foreach(feature ${CXX_ELEVEN_FEATURE_LIST})
list(APPEND MTL_COMPILE_DEFINITIONS "MTL_WITH_${feature}")
endforeach()
if(HAVE_UMFPACK OR ENABLE_SUITESPARSE OR SuiteSparse_FOUND)
list(APPEND MTL_COMPILE_DEFINITIONS "MTL_HAS_UMFPACK")
endif()
find_package(SuiteSparse QUIET)
if (SuiteSparse_FOUND)
list(APPEND MTL_COMPILE_DEFINITIONS "MTL_HAS_UMFPACK")
endif (SuiteSparse_FOUND)
endif (MTL_FOUND)
dune_register_package_flags(
COMPILE_DEFINITIONS ${MTL_COMPILE_DEFINITIONS}
INCLUDE_DIRS ${MTL_INCLUDE_DIRS})
set(HAVE_MTL MTL_FOUND)
if (MTL_FOUND)
list(APPEND MTL_COMPILE_DEFINITIONS "ENABLE_MTL=1")
dune_register_package_flags(
COMPILE_DEFINITIONS ${MTL_COMPILE_DEFINITIONS}
INCLUDE_DIRS ${MTL_INCLUDE_DIRS})
endif (MTL_FOUND)
elseif (BACKEND STREQUAL "EIGEN")
find_package(Eigen3)
set(HAVE_EIGEN EIGEN_FOUND)
if (EIGEN3_FOUND)
message(STATUS " Found Eigen3, version: ${EIGEN3_VERSION}")
list(APPEND EIGEN3_DEFINITIONS "ENABLE_EIGEN=1")
dune_register_package_flags(
COMPILE_DEFINITIONS ${EIGEN3_DEFINITIONS}
INCLUDE_DIRS ${EIGEN3_INCLUDE_DIRS})
endif (EIGEN3_FOUND)
endif ()
install(FILES
install(FILES
AddAmdisExecutable.cmake
AmdisMacros.cmake
AMDiSCXXFeatures.cmake
AmdisCXXFeatures.cmake
DESTINATION ${DUNE_INSTALL_MODULEDIR})
/* begin dune-amdis
/* begin amdis
put the definitions for config.h specific to
your project here. Everything above will be
overwritten
......@@ -40,12 +40,17 @@
/* Define to the revision of amdis */
#define AMDIS_VERSION_REVISION @AMDIS_VERSION_REVISION@
/* Define to ENABLE_MTL if the MTL library is available */
#cmakedefine HAVE_MTL ENABLE_MTL
/* Define to ENABLE_EIGEN if the Eigen3 library is available */
#cmakedefine HAVE_EIGEN ENABLE_EIGEN
/* some detected compiler features may be used in AMDiS */
#cmakedefine AMDIS_HAS_CXX_FOLD_EXPRESSIONS 1
#cmakedefine AMDIS_HAS_CXX_CONSTEXPR_IF 1
#cmakedefine AMDIS_HAS_EXPANSION_STATEMENTS 1
/* end dune-amdis
/* end amdis
Everything below here will be overwritten
*/
......@@ -3,7 +3,7 @@ Installation instructions
We provide a *cmake*-based configuration and use the `dunecontrol` build system.
Simply run
```bash
```
dunecontrol --current all
```
......@@ -13,6 +13,7 @@ The `dunecontrol` script searches for the required
- [dune-geometry](https://gitlab.dune-project.org/core/dune-geometry)
- [dune-grid](https://gitlab.dune-project.org/core/dune-grid)
- [dune-localfunctions](https://gitlab.dune-project.org/core/dune-localfunctions)
- [dune-istl](https://gitlab.dune-project.org/core/dune-istl)
- [dune-typetree](https://gitlab.dune-project.org/staging/dune-typetree)
- [dune-functions](https://gitlab.dune-project.org/staging/dune-functions)
......@@ -21,28 +22,28 @@ can be obtained from https://gitlab.dune-project.org and need to be found in a
subdirectory of `DUNE_CONTROL_PATH`. See also https://dune-project.org/doc/installation
for details about the installation of dune modules.
Additionally, we require/suggest the following libraries to be found:
Additionally the following optional libraries can be used:
- [MTL4](https://gitlab.math.tu-dresden.de/spraetor/mtl4) (use this fork to get up-to-date changes)
- [Boost](http://www.boost.org) >= 1.40
- [SuiteSparse](http://faculty.cse.tamu.edu/davis/suitesparse.html) (optional)
- [Eigen3](http://eigen.tuxfamily.org) >= 3.3
- [SuiteSparse](http://faculty.cse.tamu.edu/davis/suitesparse.html)
- libalberta >= 3.0 (For Alberta-Grids)
And a compiler that supports the C++14 standard, e.g. `g++` >= 5.0 and `clang` >= 3.6,
and `cmake` >= 3.1.
And a compiler that supports the C++14 standard, e.g. g++ >= 5.0 and clang >= 3.6, and cmake >= 3.1.
By default, the `dune-istl` linear-algebra backend is used. To choose one of `ISTL`, `MTL`, or `EIGEN`, you can specify the cmake parameter `-DBACKEND=[ISTL,MTL,EIGEN]`.
If your MTL4 installation is not found by default, you have to specify the path,
where the file `MTLConfig.cmake` is found, here called `MTL_ROOT`. Then simply use
`dunecontrol` to configure and `cmake` to build:
```bash
CMAKE_FLAGS="-DMTL_DIR:PATH=[MTL_ROOT]" dunecontrol --current all
```
This compiles the library and all examples in the `src/` directory.
CMAKE_FLAGS="-DBACKEND=MTL -DMTL_DIR:PATH=[MTL_ROOT]" dunecontrol --current configure
cmake --build build-cmake
```
Install Dune modules
--------------------
To install all required Dune modules you can either install a debian package (Version 2.6 required), using source packages (e.g. [Version 2.6](https://dune-project.org/releases/2.6.0rc1/)), or install everything from the repository:
To install all required Dune modules you can either install a debian package (Version 2.6 required), using source packages (e.g. [Version 2.6](https://dune-project.org/releases/2.6.0/)), or install everything from the repository:
```bash
cd ${SOURCE_DIR}
......@@ -50,6 +51,7 @@ git clone https://gitlab.dune-project.org/core/dune-common.git
git clone https://gitlab.dune-project.org/core/dune-geometry.git
git clone https://gitlab.dune-project.org/core/dune-grid.git
git clone https://gitlab.dune-project.org/core/dune-localfunctions.git
git clone https://gitlab.dune-project.org/core/dune-istl.git
git clone https://gitlab.dune-project.org/staging/dune-typetree.git
git clone https://gitlab.dune-project.org/staging/dune-functions.git
```
......
......@@ -22,7 +22,7 @@ and \f$ \Gamma \f$ the lower and left edge of the boundary.
using namespace AMDiS;
// A dune grid type
using Grid = Dune::AlbertaGrid<AMDIS_DIM, AMDIS_DOW>;
using Grid = Dune::AlbertaGrid<GRIDDIM, WORLDDIM>;
// A dune-functions globalBasis wrapped in a struct,
// here representing local polynomial shape functions of degree 1
......
# This file contains local changes to the doxygen configuration
# please us '+=' to add file/directories to the lists
PROJECT_NAME = AMDiS
FILE_PATTERNS += *.hpp \
*.cpp \
*.md
......@@ -19,22 +20,22 @@ EXCLUDE_SYMBOLS = AMDiS::Impl \
PREDEFINED += HAVE_UMFPACK \
HAVE_ALBERTA \
HAVE_UG \
AMDIS_BACKEND_MTL
HAVE_MTL
# The INPUT tag can be used to specify the files and/or directories that contain
# documented source files. You may enter file names like "myfile.cpp" or
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT += @top_srcdir@/dune/amdis \
@top_srcdir@/dune/amdis/assembler \
@top_srcdir@/dune/amdis/common \
@top_srcdir@/dune/amdis/gridfunctions \
@top_srcdir@/dune/amdis/io \
@top_srcdir@/dune/amdis/linear_algebra \
@top_srcdir@/dune/amdis/linear_algebra/mtl \
@top_srcdir@/dune/amdis/operations \
@top_srcdir@/dune/amdis/utility \
INPUT += @top_srcdir@/src/amdis \
@top_srcdir@/src/amdis/common \
@top_srcdir@/src/amdis/gridfunctions \
@top_srcdir@/src/amdis/linearalgebra \
@top_srcdir@/src/amdis/linearalgebra/mtl \
@top_srcdir@/src/amdis/localoperators \
@top_srcdir@/src/amdis/operations \
@top_srcdir@/src/amdis/typetree \
@top_srcdir@/src/amdis/utility \
@top_srcdir@/doc
# see e.g. dune-grid for the examples of mainpage and modules
#INPUT += @srcdir@/mainpage \
......@@ -44,14 +45,14 @@ INPUT += @top_srcdir@/dune/amdis \
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE += @top_srcdir@/dune/amdis/test \
@top_srcdir@/dune/amdis/linear_algebra/istl
EXCLUDE += @top_srcdir@/src/amdis/linearalgebra/eigen \
@top_srcdir@/src/amdis/linearalgebra/istl
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
# the \include command).
EXAMPLE_PATH += @top_srcdir@/src
EXAMPLE_PATH += @top_srcdir@/examples
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
......
......@@ -2,10 +2,8 @@
# Dune module information file #
################################
#Name of the module
Module: amdis
Version: 0.1
Maintainer: simon.praetorius@tu-dresden.de
#depending on
Depends: dune-common dune-geometry dune-localfunctions dune-typetree dune-grid dune-functions
#Suggests: dune-uggrid dune-alugrid dune-foamgrid
Depends: dune-common (>= 2.6) dune-geometry (>= 2.6) dune-localfunctions (>= 2.6) dune-typetree (>= 2.6) dune-grid (>= 2.6) dune-functions (>= 2.6)
Suggests: dune-uggrid dune-alugrid dune-foamgrid dune-spgrid
add_custom_target(examples)
set(projects2d "ellipt" "heat" "vecellipt" "stokes0" "stokes1" "stokes3" "navier_stokes")
add_amdis_executable(NAME ellipt.2d SOURCES ellipt.cc DIM 2 DOW 2)
add_amdis_executable(NAME ellipt.3d SOURCES ellipt.cc DIM 3 DOW 3)
add_dependencies(examples
ellipt.2d
ellipt.3d)
foreach(project ${projects2d})
add_executable(${project}.2d ${project}.cc)
add_dune_alberta_flags(GRIDDIM 2 WORLDDIM 2 ${project}.2d)
target_link_dune_default_libraries(${project}.2d)
target_link_libraries(${project}.2d "amdis")
target_compile_definitions(${project}.2d PRIVATE AMDIS_DIM=2 AMDIS_DOW=2)
add_dependencies(examples ${project}.2d)
endforeach()
add_amdis_executable(NAME heat.2d SOURCES heat.cc DIM 2 DOW 2)
add_amdis_executable(NAME heat.3d SOURCES heat.cc DIM 3 DOW 3)
add_dependencies(examples
heat.2d
heat.3d)
set(projects3d "ellipt" "heat")
foreach(project ${projects3d})
add_executable(${project}.3d ${project}.cc)
add_dune_alberta_flags(GRIDDIM 3 WORLDDIM 3 ${project}.3d)
target_link_dune_default_libraries(${project}.3d)
target_link_libraries(${project}.3d "amdis")
target_compile_definitions(${project}.3d PRIVATE AMDIS_DIM=3 AMDIS_DOW=3)
add_dependencies(examples ${project}.3d)
endforeach()
\ No newline at end of file
add_amdis_executable(NAME vecellipt.2d SOURCES vecellipt.cc DIM 2 DOW 2)
add_amdis_executable(NAME stokes0.2d SOURCES stokes0.cc DIM 2 DOW 2)
add_amdis_executable(NAME stokes1.2d SOURCES stokes1.cc DIM 2 DOW 2)
add_amdis_executable(NAME stokes3.2d SOURCES stokes3.cc DIM 2 DOW 2)
add_amdis_executable(NAME navier_stokes.2d SOURCES navier_stokes.cc DIM 2 DOW 2)
add_amdis_executable(NAME convection_diffusion.2d SOURCES convection_diffusion.cc DIM 2 DOW 2)
add_amdis_executable(NAME cahn_hilliard.2d SOURCES cahn_hilliard.cc DIM 2 DOW 2 ALBERTA_GRID)
add_dependencies(examples
vecellipt.2d
stokes0.2d
stokes1.2d
stokes3.2d
navier_stokes.2d
convection_diffusion.2d
cahn_hilliard.2d)
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <iostream>
#if HAVE_DUNE_SPGRID
#include <dune/grid/spgrid.hh>
#endif
#include <amdis/AMDiS.hpp>
#include <amdis/Integrate.hpp>
#include <amdis/ProblemStat.hpp>
#include <amdis/LocalOperators.hpp>
#include <amdis/common/Literals.hpp>
using namespace AMDiS;
using namespace Dune::Indices;
// 1 component with polynomial degree 2
using Param = YaspGridBasis<GRIDDIM, 2>;
using ElliptProblem = ProblemStat<Param>;
template <class SetBoundary>
void run(SetBoundary setBoundary)
{
ElliptProblem prob("ellipt");
prob.initialize(INIT_ALL);
setBoundary(prob.boundaryManager());
auto opL = makeOperator(tag::gradtest_gradtrial{}, 1.0);
prob.addMatrixOperator(opL, 0, 0);
auto f = [](auto const& x) {
double r2 = dot(x,x);
double ux = std::exp(-10.0 * r2);
return -(400.0 * r2 - 20.0 * x.size()) * ux;
};
auto opForce = makeOperator(tag::test{}, f, 6);
prob.addVectorOperator(opForce, 0);
// set boundary condition
auto g = [](auto const& x){ return std::exp(-10.0 * dot(x,x)); };
prob.addDirichletBC(BoundaryType{1}, 0, 0, g);
AdaptInfo adaptInfo("adapt");
prob.assemble(adaptInfo);
prob.solve(adaptInfo);
double errorL2 = integrate(sqr(g - prob.solution(0)), prob.gridView(), 6);
msg("error_L2 = {}", errorL2);
}
void run_periodic()
{
#if HAVE_DUNE_SPGRID
Dune::SPCube<double,2> cube({0.0,0.0},{1.0,1.0});
Dune::SPDomain<double,2> domain({cube}, Dune::SPTopology<2>(0b01));
Dune::SPGrid<double,2> grid(domain, Dune::SPMultiIndex<2>({2,2}));
using Grid = Dune::SPGrid<double,2>;
#else
Dune::YaspGrid<2> grid({1.0,1.0},{2,2},std::bitset<2>("10"),0);
using Grid = Dune::YaspGrid<2>;
#endif
using Traits = LagrangeBasis<typename Grid::LeafGridView, 2>;
ProblemStat<Traits> prob("ellipt", grid);
prob.initialize(INIT_ALL);
prob.boundaryManager().setBoxBoundary({-1,-1,1,1});
auto opL = makeOperator(tag::gradtest_gradtrial{}, 1.0);
prob.addMatrixOperator(opL, 0, 0);
auto opForce = makeOperator(tag::test{}, 1.0, 6);
prob.addVectorOperator(opForce, 0);
// set boundary condition
auto g = [](auto const& x) {
return std::sin(0.5*M_PI*x[1])*std::sin(2*M_PI * (0.25 + x[0]))
+ std::cos(0.5*M_PI*x[1])*std::sin(2*M_PI * (-0.25 + x[0]));
};
prob.addDirichletBC(BoundaryType{1}, 0, 0, g);
typename ElliptProblem::WorldMatrix A{{1.0,0.0}, {0.0,1.0}};
typename ElliptProblem::WorldVector b{1.0, 0.0};
prob.addPeriodicBC(BoundaryType{-1}, A, b);
AdaptInfo adaptInfo("adapt");
prob.assemble(adaptInfo);
prob.solve(adaptInfo);
prob.writeFiles(adaptInfo, true);
}
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
auto b = [](auto const& x){ return x[0] < 1.e-8 || x[1] < 1.e-8 || x[0] > 1.0-1.e-8 || x[1] > 1.0-1.e-8; };
auto setBoundary1 = [](auto& boundaryManager)
{
boundaryManager.setBoxBoundary({1,1,1,1});
};
run(setBoundary1);
auto setBoundary2 = [b](auto& boundaryManager)
{
boundaryManager.setIndicator([b](auto const& x) { return b(x) ? 1 : 0; });
};
run(setBoundary2);
auto setBoundary3 = [b](auto& boundaryManager)
{
boundaryManager.setPredicate(b, 1);
};
run(setBoundary3);
run_periodic();
AMDiS::finalize();
return 0;
}
#include <amdis/AMDiS.hpp>
#include <amdis/AdaptInstationary.hpp>
#include <amdis/LocalOperators.hpp>
#include <amdis/ProblemInstat.hpp>
#include <amdis/ProblemStat.hpp>
#include <amdis/GridFunctions.hpp>
#include <amdis/Marker.hpp>
using namespace AMDiS;
using Grid = Dune::AlbertaGrid<GRIDDIM, WORLDDIM>;
using Param = LagrangeBasis<typename Grid::LeafGridView, 1, 1>;
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
ProblemStat<Param> prob("ch");
prob.initialize(INIT_ALL);
ProblemInstat<Param> probInstat("ch", prob);
probInstat.initialize(INIT_UH_OLD);
AdaptInfo adaptInfo("adapt");
auto invTau = std::ref(probInstat.invTau());
auto phi = prob.solution(0);
auto phiOld = probInstat.oldSolution(0);
prob.addMatrixOperator(zot(invTau), 0, 0);
prob.addVectorOperator(zot(phiOld * invTau), 0);
double M = Parameters::get<double>("parameters->mobility").value_or(1.0);
prob.addMatrixOperator(sot(M), 0, 1);
prob.addMatrixOperator(zot(1.0), 1, 1);
double a = Parameters::get<double>("parameters->a").value_or(1.0);
double b = Parameters::get<double>("parameters->b").value_or(1.0/4.0);
double eps = Parameters::get<double>("parameters->epsilon").value_or(0.02);
prob.addMatrixOperator(sot(-a*eps), 1, 0);
auto opFimpl = zot(-b/eps * (2 + 12*phi*(phi - 1)));
prob.addMatrixOperator(opFimpl, 1, 0);
auto opFexpl = zot(b/eps * pow<2>(phi)*(6 - 8*phi));
prob.addVectorOperator(opFexpl, 1);
int ref_int = Parameters::get<int>("refinement->interface").value_or(10);
int ref_bulk = Parameters::get<int>("refinement->bulk").value_or(2);
auto marker = makeGridFunctionMarker("interface", prob.grid(),
invokeAtQP([ref_int, ref_bulk](double phi) {
return phi > 0.05 && phi < 0.95 ? ref_int : ref_bulk;
}, phi));
prob.addMarker(marker);
double radius1 = Parameters::get<double>("parameters->radius1").value_or(0.15);
double radius2 = Parameters::get<double>("parameters->radius2").value_or(0.25);
for (int i = 0; i < 6; ++i) {
phi << [eps,radius1,radius2](auto const& x) {
using Math::sqr;
return 0.5*(1 - std::tanh((radius1+radius2)*(std::sqrt(sqr(x[0]/radius1) + sqr(x[1]/radius2)) - 1.0)/(4*std::sqrt(2.0)*eps)));
};
prob.markElements(adaptInfo);
prob.adaptGrid(adaptInfo);
}
AdaptInstationary adapt("adapt", prob, adaptInfo, probInstat, adaptInfo);
adapt.adapt();
AMDiS::finalize();
return 0;
}
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