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

Fix scales launching

parent 9564b028
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Advection operator representation. Advection operator representation.
""" """
from parmepy.constants import debug from parmepy.constants import debug, np, PARMES_INDEX
from parmepy.operator.continuous import Operator from parmepy.operator.continuous import Operator
from parmepy.mpi.topology import Cartesian from parmepy.mpi.topology import Cartesian
...@@ -44,56 +44,77 @@ class Advection(Operator): ...@@ -44,56 +44,77 @@ class Advection(Operator):
""" """
Operator.setUp(self) Operator.setUp(self)
#variables discretization if self.method.find('scales') >= 0:
for v in self.variables: if not self.advectedFields.dimension == 3:
topoId, topo = self.domain.addTopology(
Cartesian(domain=self.domain, dim=self.domain.dimension,
globalMeshResolution=self.resolutions[v]))
df, dfId = v.discretize(topo)
self.discreteFieldId[v] = dfId
if self.discreteOperator is None:
if self.method.find('gpu_2k') >= 0:
if self.advectedFields.vector:
#if not isinstance(self.advectedFields.discreteField[
# self.discreteFieldId[self.advectedFields]],
# ScalarField):
raise ValueError("Not implemented yet. GPU advection" +
" is only for scalar fields")
from parmepy.operator.gpu_particle_advection_2k \
import GPUParticleAdvection2k
self.discreteOperator = \
GPUParticleAdvection2k(self, method=self.method,
**self.config)
elif self.method.find('gpu_1k') >= 0:
if self.advectedFields.vector:
#if not isinstance(self.advectedFields.discreteField[
# self.discreteFieldId[self.advectedFields]],
# ScalarField):
raise ValueError("Not implemented yet. GPU advection" +
" is only for scalar fields")
from parmepy.operator.gpu_particle_advection_1k \
import GPUParticleAdvection1k
self.discreteOperator = \
GPUParticleAdvection1k(self, method=self.method,
**self.config)
elif self.method.find('scales') >= 0:
if not self.advectedFields.dimension == 3:
raise ValueError("Scales Advection not implemented in 2D.") raise ValueError("Scales Advection not implemented in 2D.")
from parmepy.operator.scales_advection \ ## Scales imports for topology creation
import ScalesAdvection from parmepy.operator.scales_advection import ScalesAdvection
self.discreteOperator = \ from parmepy.f2py import scales2py as scales
ScalesAdvection(self, method=self.method, from parmepy.mpi.main_var import main_size
**self.config)
else: ## Extract order form self.method (default p_O2)
print "Using default advection operator" order = 'p_O2'
if self.advectedFields.vector: for o in ['p_O2', 'p_O4', 'p_M6']:
raise ValueError("Not implemented yet. default advection" + if self.method.find(o) >= 0:
" is only for scalar fields") order = o
from parmepy.operator.particle_advection \ ## Scales nbcells equals resolutions - 1
import ParticleAdvection ## resolutions is a number of points given by user
self.discreteOperator = \ nbcells = np.asarray(self.resolutions[self.advectedFields],
ParticleAdvection(self, method=self.method, dtype=PARMES_INDEX) - 1
**self.config) topodims = [1, 1, main_size]
scalesres, scalesoffset, stab_coeff = \
scales.init_advection_solver(nbcells,
self.domain.length,
topodims, order=order)
## Use same topodims as scales to create Cartesian topology
## in order to discretize our fields
for v in self.variables:
topoId, topo = self.domain.addTopology(
Cartesian.withResolution(
domain=self.domain, topoResolution=topodims,
globalMeshResolution=self.resolutions[v]))
df, dfId = v.discretize(topo)
self.discreteFieldId[v] = dfId
self.discreteOperator = ScalesAdvection(self, method=self.method,
**self.config)
else:
#variables discretization
for v in self.variables:
topoId, topo = self.domain.addTopology(
Cartesian(domain=self.domain, dim=self.domain.dimension,
globalMeshResolution=self.resolutions[v]))
df, dfId = v.discretize(topo)
self.discreteFieldId[v] = dfId
if self.discreteOperator is None:
if self.method.find('gpu_2k') >= 0:
if self.advectedFields.vector:
raise ValueError("Not implemented yet. GPU advection" +
" is only for scalar fields")
from parmepy.operator.gpu_particle_advection_2k \
import GPUParticleAdvection2k
self.discreteOperator = \
GPUParticleAdvection2k(self, method=self.method,
**self.config)
elif self.method.find('gpu_1k') >= 0:
if self.advectedFields.vector:
raise ValueError("Not implemented yet. GPU advection" +
" is only for scalar fields")
from parmepy.operator.gpu_particle_advection_1k \
import GPUParticleAdvection1k
self.discreteOperator = \
GPUParticleAdvection1k(self, method=self.method,
**self.config)
else:
print "Using default advection operator"
if self.advectedFields.vector:
raise ValueError("Not implemented yet. default" +
" advection is only for " +
"scalar fields")
from parmepy.operator.particle_advection \
import ParticleAdvection
self.discreteOperator = \
ParticleAdvection(self, method=self.method,
**self.config)
self.discreteOperator.setUp() self.discreteOperator.setUp()
def __str__(self): def __str__(self):
......
...@@ -46,8 +46,6 @@ class ScalesAdvection(DiscreteOperator): ...@@ -46,8 +46,6 @@ class ScalesAdvection(DiscreteOperator):
self.ghosts = self.topology.ghosts self.ghosts = self.topology.ghosts
self.resolution = self.topology.mesh.resolution self.resolution = self.topology.mesh.resolution
self.dim = self.topology.dim self.dim = self.topology.dim
# TODO scales setup
#scales2py.setup('p_O2', True, 'strang')
@debug @debug
def apply(self, t, dt, ite): def apply(self, t, dt, ite):
...@@ -162,8 +160,8 @@ class ScalesAdvection(DiscreteOperator): ...@@ -162,8 +160,8 @@ class ScalesAdvection(DiscreteOperator):
return self.compute_time return self.compute_time
def printComputeTime(self): def printComputeTime(self):
self.timings_info[0] = "\"Advection calculation total\"" self.time_info[0] = "\"Advection calculation total\""
self.timings_info[1] = str(self.total_time) self.time_info[1] = str(self.total_time)
print "Time of the last advection calculation loop :", \ print "Time of the last advection calculation loop :", \
self.compute_time self.compute_time
......
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