Skip to content

Commit

Permalink
Adding cpp tests
Browse files Browse the repository at this point in the history
  • Loading branch information
loumalouomega committed May 27, 2018
1 parent 68c5022 commit ab1d8c6
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 26 deletions.
63 changes: 39 additions & 24 deletions applications/convection_diffusion_application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,70 @@ message("**** configuring KratosConvectionDiffusionApplication ****")
include_directories( ${CMAKE_SOURCE_DIR}/kratos )

## generate variables with the sources
set( KRATOS_CONVECTION_DIFFUSION_APPLICATION_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/convection_diffusion_application.cpp
${CMAKE_CURRENT_SOURCE_DIR}/convection_diffusion_application_variables.cpp

${CMAKE_CURRENT_SOURCE_DIR}/custom_python/kratos_convection_diffusion_python_application.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_python/add_custom_strategies_to_python.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_python/add_custom_utilities_to_python.cpp
set( KRATOS_CONVECTION_DIFFUSION_APPLICATION_CORE_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/convection_diffusion_application.cpp
${CMAKE_CURRENT_SOURCE_DIR}/convection_diffusion_application_variables.cpp

${CMAKE_CURRENT_SOURCE_DIR}/custom_elements/eulerian_conv_diff.cpp

${CMAKE_CURRENT_SOURCE_DIR}/custom_elements/conv_diff_2d.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_elements/conv_diff_3d.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_elements/laplacian_element.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_elements/conv_diff_2d.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_elements/conv_diff_3d.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_elements/laplacian_element.cpp

${CMAKE_CURRENT_SOURCE_DIR}/custom_conditions/thermal_face2D.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_conditions/thermal_face3D.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_conditions/flux_condition.cpp
)

${CMAKE_CURRENT_SOURCE_DIR}/custom_conditions/thermal_face2D.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_conditions/thermal_face3D.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_conditions/flux_condition.cpp
## define python interface sources
set( KRATOS_CONVECTION_DIFFUSION_PYTHON_INTERFACE_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/custom_python/kratos_convection_diffusion_python_application.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_python/add_custom_strategies_to_python.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_python/add_custom_utilities_to_python.cpp
)

## define fluid dynamics test sources
if(${KRATOS_BUILD_TESTING} MATCHES ON)
file(GLOB_RECURSE KRATOS_CONVECTION_DIFFUSION_TESTING_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/cpp_tests/*.cpp)
endif(${KRATOS_BUILD_TESTING} MATCHES ON)

###############################################################
## define library Kratos which defines the basic python interface
# add_library(KratosConvectionDiffusionApplicationStaticLib STATIC ${KRATOS_CONVECTION_DIFFUSION_APPLICATION_SOURCES})
pybind11_add_module(KratosConvectionDiffusionApplication MODULE THIN_LTO ${KRATOS_CONVECTION_DIFFUSION_APPLICATION_SOURCES})
target_link_libraries(KratosConvectionDiffusionApplication PRIVATE KratosCore )
set_target_properties(KratosConvectionDiffusionApplication PROPERTIES PREFIX "")
set_target_properties(KratosConvectionDiffusionApplication PROPERTIES COMPILE_DEFINITIONS "CONVECTION_DIFFUSION_APPLICATION=EXPORT,API")
## ConvectionDiffusionApplication core library (C++ parts)
add_library( KratosConvectionDiffusionCore SHARED ${KRATOS_CONVECTION_DIFFUSION_APPLICATION_CORE_SOURCES} ${KRATOS_CONVECTION_DIFFUSION_TESTING_SOURCES} )
target_link_libraries( KratosConvectionDiffusionCore PUBLIC KratosCore)
set_target_properties( KratosConvectionDiffusionCore PROPERTIES COMPILE_DEFINITIONS "CONVECTION_DIFFUSION_APPLICATION=EXPORT,API")

## FluidDynamicsApplication python module
pybind11_add_module( KratosConvectionDiffusionApplication MODULE THIN_LTO ${KRATOS_CONVECTION_DIFFUSION_PYTHON_INTERFACE_SOURCES} )
target_link_libraries( KratosConvectionDiffusionApplication PRIVATE KratosConvectionDiffusionCore)
set_target_properties( KratosConvectionDiffusionApplication PROPERTIES PREFIX "")

# changing the .dll suffix to .pyd
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set_target_properties(KratosConvectionDiffusionApplication PROPERTIES SUFFIX .pyd)
set_target_properties(KratosConvectionDiffusionApplication PROPERTIES SUFFIX .pyd)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")

# changing the .dylib suffix to .so
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set_target_properties(KratosConvectionDiffusionApplication PROPERTIES SUFFIX .so)
set_target_properties(KratosConvectionDiffusionApplication PROPERTIES SUFFIX .so)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

if(${INSTALL_PYTHON_FILES} MATCHES ON)
get_filename_component (CURRENT_DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python_scripts DESTINATION applications/${CURRENT_DIR_NAME} FILES_MATCHING PATTERN "*.py" PATTERN ".svn" EXCLUDE)
endif(${INSTALL_PYTHON_FILES} MATCHES ON)

# Add Cotire
###############################################################################
if(USE_COTIRE MATCHES ON)
cotire(KratosConvectionDiffusionApplication)
cotire(KratosConvectionDiffusionCore)
cotire(KratosConvectionDiffusionApplication)
endif(USE_COTIRE MATCHES ON)

install(TARGETS KratosConvectionDiffusionApplication DESTINATION libs )
###############################################################################
## installing the resulting libraries

install(TARGETS KratosConvectionDiffusionCore DESTINATION libs )
install(TARGETS KratosConvectionDiffusionApplication DESTINATION libs )

# get_property(inc_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
# message("KratosIncompressibleFluidApplication subdir inc_dirs = ${inc_dirs}")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// KRATOS ___ ___ _ ___ __ ___ ___ ___ ___
// / __/ _ \| \| \ \ / /__| \_ _| __| __|
// | (_| (_) | .` |\ V /___| |) | || _|| _|
// \___\___/|_|\_| \_/ |___/___|_| |_| APPLICATION
//
// License: BSD License
// license: convection_diffusion_application/license.txt
//
// Main authors: Vicente Mataix Ferrandiz
//

// System includes
#include <limits>

// External includes

// Project includes
#include "testing/testing.h"


namespace Kratos
{
namespace Testing
{
/// Tests

/** Example test
*/

KRATOS_TEST_CASE_IN_SUITE(ExampleTest, KratosConvectionDiffusionFastSuite)
{
constexpr double tolerance = 1e-6;

// Check
KRATOS_CHECK(true);
}
} // namespace Testing
} // namespace Kratos.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from KratosMultiphysics import *
from KratosMultiphysics.ConvectionDiffusionApplication import *

def run():
Tester.SetVerbosity(Tester.Verbosity.PROGRESS) # TESTS_OUTPUTS
Tester.RunTestSuite("KratosConvectionDiffusionFastSuite")

if __name__ == '__main__':
run()
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# import Kratos
from KratosMultiphysics import *
from KratosMultiphysics.ConvectionDiffusionApplication import *
import KratosMultiphysics
import KratosMultiphysics.ConvectionDiffusionApplication
import run_cpp_unit_tests

# Import Kratos "wrapper" for unittests
import KratosMultiphysics.KratosUnittest as KratosUnittest
Expand Down Expand Up @@ -46,4 +47,10 @@ def AssembleTestSuites():
return suites

if __name__ == '__main__':
KratosMultiphysics.Logger.PrintInfo("Unittests", "\nRunning cpp unit tests ...")
run_cpp_unit_tests.run()
KratosMultiphysics.Logger.PrintInfo("Unittests", "Finished running cpp unit tests!")

KratosMultiphysics.Logger.PrintInfo("Unittests", "\nRunning python tests ...")
KratosUnittest.runTests(AssembleTestSuites())
KratosMultiphysics.Logger.PrintInfo("Unittests", "Finished python tests!")

0 comments on commit ab1d8c6

Please sign in to comment.