Skip to content
Snippets Groups Projects
Commit bfb293ca authored by Dominic Kempf's avatar Dominic Kempf
Browse files

[!300] Allow grid analysis with custom analyzing executable

Merge branch 'feature/enhanced-analyze-grid' into 'master'

ref:extensions/dune-codegen @rhess You might want to have a look. I changed
the naming scheme of the csv file as well to make sure it is always written to
the build directory.

See merge request [extensions/dune-codegen!300]

  [extensions/dune-codegen!300]: gitlab.dune-project.org/extensions/dune-codegen/merge_requests/300
parents 9b2b116b 63476c3e
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
#ifndef DUNE_CODEGEN_SUMFACT_ANALYZEGRID_HH
#define DUNE_CODEGEN_SUMFACT_ANALYZEGRID_HH
#include<fstream>
#include<set>
#include<string>
#include <dune/pdelab/common/intersectiontype.hh>
......
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