CFD-GO / TCLB

TCLB - Templated MPI+CUDA/CPU Lattice Boltzmann code
https://tclb.io
GNU General Public License v3.0
180 stars 71 forks source link

error in tutorial d2q9_shanchen #521

Closed Jing-Lee-tj closed 1 month ago

Jing-Lee-tj commented 2 months ago

Environment: Operating System: macOS 14.5 (23F79) Compiler: CXX = clang++

I followed the steps in the tutorial to create the Dynamic.c and Dynamic.R files, but when I tried to compile, I encountered the following errors:

“  RT         CLB/d2q9_shanchen/Global.cpp
Error in eval(ei, envir) : 
  Reading fields [f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], f[8], rho] in stage 'BaseInit' werent yet written in action 'Init'
error in rtemplate::RTscript(): ”

the related code is just like in the tutorial: for Dynamic.R

# Stages and Actions
# Initialization list
AddStage("BaseInit"     , "Init", save=Fields$group %in% c("f", "density", "neighbour_type_group"), load=DensityAll$group%in% c("f","density"))

# Iteration list
AddStage("BaseIteration", "Run"     ,  save=Fields$group %in% c("f", "density", "neighbour_type_group") , load=DensityAll$group %in% c("f","density","neighbour_type_group"))
AddStage("PsiIteration" , "calcPsi" ,  save=Fields$name=="psi", load=DensityAll$group %in% c("f", "density"))

AddAction("Init"     , c("BaseInit",      "PsiIteration"))
AddAction("Iteration", c("BaseIteration", "PsiIteration"))

for Dynamic.c

CudaDeviceFunction void Init(){
    real_t u[2] = {VelocityX, VelocityY};
    real_t d = Density;
    SetEquilibrium(d,u);

    rho = calcRho(); //  calculate rho from equilibrium distributions.

    neighbour_type=0;

    if ((NodeType & NODE_BOUNDARY) == NODE_Wall) {
        neighbour_type=1;
    } 
}
Jing-Lee-tj commented 1 month ago

I finally discovered that the file extension was missing 'rt'. The issue has been resolved.