Exemplo 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
Exemplo n.º 2
0
def diffAllTimes():
    case1, case2, field = sys.argv[1:]
    mesh1 = Mesh.create(case1)
    mesh2 = Mesh.create(case2)

    times1 = mesh1.getTimes()
    times2 = mesh2.getTimes()

    for time1, time2 in zip(times1, times2):
        Field.setMesh(mesh1)
        with IOField.handle(time1):
            phi1 = IOField.read(field)
        Field.setMesh(mesh2)
        with IOField.handle(time2):
            phi2 = IOField.read(field)
        diff = np.abs(phi1.field-phi2.field)
        norm = np.sqrt(parallel.sum(diff**2*mesh1.volumes))
        pprint(parallel.min(diff))
        pprint('norm:', norm)
Exemplo n.º 3
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*')))
Exemplo n.º 4
0
#!/usr/bin/python2
import sys, os
import numpy as np

from adFVM import config
from adFVM.field import Field, IOField
from adFVM.mesh import Mesh

case1, case2 = sys.argv[1:]
mesh = Mesh.create(case1)
times = mesh.getTimes()
Field.setMesh(mesh)

fields = ['p', 'T', 'U']
for name in fields:
    phimax = -1
    for time in times:
        mesh.case = case1
        phi1 = IOField.read(name, mesh, time)
        phi1.partialComplete()
        if phimax < 0:
            phimax = phi1.field.max()
        mesh.case = case2
        phi2 = IOField.read(name, mesh, time)
        phi2.partialComplete()
        phi1.name += '_diff'
        phi1.field = (phi2.field-phi1.field)/phimax
        phi1.write(time)

Exemplo n.º 5
0
import numpy as np

from adFVM import config
from adFVM.field import Field, IOField
from adFVM.mesh import Mesh

#config.hdf5 = True
case1, case2, time1, time2 = sys.argv[1:5]
if len(sys.argv) > 5:
    skipZ = True
else:
    skipZ = False
time1 = float(time1)
time2 = float(time2)

mesh1 = Mesh.create(case1)
mesh2 = Mesh.create(case2)

from scipy.spatial import cKDTree as KDTree


def mapNearest(centres1, centres2):
    if skipZ:
        centres1 = centres1[:, :2]
        centres2 = centres2[:, :2]
    tree = KDTree(centres1)
    indices = tree.query(centres2)[1]
    #print centres1.shape, centres2.shape, indices.shape
    return indices