added timing to gaussian filter
This commit is contained in:
parent
928f3bcde9
commit
9bfc4d6fc1
|
|
@ -304,6 +304,7 @@ class PPP:
|
||||||
def gaussian_filter(self,key,sigma,truncate=4.0,key_out=None,iterate=False):
|
def gaussian_filter(self,key,sigma,truncate=4.0,key_out=None,iterate=False):
|
||||||
'''Applies a gaussian filter to a field as in-place operation. Sigma is the std of the filter in terms of grid width.'''
|
'''Applies a gaussian filter to a field as in-place operation. Sigma is the std of the filter in terms of grid width.'''
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from mpi4py import MPI
|
||||||
if key_out is None:
|
if key_out is None:
|
||||||
key_out = key
|
key_out = key
|
||||||
if key!=key_out:
|
if key!=key_out:
|
||||||
|
|
@ -328,7 +329,8 @@ class PPP:
|
||||||
"increase number of ghost cells. {}".format(radius)
|
"increase number of ghost cells. {}".format(radius)
|
||||||
parprint('Gaussian filter: iterations={}, stencil radius={}'.format(niter,radius))
|
parprint('Gaussian filter: iterations={}, stencil radius={}'.format(niter,radius))
|
||||||
for iiter in range(niter):
|
for iiter in range(niter):
|
||||||
parprint('Iter #{:d}'.format(iiter))
|
parprint('Iter #{:d}: '.format(iiter),end='')
|
||||||
|
tbeg = MPI.Wtime()
|
||||||
# Filter field: if key_out is None, perform operation inplace
|
# Filter field: if key_out is None, perform operation inplace
|
||||||
self.field[key_out] = self.field[key].gaussian_filter(sigma,
|
self.field[key_out] = self.field[key].gaussian_filter(sigma,
|
||||||
truncate=truncate,only_keep_interior=False)
|
truncate=truncate,only_keep_interior=False)
|
||||||
|
|
@ -337,6 +339,7 @@ class PPP:
|
||||||
self.impose_boundary_conditions(key_out)
|
self.impose_boundary_conditions(key_out)
|
||||||
# Iterate inplace from now on
|
# Iterate inplace from now on
|
||||||
key = key_out
|
key = key_out
|
||||||
|
parprint('{:g} sec'.format(MPI.Wtime()-tbeg))
|
||||||
|
|
||||||
def broadcast(self,key,operation,arg,key_out=None):
|
def broadcast(self,key,operation,arg,key_out=None):
|
||||||
'''Broadcasts an operation involving a scalar or matrix on
|
'''Broadcasts an operation involving a scalar or matrix on
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue