Example #1
0
        pass

    # Place the impactor at the point of impact. It is coming from the
    # positive x direction in the xy plane.
    displace = Vector((rTarget + rImpactor) * cos(pi / 180.0 * angleImpact),
                      (rTarget + rImpactor) * sin(pi / 180.0 * angleImpact),
                      0.0)
    for k in range(impactorGenerator.localNumNodes()):
        impactorGenerator.x[k] += displace.x
        impactorGenerator.y[k] += displace.y
        impactorGenerator.z[k] += displace.z
        pass

    # Fill node lists using generators and distribute to ranks.
    print "Starting node distribution..."
    distributeNodes3d((target, targetGenerator), (impactor, impactorGenerator))
    nGlobalNodes = 0
    for n in nodeSet:
        print "Generator info for %s" % n.name
        print "   Minimum number of nodes per domain : ", \
              mpi.allreduce(n.numInternalNodes, mpi.MIN)
        print "   Maximum number of nodes per domain : ", \
              mpi.allreduce(n.numInternalNodes, mpi.MAX)
        print "               Global number of nodes : ", \
              mpi.allreduce(n.numInternalNodes, mpi.SUM)
        nGlobalNodes += mpi.allreduce(n.numInternalNodes, mpi.SUM)
    del n
    print "Total number of (internal) nodes in simulation: ", nGlobalNodes
    WMR = (max(impactor.mass().max(),
               target.mass().max()) / min(impactor.mass().min(),
                                          target.mass().min()))
Example #2
0
        nrCuAnvil,
        nlCuAnvil,
        0,
        rho0Cu,
        "cylindrical",
        rmin=rminCuAnvil,
        rmax=rmaxCuAnvil,
        thetamin=0,
        thetamax=phi,
        zmin=zminCuAnvil,
        zmax=zmaxCuAnvil,
        nNodePerh=nPerh,
        SPH=(NodeListConstructor is SphNodeList))

    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, 3, tubeOpeningAngle,
                                        rtubeInner, tubeThickness, zBevelBegin)
    print "Beveled %i nodes in the tube opening." % mpi.allreduce(
        pass

    # Place the impactor at the point of impact. It is coming from the 
    # positive x direction in the xy plane.
    displace = Vector((rTarget+rImpactor)*cos(pi/180.0*angleImpact),
                      (rTarget+rImpactor)*sin(pi/180.0*angleImpact),
                      0.0)
    for k in range(impactorGenerator.localNumNodes()):
        impactorGenerator.x[k] += displace.x
        impactorGenerator.y[k] += displace.y
        impactorGenerator.z[k] += displace.z
        pass
                                                       
    # Fill node lists using generators and distribute to ranks.
    print "Starting node distribution..."
    distributeNodes3d((target, targetGenerator),
                      (impactor, impactorGenerator))
    nGlobalNodes = 0
    for n in nodeSet:
        print "Generator info for %s" % n.name
        print "   Minimum number of nodes per domain : ", \
              mpi.allreduce(n.numInternalNodes, mpi.MIN)
        print "   Maximum number of nodes per domain : ", \
              mpi.allreduce(n.numInternalNodes, mpi.MAX)
        print "               Global number of nodes : ", \
              mpi.allreduce(n.numInternalNodes, mpi.SUM)
        nGlobalNodes += mpi.allreduce(n.numInternalNodes, mpi.SUM)
    del n
    print "Total number of (internal) nodes in simulation: ", nGlobalNodes
    WMR = (max(impactor.mass().max(), target.mass().max())/
           min(impactor.mass().min(), target.mass().min()))
    if WMR < 1.5:
                                                      rMaxForMassMatching=rPlanet)

    msum = mpi.allreduce(sum(genIron.m + [0.0]), mpi.SUM)
    msum += mpi.allreduce(sum(genGranite.m + [0.0]), mpi.SUM)
    assert msum > 0.0
    print "Found planet mass = %g kg." % (msum*units.unitMassKg)



    
    print "Starting node distribution..."
    if mpi.procs > 1:
        from VoronoiDistributeNodes import distributeNodes3d
    else:
        from DistributeNodes import distributeNodes3d
    distributeNodes3d((nodesIron,genIron),(nodesGranite,genGranite))
    #distributor((nodes1,genPlanet))
    #distributor((nodes3,genCollider))

    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

    #wait = raw_input("Press Enter to Continue...")
Example #5
0
            pass
        planetGenerator = GenerateIcosahedronMatchingProfile3d(
                            n = nxPlanet/2,
                            densityProfileMethod = rhoProfile,
                            rmin = 0.0,
                            rmax = rPlanet,
                            nNodePerh = nPerh)
        pass
    else:
        print "ERROR: unknown or obsolete generator type: {}".format(generator_type)
        sys.exit(1)
        pass

    # Fill node list using generator and distribute to ranks.
    print "Starting node distribution..."
    distributeNodes3d((planet, planetGenerator))
    nGlobalNodes = 0
    for n in nodeSet:
        print "Generator info for %s" % n.name
        print "   Minimum number of nodes per domain : ", \
              mpi.allreduce(n.numInternalNodes, mpi.MIN)
        print "   Maximum number of nodes per domain : ", \
              mpi.allreduce(n.numInternalNodes, mpi.MAX)
        print "               Global number of nodes : ", \
              mpi.allreduce(n.numInternalNodes, mpi.SUM)
        nGlobalNodes += mpi.allreduce(n.numInternalNodes, mpi.SUM)
    del n
    print "Total number of (internal) nodes in simulation: ", nGlobalNodes
    WMR = planet.mass().max()/planet.mass().min()
    if WMR < 1.5:
        sys.stderr.write("\033[32m")
Example #6
0
                                   xmin=(x0, y0, z0),
                                   xmax=(x1, y1, z1),
                                   nNodePerh=nPerh,
                                   SPH=not ASPH)
gen2 = GeneratePlanarNodeProfile3d(nx=nx2,
                                   ny=ny2,
                                   nz=nz2,
                                   rho=rho_initial,
                                   xmin=(x1, y0, z0),
                                   xmax=(x2, y1, z1),
                                   nNodePerh=nPerh,
                                   SPH=not ASPH)

if numNodeLists == 1:
    gen = CompositeNodeDistribution(gen1, gen2)
    distributeNodes3d((nodes1, gen))
else:
    distributeNodes3d((nodes1, gen1), (nodes2, gen2))

for n in nodeSet:
    output("n.name")
    output("   mpi.reduce(n.numInternalNodes, mpi.MIN)")
    output("   mpi.reduce(n.numInternalNodes, mpi.MAX)")
    output("   mpi.reduce(n.numInternalNodes, mpi.SUM)")
del n

# Set node specific thermal energies
for nodes in nodeSet:

    pos = nodes.positions()
    eps = nodes.specificThermalEnergy()
Example #7
0
)

# For consistency with our 2-D case, we spin the coordinates so
# that the rod is aligned along the x axis rather than z.
R = Tensor(0, 0, 1, 0, 1, 0, -1, 0, 0)
for i in xrange(generator.localNumNodes()):
    vi = generator.localPosition(i)
    Hi = generator.localHtensor(i)
    v1 = R.dot(vi)
    Hi.rotationalTransform(R)
    generator.x[i] = v1.x
    generator.y[i] = v1.y
    generator.z[i] = v1.z
    generator.H[i] = Hi

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
# eps0 = eos.specificThermalEnergy(rho0, 300.0)
# nodes.specificThermalEnergy(ScalarField("tmp", nodes, eps0))

# Set node velocites.
for i in xrange(nodes.numInternalNodes):
    nodes.velocity()[i].x = nodes.positions()[i].x / (0.5 * length) * v0

