Skip to content
Snippets Groups Projects
Commit fb91821d authored by Jean-Matthieu Etancelin's avatar Jean-Matthieu Etancelin
Browse files

Example update

parent 1ffb5409
No related branches found
No related tags found
No related merge requests found
...@@ -13,7 +13,7 @@ __kernel void initScalar(__global float* scalar, ...@@ -13,7 +13,7 @@ __kernel void initScalar(__global float* scalar,
} }
} }
#define PI (float)M_PI
__kernel void initVelocity(__global float* veloX,__global float* veloY, __kernel void initVelocity(__global float* veloX,__global float* veloY,
//float t, //float t,
float4 minPos, float4 minPos,
...@@ -26,7 +26,7 @@ __kernel void initVelocity(__global float* veloX,__global float* veloY, ...@@ -26,7 +26,7 @@ __kernel void initVelocity(__global float* veloX,__global float* veloY,
float time_term = 1.0;//cos(t*M_PI/3.0f); float time_term = 1.0;//cos(t*M_PI/3.0f);
for(i=gidX; i<WIDTH; i+=WGN) for(i=gidX; i<WIDTH; i+=WGN)
{ {
v = veloX[i+gidY*(WIDTH)] = -sin(i*size.x * M_PI)*sin(i*size.x * M_PI)*sin(gidY*size.y * M_PI * 2)*time_term; v = veloX[i+gidY*(WIDTH)] = -sin(i*size.x * PI)*sin(i*size.x * PI)*sin(gidY*size.y * PI * 2)*time_term;
veloX[i+gidY*(WIDTH)] = v; // = Vx(x,y) veloX[i+gidY*(WIDTH)] = v; // = Vx(x,y)
veloY[i+gidY*(WIDTH)] = -v;// = Vy(y,x) = -Vx(x,y) veloY[i+gidY*(WIDTH)] = -v;// = Vy(y,x) = -Vx(x,y)
} }
......
#!/bin/env python #!/bin/env python
import time import time
import parmepy as pp import parmepy as pp
from parmepy.gpu import PARMES_REAL_GPU, PARMES_DOUBLE_GPU
from parmepy.fields.continuous import Field
from parmepy.fields.analytical import AnalyticalField
from parmepy.operator.advection import Advection
from parmepy.problem.transport import TransportProblem
from parmepy.operator.monitors.printer import Printer
import math import math
import sys import sys
...@@ -27,9 +33,9 @@ def run(nb=257): ...@@ -27,9 +33,9 @@ def run(nb=257):
timeStep = 0.05 timeStep = 0.05
#period = 10. #period = 10.
finalTime = 40*timeStep finalTime = 40 * timeStep
outputFilePrefix = './res_2D/levelSet_2D_' outputFilePrefix = './res_2D/levelSet_2D_'
outputModulo = 0 outputModulo = 40
t0 = time.time() t0 = time.time()
...@@ -37,38 +43,36 @@ def run(nb=257): ...@@ -37,38 +43,36 @@ def run(nb=257):
box = pp.Box(dim, length=boxLength, origin=boxMin) box = pp.Box(dim, length=boxLength, origin=boxMin)
## Fields ## Fields
scal = pp.ContinuousField(domain=box, name='Scalar') scal = Field(domain=box, name='Scalar')
velo = pp.ContinuousField(domain=box, name='Velocity', vector=True) velo = Field(domain=box, name='Velocity', vector=True)
#scal = pp.AnalyticalField(domain=box, formula=scalaire, name='Scalar') #scal = AnalyticalField(domain=box, formula=scalaire,
#velo = pp.AnalyticalField(domain=box, formula=vitesse, name='Velocity', vector=True) # name='Scalar')
#velo = AnalyticalField(domain=box, formula=vitesse,
# name='Velocity', vector=True)
## Operators ## Operators
advec = pp.Transport(velo, scal) advec = Advection(velo, scal)
#velocity = pp.Velocity(velo) #velocity = pp.Velocity(velo)
## Solver creation (discretisation of objects is done in solver initialisation)
topo3D = pp.CartesianTopology(domain=box, resolution=nbElem, dim=dim)
##Problem ##Problem
#pb = pp.Problem(topo3D, [velocity, advec]) pb = TransportProblem(advec,
pb = pp.Problem(topo3D, [advec]) monitors=[Printer(fields=[scal, velo],
frequency=outputModulo,
outputPrefix=outputFilePrefix)])
## Setting solver to Problem ## Setting solver to Problem
pb.setSolver(finalTime, timeStep, 'gpu', pb.setUp(finalTime, timeStep,
src=['./levelSet2D.cl'], advection_config={'resolutions': {velo: nbElem,
io=pp.Printer(fields=[scal, velo], scal: nbElem},
frequency=outputModulo, 'method': 'gpu_1k',
outputPrefix=outputFilePrefix), 'src': ['./levelSet2D.cl'],
precision=pp.constants.PARMES_REAL_GPU 'precision': PARMES_REAL_GPU,
#precision=pp.constants.PARMES_DOUBLE_GPU },
) )
pb.initSolver()
t1 = time.time() t1 = time.time()
## Solve problem ## Solve problem
timings = pb.solve() timings = pb.solve()
tf = time.time() tf = time.time()
print "\n" print "\n"
...@@ -76,10 +80,11 @@ def run(nb=257): ...@@ -76,10 +80,11 @@ def run(nb=257):
print "Init time : ", t1 - t0, "sec (CPU)" print "Init time : ", t1 - t0, "sec (CPU)"
print "Solving time : ", tf - t1, "sec (CPU)" print "Solving time : ", tf - t1, "sec (CPU)"
print "" print ""
return pb.timings_info[0] + "\"Solving time\" \"Init time\" \"Total time\"", pb.timings_info[1] + str(tf - t1) + " " + str(t1 - t0) + " " + str(tf - t0) return (pb.time_info[0] + "\"Solving time\" \"Init time\" \"Total time\"",
pb.time_info[1] + str(tf - t1) + " " + str(t1 - t0) + " " + str(tf - t0))
if __name__ == "__main__": if __name__ == "__main__":
run(4097) run(257)
# timings = {} # timings = {}
# f = open('bench_levelSet2D.dat', 'w') # f = open('bench_levelSet2D.dat', 'w')
# header = "#size dim nPart " # header = "#size dim nPart "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment