Пример #1
0
        pa.u = pa.c_s*u_f*(2*(x<0)-1)
        print 'u_f:', pb.u[-1]/pb.c_s, '(%s)'%pb.u[-1]
        
        pb.set(idx=numpy.arange(len(pb.x)))
        print 'Number of particles: ', len(pb.x)

        return [pa, pb]
    else:
        return pa



cfl = 0.1
# use the solvers default cubic spline kernel
# s = StressSolver(dim=2, integrator_type=solver.RK2Integrator)
s = StressSolver(dim=2, integrator_type=solver.PredictorCorrectorIntegrator,
                 xsph=0.5, marts_eps=0.3, marts_n=4, CFL=cfl)


# can be overriden by commandline arguments
dt = 1e-8
tf = 1e-2
s.set_time_step(dt)
s.set_final_time(tf)
s.set_kernel_correction(-1)
s.pfreq = 100

app.setup(s, create_particles=create_particles)

particles = s.particles
pa = particles.arrays[0]
Пример #2
0
    def __init__(self, source, dest, particle_indices, props=['x','y','z'],
                 values=[0,0,0], setup_arrays=True):
        self.indices = particle_indices
        self.props = props
        self.values = values
        SPHFunction.__init__(self, source, dest, setup_arrays)
    
    def set_src_dst_reads(self):
        self.src_reads = self.dst_reads = self.props
        
    def eval(self, solver):
        for i,prop in enumerate(self.props):
            self.dest.get(prop)[self.indices] = self.values[i]

# use the solvers default cubic spline kernel
s = StressSolver(dim=1, integrator_type=solver.PredictorCorrectorIntegrator, xsph=0.5, marts_eps=0.3, marts_n=4, CFL=None)

# can be overriden by commandline arguments
s.set_time_step(1e-7)
s.set_final_time(1e-3)

app.setup(s, create_particles=create_particles)
particles = s.particles
pa = particles.arrays[0]

s.pre_step_functions.append(FixedBoundary(pa, pa, props=['u','x'], values=[0,0],
                                      particle_indices=numpy.flatnonzero(pa.bdry)))

for i in range(len(particles.arrays[0].x)):
    app.command_manager.add_function(PrintPos(i, ['x','y','u','p','rho','sigma00','ubar'],
                  s.output_directory+'/stress%s.dat'%i).function,