def __init__( self, r0, # initial blob radius rhoThreshold, # density cutoff epsThreshold, # specific thermal energy cutoff nodes, # blob NodeList filename): # file to write the results to self.r0 = r0 self.rho0 = rhoThreshold self.eps0 = epsThreshold NodeHistory.__init__(self, nodeList=nodes, nodeIndicies=[], sampleMethod=self.measureCloudFraction, filename=filename, labels=("mfrac", "mass", "volume")) # Check our dimensionality if isinstance(nodes, Spheral.NodeList2d): self.ndim = 2 elif isinstance(nodes, Spheral.NodeList3d): self.ndim = 3 else: raise RuntimeError, "What the heck is %s?" % nodes # Find the starting mass of the cloud. self.M0 = nodes.mass().sumElements() return
histories = [] tracerNumber = 1 for nodes, samplePositions in ((nodesAl, (-0.0375, -0.0625, -0.9875)), (nodesTa, ( 0.0375, 0.0625, 0.9875))): pos = nodes.positions() for x0 in samplePositions: thpt = [(abs(pos[i].x - x0), i) for i in xrange(nodes.numInternalNodes)] + [(1e100, -1)] thpt.sort() dxmin = mpi.allreduce(thpt[0][0], mpi.MIN) if thpt[0][0] == dxmin: i = thpt[0][1] indices = [i] sys.stderr.write("Tracer %i is node %i @ %s.\n" % (tracerNumber, i, pos[i])) else: indices = [] histories.append(NodeHistory(nodes, indices, tp106tracersample, tracerOutputName % tracerNumber, labels = ("pos", "vel", "rho", "eps", "P"))) tracerNumber += 1 #------------------------------------------------------------------------------- # Build the controller. #------------------------------------------------------------------------------- control = SpheralController(integrator, WT, statsStep = statsStep, restartStep = restartStep, restartBaseName = restartBaseName, restoreCycle = restoreCycle) output("control") #------------------------------------------------------------------------------- # Add the diagnostics to the controller. #-------------------------------------------------------------------------------
result += m[i] * (v[i].dot(runit)) globalMassSum = mpi.allreduce(massSum, mpi.SUM) globalResult = mpi.allreduce(result, mpi.SUM) assert globalMassSum > 0.0 globalResult /= globalMassSum return globalResult #------------------------------------------------------------------------------- # Build the history objects to simulate the VISAR velocity probes. #------------------------------------------------------------------------------- nodesA = SelectVISARNodes(zVISARa, dzVISAR, drVISAR, "A") nodesB = SelectVISARNodes(zVISARb, dzVISAR, drVISAR, "B") nodesC = SelectVISARNodes(zVISARc, dzVISAR, drVISAR, "C") VISARa = NodeHistory(nodesSteel, nodesA, averageCylindricalRadialVelocity, dataDir + "/VISAR-a") VISARb = NodeHistory(nodesSteel, nodesB, averageCylindricalRadialVelocity, dataDir + "/VISAR-b") VISARc = NodeHistory(nodesSteel, nodesC, averageCylindricalRadialVelocity, dataDir + "/VISAR-c") VISARa.nodeFlags.name = "VISAR a points" VISARb.nodeFlags.name = "VISAR b points" VISARc.nodeFlags.name = "VISAR c points" control.appendPeriodicWork(VISARa.sample, VISARsampleFrequency) control.appendPeriodicWork(VISARb.sample, VISARsampleFrequency) control.appendPeriodicWork(VISARc.sample, VISARsampleFrequency) #------------------------------------------------------------------------------- # Helper method for dumping viz files.
output("integrator") output("integrator.havePhysicsPackage(hydro)") output("integrator.lastDt") output("integrator.dtMin") output("integrator.dtMax") output("integrator.dtGrowth") output("integrator.domainDecompositionIndependent") output("integrator.rigorousBoundaries") output("integrator.verbose") #------------------------------------------------------------------------------- # Build the history object to measure the time-dependent mix length. #------------------------------------------------------------------------------- mixlengthhistory = NodeHistory(nodes, [], sampleMethod=RTMixLength(nodes, 0.5, 95.0), filename=os.path.join(dataDir, "mix_length.gnu"), labels=("yhigh", "ylow", "L")) #------------------------------------------------------------------------------- # Make the problem controller. #------------------------------------------------------------------------------- if useVoronoiOutput: import SpheralVoronoiSiloDump vizMethod = SpheralVoronoiSiloDump.dumpPhysicsState else: import SpheralPointmeshSiloDump vizMethod = SpheralPointmeshSiloDump.dumpPhysicsState control = SpheralController(integrator, WT,
# Find shells of points in binned radii histories = [] dr = (R1 - R0) / nshells pos = nodesBe.positions() shellIndices = [[] for i in xrange(nr)] for i in xrange(nodesBe.numInternalNodes): ishell = min(nr - 1, int((pos[i].magnitude() - R0) / dr + 0.5)) shellIndices[ishell].append(i) for ishell in xrange(nshells): n = mpi.allreduce(len(shellIndices[ishell]), mpi.SUM) print "Selected %i nodes for shell %i." % (n, ishell) if n > 0: histories.append( NodeHistory(nodesBe, shellIndices[ishell], verneySample, historyOutputName % ishell, labels=("r", "vel", "rho", "eps", "P", "plastic strain", "h"))) #------------------------------------------------------------------------------- # Build the controller. #------------------------------------------------------------------------------- control = SpheralController(integrator, WT, statsStep=statsStep, restartStep=restartStep, restartBaseName=restartBaseName, restoreCycle=restoreCycle, vizBaseName=vizBaseName, vizDir=vizDir, vizTime=vizTime,