-
Notifications
You must be signed in to change notification settings - Fork 10
/
HugeScaleSolver.cu
104 lines (82 loc) · 2.33 KB
/
HugeScaleSolver.cu
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <stdio.h>
#include <string>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
//#include <cuda_fp16.h>
#include "cutil_math.h"
#define _USE_MATH_DEFINES
#include <cmath>
#include <openvdb/openvdb.h>
#include <openvdb/tools/LevelSetSphere.h>
#include <openvdb/tools/SignedFloodFill.h>
#include <openvdb/io/Stream.h>
#include <openvdb/io/Compression.h>
#include <openvdb/tree/ValueAccessor.h>
////////////////////////////////////////////
#include "third_party/openvdb/nanovdb/nanovdb/NanoVDB.h"
#include <windows.h>
#include <ppl.h>
#include <thread>
#include <atomic>
//#include <condition_variable>
//#include "OpenVDB-old/tinyvdbio.h"
#include <time.h>
#include <nanovdb/util/GridBuilder.h>
#include <nanovdb/util/IO.h>
#include <nanovdb/util/CudaDeviceBuffer.h>
#include <nanovdb/util/GridBuilder.h>
#include <nanovdb/util/NanoToOpenVDB.h>
#include <nanovdb/util/OpenToNanoVDB.h>
#include <openvdb/tools/ValueTransformer.h>
////////////////////////////////////////////
#define EXAMPLE__ 2
//#define NOSAVE
//#define WINDOWS7_BUILD
//#define FASTER_KERNELS
#ifndef FASTER_KERNELS
#include "Fluid_Kernels_Fast.cuh"
#else
#include "Fluid_Kernels_Faster.cuh" //new
#endif
#include "Unified_Buffer.cpp"
//#define EXPERIMENTAL
//#include <driver_functions.h>
//#include <driver_types.h>
struct fluid_state_huge {
float3 impulseLoc;
float impulseTemp;
float impulseDensity;
float impulseRadius;
float f_weight;
float cell_size;
float time_step;
int3 dim;
int64_t nelems;
int step;
UnifiedBuffer<float3>* velocity;
UnifiedBuffer<float>* density;
UnifiedBuffer<float>* temperature;
UnifiedBuffer<float>* pressure;
float* diverge;
fluid_state_huge(int3 dims) {
step = 0;
dim = dims;
nelems = dims.x * dims.y * dims.z;
velocity = new UnifiedBuffer<float3>((int)nelems);
density = new UnifiedBuffer<float>((int)nelems);
temperature = new UnifiedBuffer<float>((int)nelems);
pressure = new UnifiedBuffer<float>((int)nelems);
cudaMalloc((void**)&diverge, sizeof(float) * nelems);
//cudaDeviceSynchronize();
}
~fluid_state_huge() {
delete velocity;
delete density;
delete temperature;
delete pressure;
cudaFree(diverge);
}
};