Skip to content
Snippets Groups Projects
Commit 479d91a4 authored by Chloe Mimeau's avatar Chloe Mimeau
Browse files

updates for TG problem

parent 19f96cfa
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
import parmepy as pp
from parmepy.f2py import fftw2py
import numpy as np
from parmepy.mpi.topology import Cartesian
from parmepy.operator.advection import Advection
from parmepy.operator.stretching import Stretching
from parmepy.operator.poisson import Poisson
......@@ -11,8 +12,8 @@ from parmepy.operator.diffusion import Diffusion
from parmepy.operator.redistribute import Redistribute
from parmepy.problem.navier_stokes import NSProblem
from parmepy.operator.monitors.energy_enstrophy import Energy_enstrophy
from dataTG import dim, nb, pi, ADVECTION_METHOD, VISCOSITY, WITH_PROJ,\
OUTPUT_FREQ, FILENAME, simu
from dataTG import dim, nb, pi, NBGHOSTS, ADVECTION_METHOD, VISCOSITY, \
WITH_PROJ, OUTPUT_FREQ, FILENAME, simu
## ----------- A 3d problem -----------
......@@ -46,6 +47,11 @@ velo = pp.Field(domain=box, formula=computeVel,
vorti = pp.Field(domain=box, formula=computeVort,
name='Vorticity', isVector=True)
## Usual Cartesian topology definition
ghosts = np.ones((box.dimension)) * NBGHOSTS
topo = Cartesian(box, box.dimension, nbElem,
ghosts=ghosts)
## Operators
advec = Advection(velo, vorti,
resolutions={velo: nbElem,
......@@ -55,7 +61,8 @@ advec = Advection(velo, vorti,
stretch = Stretching(velo, vorti,
resolutions={velo: nbElem,
vorti: nbElem}
vorti: nbElem},
topo=topo
)
diffusion = Diffusion(vorti,
......@@ -69,24 +76,27 @@ poisson = Poisson(velo, vorti,
projection=WITH_PROJ)
## Diagnostics related to the problem
energy = Energy_enstrophy(velo, vorti,
resolutions={velo: nbElem,
vorti: nbElem},
topo=topo,
viscosity=VISCOSITY,
frequency=OUTPUT_FREQ,
prefix=FILENAME)
distrAdvStr = Redistribute([vorti, velo], advec, stretch)
distrStrPoiss = Redistribute([vorti], stretch, poisson)
distrPoissStretch = Redistribute([vorti, velo], poisson, stretch)
## Define the problem to solve
pb = NSProblem(operators=[advec, distrAdvStr, stretch, distrStrPoiss,
diffusion, poisson],
diffusion, poisson, distrPoissStretch],
simulation=simu, monitors=[energy])
## Setting solver to Problem
pb.setUp()
print 'all topologies', box.topologies
## Solve problem
#poisson.apply(simu)
......
......@@ -3,10 +3,12 @@
# problem dimension
dim = 3
# resolution
nb = 33
nb = 129
# pi constant
import math
pi = math.pi
# number of ghosts in usual cartesian topo
NBGHOSTS = 2
# Advection method
ADVECTION_METHOD = 'scales_p_M6'
#
......
......@@ -66,8 +66,8 @@ class Energy_enstrophy(Monitoring):
self._isUpToDate = True
spaceStep = [self.topovel.mesh.spaceStep,
self.topovort.mesh.spaceStep]
spaceStep = [self.topovel.mesh.space_step,
self.topovort.mesh.space_step]
length = self.topo.domain.length
self.coeffEnergy = 0.5 * (np.prod(spaceStep[0]) /
......@@ -103,22 +103,19 @@ class Energy_enstrophy(Monitoring):
for i in xrange(nbc)])
# Collective communications
topovelo = self.velo.topology
energy = topovelo.comm.reduce(energy, PARMES_MPI_REAL,
op=MPI.SUM, root=0)
energyBuff1 = topovelo.comm.reduce(self.buffer_1, PARMES_MPI_REAL,
op=MPI.SUM, root=0)
energyBuff2 = topovelo.comm.reduce(self.buffer_2, PARMES_MPI_REAL,
op=MPI.SUM, root=0)
topovort = self.vort.topology
enstrophy = topovort.comm.reduce(enstrophy, PARMES_MPI_REAL,
op=MPI.SUM, root=0)
energy = self.topovel.comm.reduce(energy, PARMES_MPI_REAL,
op=MPI.SUM, root=0)
energyBuff1 = self.topovel.comm.reduce(self._buffer_1, PARMES_MPI_REAL,
op=MPI.SUM, root=0)
energyBuff2 = self.topovel.comm.reduce(self._buffer_2, PARMES_MPI_REAL,
op=MPI.SUM, root=0)
enstrophy = self.topovort.comm.reduce(enstrophy, PARMES_MPI_REAL,
op=MPI.SUM, root=0)
# Update buffers
self.buffer_2 = self.buffer_1
self.buffer_1 = energy
self._buffer_2 = self._buffer_1
self._buffer_1 = energy
# Effective viscosity computation
......
......@@ -5,11 +5,11 @@
MultiPhase Rot Grad P
"""
from parmepy.operator.continuous import Operator
from parmepy.operator.discrete.multiphase import Pressure_d
from parmepy.operator.discrete.multiphase import Baroclinic_d
from parmepy.constants import debug
class Pressure(Operator):
class Baroclinic(Operator):
"""
Pressure operator representation
"""
......
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