Commit cd6c5192 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Fixing Lax-Fridrichs scheme for CUDA.

parent 8110508d
Loading
Loading
Loading
Loading
+0 −24
Original line number Diff line number Diff line
#!/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     
+6 −6
Original line number Diff line number Diff line
@@ -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: