mirror of
https://github.com/smyalygames/FiniteVolumeGPU.git
synced 2025-05-18 14:34:13 +02:00
Updated to python 3, and took a look at WAF
This commit is contained in:
parent
c5dc865c48
commit
e5200cd200
File diff suppressed because one or more lines are too long
@ -25,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#Import packages we need
|
||||
import numpy as np
|
||||
import pyopencl as cl #OpenCL in Python
|
||||
import Common
|
||||
from SWESimulators import Common
|
||||
|
||||
|
||||
|
||||
@ -103,6 +103,8 @@ class CDKLM16:
|
||||
)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return "Chertok, Dudzinski, Kurganov, Lukacova-Medvidova"
|
||||
|
||||
|
||||
"""
|
||||
|
@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#Import packages we need
|
||||
import numpy as np
|
||||
import pyopencl as cl #OpenCL in Python
|
||||
import Common
|
||||
from SWESimulators import Common
|
||||
|
||||
|
||||
|
||||
@ -109,6 +109,8 @@ class CTCS:
|
||||
)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return "Centered in time, centered in space"
|
||||
|
||||
|
||||
"""
|
||||
|
@ -26,7 +26,8 @@ def get_kernel(cl_ctx, kernel_filename, block_width, block_height):
|
||||
return '"' + s.replace(" ", "\\ ") + '"'
|
||||
elif ('NVIDIA' in platform_name):
|
||||
#NVIDIA doesn't like double quoted paths...
|
||||
return "'" + s + "'"
|
||||
#return "'" + s + "'"
|
||||
return s
|
||||
|
||||
module_path = os.path.dirname(os.path.realpath(__file__))
|
||||
module_path_escaped = shellquote(module_path)
|
||||
@ -96,7 +97,7 @@ class OpenCLArray2D:
|
||||
@staticmethod
|
||||
def convert_to_float32(data):
|
||||
if (not np.issubdtype(data.dtype, np.float32) or np.isfortran(data)):
|
||||
print "Converting H0"
|
||||
#print("Converting H0")
|
||||
return data.astype(np.float32, order='C')
|
||||
else:
|
||||
return data
|
||||
|
@ -103,7 +103,7 @@ class CTCSNetCDFWriter:
|
||||
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
print "Closing '" + self.ncfile.filepath() + "'"
|
||||
#print("Closing '" + self.ncfile.filepath() + "'")
|
||||
self.ncfile.close()
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#Import packages we need
|
||||
import numpy as np
|
||||
import pyopencl as cl #OpenCL in Python
|
||||
import Common
|
||||
from SWESimulators import Common
|
||||
|
||||
|
||||
|
||||
@ -111,6 +111,8 @@ class FBL:
|
||||
)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return "Forward Backward Linear"
|
||||
|
||||
|
||||
"""
|
||||
|
@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#Import packages we need
|
||||
import numpy as np
|
||||
import pyopencl as cl #OpenCL in Python
|
||||
import Common
|
||||
from SWESimulators import Common
|
||||
|
||||
|
||||
|
||||
@ -93,6 +93,8 @@ class FORCE:
|
||||
)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return "First order centered"
|
||||
|
||||
|
||||
"""
|
||||
|
@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#Import packages we need
|
||||
import numpy as np
|
||||
import pyopencl as cl #OpenCL in Python
|
||||
import Common
|
||||
from SWESimulators import Common
|
||||
|
||||
|
||||
|
||||
@ -89,6 +89,8 @@ class HLL:
|
||||
)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return "Harten-Lax-van Leer"
|
||||
|
||||
|
||||
"""
|
||||
|
@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#Import packages we need
|
||||
import numpy as np
|
||||
import pyopencl as cl #OpenCL in Python
|
||||
import Common
|
||||
from SWESimulators import Common
|
||||
|
||||
|
||||
|
||||
@ -92,6 +92,8 @@ class HLL2:
|
||||
)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return "Harten-Lax-van Leer contact discontinuity"
|
||||
|
||||
|
||||
"""
|
||||
|
@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#Import packages we need
|
||||
import numpy as np
|
||||
import pyopencl as cl #OpenCL in Python
|
||||
import Common
|
||||
from SWESimulators import Common
|
||||
|
||||
|
||||
|
||||
@ -111,6 +111,8 @@ class KP07:
|
||||
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return "Kurganov-Petrova"
|
||||
|
||||
"""
|
||||
Function which steps n timesteps
|
||||
|
@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#Import packages we need
|
||||
import numpy as np
|
||||
import pyopencl as cl #OpenCL in Python
|
||||
import Common
|
||||
from SWESimulators import Common
|
||||
|
||||
|
||||
|
||||
@ -93,6 +93,8 @@ class KP07_dimsplit:
|
||||
)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return "Kurganov-Petrova dimensionally split"
|
||||
|
||||
|
||||
"""
|
||||
|
@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#Import packages we need
|
||||
import numpy as np
|
||||
import pyopencl as cl #OpenCL in Python
|
||||
import Common
|
||||
from SWESimulators import Common
|
||||
|
||||
|
||||
|
||||
@ -94,6 +94,8 @@ class LxF:
|
||||
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return "Lax Friedrichs"
|
||||
|
||||
"""
|
||||
Function which steps n timesteps
|
||||
|
@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#Import packages we need
|
||||
import numpy as np
|
||||
import pyopencl as cl #OpenCL in Python
|
||||
import Common
|
||||
from SWESimulators import Common
|
||||
|
||||
|
||||
|
||||
|
@ -749,7 +749,7 @@ float WAF_minbee(float r_, float c_) {
|
||||
if (r_ <= 0.0f) {
|
||||
return 1.0f;
|
||||
}
|
||||
else if (r_ <= 1.0f) {
|
||||
else if (r_ >= 0.0f && r_ <= 1.0f) {
|
||||
return 1.0f - (1.0f - fabs(c_))*r_;
|
||||
}
|
||||
else {
|
||||
@ -833,17 +833,13 @@ float3 WAF_1D_flux(const float3 Q_l2, const float3 Q_l1, const float3 Q_r1, cons
|
||||
const float c_3 = S_r * dt_ / dx_;
|
||||
|
||||
// Compute the "upwind change" vectors for the i-3/2 and i+3/2 interfaces
|
||||
// We use h for the tangential direction, and v for the normal direction
|
||||
const float dh = h_r - h_l;
|
||||
const float rh_m = (h_l - h_l2) / dh;
|
||||
const float rh_p = (h_r2 - h_r) / dh;
|
||||
const float rh_m = fmin(fmax( (h_l - h_l2) / (h_r - h_l), -1.0f ), 1.0f);
|
||||
const float rh_p = fmin(fmax( (h_r2 - h_r) / (h_r - h_l), -1.0f ), 1.0f);
|
||||
|
||||
const float dv = v_r - v_l;
|
||||
const float rv_m = (v_l - v_l2) / dv;
|
||||
const float rv_p = (v_r2 - v_r) / dv;
|
||||
const float rv_m = fmin(fmax( (v_l - v_l2) / (v_r - v_l), -1.0f ), 1.0f);
|
||||
const float rv_p = fmin(fmax( (v_r2 - v_r) / (v_r - v_l), -1.0f ), 1.0f);
|
||||
|
||||
// Compute the r parameters for the flux limiter
|
||||
// Note that you use h for h and hu, and v for hv component/equation
|
||||
const float rh_1 = (c_1 > 0.0f) ? rh_m : rh_p;
|
||||
const float rv_1 = (c_1 > 0.0f) ? rv_m : rv_p;
|
||||
|
||||
@ -854,9 +850,10 @@ float3 WAF_1D_flux(const float3 Q_l2, const float3 Q_l1, const float3 Q_r1, cons
|
||||
const float rv_3 = (c_3 > 0.0f) ? rv_m : rv_p;
|
||||
|
||||
// Compute the limiter
|
||||
const float A_1 = sign(c_1)*WAF_minbee(rh_1, c_1);
|
||||
const float A_2 = sign(c_2)*WAF_minbee(rv_2, c_2);
|
||||
const float A_3 = sign(c_3)*WAF_minbee(rh_3, c_3);
|
||||
// We use h for the nonlinear waves, and v for the middle shear wave
|
||||
const float A_1 = c_1;//sign(c_1)*WAF_minbee(rh_1, c_1);
|
||||
const float A_2 = c_2;//sign(c_2)*WAF_minbee(rv_2, c_2); //Middle shear wave
|
||||
const float A_3 = c_3;//sign(c_3)*WAF_minbee(rh_3, c_3);
|
||||
|
||||
//Average the fluxes
|
||||
const float3 flux = 0.5f*( F_1 + F_4 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user