Added an example for creating arbitrary projects, see acc/test_solver and src/exampleproject. Note: make sure that dt is calculated adequately and that all parameters are defined properly (see src/exampleproject/simulation.cc)
This commit is contained in:
36
acc/test_solver/stencil_assembly.sas
Normal file
36
acc/test_solver/stencil_assembly.sas
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "stencil_definition.sdh"
|
||||
|
||||
|
||||
//JP NOTE IMPORTANT/////////////////////////////////////////////////////////////////////////////////
|
||||
// These functions are defined here temporarily.
|
||||
//
|
||||
// Currently the built-in functions (derx, derxx etc) are defined in CUDA in integrate.cuh.
|
||||
// This is bad. Instead the built-in functions should be defined in the DSL, and be "includable"
|
||||
// as a standard DSL library, analogous to f.ex. stdlib.h in C.
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Preprocessed Scalar
|
||||
value(in ScalarField vertex)
|
||||
{
|
||||
return vertex[vertexIdx];
|
||||
}
|
||||
|
||||
Preprocessed Vector
|
||||
gradient(in ScalarField vertex)
|
||||
{
|
||||
return (Vector){derx(vertexIdx, vertex), dery(vertexIdx, vertex), derz(vertexIdx, vertex)};
|
||||
}
|
||||
|
||||
Preprocessed Matrix
|
||||
hessian(in ScalarField vertex)
|
||||
{
|
||||
Matrix hessian;
|
||||
|
||||
hessian.row[0] = (Vector){derxx(vertexIdx, vertex), derxy(vertexIdx, vertex),
|
||||
derxz(vertexIdx, vertex)};
|
||||
hessian.row[1] = (Vector){hessian.row[0].y, deryy(vertexIdx, vertex), deryz(vertexIdx, vertex)};
|
||||
hessian.row[2] = (Vector){hessian.row[0].z, hessian.row[1].z, derzz(vertexIdx, vertex)};
|
||||
|
||||
return hessian;
|
||||
}
|
18
acc/test_solver/stencil_definition.sdh
Normal file
18
acc/test_solver/stencil_definition.sdh
Normal file
@@ -0,0 +1,18 @@
|
||||
//JP NOTE IMPORTANT/////////////////////////////////////////////////////////////////////////////////
|
||||
// AC_dsx etc are defined here temporarily (otherwise does not compile).
|
||||
//
|
||||
// These should ultimately be defined in the standard DSL libraries.
|
||||
// See test_solver/stencil_assembly.sas for more info.
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uniform Scalar AC_dsx;// TODO include these from the std lib
|
||||
uniform Scalar AC_dsy;
|
||||
uniform Scalar AC_dsz;
|
||||
uniform Scalar AC_inv_dsx;
|
||||
uniform Scalar AC_inv_dsy;
|
||||
uniform Scalar AC_inv_dsz;
|
||||
uniform Scalar AC_dt;
|
||||
|
||||
uniform ScalarField VTXBUF_A;
|
||||
uniform ScalarField VTXBUF_B;
|
||||
uniform ScalarField VTXBUF_C;
|
18
acc/test_solver/stencil_process.sps
Normal file
18
acc/test_solver/stencil_process.sps
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "stencil_definition.sdh"
|
||||
|
||||
Vector
|
||||
value(in VectorField uu)
|
||||
{
|
||||
return (Vector){value(uu.x), value(uu.y), value(uu.z)};
|
||||
}
|
||||
|
||||
in VectorField uu(VTXBUF_A, VTXBUF_B, VTXBUF_C);
|
||||
out VectorField out_uu(VTXBUF_A, VTXBUF_B, VTXBUF_C);
|
||||
|
||||
Kernel void
|
||||
solve()
|
||||
{
|
||||
Scalar dt = AC_dt;
|
||||
Vector rate_of_change = (Vector){1, 2, 3};
|
||||
out_uu = rk3(out_uu, uu, rate_of_change, dt);
|
||||
}
|
Reference in New Issue
Block a user