# Set an initial damage if requested.
if initialBreakRadius > 0.0:
    pos = nodes.positions()
                   (0, -sin(theta), cos(theta))])
    R = np.dot(R1, R2)

    for k in range(coreGenerator.localNumNodes()):
        Xk = np.array([(coreGenerator.x[k],
                       coreGenerator.y[k],
                       coreGenerator.z[k])]).transpose()
        Xk = np.dot(R, Xk)
        coreGenerator.x[k] = Xk[0]
        coreGenerator.y[k] = Xk[1]
        coreGenerator.z[k] = Xk[2]
        pass
    
    # Fill node lists using generators and distribute to ranks.
    print "Starting node distribution..."
    distributeNodes3d((core, coreGenerator),
                      (mantle, mantleGenerator))
    nGlobalNodes = 0
    for n in nodeSet:
        print "Generator info for %s" % n.name
        print "   Minimum number of nodes per domain : ", \
              mpi.allreduce(n.numInternalNodes, mpi.MIN)
        print "   Maximum number of nodes per domain : ", \
              mpi.allreduce(n.numInternalNodes, mpi.MAX)
        print "               Global number of nodes : ", \
              mpi.allreduce(n.numInternalNodes, mpi.SUM)
        nGlobalNodes += mpi.allreduce(n.numInternalNodes, mpi.SUM)
    del n
    print "Total number of (internal) nodes in simulation: ", nGlobalNodes
    
    pass # end restoreCycle branching
                                                    rmax = rPlanet,
                                                    nNodePerh=nPerh,
                                                      rMaxForMassMatching=rPlanet)

    msum = mpi.allreduce(sum(genIron.m + [0.0]), mpi.SUM)
    msum += mpi.allreduce(sum(genGranite.m + [0.0]), mpi.SUM)
    assert msum > 0.0
    print "Found planet mass = %g kg." % (msum*units.unitMassKg)

    
    print "Starting node distribution..."
    if mpi.procs > 1:
        from VoronoiDistributeNodes import distributeNodes3d
    else:
        from DistributeNodes import distributeNodes3d
    distributeNodes3d((nodesIron,genIron),(nodesGranite,genGranite))
    #distributor((nodes1,genPlanet))
    #distributor((nodes3,genCollider))

    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

    #wait = raw_input("Press Enter to Continue...")
    R2 = np.array([(1, 0, 0), (0, cos(theta), sin(theta)),
                   (0, -sin(theta), cos(theta))])
    R = np.dot(R1, R2)

    for k in range(coreGenerator.localNumNodes()):
        Xk = np.array([(coreGenerator.x[k], coreGenerator.y[k],
                        coreGenerator.z[k])]).transpose()
        Xk = np.dot(R, Xk)
        coreGenerator.x[k] = Xk[0]
        coreGenerator.y[k] = Xk[1]
        coreGenerator.z[k] = Xk[2]
        pass

    # Fill node lists using generators and distribute to ranks.
    print "Starting node distribution..."
    distributeNodes3d((core, coreGenerator), (mantle, mantleGenerator))
    nGlobalNodes = 0
    for n in nodeSet:
        print "Generator info for %s" % n.name
        print "   Minimum number of nodes per domain : ", \
              mpi.allreduce(n.numInternalNodes, mpi.MIN)
        print "   Maximum number of nodes per domain : ", \
              mpi.allreduce(n.numInternalNodes, mpi.MAX)
        print "               Global number of nodes : ", \
              mpi.allreduce(n.numInternalNodes, mpi.SUM)
        nGlobalNodes += mpi.allreduce(n.numInternalNodes, mpi.SUM)
    del n
    print "Total number of (internal) nodes in simulation: ", nGlobalNodes

    pass  # end restoreCycle branching
Example #11
0
flags = [1, 1, 1, 0, 0, 0]

gen = ExtrudedSurfaceGenerator(surface,
                               lconstant=0.05,
                               lextrude=0.5,
                               nextrude=20,
                               dltarget=0.005,
                               dstarget=0.1,
                               rho=1.0,
                               flags=flags,
                               nNodePerh=1.01,
                               SPH=False)

eos = GammaLawGasMKS(5.0 / 3.0, 1.0)
nodes = makeFluidNodeList("test", eos, hminratio=1.0e-10)

distributeNodes3d((nodes, gen))

H = nodes.Hfield()
Hinv = SymTensorField("H inverse", nodes)
for i in xrange(nodes.numNodes):
    Hinv[i] = H[i].Inverse()

siloPointmeshDump(
    "test_void",
    fields=[nodes.mass(),
            nodes.massDensity(),
            nodes.Hfield(), Hinv])
writePolyhedronOBJ(surface, "test_void_surface.obj")
Example #12
0
#-------------------------------------------------------------------------------
if restoreCycle is None:
    generator1 = GenerateNodeDistribution3d(nx,
                                            ny,
                                            nz,
                                            rho1,
                                            seed,
                                            xmin=xmin,
                                            xmax=xmax,
                                            nNodePerh=nPerh)

    if mpi.procs > 1:
        from VoronoiDistributeNodes import distributeNodes3d
    else:
        from DistributeNodes import distributeNodes3d
    distributeNodes3d((nodes1, generator1))
    output("mpi.reduce(nodes1.numInternalNodes, mpi.MIN)")
    output("mpi.reduce(nodes1.numInternalNodes, mpi.MAX)")
    output("mpi.reduce(nodes1.numInternalNodes, mpi.SUM)")

    # Set node specific thermal energies
    nodes1.specificThermalEnergy(ScalarField("tmp", nodes1, eps1))

