Skip to content
Snippets Groups Projects
Commit a55dfcd1 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Fixing the function adapter.

parent 28b6782f
No related branches found
No related tags found
No related merge requests found
......@@ -32,32 +32,22 @@ if( WITH_TEMPLATE_EXPLICIT_INSTANTIATION STREQUAL "yes" )
AddCompilerFlag( "-DTEMPLATE_EXPLICIT_INSTANTIATION " )
endif()
if( WITH_CUDA STREQUAL "yes" )
AddCompilerFlag( "-DHAVE_NOT_CXX11 -U_GLIBCXX_ATOMIC_BUILTINS -U_GLIBCXX_USE_INT128" )
set( CUDA_LINKER_OPTIONS "-arch sm_20 -shared" )
else()
AddCompilerFlag( "-std=gnu++0x" )
endif()
#####
# Check for CUDA
#
if( NOT WITH_CUDA STREQUAL "no" )
if( WITH_CUDA STREQUAL "yes" )
find_package( CUDA )
if( CUDA_FOUND )
set( BUILD_CUDA TRUE)
set(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF)
set(BUILD_SHARED_LIBS ON)
set(CUDA_SEPARABLE_COMPILATION ON)
set(CUSPARSE_LIBRARY /usr/local/cuda/lib64/libcusparse.so) # TODO: fix this
set(CUSPARSE_LIBRARY /usr/local/cuda/lib64/libcusparse.so) # TODO: fix this
set( CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-DHAVE_CUDA)
#set( CUDA_ADD_EXECUTABLE_OPTIONS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=\"sm_35,compute_35\" )
#set( CUDA_ADD_LIBRARY_OPTIONS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=\"sm_35,compute_35\" -shared )
set( CUDA_ADD_EXECUTABLE_OPTIONS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 )
set( CUDA_ADD_LIBRARY_OPTIONS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -shared )
AddCompilerFlag( "-DHAVE_NOT_CXX11 -U_GLIBCXX_ATOMIC_BUILTINS -U_GLIBCXX_USE_INT128" )
set( CUDA_ADD_EXECUTABLE_OPTIONS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 )
set( CUDA_ADD_LIBRARY_OPTIONS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -shared )
set( CUDA_LINKER_OPTIONS "-arch sm_20 -shared" )
####
# Check for CUSP
#
......@@ -90,9 +80,13 @@ if( NOT WITH_CUDA STREQUAL "no" )
cuda_include_directories( ${CUSPARSE_INCLUDE_DIR} )
endif()
endif( NOT WITH_CUSPARSE STREQUAL "no" )
else( CUDA_FOUND )
AddCompilerFlag( "-std=gnu++0x" )
endif( CUDA_FOUND )
endif( NOT WITH_CUDA STREQUAL "no" )
else( WITH_CUDA STREQUAL "yes" )
AddCompilerFlag( "-std=gnu++0x" )
endif( WITH_CUDA STREQUAL "yes" )
####
# Check for OpenMP
......
......@@ -24,7 +24,6 @@
#include <operators/tnlAnalyticNeumannBoundaryConditions.h>
#include <operators/tnlNeumannBoundaryConditions.h>
#include <functions/tnlConstantFunction.h>
#include <functions/tnlAnalyticFunctionAdapter.h>
#include "heatEquationSolver.h"
//typedef tnlDefaultConfigTag BuildConfig;
......
......@@ -35,10 +35,10 @@ class tnlFunctionAdapter
#ifdef HAVE_CUDA
__device__ __host__
#endif
RealType getValue( const MeshType& mesh,
const FunctionType& function,
const IndexType index,
const RealType& time = 0.0 )
static RealType getValue( const MeshType& mesh,
const FunctionType& function,
const IndexType index,
const RealType& time = 0.0 )
{
return function.getValue( mesh.template getEntityCenter< MeshEntityDimension >,
time );
......@@ -67,10 +67,10 @@ class tnlFunctionAdapter< Mesh, tnlConstantFunction< FunctionDimensions, Real >
#ifdef HAVE_CUDA
__device__ __host__
#endif
RealType getValue( const MeshType& mesh,
const FunctionType& function,
const IndexType index,
const RealType& time = 0.0 )
static RealType getValue( const MeshType& mesh,
const FunctionType& function,
const IndexType index,
const RealType& time = 0.0 )
{
VertexType v;
return function.getValue( v, time );
......@@ -100,11 +100,11 @@ class tnlFunctionAdapter< tnlGrid< Dimensions, Real, Device, Index >, Function >
#ifdef HAVE_CUDA
__device__ __host__
#endif
RealType getValue( const MeshType& mesh,
const FunctionType& function,
const IndexType index,
const CoordinatesType& coordinates,
const RealType& time = 0.0 )
static RealType getValue( const MeshType& mesh,
const FunctionType& function,
const IndexType index,
const CoordinatesType& coordinates,
const RealType& time = 0.0 )
{
return function.getValue( mesh.template getCellCenter( coordinates ),
time );
......@@ -134,11 +134,11 @@ class tnlFunctionAdapter< tnlGrid< Dimensions, Real, Device, Index >,
#ifdef HAVE_CUDA
__device__ __host__
#endif
RealType getValue( const MeshType& mesh,
const FunctionType& function,
const IndexType index,
const CoordinatesType& coordinates,
const RealType& time = 0.0 )
static RealType getValue( const MeshType& mesh,
const FunctionType& function,
const IndexType index,
const CoordinatesType& coordinates,
const RealType& time = 0.0 )
{
VertexType v;
return function.getValue( v, time );
......@@ -163,10 +163,10 @@ class tnlFunctionAdapter< Mesh, tnlVector< Real, Device, Index > >
#ifdef HAVE_CUDA
__device__ __host__
#endif
RealType getValue( const MeshType& mesh,
const FunctionType& function,
const IndexType index,
const RealType& time = 0.0 )
static RealType getValue( const MeshType& mesh,
const FunctionType& function,
const IndexType index,
const RealType& time = 0.0 )
{
return function[ index ];
}
......@@ -206,11 +206,11 @@ class tnlFunctionAdapter< tnlGrid< Dimensions, Real, Device, Index >,
#ifdef HAVE_CUDA
__device__ __host__
#endif
RealType getValue( const MeshType& mesh,
const FunctionType& function,
const IndexType index,
const CoordinatesType& coordinates,
const RealType& time = 0.0 )
static RealType getValue( const MeshType& mesh,
const FunctionType& function,
const IndexType index,
const CoordinatesType& coordinates,
const RealType& time = 0.0 )
{
return function[ index ];
}
......
......@@ -150,10 +150,12 @@ class tnlLinearSystemAssembler
TraversalUserData& userData,
const IndexType index )
{
typedef tnlFunctionAdapter< MeshType, RightHandSide > FunctionAdapter;
userData.b[ index ] = userData.u[ index ] +
userData.tau * userData.rightHandSide.getValue( mesh,
index,
userData.time );
FunctionAdapter::getValue( mesh,
userData.rightHandSide,
index,
userData.time );
typename MatrixType::IndexType rowLength;
userData.differentialOperator.updateLinearSystem( userData.time,
userData.tau,
......@@ -257,12 +259,14 @@ class tnlLinearSystemAssembler< tnlGrid< Dimensions, Real, Device, Index >,
const IndexType index,
const CoordinatesType& coordinates )
{
typedef typename MeshType::VertexType VertexType;
typedef tnlFunctionAdapter< MeshType, RightHandSide > FunctionAdapter;
userData.b[ index ] = userData.u[ index ] +
userData.tau * userData.rightHandSide.template getValue< VertexType >( mesh,
index,
coordinates,
userData.time );
FunctionAdapter::getValue( mesh,
userData.rightHandSide,
index,
coordinates,
userData.time );
typename MatrixType::IndexType rowLength;
userData.differentialOperator.updateLinearSystem( userData.time,
userData.tau,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment