Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small mods to develop #490

Merged
merged 12 commits into from
Jan 14, 2024
4 changes: 1 addition & 3 deletions example/heat/d2q9q9_Hot_Karman_Re100_Pr5.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

<!-- To be used with d2q9q9_cm_cht_OutFlowNeumann_AVG_IBB -->

<?xml version="1.0"?>
<!-- To be used with d2q9q9_cm_cht_OutFlowNeumann_AVG_IBB -->
<CLBConfig version="2.0" output="output/d2q9q9_HotKarman_Re100_Pr5/">
<Geometry nx="512" ny="100" >
<!-- <CM_HIGHER> <Box/> </CM_HIGHER> -->
Expand Down
4 changes: 1 addition & 3 deletions example/heat/d2q9q9_lid_driven_cavity.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

<!-- To be used with d2q9q9_cm_cht -->

<?xml version="1.0"?>
<!-- To be used with d2q9q9_cm_cht -->
<CLBConfig version="2.0" output="output/d2q9q9_LidDrivenCavity/">
<Geometry nx="256" ny="256" >
<CM_HIGHER> <Box/> </CM_HIGHER>
Expand Down
4 changes: 1 addition & 3 deletions example/heat/d3q27q27_Hot_Karman_Re100_Pr5.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

<!-- To be used with d3q27q27_cm_cht_OutFlowNeumann_AVG_IBB -->

<?xml version="1.0"?>
<!-- To be used with d3q27q27_cm_cht_OutFlowNeumann_AVG_IBB -->
<CLBConfig version="2.0" output="output/d3q27q27_HotKarman_Re100_Pr5/">
<Geometry nx="512" ny="100" nz="3" >
<BGK> <Box/> </BGK>
Expand Down
4 changes: 1 addition & 3 deletions example/heat/d3q27q7_Hot_Karman_Re100_Pr5.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

<!-- To be used with d3q27q27_cm_cht_OutFlowNeumann_AVG_IBB -->

<?xml version="1.0"?>
<!-- To be used with d3q27q27_cm_cht_OutFlowNeumann_AVG_IBB -->
<CLBConfig version="2.0" output="output/d3q27q7_HotKarman_Re100_Pr5/">
<Geometry nx="512" ny="100" nz="3" >
<CM> <Box/> </CM>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,3 @@ for (i in 1:nrow(tab)) {
detach()
}
?>


7 changes: 0 additions & 7 deletions src/Dynamics.h.Rt

This file was deleted.

1 change: 1 addition & 0 deletions src/Handlers.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef Handler_H
#define Handler_H

#include "Global.h"
#include "Handlers/vHandler.h"
#include "Handlers/NullHandler.h"
#include "HandlerFactory.h"
Expand Down
1 change: 0 additions & 1 deletion src/Handlers/vHandler.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef VHANDLER_H
#define VHANDLER_H

#include "../Consts.h"
#include "../pugixml.hpp"
#include <math.h>
#define HANDLER_CALLBACK 0x01
Expand Down
2 changes: 2 additions & 0 deletions src/Lattice.hpp.Rt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ c_header();
#include <utility>

#include "Global.h"
#include "CartLattice.h"


template <typename LatticeType>
struct Lattice : public LatticeType {
Expand Down
15 changes: 7 additions & 8 deletions src/Node.hpp.Rt
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,17 @@ template < class LA > struct Node < LA, <?%s T1 ?>, <?%s T2 ?>, <?%s T3 ?> > {
CudaDeviceFunction void inline Glob() {
glob.Glob();
}
<?R
if (! tp$adjoint) { ?>
#include "Dynamics.h" <?R
} else { ?>
#undef DYNAMICS_B_LOADED <?R
} ?>
// #include "Dynamics.h"
<?R for (n in c_table_decl(unique(c(Density$name,Fields$name)))) { ?>
real_t <?%s n ?>;
<?R } ?>

#ifdef CALC_DOUBLE_PRECISION
#include "Dynamics.c"
#else
#include "Dynamics_sp.c"
#endif <?R
#endif

<?R
if (tp$adjoint) {
if (tp$Globals == "Globs") { ?>
#include "DynamicsS_b.c" <?R
Expand Down
8 changes: 4 additions & 4 deletions src/RemoteForceInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#define output printf
#define RFI_DEF_output
#endif
#ifndef STRING_LEN
#define STRING_LEN 1024*4
#ifndef RFI_STRING_LEN
#define RFI_STRING_LEN 1024*4
#endif

namespace rfi {
Expand Down Expand Up @@ -148,7 +148,7 @@ void RemoteForceInterface < TYPE, ROT, STORAGE, rfi_real_t, tab_allocator >::all
sizesStatsNum = 0;
waitStats.resize(12, 0);
waitStatsNum.resize(12, 0);
char fn[STRING_LEN];
char fn[RFI_STRING_LEN];

if (stats_prefix == "") stats_prefix = "RFI";
sprintf(fn, "%s_%s_P%02d.txt", stats_prefix.c_str(), name.c_str(), rank);
Expand Down Expand Up @@ -184,7 +184,7 @@ void RemoteForceInterface < TYPE, ROT, STORAGE, rfi_real_t, tab_allocator >::sav
template < rfi_type_t TYPE, rfi_rot_t ROT, rfi_storage_t STORAGE, typename rfi_real_t, typename tab_allocator >
void RemoteForceInterface < TYPE, ROT, STORAGE, rfi_real_t, tab_allocator >::printStats() {
if (sizesStatsNum == stats_iter) {
char fn[STRING_LEN];
char fn[RFI_STRING_LEN];
sprintf(fn, "RFI_stats_%s_%d.txt", name.c_str(), rank);
FILE * f = fopen(stats_filename.c_str(), "a");
fprintf(f,"%ld", sizesStatsNum);
Expand Down
2 changes: 1 addition & 1 deletion src/SUMMARY.Rt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?R
plot.access=TRUE
plot_access=TRUE
source("conf.R")
save.image(file="SUMMARY.Rdata")
options(width=4000)
Expand Down
3 changes: 3 additions & 0 deletions src/ZoneSettings.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include "Consts.h"
#include "Global.h"
#include "cross.h"
#include "types.h"
#include <stdlib.h>
#include <assert.h>
#include <vector>

#ifndef ZONESETTINGS_H
#define ZONESETTINGS_H
Expand Down
41 changes: 18 additions & 23 deletions src/conf.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ if (!exists("SYMALGEBRA")) SYMALGEBRA=FALSE
if (!exists("NEED_OFFSETS")) NEED_OFFSETS=TRUE
if (!exists("X_MOD")) X_MOD=0
if (!exists("CPU_LAYOUT")) CPU_LAYOUT=FALSE
if (!exists("plot.access")) plot.access=FALSE
if (!exists("plot_access")) plot_access=FALSE

memory_arr_cpu = CPU_LAYOUT
memory_arr_mod = X_MOD

# SYMALGEBRA=TRUE

options(stringsAsFactors=FALSE)
format.list = function(x,...) sapply(x, class)

if (! SYMALGEBRA) {
library(polyAlgebra,quietly=TRUE,warn.conflicts=FALSE)
Expand Down Expand Up @@ -63,7 +62,6 @@ SetOptions = function(...) {
}

AddDensity = function(name, dx=0, dy=0, dz=0, comment="", field=name, adjoint=F, group="", parameter=F, average=F, default=NA, sym=c("","",""), shift=NULL, ...) {
if (any((parameter) && (dx != 0) && (dy != 0) && (dz != 0))) stop("Parameters cannot be streamed (AddDensity)");
if (missing(name)) stop("Have to supply name in AddDensity!")
if (missing(group)) group = name
if (length(sym) != 3) stop("sym provided to AddDensity have to be a vector of length 3");
Expand All @@ -85,6 +83,7 @@ AddDensity = function(name, dx=0, dy=0, dz=0, comment="", field=name, adjoint=F,
symY=sym[2],
symZ=sym[3]
)
if (any((dd$parameter) & (dd$dx != 0) & (dd$dy != 0) & (dd$dz != 0))) stop("Parameters cannot be streamed (AddDensity)")
DensityAll <<- rbind(DensityAll,dd)
for (d in rows(dd)) {
AddField(name=d$field,
Expand Down Expand Up @@ -265,7 +264,7 @@ AddNodeType = function(name, group) {


## Description
read.a.file = function(file) {
read_a_file = function(file) {
pot = c(file, paste(include.dir,file,sep="/"))
sel = sapply(pot,file.exists)
sel = which(sel)
Expand All @@ -281,7 +280,7 @@ AddDescription = function(short, long) {
stop("Adding descripition twice!")
}
if (missing(long)) {
long = read.a.file("Description.md")
long = read_a_file("Description.md")
if (is.null(long)) long = short
}
Description <<- list(
Expand Down Expand Up @@ -430,7 +429,7 @@ if (any(duplicated(Stages$name))) stop ("Duplicated Stages' names\n")

row.names(Stages)=Stages$name

if (plot.access) {
if (plot_access) {

pa_fi = Fields
pa_fi$index = seq_len(nrow(pa_fi))
Expand Down Expand Up @@ -475,7 +474,7 @@ for (a in rows(Actions)) {
bufout = rep(FALSE, nrow(Fields))
first = TRUE
pa_si = 0
if (plot.access) {
if (plot_access) {
pa_s = length(a$stages)
plot(NA,xlim=c(-0.5,pa_ws*pa_s+0.5),ylim=pa_frange,xaxt='n',yaxt='n',xlab="",ylab="",main=a$name,asp=1)
legend(par('usr')[2], par('usr')[3], xpd=TRUE, yjust=1, xjust=1, ncol=2, cex=0.7, bty = "n", bg="white",
Expand All @@ -498,7 +497,7 @@ for (a in rows(Actions)) {
sl = DensityAll[,s$loadtag]
sl = Fields$name %in% unique(DensityAll$field[sl])
sr[(!bufin) & is.na(sr)] = FALSE
if (plot.access) {
if (plot_access) {
pa_col = rep("white",nrow(pa_fi))
pa_col[bufout] = "darkgreen"
pa_col[ss] = "green"
Expand Down Expand Up @@ -540,7 +539,7 @@ for (a in rows(Actions)) {
}
}

if (plot.access) {
if (plot_access) {
dev.off()
}

Expand All @@ -559,9 +558,9 @@ if (nrow(NodeTypes) > 0) {
NodeTypes = do.call(rbind, by(NodeTypes,NodeTypes$group,function(tab) {
n = nrow(tab)
l = ceiling(log2(n+1))
tab$index = 1:n
tab$index = seq_len(n)
tab$Index = paste("NODE",tab$name,sep="_")
tab$value = NodeShift*(1:n)
tab$value = NodeShift*(seq_len(n))
tab$mask = NodeShift*((2^l)-1)
tab$max = n
tab$bits = l
Expand Down Expand Up @@ -816,7 +815,7 @@ for (n in c("Settings","DensityAll","Density","DensityAD","Globals","Quantities"
if (is.null(v)) v = data.frame()
Consts = rbind(Consts, data.frame(name=toupper(n), value=nrow(v)));
if (nrow(v) > 0) {
v$index = 1:nrow(v)-1
v$index = seq_len(nrow(v))-1
v$nicename = gsub("[][ ]","",v$name)
v$Index = paste(" ",toupper(n), "_", v$nicename, " ", sep="")
row.names(v) = v$name
Expand Down Expand Up @@ -852,15 +851,11 @@ if (is.power.of.two(memory_arr_mod)) stop("memory_arr_mod has to be a power of 2
offsets = function() {
mw = PV(c("nx","ny","nz"))
one = PV(c(1L,1L,1L))
bp = expand.grid(x=1:3,y=1:3,z=1:3)
p = expand.grid(x=1:3*3-2,y=1:3*3-1,z=1:3*3)
tab1 = c(1,-1,0)
tab2 = c(0,-1,1)
get_tab = cbind(tab1[bp$x],tab1[bp$y],tab1[bp$z],tab2[bp$x],tab2[bp$y],tab2[bp$z])
sizes = c(one,mw,one)
size = sizes[p$x] * sizes[p$y] * sizes[p$z]
MarginNSize = PV(rep(0L,27))
calc.functions = function(f) {
calc_functions = function(f) {
mins = c(f$minx,f$miny,f$minz)
maxs = c(f$maxx,f$maxy,f$maxz)
tab1 = c(0,0,0,ifelse(mins == maxs & maxs > 0,-1,0),ifelse(maxs > 0,1,0))
Expand All @@ -874,7 +869,7 @@ offsets = function() {
nsize = nsizes[p$x] * nsizes[p$y] * nsizes[p$z]
mSize = MarginNSize
MarginNSize <<- mSize + nsize
offset.p = function(positions) {
offset_p = function(positions) {
positions[c(mins > -2, c(FALSE,FALSE,FALSE), maxs < 2)] = PV(0L)
if (memory_arr_cpu) {
offset = (positions[p$x] +
Expand Down Expand Up @@ -927,13 +922,13 @@ offsets = function() {
mins = PV(as.integer(mins))
get_tab = cbind(tab1[p$x],tab1[p$y],tab1[p$z],tab2[p$x],tab2[p$y],tab2[p$z])
get_sel = tab3[p$x] & tab3[p$y] & tab3[p$z]
offset = offset.p(c(w+dw - mins,w+dw,w+dw - mw))
offset = offset_p(c(w+dw - mins,w+dw,w+dw - mw))
cond = c(w+dw,mw-w-dw-one)
list(Offset=offset,Conditions=cond,Table=get_tab,Selection=get_sel)
},
put_offsets =
function(w) {
offset = offset.p(c(w - mw - PV(as.integer(mins)),w,w))
offset = offset_p(c(w - mw - PV(as.integer(mins)),w,w))
cond = c(w+PV(as.integer(-maxs)),mw-w+PV(as.integer(mins))-one)
list(Offset=offset,Conditions=cond,Table=put_tab,Selection=put_sel)
},
Expand All @@ -944,8 +939,8 @@ offsets = function() {
ret$get_offsets = rep(list(NULL),nrow(ret))
ret$put_offsets = rep(list(NULL),nrow(ret))
ret$fOffset = rep(list(NULL),nrow(ret))
for (idx in 1:nrow(ret)) {
fun = calc.functions(ret[idx,])
for (idx in seq_len(nrow(ret))) {
fun = calc_functions(ret[idx,])
ret$get_offsets[[idx]] = fun$get_offsets
ret$put_offsets[[idx]] = fun$put_offsets
ret$fOffset[[idx]] = fun$fOffset
Expand All @@ -956,7 +951,7 @@ offsets = function() {
if (NEED_OFFSETS) {
ret = offsets()
Fields = ret$Fields
for (i in 1:length(Margin)) {
for (i in seq_along(Margin)) {
Margin[[i]]$Size = ret$MarginSizes[i]
if (! is.zero(Margin[[i]]$Size)) {
Margin[[i]]$size = 1L;
Expand Down
1 change: 0 additions & 1 deletion src/cuda.cu.Rt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Here is nearly all of the CUDA C code. It includes:
CartLatticeContainer.hpp
Dynamics.c
Dynamics.h
Dynamics_b.c (adjoint)
Dynamics_adj.c (adjoint)
ADTools.c (adjoint)
Expand Down
6 changes: 5 additions & 1 deletion src/gpu_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#ifndef __GPU_ANIM_H__
#define __GPU_ANIM_H__

#include "../config.h"

#ifdef GRAPHICS

#include "gl_helper.h"

#include <cuda.h>
Expand Down Expand Up @@ -182,6 +186,6 @@ struct GPUAnimBitmap {
}
};


#endif // GRAPHICS
#endif // __GPU_ANIM_H__

2 changes: 1 addition & 1 deletion src/makefile.main.Rt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SOURCE_PLAN+=main.cpp
SOURCE_PLAN+=Global.h gpu_anim.h LatticeData.hpp LatticeBase.hpp LatticeBase.cpp cross.h cross.hpp StorageConversions.h
SOURCE_PLAN+=CartLattice.h Region.h vtkLattice.h vtkOutput.h CartLatticeContainer.h CartLatticeLauncher.h CartLatticeLauncher.hpp CartConnectivity.hpp
SOURCE_PLAN+=ArbLatticeAccess.hpp ArbLatticeContainer.hpp ArbLatticeLauncher.h ArbLatticeLauncher.hpp Lattice.hpp
SOURCE_PLAN+=gl_helper.h Dynamics.h types.h Consts.h Solver.h pugixml.hpp pugiconfig.hpp Node.hpp
SOURCE_PLAN+=gl_helper.h types.h Consts.h Solver.h pugixml.hpp pugiconfig.hpp Node.hpp
SOURCE_PLAN+=Geometry.h utils.h utils.cpp unit.h ZoneSettings.h SyntheticTurbulence.h Sampler.h spline.h TCLBForceGroupCommon.h
SOURCE_PLAN+=RemoteForceInterface.cpp RemoteForceInterface.h RemoteForceInterface.hpp
SOURCE_PLAN+=TCLBForceGroupCommon.h MPMD.hpp empty.cpp Particle.hpp lammps.cpp
Expand Down
2 changes: 2 additions & 0 deletions src/range_int.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef RANGE_INT_HPP
#define RANGE_INT_HPP

#include "cross.h"

template <int A, int B=0, int C=A, int D=B>
struct range_int {
const int val;
Expand Down
Loading