Example #1
0
        nullDistributeNodes3d((nodes, generator))
    else:
        from ParMETISDistributeNodes import distributeNodes3d
        generator = GenerateNodeDistribution3d(
            nx,
            ny,
            nz,
            rho1,
            seed,
            xmin=xmin,
            xmax=xmax,
            rmin=rmin,
            rmax=rmax,
            nNodePerh=nPerh,
            SPH=(NodeListConstructor == SphNodeList3d))
        distributeNodes3d((nodes, generator))
    output("mpi.reduce(nodes.numInternalNodes, mpi.MIN)")
    output("mpi.reduce(nodes.numInternalNodes, mpi.MAX)")
    output("mpi.reduce(nodes.numInternalNodes, mpi.SUM)")

    # Set node specific thermal energies
    nodes.specificThermalEnergy(ScalarField3d("tmp", nodes, eps1))

    # Set node velocities
    for nodeID in xrange(nodes.numNodes):
        nodes.velocity()[nodeID] = nodes.positions()[nodeID].unitVector() * vr1

#-------------------------------------------------------------------------------
# Construct a DataBase to hold our node list
#-------------------------------------------------------------------------------
db = DataBase3d()
Example #2
0
                                            nNodePerh = nPerh,
                                            SPH = not isinstance(nodes2, AsphSolidNodeList3d))

    # Displace the nodes to the correct centering.
    assert generator1.localNumNodes() == generator2.localNumNodes()
    for i in xrange(generator1.localNumNodes()):
        generator1.x[i] += x0
        generator1.y[i] += y0
        generator1.z[i] += z0
        generator2.x[i] -= x0
        generator2.y[i] += y0
        generator2.z[i] += z0

    print "Starting node distribution..."
    if twoBalls:
        distributeNodes3d((nodes1, generator1),
                          (nodes2, generator2))
    else:
        distributeNodes3d((nodes1, generator1))
    for nodes in nodeSet:
        output("nodes.name()")
        output("    mpi.allreduce(nodes.numInternalNodes, mpi.MIN)")
        output("    mpi.allreduce(nodes.numInternalNodes, mpi.MAX)")
        output("    mpi.allreduce(nodes.numInternalNodes, mpi.SUM)")
    del nodes

    # Set node specific thermal energies
    print "Initial pressure for %s: %g" % (nodes1.name(),
                                           nodes1.equationOfState().pressure(rho0, 0.0))
    print "Initial pressure for %s: %g" % (nodes2.name(),
                                           nodes2.equationOfState().pressure(rho0, 0.0))
   def Fluid(self, n, dim):#, smooth = False, equalSpacing = False):
      """Initializes a fluid in the shock tube."""

      # Give me a conducting node list.
      nodes = ConductingFluidNodeList("fluid", self.eos, self.WT, self.WTPi)
      nodes.HsmoothFraction = HsmoothFraction
      nodes.XSPH = XSPH
      nodes.nodesPerSmoothingScale = nPerh
      nodes.epsilonTensile = epsilonTensile
      nodes.nTensile = nTensile
      nodes.hmin = hmin
      nodes.hmax = hmax
      nodes.hminratio = hminratio

      #-------------------------------------------------------------------------------
      # Construct the neighbor objects.
      #-------------------------------------------------------------------------------
      neighbor = NestedGridNeighbor3d(nodes,
                                      neighborSearchType,
                                      numGridLevels,
                                      topGridCellSize,
                                      origin,
                                      kernelExtent)
      nodes.registerNeighbor(neighbor)

      # Stick this neighbor into the global list to prevent its garbage 
      # collection.
      neighbors.append(neighbor)

      if restoreCycle is None:
#         mpi.synchronizeQueuedOutput(None, None)
         gen = ShockTubeGenerator(n, dim, self.WT, self.rhoL, self.rhoR, nNodePerh = nPerh)

         # Distribute the nodes.
         from ParMETISDistributeNodes import distributeNodes3d
         distributeNodes3d((nodes, gen))

         # Set the "left" and "right" states within the shock tube.
         x = nodes.positions()
         rho = nodes.massDensity()
         v = nodes.velocity()
         u = nodes.specificThermalEnergy()
         B = nodes.magneticInduction()
         if dim == 1:
            # 1D configuration: left-right boundary is at x = 0.
            for i in xrange(nodes.numNodes):
               if x[i].x <= 0.0:
                  rho[i] = self.rhoL
                  v[i] = self.vL
                  u[i] = self.uL
                  B[i] = self.BL
               else:
                  rho[i] = self.rhoR
                  v[i] = self.vR
                  u[i] = self.uR
                  B[i] = self.BR
         elif dim == 2:
            # 2D configuration: left-right boundary is at x = y.
            for i in xrange(nodes.numInternalNodes):
               if x[i].x <= x[i].y:
                  rho[i] = self.rhoL
                  v[i] = self.vL
                  u[i] = self.uL
                  B[i] = self.BL
               else:
                  rho[i] = self.rhoR
                  v[i] = self.vR
                  u[i] = self.uR
                  B[i] = self.BR
         else:
            # 3D configuration: left-right boundary is at x = y = z.
            for i in xrange(nodes.numInternalNodes):
               if x[i].x <= x[i].y and x[i].y <= x[i].z:
                  rho[i] = self.rhoL
                  v[i] = self.vL
                  u[i] = self.uL
                  B[i] = self.BL
               else:
                  rho[i] = self.rhoR
                  v[i] = self.vR
                  u[i] = self.uR
                  B[i] = self.BR
      else:
         # We still need nx, ny, nz!
         gen = ShockTubeGenerator(n, dim, self.WT, self.rhoL, self.rhoR, nNodePerh = nPerh)

      # Specify boundary conditions based on the left and right velocities. 
