From cd6c5192b5d8a256896ae5875ee99c6f78915a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Oberhuber?= <oberhuber.tomas@gmail.com> Date: Wed, 8 Feb 2017 19:01:23 +0100 Subject: [PATCH] Fixing Lax-Fridrichs scheme for CUDA. --- examples/advection/tnl-run-advection1 | 24 ---------------------- src/TNL/Operators/Advection/LaxFridrichs.h | 12 +++++------ 2 files changed, 6 insertions(+), 30 deletions(-) delete mode 100644 examples/advection/tnl-run-advection1 diff --git a/examples/advection/tnl-run-advection1 b/examples/advection/tnl-run-advection1 deleted file mode 100644 index fb5e81faf2..0000000000 --- a/examples/advection/tnl-run-advection1 +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -tnl-grid-setup --dimensions 2 \ - --origin-x 0.0 \ - --origin-y 0.0 \ - --proportions-x 10.0 \ - --proportions-y 10.0 \ - --size-x 500 \ - --size-y 500 \ - -#tnl-init --test-function sin-wave \ -# --output-file init.tnl -./advection --time-discretisation explicit \ - --time-step 1.0e-3 \ - --boundary-conditions-constant 0 \ - --discrete-solver euler \ - --snapshot-period 0.1 \ - --final-time 1.0 \ - --artifical-viscosity 0.2 \ - --begin sin_square \ - --advection-speedX 2.0 \ - --advection-speedY 2.0 \ - -tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/TNL/Operators/Advection/LaxFridrichs.h b/src/TNL/Operators/Advection/LaxFridrichs.h index 2c31965ece..9b939e184c 100644 --- a/src/TNL/Operators/Advection/LaxFridrichs.h +++ b/src/TNL/Operators/Advection/LaxFridrichs.h @@ -99,7 +99,7 @@ class LaxFridrichs< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index, const IndexType& west = neighbourEntities.template getEntityIndex< -1 >(); typedef Functions::FunctionAdapter< MeshType, VelocityFunctionType > FunctionAdapter; return ( 0.5 / this->tau ) * this->artificialViscosity * ( u[ west ]- 2.0 * u[ center ] + u[ east ] ) - - FunctionAdapter::getValue( this->velocityField.getData()[ 0 ], entity, time ) * ( u[ east ] - u[ west ] ) * hxInverse * 0.5; + FunctionAdapter::getValue( this->velocityField.template getData< DeviceType >()[ 0 ], entity, time ) * ( u[ east ] - u[ west ] ) * hxInverse * 0.5; } protected: @@ -196,8 +196,8 @@ class LaxFridrichs< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index, typedef Functions::FunctionAdapter< MeshType, VelocityFunctionType > FunctionAdapter; return ( 0.25 / this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ north ] + u[ south ] - 4.0 * u[ center ] ) - - 0.5 * ( FunctionAdapter::getValue( this->velocityField.getData()[ 0 ], entity, time ) * ( u[ east ] - u[ west ] ) * hxInverse + - FunctionAdapter::getValue( this->velocityField.getData()[ 1 ], entity, time ) * ( u[ north ] - u[ south ] ) * hyInverse ); + 0.5 * ( FunctionAdapter::getValue( this->velocityField.template getData< DeviceType >()[ 0 ], entity, time ) * ( u[ east ] - u[ west ] ) * hxInverse + + FunctionAdapter::getValue( this->velocityField.template getData< DeviceType >()[ 1 ], entity, time ) * ( u[ north ] - u[ south ] ) * hyInverse ); } protected: @@ -296,9 +296,9 @@ class LaxFridrichs< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index, typedef Functions::FunctionAdapter< MeshType, VelocityFunctionType > FunctionAdapter; return ( 0.25 / this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ north ] + u[ south ] + u[ up ] + u[ down ] - 6.0 * u[ center ] ) - - 0.5 * ( FunctionAdapter::getValue( this->velocityField.getData()[ 0 ], entity, time ) * ( u[ east ] - u[ west ] ) * hxInverse + - FunctionAdapter::getValue( this->velocityField.getData()[ 1 ], entity, time ) * ( u[ north ] - u[ south ] ) * hyInverse + - FunctionAdapter::getValue( this->velocityField.getData()[ 2 ], entity, time ) * ( u[ up ] - u[ down ] ) * hzInverse ); + 0.5 * ( FunctionAdapter::getValue( this->velocityField.template getData< DeviceType >()[ 0 ], entity, time ) * ( u[ east ] - u[ west ] ) * hxInverse + + FunctionAdapter::getValue( this->velocityField.template getData< DeviceType >()[ 1 ], entity, time ) * ( u[ north ] - u[ south ] ) * hyInverse + + FunctionAdapter::getValue( this->velocityField.template getData< DeviceType >()[ 2 ], entity, time ) * ( u[ up ] - u[ down ] ) * hzInverse ); } protected: -- GitLab