Exemplo n.º 1
0
    def setUp(self):

        print "--------------------------------------------------------------------------------"
        print "2-D %s regular cylindrical test." % self._NeighborType
        print "--------------------------------------------------------------------------------"

        self.ncheck = 50
        self.noverlapcheck = 2

        from GenerateNodeDistribution2d import GenerateNodeDistribution2d
        from DistributeNodes import distributeNodes2d
        self.eos = GammaLawGasMKS2d(2.0, 2.0)
        self.WT = TableKernel2d(BSplineKernel2d(), 100)
        self.nodes1 = makeFluidNodeList2d(
            "cylindrical nodes 1",
            self.eos,
            NeighborType=NeighborCylindrical2d._NeighborType)
        self.kernelExtent = 2.0
        generator = GenerateNodeDistribution2d(
            nRadial=100,
            nTheta=100,
            rho=1.0,
            distributionType="constantDTheta",
            rmin=0.0,
            rmax=1.0,
            theta=0.5 * pi,
            nNodePerh=2.01)
        distributeNodes2d((self.nodes1, generator))
        self.dataBase = DataBase2d()
        self.dataBase.appendNodeList(self.nodes1)

        return
Exemplo n.º 2
0
                                      rho1,
                                      distributionType="lattice",
                                      xmin=(x0, x0),
                                      xmax=(x1, x2),
                                      nNodePerh=nPerh,
                                      SPH=True)
    gen2 = GenerateNodeDistribution2d(nx2,
                                      2 * nx2,
                                      rho2,
                                      distributionType="lattice",
                                      xmin=(x1, x0),
                                      xmax=(x2, x2),
                                      nNodePerh=nPerh,
                                      SPH=True)
    gen = CompositeNodeDistribution(gen1, gen2)
    distributeNodes2d((nodes1, gen))

