Esempio n. 1
0
def test_mpi_comm_method(case_path):
    mesh = Mesh.create(case_path)
    IOField.setMesh(mesh)
    with IOField.handle(1.):
        U = IOField.read('U')
        U.partialComplete()
    with IOField.handle(2.):
        U.write()
    return
Esempio n. 2
0
def test_mpi_comm():
    case_path = os.path.join(cases_path, 'forwardStep')
    mesh = Mesh.create(case_path)
    IOField.setMesh(mesh)
    with IOField.handle(0.):
        U = IOField.read('U')
        U.partialComplete()
    U.field = np.random.rand(*U.field.shape)

    try:
        with IOField.handle(1.):
            U.write()
        time.sleep(1)
        subprocess.check_output(
            ['decomposePar', '-case', case_path, '-time', '1'])
        subprocess.check_output([
            'mpirun', '-np', '4', 'python2', __file__, 'RUN',
            'test_mpi_comm_method', case_path
        ])
        checkFields(case_path, 'U', '1.0', '2.0', relThres=1e-12, nProcs=4)
    finally:
        shutil.rmtree(os.path.join(case_path, '1'))
        map(shutil.rmtree, glob.glob(os.path.join(case_path, 'processor*')))
Esempio n. 3
0
File: hdf5.py Progetto: qiqi/adFVM
#!/usr/bin/python2
from adFVM import parallel, config
import sys
import os
case = sys.argv[1]
times = [float(x) for x in sys.argv[2:]]

config.hdf5 = False
from adFVM.field import IOField
from adFVM.mesh import Mesh

mesh = Mesh.create(case)
mesh.writeHDF5(case)
IOField.setMesh(mesh)

if len(times) == 0:
    times = mesh.getTimes()

for time in times:
    config.hdf5 = False
    fields = []
    with IOField.handle(time):
        for name in mesh.getFields(time):
            if name == 'polyMesh':
                # replace mesh boundary !!
                continue
            phi = IOField.readFoam(name)
            phi.partialComplete()
            fields.append(phi)

    config.hdf5 = True