###  CMakeLists.txt ---

#  Author(s): Christophe Prud'homme <christophe.prudhomme@ujf-grenoble.fr>
#       Date: 2010-06-12
#
#  Copyright (C) 2010 Universit Joseph Fourier (Grenoble I)
#
# Distributed under the GPL(GNU Public License):
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
INCLUDE_DIRECTORIES (
  ${FEEL_SOURCE_DIR}/benchmarks/navierstokes/kovasznay/
  )
ENABLE_TESTING()

macro(feel_add_bench_kovasznay examplename)

  set(targetname feel_bench_${examplename})
  set(filename ${examplename}.cpp)
  add_executable(${targetname} ${filename}  stokes.cpp )
  target_link_libraries(${targetname} ${FEEL_LIBRARIES} )
endmacro(feel_add_bench_kovasznay)

foreach( orderp 1 2 )
  math(EXPR orderu1 '${orderp}+1')
  math(EXPR orderu2 '${orderp}+2')
  #foreach( orderu ${orderp} ${orderu1} ${orderu2}  )
  foreach( orderu ${orderp} ${orderu1} )
    foreach( convex Simplex Hypercube )
      set(modulename "kovasznay")
      set(BENCH "${modulename}_${orderu}${orderp}_${convex}" )
      set(targetname feel_bench_${BENCH})
      FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${BENCH}.cpp
      "// this file is auto-generated by Feel++ \n\n
#include<kovasznay.hpp>\n\n
int main( int argc, char** argv )
{
    Feel::Assert::setLog( \"${BENCH}.assert\");
    Feel::Kovasznay<${orderu}, ${orderp}, Feel::${convex}<2> > kov( argc, argv, makeAbout(), makeOptions() );
    kov.run();
}
\n" )

      add_executable(${targetname} ${BENCH}.cpp kovasznay.cpp)
      target_link_libraries(${targetname} ${FEEL_LIBRARIES} )
      set_property(TARGET ${targetname} PROPERTY LABELS benchmarks)
      add_dependencies( benchmarks ${targetname} )

      # test each backend
      foreach( BACKEND ${FEEL_BACKENDS} )
        add_test( ${targetname}_${BENCH}-${BACKEND}-weak
          ${PYTHON_EXECUTABLE}  ${FEEL_SOURCE_DIR}/benchmarks/python/batch_validation.py
          --program=${targetname}
          --mode=0
          --path=${FEEL_BUILD_DIR}/benchmarks/navierstokes/kovasznay/
          --cmdargs="--backend=${BACKEND} --export=0 --weak --penalisation=1 --beta=1 ${${BACKEND}_LU_UMFPACK_SOLVER_OPTIONS}")
        set_property(TEST  ${targetname}_${BENCH}-${BACKEND}-weak PROPERTY LABELS benchmarks)
      endforeach() # backend

    endforeach() # convex
  endforeach() # orderu
endforeach() # orderp

