-
Notifications
You must be signed in to change notification settings - Fork 2
/
PdeFiniteDifference2D.cuh
43 lines (37 loc) · 2.07 KB
/
PdeFiniteDifference2D.cuh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
#include <Common.cuh>
#include <Flags.cuh>
#include <Types.h>
#include "FiniteDifferenceTypes.h"
EXTERN_C
{
/**
* Calculates the space discretization for the advection-diffusion equation
u_t = (xVelocity, yVelocity) * grad(u) + diffusion * laplacian(u)
*/
EXPORT int _MakeSpaceDiscretizer2D(MemoryTile& spaceDiscretizer, const FiniteDifferenceInput2D& input);
EXPORT int _SetBoundaryConditions2D(MemoryTile& solution, const FiniteDifferenceInput2D& input);
/**
* Evolve the solution for nSteps steps using the time discretizer, and sets the boundary conditions
* N.B.:
* * solution is a memory tile, as multi-step solvers require the solution history
* * if provided, workBuffer is a previously allocated buffer used for matrix-vector multiplication
* * the more the steps, the more efficient it will be, as there's less overhead in creating and destroying volatile buffers
*/
EXPORT int _Iterate2D(MemoryTile& solution, const MemoryCube& timeDiscretizer, const FiniteDifferenceInput2D& input, const unsigned nSteps);
EXPORT int _SparseIterate2D(MemoryBuffer& solution, SparseMemoryTile& timeDiscretizer, const FiniteDifferenceInput2D& input, const unsigned nSteps);
}
template <typename T>
GLOBAL void __MakeSpaceDiscretizer2D__(T* RESTRICT spaceDiscretizer,
const T* RESTRICT xGrid, const T* RESTRICT yGrid,
const T* RESTRICT xVelocity, const T* RESTRICT yVelocity,
const T* RESTRICT diffusion,
const SpaceDiscretizerType discretizerType, const T dt, const unsigned nRows, const unsigned nCols);
template <typename T>
GLOBAL void __SetBoundaryConditions2D__(T* RESTRICT solution,
const T leftValue, const T rightValue, const T downValue, const T upValue,
const BoundaryConditionType leftBoundaryConditionType,
const BoundaryConditionType rightBoundaryConditionType,
const BoundaryConditionType downBoundaryConditionType,
const BoundaryConditionType upBoundaryConditionType,
const T* RESTRICT xGrid, const T* RESTRICT yGrid, const unsigned nRows, const unsigned nCols);