コード例 #1
0
ファイル: System.py プロジェクト: daveb-dev/ParticleModule
def get_system_from_options(options_file=None,
                            boundary_grid=None,
                            block=None,
                            velocity_name='Velocity',
                            dist=None):
    """Derive particle system from options file."""

    reader = Options.OptionsReader(options_file)

    if boundary_grid is None:

        mesh = IO.GmshMesh()
        mesh.read(reader.get_mesh_filename())

        boundary_grid = IO.make_boundary_from_msh(mesh)

    boundary = IO.BoundaryData(bnd=boundary_grid,
                               outlet_ids=reader.get_outlet_ids(),
                               inlets=reader.get_inlets(),
                               dist=dist)

    if block is None:
        system = System(boundary,
                        base_name=reader.get_name(),
                        gravity=reader.get_gravity(),
                        omega=reader.get_rotation()[0],
                        velocity_name=velocity_name)
    else:
        system = System(boundary,
                        block=block,
                        gravity=reader.get_gravity(),
                        omega=reader.get_rotation()[0],
                        velocity_name=velocity_name)

    return system
コード例 #2
0
def test_make_unstructured_grid(tmpdir):
    """ Test the make_unstructured_grid routine."""

    mesh = IO.GmshMesh()
    mesh.read("/".join((DATA_DIR, 'Structured.msh')))

    print("/".join((DATA_DIR, 'Structured.msh')))
    num = len(mesh.nodes)

    vel = numpy.zeros((num, 3))
    pres = numpy.zeros((num, ))
    time = 0

    ugrid = IO.make_unstructured_grid(
        mesh, vel, pres, time, outfile=tmpdir.join('Structured.vtu').strpath)

    assert num > 0
    assert ugrid.GetNumberOfPoints() == num
    assert ugrid.GetNumberOfCells() == len(mesh.elements)
    assert filecmp.cmpfiles(DATA_DIR, tmpdir.strpath, 'Structured.vtu')

    ugrid = IO.make_unstructured_grid(
        mesh,
        lambda x: (0, 0, 0),
        lambda x: 0,
        time,
        outfile=tmpdir.join('Structured.vtu').strpath)

    assert ugrid.GetNumberOfPoints() == num
    assert ugrid.GetNumberOfCells() == len(mesh.elements)
    assert filecmp.cmpfiles(DATA_DIR, tmpdir.strpath, 'Structured.vtu')
コード例 #3
0
ファイル: System.py プロジェクト: daveb-dev/ParticleModule
def get_system_from_reader(reader, boundary_grid=None):
    """Derive system from options reader."""

    if boundary_grid is None:

        mesh = IO.GmshMesh()
        mesh.read(reader.get_mesh_filename())

        boundary_grid = IO.make_boundary_from_msh(mesh)

    boundary = IO.BoundaryData(bnd=boundary_grid)
    system = System(boundary,
                    base_name=reader.get_name(),
                    gravity=reader.get_gravity(),
                    omega=reader.get_rotation()[0])

    return system
コード例 #4
0
        locator.SetDataSet(reader.GetOutput())
        locator.BuildLocator()

        return ([[0.0, self.fname, reader.GetOutput(), locator],
                 [1.0, self.fname, reader.GetOutput(), locator]], 0.0,
                [['Velocity', 'Pressure'], ['Velocity', 'Pressure']])


BOUNDARY = IO.BoundaryData('particle_model/tests/data/rightward_boundary.vtu')
BOUNDARY3D = IO.BoundaryData('particle_model/tests/data/cube_boundary.vtu')
SYSTEM = System.System(BOUNDARY, coeff=1.0, temporal_cache=temp_cache(),
                       rho=1.0e3, )
SYSTEM3D = System.System(BOUNDARY3D, coeff=1.0,
                         temporal_cache=temp_cache('cube_0.vtu'))

MESH = IO.GmshMesh()
MESH.read('particle_model/tests/data/Structured.msh')
MESH3D = IO.GmshMesh()
MESH3D.read('particle_model/tests/data/Structured_cube.msh')

PAR0 = ParticleBase.PhysicalParticle(diameter=1.0e32,rho=1.0)
PAR1 = ParticleBase.PhysicalParticle(diameter=100.0e-4,rho=1.0e3)

def test_tests():
    """ Test test structure with a minimal test."""
    assert 1

def test_base_particle_initialization():
    """Test basic particle initialization"""
    from numpy import zeros