Commit 067e396b authored by Praetorius, Simon's avatar Praetorius, Simon

Merge branch 'feature/amdisproject' into 'develop'

initial version of amdisproject script

See merge request !70
parents 14a25e76 d655c2cc
Pipeline #1775 passed with stage
in 43 minutes and 6 seconds
...@@ -14,12 +14,13 @@ dune_project() ...@@ -14,12 +14,13 @@ dune_project()
dune_enable_all_packages(MODULE_LIBRARIES amdis fmt) 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("src")
add_subdirectory("test") add_subdirectory("test")
add_subdirectory("examples" EXCLUDE_FROM_ALL) add_subdirectory("examples" EXCLUDE_FROM_ALL)
add_subdirectory("doc")
add_subdirectory("cmake/modules")
add_subdirectory("externals")
target_link_libraries(amdis fmt) target_link_libraries(amdis fmt)
......
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(AMDiSCXXFeatures) include(AmdisCXXFeatures)
include(AddAmdisExecutable)
set(BACKEND "ISTL" CACHE STRING "LinearAlgebra backend. One of MTL, EIGEN, ISTL") set(BACKEND "ISTL" CACHE STRING "LinearAlgebra backend. One of MTL, EIGEN, ISTL")
set_property(CACHE BACKEND PROPERTY STRINGS "MTL" "EIGEN" "ISTL") set_property(CACHE BACKEND PROPERTY STRINGS "MTL" "EIGEN" "ISTL")
......
install(FILES
install(FILES AddAmdisExecutable.cmake
AmdisMacros.cmake AmdisMacros.cmake
AMDiSCXXFeatures.cmake AmdisCXXFeatures.cmake
DESTINATION ${DUNE_INSTALL_MODULEDIR}) DESTINATION ${DUNE_INSTALL_MODULEDIR})
...@@ -22,7 +22,7 @@ and \f$ \Gamma \f$ the lower and left edge of the boundary. ...@@ -22,7 +22,7 @@ and \f$ \Gamma \f$ the lower and left edge of the boundary.
using namespace AMDiS; using namespace AMDiS;
// A dune grid type // 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, // A dune-functions globalBasis wrapped in a struct,
// here representing local polynomial shape functions of degree 1 // here representing local polynomial shape functions of degree 1
......
add_custom_target(examples) add_custom_target(examples)
set(projects2d add_amdis_executable(NAME ellipt.2d SOURCES ellipt.cc DIM 2 DOW 2)
"ellipt" add_amdis_executable(NAME ellipt.3d SOURCES ellipt.cc DIM 3 DOW 3)
"heat" add_dependencies(examples
"vecellipt" ellipt.2d
"stokes0" ellipt.3d)
"stokes1"
"stokes3"
"navier_stokes"
"convection_diffusion"
"boundary"
"periodic"
"neumann")
foreach(project ${projects2d}) add_amdis_executable(NAME heat.2d SOURCES heat.cc DIM 2 DOW 2)
add_executable(${project}.2d ${project}.cc) add_amdis_executable(NAME heat.3d SOURCES heat.cc DIM 3 DOW 3)
add_dune_alberta_flags(GRIDDIM 2 WORLDDIM 2 ${project}.2d) add_dependencies(examples
target_link_dune_default_libraries(${project}.2d) heat.2d
target_link_libraries(${project}.2d amdis) heat.3d)
target_compile_definitions(${project}.2d PRIVATE AMDIS_DIM=2 AMDIS_DOW=2)
add_dependencies(examples ${project}.2d)
endforeach()
set(projects3d "ellipt" "heat") 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)
foreach(project ${projects3d}) add_amdis_executable(NAME stokes1.2d SOURCES stokes1.cc DIM 2 DOW 2)
add_executable(${project}.3d ${project}.cc) add_amdis_executable(NAME stokes3.2d SOURCES stokes3.cc DIM 2 DOW 2)
add_dune_alberta_flags(GRIDDIM 3 WORLDDIM 3 ${project}.3d) add_amdis_executable(NAME navier_stokes.2d SOURCES navier_stokes.cc DIM 2 DOW 2)
target_link_dune_default_libraries(${project}.3d) add_amdis_executable(NAME convection_diffusion.2d SOURCES convection_diffusion.cc DIM 2 DOW 2)
target_link_libraries(${project}.3d amdis) add_dependencies(examples
target_compile_definitions(${project}.3d PRIVATE AMDIS_DIM=3 AMDIS_DOW=3) vecellipt.2d
add_dependencies(examples ${project}.3d) stokes0.2d
endforeach() stokes1.2d
stokes3.2d
navier_stokes.2d
convection_diffusion.2d)
\ No newline at end of file
...@@ -17,7 +17,7 @@ using namespace AMDiS; ...@@ -17,7 +17,7 @@ using namespace AMDiS;
using namespace Dune::Indices; using namespace Dune::Indices;
// 1 component with polynomial degree 2 // 1 component with polynomial degree 2
using Param = YaspGridBasis<AMDIS_DIM, 2>; using Param = YaspGridBasis<GRIDDIM, 2>;
using ElliptProblem = ProblemStat<Param>; using ElliptProblem = ProblemStat<Param>;
template <class SetBoundary> template <class SetBoundary>
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
using namespace AMDiS; using namespace AMDiS;
// 1 component with polynomial degree 1 // 1 component with polynomial degree 1
//using Grid = Dune::AlbertaGrid<AMDIS_DIM, AMDIS_DOW>; //using Grid = Dune::AlbertaGrid<GRIDDIM, WORLDDIM>;
using ElliptParam = YaspGridBasis<AMDIS_DIM, 1>; using ElliptParam = YaspGridBasis<GRIDDIM, 1>;
using ElliptProblem = ProblemStat<ElliptParam>; using ElliptProblem = ProblemStat<ElliptParam>;
int main(int argc, char** argv) int main(int argc, char** argv)
......
...@@ -13,14 +13,14 @@ using namespace AMDiS; ...@@ -13,14 +13,14 @@ using namespace AMDiS;
using namespace Dune::Indices; using namespace Dune::Indices;
// 1 component with polynomial degree 1 // 1 component with polynomial degree 1
using Param = YaspGridBasis<AMDIS_DIM, 2>; using Param = YaspGridBasis<GRIDDIM, 2>;
using ElliptProblem = ProblemStat<Param>; using ElliptProblem = ProblemStat<Param>;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
AMDiS::init(argc, argv); AMDiS::init(argc, argv);
int numLevels = AMDIS_DIM == 2 ? 8 : 5; int numLevels = GRIDDIM == 2 ? 8 : 5;
if (argc > 2) if (argc > 2)
numLevels = std::atoi(argv[2]); numLevels = std::atoi(argv[2]);
...@@ -30,7 +30,7 @@ int main(int argc, char** argv) ...@@ -30,7 +30,7 @@ int main(int argc, char** argv)
return -(400.0 * r2 - 20.0 * x.size()) * ux; return -(400.0 * r2 - 20.0 * x.size()) * ux;
}; };
auto g = [](auto const& x){ return std::exp(-10.0 * dot(x,x)); }; auto g = [](auto const& x){ return std::exp(-10.0 * dot(x,x)); };
auto grad_g = [](auto const& x) -> FieldMatrix<double,1,AMDIS_DIM> { auto grad_g = [](auto const& x) -> FieldMatrix<double,1,GRIDDIM> {
return {-20.0 * std::exp(-10.0 * dot(x,x)) * x}; return {-20.0 * std::exp(-10.0 * dot(x,x)) * x};
}; };
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
using namespace AMDiS; using namespace AMDiS;
// 1 component with polynomial degree 1 // 1 component with polynomial degree 1
//using Grid = Dune::AlbertaGrid<AMDIS_DIM, AMDIS_DOW>; //using Grid = Dune::AlbertaGrid<GRIDDIM, WORLDDIM>;
using HeatParam = YaspGridBasis<AMDIS_DIM, 2>; using HeatParam = YaspGridBasis<GRIDDIM, 2>;
using HeatProblem = ProblemStat<HeatParam>; using HeatProblem = ProblemStat<HeatParam>;
using HeatProblemInstat = ProblemInstat<HeatParam>; using HeatProblemInstat = ProblemInstat<HeatParam>;
......
...@@ -18,7 +18,7 @@ using namespace AMDiS; ...@@ -18,7 +18,7 @@ using namespace AMDiS;
struct NavierStokesBasis struct NavierStokesBasis
{ {
using Grid = Dune::YaspGrid<AMDIS_DIM>; using Grid = Dune::YaspGrid<GRIDDIM>;
using GlobalBasis = typename TaylorHoodBasis<Grid::LeafGridView>::GlobalBasis; using GlobalBasis = typename TaylorHoodBasis<Grid::LeafGridView>::GlobalBasis;
}; };
...@@ -70,7 +70,7 @@ int main(int argc, char** argv) ...@@ -70,7 +70,7 @@ int main(int argc, char** argv)
density * trans(gradientAtQP(prob.solution(_v)))); density * trans(gradientAtQP(prob.solution(_v))));
prob.addMatrixOperator(opNonlin1, _v, _v); prob.addMatrixOperator(opNonlin1, _v, _v);
for (std::size_t i = 0; i < AMDIS_DOW; ++i) { for (std::size_t i = 0; i < WORLDDIM; ++i) {
// <(u^old * nabla)u_i, v_i> // <(u^old * nabla)u_i, v_i>
auto opNonlin2 = makeOperator(tag::test_gradtrial{}, auto opNonlin2 = makeOperator(tag::test_gradtrial{},
density * prob.solution(_v)); density * prob.solution(_v));
......
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
#ifdef DOW #ifdef DOW
#undef DOW #undef DOW
#endif #endif
#define DOW AMDIS_DOW #define DOW WORLDDIM
using namespace AMDiS; using namespace AMDiS;
// 3 components: velocity with polynomial degree 2 and pressure with polynomial degree 1 // 3 components: velocity with polynomial degree 2 and pressure with polynomial degree 1
using Grid = Dune::YaspGrid<AMDIS_DIM>; using Grid = Dune::YaspGrid<GRIDDIM>;
using StokesParam = TaylorHoodBasis<Grid::LeafGridView>; using StokesParam = TaylorHoodBasis<Grid::LeafGridView>;
using StokesProblem = ProblemStat<StokesParam>; using StokesProblem = ProblemStat<StokesParam>;
......
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
#ifdef DOW #ifdef DOW
#undef DOW #undef DOW
#endif #endif
#define DOW AMDIS_DOW #define DOW WORLDDIM
using namespace AMDiS; using namespace AMDiS;
// 3 components: velocity with polynomial degree 2 and pressure with polynomial degree 1 // 3 components: velocity with polynomial degree 2 and pressure with polynomial degree 1
using Grid = Dune::YaspGrid<AMDIS_DIM>; using Grid = Dune::YaspGrid<GRIDDIM>;
using StokesParam = TaylorHoodBasis<Grid::LeafGridView>; using StokesParam = TaylorHoodBasis<Grid::LeafGridView>;
using StokesProblem = ProblemStat<StokesParam>; using StokesProblem = ProblemStat<StokesParam>;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
using namespace AMDiS; using namespace AMDiS;
using Grid = Dune::YaspGrid<AMDIS_DIM>; using Grid = Dune::YaspGrid<GRIDDIM>;
using StokesParam = TaylorHoodBasis<Grid::LeafGridView>; using StokesParam = TaylorHoodBasis<Grid::LeafGridView>;
using StokesProblem = ProblemStat<StokesParam>; using StokesProblem = ProblemStat<StokesParam>;
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
using namespace AMDiS; using namespace AMDiS;
// 1 component with polynomial degree 1 // 1 component with polynomial degree 1
//using Grid = Dune::AlbertaGrid<AMDIS_DIM, AMDIS_DOW>; //using Grid = Dune::AlbertaGrid<GRIDDIM, WORLDDIM>;
using ElliptParam = YaspGridBasis<AMDIS_DIM, 2,2>; using ElliptParam = YaspGridBasis<GRIDDIM, 2,2>;
using ElliptProblem = ProblemStat<ElliptParam>; using ElliptProblem = ProblemStat<ElliptParam>;
int main(int argc, char** argv) int main(int argc, char** argv)
......
...@@ -100,14 +100,14 @@ namespace AMDiS ...@@ -100,14 +100,14 @@ namespace AMDiS
/// \brief Functor F is collable with GlobalCoordinates `F(Dune::FieldVector<double,DOW>)` /// \brief Functor F is collable with GlobalCoordinates `F(Dune::FieldVector<double,DOW>)`
#ifndef AMDIS_DOW #ifndef WORLDDIM
template <class F> template <class F>
constexpr bool CallableDomain = constexpr bool CallableDomain =
Definition::CallableDow<F, 1> || Definition::CallableDow<F, 2> || Definition::CallableDow<F, 3>; Definition::CallableDow<F, 1> || Definition::CallableDow<F, 2> || Definition::CallableDow<F, 3>;
#else #else
template <class F> template <class F>
constexpr bool CallableDomain = constexpr bool CallableDomain =
Definition::CallableDow<F, AMDIS_DOW>; Definition::CallableDow<F, WORLDDIM>;
#endif #endif
/// \brief GridFunction GF is a Type that has LocalFunction and provides some /// \brief GridFunction GF is a Type that has LocalFunction and provides some
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment