diff --git a/cmake/modules/DuneCodegenMacros.cmake b/cmake/modules/DuneCodegenMacros.cmake index 0bc00246a0194b7dd4bd2c76af3139348bbb9889..69de840ca0d3a02d4e9a6519f94af308330b6859 100644 --- a/cmake/modules/DuneCodegenMacros.cmake +++ b/cmake/modules/DuneCodegenMacros.cmake @@ -45,6 +45,27 @@ # Set this option, if you do not want the target to be automatically # built. This option is forwarded to the builtin command add_executable. # +# .. cmake_param:: ANALYZE_GRID +# :option: +# +# Set this option to enable code generation time grid analysis. +# This is useful to reduce the variety of sum factorization kernels +# in unstructured grids. Note that the grid analysis tool needs to +# be able to construct your grid from the given inifile. If you have +# a custom grid construction method, you can use ANALYZE_GRID_COMMAND +# instead. +# +# .. cmake_param:: ANALYZE_GRID_COMMAND +# :multi: +# :argname command: +# +# Use this to pass a custom grid analysis command. This is necessary +# if you use a custom grid generation methdod. The inifile and the +# outputfile will be appended to this command. You can use the analysis code in +# dune/codegen/sumfact/analyzegrid.hh to write your own tool. +# Specifying this option will automatically set ANALYZE_GRID. +# +# # Add an executable to the project that gets automatically # generated at configure time with the form compiler uf2pdelab. # Regeneration is triggered correctly if the UFL file or the @@ -73,7 +94,7 @@ file(GLOB_RECURSE UFL2PDELAB_SOURCES ${UFL2PDELAB_GLOB_PATTERN}) function(add_generated_executable) set(OPTIONS EXCLUDE_FROM_ALL ANALYZE_GRID) set(SINGLE TARGET SOURCE UFLFILE INIFILE) - set(MULTI FORM_COMPILER_ARGS DEPENDS) + set(MULTI FORM_COMPILER_ARGS DEPENDS ANALYZE_GRID_COMMAND) include(CMakeParseArguments) cmake_parse_arguments(GEN "${OPTIONS}" "${SINGLE}" "${MULTI}" ${ARGN}) @@ -114,6 +135,12 @@ function(add_generated_executable) else() set(GEN_EXCLUDE_FROM_ALL "") endif() + if(GEN_ANALYZE_GRID_COMMAND) + set(GEN_ANALYZE_GRID 1) + else() + dune_module_path(MODULE dune-codegen RESULT codegenbin BUILD_DIR) + set(GEN_ANALYZE_GRID_COMMAND ${codegenbin}/bin/analyzegrid/analyze_grid) + endif() # Process analyze grid option set(ANALYZE_GRID_FILE) @@ -122,10 +149,10 @@ function(add_generated_executable) if(NOT consistent-edge-orientation_FOUND) message(FATAL_ERROR "Asked for grid analysis, but the module consistent-edge-orientation was not found!") endif() - set(ANALYZE_GRID_FILE "${GEN_INIFILE}.csv") + set(ANALYZE_GRID_FILE "${CMAKE_CURRENT_BINARY_DIR}/${GEN_TARGET}.csv") set(ANALYZE_GRID_OPTION "--grid-info=${ANALYZE_GRID_FILE}") add_custom_command(OUTPUT ${ANALYZE_GRID_FILE} - COMMAND ${CMAKE_BINARY_DIR}/bin/analyzegrid/analyze_grid ${GEN_INIFILE} ${ANALYZE_GRID_FILE} + COMMAND ${GEN_ANALYZE_GRID_COMMAND} ${GEN_INIFILE} ${ANALYZE_GRID_FILE} COMMENT "Analyzing the grid for target ${GEN_TARGET}..." ) endif() diff --git a/dune/codegen/sumfact/analyzegrid.hh b/dune/codegen/sumfact/analyzegrid.hh index cc5180b0ed7f1de18e46e1206dce4d417f37e64e..83e13974d3ebb769b5e90b52ea51cc9d2546d8da 100644 --- a/dune/codegen/sumfact/analyzegrid.hh +++ b/dune/codegen/sumfact/analyzegrid.hh @@ -1,6 +1,9 @@ #ifndef DUNE_CODEGEN_SUMFACT_ANALYZEGRID_HH #define DUNE_CODEGEN_SUMFACT_ANALYZEGRID_HH +#include<fstream> +#include<set> +#include<string> #include <dune/pdelab/common/intersectiontype.hh>