#-------------------------------------------------------------------------------
# Construct a DataBase to hold our node list
#-------------------------------------------------------------------------------
db = DataBase3d()
output("db")
db.appendNodeList(nodes1)
output("db.numNodeLists")
output("db.numFluidNodeLists")
Example #13
0
                                                nz1,
                                                rhoblob,
                                                distributionType="lattice",
                                                xmin=(xb0, yb0, zb0),
                                                xmax=(xb1, yb1, zb1),
                                                origin=(bx, by, bz),
                                                rmax=br,
                                                nNodePerh=nPerh,
                                                SPH=(not ASPH))

if mpi.procs > 1:
    from VoronoiDistributeNodes import distributeNodes3d
else:
    from DistributeNodes import distributeNodes3d

distributeNodes3d((outerNodes, generatorOuter), (innerNodes, generatorInner))
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, generatorOuter, generatorInner

# Set node specific thermal energies
for (nodes, rho) in ((outerNodes, rhoext), (innerNodes, rhoblob)):
    eps0 = Pequi / ((gamma - 1.0) * rho)
    nodes.specificThermalEnergy(ScalarField("tmp", nodes, eps0))
del nodes

#for nodes in nodeSet:
#  vel = nodes.velocity()
Example #14
0
                                               SPH=(not ASPH))
    generatorLow = GenerateNodeDistribution3d(nx,
                                              ny,
                                              nz,
                                              rho=rho1,
                                              distributionType="lattice",
                                              xmin=(0.0, 0.5, 0.0),
                                              xmax=(1.0, 1.0, 1.0),
                                              nNodePerh=nPerh,
                                              SPH=(not ASPH))
    if mpi.procs > 1:
        from VoronoiDistributeNodes import distributeNodes3d
    else:
        from DistributeNodes import distributeNodes3d

    distributeNodes3d((nodesLow, generatorLow), (nodesHigh, generatorHigh))

    # Finish initial conditions.
    rhom = 0.5 * (rho1 - rho2)
    vxm = 0.5 * (vx1 - vx2)
    for (nodes, vx) in ((nodesLow, vx1), (nodesHigh, vx2)):
        pos = nodes.positions()
        vel = nodes.velocity()
        rho = nodes.massDensity()
        eps = nodes.specificThermalEnergy()
        mass = nodes.mass()
        for i in xrange(nodes.numInternalNodes):
            yval = pos[i].y
            xval = pos[i].x
            zval = pos[i].z
            velx = 0.0
#-------------------------------------------------------------------------------
# First, create an equation of state.
units = sph.PhysicalConstants(1.0,1.0,1.0)
eos = shelpers.construct_eos_for_material('h2oice',units)

# Create an empty node list.
nodes = sph.makeFluidNodeList('nodelist', eos)

# Create a stock generator.
generator = GenerateNodeDistribution3d(2, 2, 2, 
                                       eos.referenceDensity,
                                       distributionType = 'lattice')

# Distribute nodes to ranks (suppress with any cl arg to speed things up).
if len(sys.argv) == 1:
    distributeNodes3d((nodes, generator))

# Create a DataBase object to hold the node lists.
db = sph.DataBase()
db.appendNodeList(nodes)

# Create the kernel function for SPH.
WT = sph.TableKernel(sph.BSplineKernel(), 1000)

# Create the artificial viscosity object.
q = sph.MonaghanGingoldViscosity(1.0, 1.0)

# Create the hydro package.
hydro = sph.ASPHHydro(W = WT, Q = q)

# Create the time integrator and attach the physics package to it.
Example #16
0
                                        thetamin = 0.0,
                                        thetamax = 2.0*pi,
                                        zmin = z0,
                                        zmax = z1,
                                        nNodePerh = 2.01,
                                        SPH = True)
generator2 = GenerateNodeDistribution3d(nr, nz, 0, 1.0, "cylindrical",
                                        rmin = 0.0,
                                        rmax = r,
                                        thetamin = 0.0,
                                        thetamax = 2.0*pi,
                                        zmin = z1,
                                        zmax = z2,
                                        nNodePerh = 2.01,
                                        SPH = True)
distributeNodes3d((nodes1, generator1),
                  (nodes2, generator2))

mesh, void = generatePolyhedralMesh([nodes1, nodes2, nodes3],
                                    xmin = Vector(-2, -2, -2),
                                    xmax = Vector(2, 2, 2),
                                    generateVoid = False,
                                    generateParallelConnectivity = False,
                                    removeBoundaryZones = True)

nodeLists = vector_of_NodeList()
for nodes in [nodes1, nodes2, nodes3]:
    nodeLists.append(nodes)
    nodes.neighbor().updateNodes()
W = TableKernel(BSplineKernel(), 1000)
mom0 = ScalarFieldList(CopyFields)
mom1 = VectorFieldList(CopyFields)