energiesO = [] fO = [] for test in xrange(ntests): nx = (test + 1)*nx0 ny = (test + 1)*ny0 nodes.numInternalNodes = 0 print "Generating node distribution." generator = GenerateNodeDistribution2d(nx, ny, rho0, seed, xmin = xmin1, xmax = xmax2, nNodePerh = nPerh) distributeNodes2d((nodes, generator)) output('mpi.reduce(nodes.numInternalNodes, mpi.MIN)') output('mpi.reduce(nodes.numInternalNodes, mpi.MAX)') output('mpi.reduce(nodes.numInternalNodes, mpi.SUM)') m = nodes.mass() rho = nodes.massDensity() print "Area sum: ", mpi.allreduce(sum([m[i]/rho[i] for i in xrange(nodes.numInternalNodes)]), mpi.SUM) # Construct the flaws. localFlawsBA = weibullFlawDistributionBenzAsphaug(volume, 1.0, randomSeed, kWeibull, mWeibull, nodes,
ny1, rho1, "lattice", xmin=(x0, y0), xmax=(x1, y1), nNodePerh=nPerh, SPH=True) gen2 = GenerateNodeDistribution2d(nx2, ny2, rho2, "lattice", xmin=(x1, y0), xmax=(x2, y1), nNodePerh=nPerh, SPH=True) distributeNodes2d((nodes1, gen1), (nodes2, gen2)) output("nodes1.numNodes") output("nodes2.numNodes") # Set node velocities for nodes in nodeSet: vel = nodes.velocity() for i in xrange(nodes.numInternalNodes): vel[i].x = vx0 #------------------------------------------------------------------------------- # Construct a DataBase to hold our node list #------------------------------------------------------------------------------- db = DataBase() output("db")
output(" nodes.hmax") output(" nodes.nodesPerSmoothingScale") #------------------------------------------------------------------------------- # Initial conditions #------------------------------------------------------------------------------- gen = GenerateNodeDistribution2d(nx, ny, rho0, "lattice", xmin=(x0, y0), xmax=(x1, y1), nNodePerh=nPerh, SPH=not asph, rejecter=PolygonalSurfaceRejecter(triangle)) distributeNodes2d((nodes, gen)) output("nodes.numNodes") # Set node velocities vel = nodes.velocity() for i in xrange(nodes.numInternalNodes): vel[i].x = v0 #------------------------------------------------------------------------------- # Construct a DataBase to hold our node list #------------------------------------------------------------------------------- db = DataBase() output("db") output("db.appendNodeList(nodes)") output("db.numNodeLists") output("db.numFluidNodeLists")
# Set the node properties. #------------------------------------------------------------------------------- from GenerateNodeDistribution2d import GenerateNodeDistribution2d gen1 = GenerateNodeDistribution2d(nx1, ny1, rho=rho1, distributionType="lattice", xmin=(x0, y0), xmax=(x1, y1), nNodePerh=nPerh, SPH=True) if mpi.procs > 1: from PeanoHilbertDistributeNodes import distributeNodes2d else: from DistributeNodes import distributeNodes2d distributeNodes2d((nodes1, gen1)) # Set the node positions, velocities, and densities. nodes1.velocity(VectorField("tmp velocity", nodes1, Vector(vx1, vy1))) #------------------------------------------------------------------------------- # Construct a DataBase to hold our node list #------------------------------------------------------------------------------- db = DataBase() db.appendNodeList(nodes1) #------------------------------------------------------------------------------- # Construct the artificial viscosity. #------------------------------------------------------------------------------- q = MonaghanGingoldViscosity(0.0, 0.0)
xmin=(0.0, 0.0), xmax=(1.0, 0.25), nNodePerh=nPerh, SPH=SPH) generator22 = GenerateNodeDistribution2d(nx2, int(0.5 * ny2 + 0.5), rho=rho2, distributionType="lattice", xmin=(0.0, 0.75), xmax=(1.0, 1.0), nNodePerh=nPerh, SPH=SPH) generator2 = CompositeNodeDistribution(generator21, generator22) if numNodeLists == 2: distributeNodes2d((nodes1, generator1), (nodes2, generator2)) else: gen = CompositeNodeDistribution(generator1, generator2) distributeNodes2d((nodes1, gen)) # A helpful method for setting y velocities. def vy(ri): thpt = 1.0 / (2.0 * sigma * sigma) return (w0 * sin(freq * pi * ri.x) * (exp(-((ri.y - 0.25)**2 * thpt)) + exp(-( (ri.y - 0.75)**2 * thpt)))) * abs(0.5 - ri.y) # Finish initial conditions. eps1 = P1 / ((gamma - 1.0) * rho1) eps2 = P2 / ((gamma - 1.0) * rho2) if numNodeLists == 2:
def setUp(self): from Spheral2d import (vector_of_int, Vector, Tensor, GammaLawGasMKS, TableKernel, BSplineKernel, makeFluidNodeList, ScalarField, VectorField, DataBase, Plane, PeriodicBoundary) self.ndim = 2 self.genxmin = (0.0, 0.0) self.genxmax = (1.0, 1.0) self.xmin = Vector(0.2, 0.2) self.xmax = Vector(0.8, 0.8) self.nsample = vector_of_int() [self.nsample.append(x) for x in (100, 100)] # Tolerances for the test self.scalarTol = 1.0e-2 self.vectorTol = 1.0e-2 self.tensorTol = 1.0e-2 nx, ny = 50, 50 self.rho0 = 10.0 self.v0 = Vector(1.0, -1.0) self.eps0 = -1.0 self.gradv0 = Tensor(8.5, -4.0, 2.2, 1.3) # Create the nodes and such. self.eos = GammaLawGasMKS(5.0 / 3.0, 1.0) self.WT = TableKernel(BSplineKernel()) self.nodes = makeFluidNodeList("nodes", self.eos) # Distribute the nodes. from GenerateNodeDistribution2d import GenerateNodeDistribution2d from PeanoHilbertDistributeNodes import distributeNodes2d generator = GenerateNodeDistribution2d(nx, ny, self.rho0, "lattice", xmin=self.genxmin, xmax=self.genxmax, nNodePerh=2.01) distributeNodes2d((self.nodes, generator)) # Set the velocities and energies. self.nodes.velocity(VectorField("tmp", self.nodes, self.v0)) self.nodes.specificThermalEnergy( ScalarField("tmp", self.nodes, self.eps0)) self.db = DataBase() self.db.appendNodeList(self.nodes) # Create the boundary conditions. px0 = Plane(Vector(0.0, 0.0), Vector(1.0, 0.0)) px1 = Plane(Vector(1.0, 0.0), Vector(-1.0, 0.0)) py0 = Plane(Vector(0.0, 0.0), Vector(0.0, 1.0)) py1 = Plane(Vector(0.0, 1.0), Vector(0.0, -1.0)) xbc = PeriodicBoundary(px0, px1) ybc = PeriodicBoundary(py0, py1) self.bcs = [xbc, ybc] try: self.bcs.append(TreeDistributedBoundary2d.instance()) except: if mpi.procs > 1: raise RuntimeError, "Unable to get parallel boundary condition" else: pass # Enforce boundaries. db = DataBase() db.appendNodeList(self.nodes) for bc in self.bcs: bc.setAllGhostNodes(db) bc.finalizeGhostBoundary() self.nodes.neighbor().updateNodes() for bc in self.bcs: bc.applyGhostBoundary(self.nodes.mass()) bc.applyGhostBoundary(self.nodes.massDensity()) bc.applyGhostBoundary(self.nodes.specificThermalEnergy()) bc.applyGhostBoundary(self.nodes.velocity()) for bc in self.bcs: bc.finalizeGhostBoundary() self.H0 = self.nodes.Hfield()[0] return
nNodePerh = nPerh, SPH = SPH) generatorBottom = GenerateNodeDistribution2d(nx3, ny3, rho3, distributionType = "lattice", xmin = (x1, y0), xmax = (x2, y1), nNodePerh = nPerh, SPH = SPH) if mpi.procs > 1: from PeanoHilbertDistributeNodes import distributeNodes2d else: from DistributeNodes import distributeNodes2d distributeNodes2d((leftNodes, generatorLeft), (topNodes,generatorTop), (bottomNodes, generatorBottom)) for nodes in nodeSet: print nodes.name, ":" output(" mpi.reduce(nodes.numInternalNodes, mpi.MIN)") output(" mpi.reduce(nodes.numInternalNodes, mpi.MAX)") output(" mpi.reduce(nodes.numInternalNodes, mpi.SUM)") del nodes # Set node specific thermal energies for (nodes, gamma, rho, P) in ((leftNodes, gamma1, rho1, P1), (topNodes, gamma2, rho2, P2), (bottomNodes, gamma3, rho3, P3)): eps0 = P/((gamma - 1.0)*rho) nodes.specificThermalEnergy(ScalarField("tmp", nodes, eps0)) del nodes