elif testDim == "3d":
    from DistributeNodes import distributeNodes3d
    from GenerateNodeDistribution3d import GenerateNodeDistribution3d
    from CompositeNodeDistribution import CompositeNodeDistribution
    gen1 = GenerateNodeDistribution3d(nx1,
                                      nx1,
                                      nx1,
                                      rho1,
                                      distributionType="lattice",
                                      xmin=(x0, x0, x0),
                                      xmax=(x1, x1, x2),
                                      nNodePerh=nPerh,
                                      SPH=True)
    gen2 = GenerateNodeDistribution3d(nx2,
Exemplo n.º 3
0
        myRejecter = Rejecter(holeRadius)
        generator = GenerateNodeDistribution2d(nx,ny,rho0,"lattice",
                                               rmin = rmin,
                                               rmax = rmax,
                                               xmin = xmin,
                                               xmax = xmax,
                                               theta = 2*pi,
                                               nNodePerh = nPerh,
                                               SPH = (not ASPH),
                                               rejecter = myRejecter)
    if mpi.procs > 1:
        from VoronoiDistributeNodes import distribueNodes2d
    else:
        from DistributeNodes import distributeNodes2d

    distributeNodes2d((nodes1,generator))
    output("mpi.reduce(nodes1.numInternalNodes, mpi.MIN)")
    output("mpi.reduce(nodes1.numInternalNodes, mpi.MAX)")
    output("mpi.reduce(nodes1.numInternalNodes, mpi.SUM)")

    for nodeID in xrange(nodes1.numInternalNodes):
        eps[nodeID] = eps0

#-------------------------------------------------------------------------------
# Construct a DataBase to hold our node list
#-------------------------------------------------------------------------------
db = DataBase()
output("db")
output("db.appendNodeList(nodes1)")
output("db.numNodeLists")
output("db.numFluidNodeLists")
Exemplo n.º 4
0
    def setUp(self):

        self.ndim = 2
        self.genxmin = (0.0, 0.0)
        self.genxmax = (1.0, 1.0)
        self.xmin = Vector2d(0.2, 0.2)
        self.xmax = Vector2d(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 = Vector2d(1.0, -1.0)
        self.eps0 = -1.0
        self.gradv0 = Tensor2d(8.5, -4.0, 2.2, 1.3)

        # Create the nodes and such.
        self.eos = GammaLawGasMKS2d(5.0 / 3.0, 1.0)
        self.WT = TableKernel2d(BSplineKernel2d())
        self.nodes = makeFluidNodeList2d("nodes", self.eos)
        self.neighbor = self.nodes.neighbor()

        # Distribute the nodes.
        from GenerateNodeDistribution2d import GenerateNodeDistribution2d
        from DistributeNodes 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(VectorField2d("tmp", self.nodes, self.v0))
        self.nodes.specificThermalEnergy(
            ScalarField2d("tmp", self.nodes, self.eps0))

        self.db = DataBase2d()
        self.db.appendNodeList(self.nodes)

        # Create the boundary conditions.
        px0 = Plane2d(Vector2d(0.0, 0.0), Vector2d(1.0, 0.0))
        px1 = Plane2d(Vector2d(1.0, 0.0), Vector2d(-1.0, 0.0))
        py0 = Plane2d(Vector2d(0.0, 0.0), Vector2d(0.0, 1.0))
        py1 = Plane2d(Vector2d(0.0, 1.0), Vector2d(0.0, -1.0))
        xbc = PeriodicBoundary2d(px0, px1)
        ybc = PeriodicBoundary2d(py0, py1)
        self.bcs = [xbc, ybc]
        try:
            dbc = TreeDistributedBoundary2d.instance()
            self.bcs.append(dbc)
        except:
            if mpi.procs > 1:
                raise RuntimeError, "Unable to get parallel boundary condition"
            else:
                pass

        # Enforce boundaries.
        db = DataBase2d()
        db.appendNodeList(self.nodes)
        for bc in self.bcs:
            bc.setAllGhostNodes(db)
            bc.finalizeGhostBoundary()
            self.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
nodes1 = SphNodeList2d(0, eos)
nodes2 = SphNodeList2d(0, eos)
from DistributeNodes import distributeNodes2d
generator1 = GenerateNodeDistribution2d(nx1, ny1, rho0, seed,
                                        rmin = rmin1,
                                        rmax = rmax1,
                                        nNodePerh = nPerh)
generator2 = GenerateNodeDistribution2d(nx2, ny2, rho0, seed,
                                        rmin = rmin2,
                                        rmax = rmax2,
                                        nNodePerh = nPerh)
n1 = generator1.globalNumNodes()
n2 = generator2.globalNumNodes()
nodeTuples = [(nodes1, n1, generator1),
              (nodes2, n2, generator2)]
nodeInfo = distributeNodes2d(nodeTuples)
output('nodes1.numInternalNodes')
output('nodes2.numInternalNodes')
assert len(nodeInfo[nodes1]['globalNodeListID']) == nodes1.numInternalNodes
assert len(nodeInfo[nodes2]['globalNodeListID']) == nodes2.numInternalNodes

for tup in nodeTuples:
    nodes = tup[0]
    gen = tup[2]
    for i in xrange(nodes.numInternalNodes):
        globalID = nodeInfo[nodes]['globalNodeListID'][i]
        nodes.mass[i] = gen.mass(globalID)
        Hi = gen.Htensor(globalID)
        h = sqrt(Hi.Determinant())
        Hi = SymTensor2d(h, 0, 0, h)
        nodes.Hfield[i] = Hi
#-------------------------------------------------------------------------------
# Set node properties (positions, masses, H's, etc.)
#-------------------------------------------------------------------------------
if restoreCycle is None:
    print "Generating node distribution."
    from GenerateNodeDistribution2d import *
    from DistributeNodes import distributeNodes2d
    generator = GenerateNodeDistribution2d(nx,
                                           ny,
                                           rho0,
                                           seed,
                                           xmin = xmin,
                                           xmax = xmax,
                                           nNodePerh = nPerh)
    n = generator.globalNumNodes()
    nodeInfo = distributeNodes2d([(nodes, n, generator)])
    output('mpi.reduce(nodes.numInternalNodes, mpi.MIN)')
    output('mpi.reduce(nodes.numInternalNodes, mpi.MAX)')
    output('mpi.reduce(nodes.numInternalNodes, mpi.SUM)')

    # Set the node masses.
    nodes.setMass(ScalarField2d("tmp", nodes, m0))

    # Set the smoothing scales.
    nodes.setHfield(SymTensorField2d("tmp", nodes, H0))

    # Set the node mass densities.
    nodes.setMassDensity(ScalarField2d("tmp", nodes, rho0))
    nodes.updateWeight()

    # Set node specific thermal energies
Exemplo n.º 7
0
# Set node properties (positions, masses, H's, etc.)
#-------------------------------------------------------------------------------
eps0 = 0.0
if restoreCycle is None:
    print "Generating node distribution."
    from GenerateNodeDistribution2d import *
    from DistributeNodes import distributeNodes2d
    generator = GenerateNodeDistribution2d(nx,
                                           ny,
                                           rho0,
                                           seed,
                                           xmin = xmin,
                                           xmax = xmax,
                                           nNodePerh = nPerh)
    n = generator.globalNumNodes()
    distributeNodes2d([(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.setSpecificThermalEnergy(ScalarField2d("tmp", nodes, eps0))

    # Set node velocites.
    for i in xrange(nodes.numInternalNodes):
        xi = nodes.positions()[i]
        r = xi.magnitude()
        runit = xi.unitVector()
        vunit = Vector2d(-runit.y, runit.x)
        nodes.velocity()[i] = vunit*r*omega0
Exemplo n.º 8
0
elif testDim == "2d":
    from DistributeNodes import distributeNodes2d
    from GenerateNodeDistribution2d import GenerateNodeDistribution2d
    gen1 = GenerateNodeDistribution2d(nx1, nx1 + nx2, rho1,
                                      distributionType = "lattice",
                                      xmin = (x0, x0),
                                      xmax = (x1, x2),
                                      nNodePerh = nPerh,
                                      SPH = True)
    gen2 = GenerateNodeDistribution2d(nx2, nx1 + nx2, rho2,
                                      distributionType = "lattice",
                                      xmin = (x1, x0),
                                      xmax = (x2, x2),
                                      nNodePerh = nPerh,
                                      SPH = True)
    distributeNodes2d((nodes1, gen1),
                      (nodes2, gen2))

elif testDim == "3d":
    from DistributeNodes import distributeNodes3d
    from GenerateNodeDistribution3d import GenerateNodeDistribution3d
    gen1 = GenerateNodeDistribution3d(nx1, nx1 + nx2, nx1 + nx2, rho1,
                                      distributionType = "lattice",
                                      xmin = (x0, x0, x0),
                                      xmax = (x1, x2, x2),
                                      nNodePerh = nPerh,
                                      SPH = True)
    gen2 = GenerateNodeDistribution3d(nx2, nx1 + nx2, nx1 + nx2, rho2,
                                      distributionType = "lattice",
                                      xmin = (x1, x0, x0),
                                      xmax = (x2, x2, x2),
                                      nNodePerh = nPerh,