#      self.BCs = []
#      if v[0].x > 0.0:
#         self.BCs.append(SPH.InflowBC(leftPlane, nf))
#      elif v[0].x < 0.0:
#         self.BCs.append(SPH.OutflowBC(leftPlane, nf))
#      else:
#         self.BCs.append(SPH.ReflectingBC(leftPlane, nf))
#      if v[-1].x < 0.0:
#         self.BCs.append(SPH.InflowBC(rightPlane, nf))
#      elif v[-1].x > 0.0:
#         self.BCs.append(SPH.OutflowBC(rightPlane, nf))
#      else:
#         self.BCs.append(SPH.ReflectingBC(rightPlane, nf))

      # Smooth the initial conditions if requested.
#      if smooth:
#         print 'Smoothing initial conditions...'
#         # Determine the number of smoothed nodes.
#         dxL = (xC - xL).magnitude() / NL
#         dxR = (xR - xC).magnitude() / NR
#         d = 0.5 * dxR
#         Ns = int(4 * dxR/dxL)
#         for i in xrange(NL-Ns, N):
#            # Space the smoothed nodes appropriately.
#            x[i] = x[i-2] + X.Vector(2.0*self.rhoR*dxR/rho[i-1])
#
#            # Smooth the magnetic field, the density, and the 
#            # specific thermal energy.
#            xi = min(x[i].x/d, 10.0)
#            expxd = exp(xi)
#            B[i] = (self.BL + self.BR * expxd)/(1 + expxd)
#            rho[i] = (self.rhoL + self.rhoR * expxd)/(1 + expxd)
#            u[i] = (self.uL + self.uR * expxd)/(1 + expxd)
#
#         # Assign H to the inverse density.
#         for i in xrange(N):
#            H[i] = X.SymTensor2(rho[i]/(1.5*m[i]))
#
#         # Reset the position of the right boundary plane so that oscillations
#         # don't crop up there from the varied spacing in the nodes on the 
#         # right side of the problem.  This isn't quite enough to fix the 
#         # problem, but it should stave it off a bit.
#         for BC in self.BCs:
#            if BC.surface is rightPlane:
#               BC.surface.center = x[-1] + X.Vector(0.5*dxR)

      return nodes, gen.nx, gen.ny, gen.nz, gen.xmin, gen.xmax
Example #4
0
                                                    xmax = xmaxFoamAnvil,
                                                    nNodePerh = nPerh,
                                                    SPH = not isinstance(nodesFoamAnvil, AsphSolidNodeList3d))
    generatorCuAnvil = GenerateNodeDistributionRZ(nlCuAnvil,
                                                  nrCuAnvil,
                                                  rho0Cu,
                                                  "lattice",
                                                  xmin = xminCuAnvil,
                                                  xmax = xmaxCuAnvil,
                                                  nNodePerh = nPerh,
                                                  SPH = not isinstance(nodesCuAnvil, AsphSolidNodeList3d))

    print "Starting node distribution..."
    distributeNodes3d((nodesSteel, generatorTube),
                      (nodesPlug, generatorPlug),
                      (nodesProj, generatorProj),
                      (nodesSteelAnvil, generatorSteelAnvil),
                      (nodesFoamAnvil, generatorFoamAnvil),
                      (nodesCuAnvil, generatorCuAnvil))
    nGlobalNodes = 0
    for n in nodeSet:
        print "Generator info for %s" % n.name()
        output("    mpi.allreduce(n.numInternalNodes, mpi.MIN)")
        output("    mpi.allreduce(n.numInternalNodes, mpi.MAX)")
        output("    mpi.allreduce(n.numInternalNodes, mpi.SUM)")
        nGlobalNodes += mpi.allreduce(n.numInternalNodes, mpi.SUM)
    del n
    print "Total number of (internal) nodes in simulation: ", nGlobalNodes

    # Bevel the inner opening surface of the target tube.
    numNodesBeveled = bevelTubeEntrance(nodesSteel,
                                        2,