From 06db1f52945bdeec3bd936550c6cecdbf94e2972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franck=20P=C3=A9rignon?= <franck.perignon@imag.fr> Date: Wed, 5 Mar 2014 16:18:57 +0000 Subject: [PATCH] Update NSDebug example + move topo stuff in monitor.setup for hybrid computation --- Examples/NSDebug.py | 24 +++++++++---------- Examples/postNSBluff.py | 2 +- .../hysop/operator/monitors/compute_forces.py | 21 ++++++++-------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Examples/NSDebug.py b/Examples/NSDebug.py index 7ed53df66..2047a42e1 100755 --- a/Examples/NSDebug.py +++ b/Examples/NSDebug.py @@ -152,7 +152,7 @@ for ope in distr.values(): ope.discretize() # === Simulation setup === -simu = Simulation(tinit=0.0, tend=0.2, timeStep=0.005, iterMax=1000000) +simu = Simulation(tinit=0.0, tend=1, nbIter=10, iterMax=1000000) ## === Monitoring operators === monitors = {} @@ -291,20 +291,20 @@ while not simu.isOver: ## print 'total time (rank):', MPI.Wtime() - time, '(', topo.rank, ')' -print 'aaaa', velo.norm(topofft) -op['correction'].apply(simu) -print 'iiii', velo.norm(topofft) +## print 'aaaa', velo.norm(topofft) +## op['correction'].apply(simu) +## print 'iiii', velo.norm(topofft) -sref = op['correction'].discreteOperator.surfRef +## sref = op['correction'].discreteOperator.surfRef -flowrate = velo.integrateOnSurface(sref, topofft) -print flowrate -assert (flowrate - ref_rate) < 1e-10 +## flowrate = velo.integrateOnSurface(sref, topofft) +## print flowrate +## assert (flowrate - ref_rate) < 1e-10 -flowratey = velo.integrateOnSurface(sref, topofft, component=1) -print flowratey -flowratez = velo.integrateOnSurface(sref, topofft, component=2) -print flowratez +## flowratey = velo.integrateOnSurface(sref, topofft, component=1) +## print flowratey +## flowratez = velo.integrateOnSurface(sref, topofft, component=2) +## print flowratez # === Finalize for all declared operators === diff --git a/Examples/postNSBluff.py b/Examples/postNSBluff.py index 6a7280e57..1ca239dea 100644 --- a/Examples/postNSBluff.py +++ b/Examples/postNSBluff.py @@ -60,7 +60,7 @@ def plotReprojection(filename): plt.ioff() direc = 'NSDebug' -nprocs = 1 +nprocs = 8 fileroot = direc + '/p' + str(nprocs) + '/' plotEnergyEnstrophy(fileroot + 'energy_enstrophy') plotDragAndLift(fileroot + 'drag_and_lift') diff --git a/HySoP/hysop/operator/monitors/compute_forces.py b/HySoP/hysop/operator/monitors/compute_forces.py index 00b0c59f3..64e6db21e 100644 --- a/HySoP/hysop/operator/monitors/compute_forces.py +++ b/HySoP/hysop/operator/monitors/compute_forces.py @@ -50,9 +50,6 @@ class DragAndLift(Monitoring): self._dim = self.domain.dimension msg = 'Force computation undefined for domain of dimension 1.' assert self._dim > 1, msg - self._step = np.asarray(self.topo.mesh.space_step) - self._dvol = np.prod(self._step) - self._work = npw.zeros(self.topo.mesh.resolution) if obstacles is None: obstacles = [] ## A list of obstacles (rigid bodies) in the control box @@ -64,13 +61,6 @@ class DragAndLift(Monitoring): self.force = npw.zeros(self._dim) # Coef in the Noca formula self._coeff = 1. / (self._dim - 1) - # function to compute the laplacian of a - # scalar field. Default fd scheme. (See Laplacian) - self._laplacian = Laplacian(topo) - # function used to compute first derivative of - # a scalar field in a given direction. - # Default = FD_C_2. Todo : set this as an input method value. - self._fd_scheme = FD_C_2(topo.mesh.space_step) # Set how reduction will be performed # Default = reduction over all process. # \todo : add param to choose this option @@ -106,6 +96,17 @@ class DragAndLift(Monitoring): """ """ if not self._isUpToDate: + self._step = np.asarray(self.topo.mesh.space_step) + self._dvol = np.prod(self._step) + self._work = npw.zeros(self.topo.mesh.resolution) + # function to compute the laplacian of a + # scalar field. Default fd scheme. (See Laplacian) + self._laplacian = Laplacian(self.topo) + # function used to compute first derivative of + # a scalar field in a given direction. + # Default = FD_C_2. Todo : set this as an input method value. + self._fd_scheme = FD_C_2(self.topo.mesh.space_step) + for v in self.variables: # the discrete fields self.discreteFields[v] = v.discretize(self.topo) -- GitLab