Пример #1
0
    def update_from_file(self, path_u=None, path_p=None, path_rho=None):
        if path_u is None:
            path_u = self.path_u

        if path_p is None:
            path_p = self.path_p

        if path_rho is None:
            path_rho = self.path_rho

        u_data = Ofpp.parse_internal_field(self.path_dir + path_u)
        p_data = Ofpp.parse_internal_field(self.path_dir + path_p)
        rho_data = Ofpp.parse_internal_field(self.path_dir + path_rho)

        # Calculate conservative variables
        u = u_data[:, 0]
        v = u_data[:, 1]
        w = u_data[:, 2]

        ru = rho_data * u
        rv = rho_data * v
        rw = rho_data * w
        e = p_data / (1.4 - 1.0) + 0.5 * rho_data * (u * u + v * v + w * w)

        self.n_cell = u_data.shape[0]
        # self.data = np.hstack((rho_data[:, np.newaxis], u_data, p_data[:, np.newaxis]))
        self.data = np.vstack((rho_data, ru, rv, rw, e)).T
Пример #2
0
def getfeatures(path):
    import Ofpp
    dir_xyz = '0'
    meshx_test = Ofpp.parse_internal_field(path+dir_xyz+'/ccx')
    meshy_test = Ofpp.parse_internal_field(path+dir_xyz+'/ccy')
    meshz_test = Ofpp.parse_internal_field(path+dir_xyz+'/ccz')
    meshx_test = meshx_test + 0.02 + 0.018
    mesh_test = np.vstack([meshx_test.T,meshy_test.T,meshz_test.T]).T
    return mesh_test
Пример #3
0
    def update_from_file(self, path_u=None, path_p=None, path_rho=None):
        if path_u is None:
            path_u = self.path_u

        if path_p is None:
            path_p = self.path_p

        if path_rho is None:
            path_rho = self.path_rho

        u_data = Ofpp.parse_internal_field(self.path_dir + path_u)
        p_data = Ofpp.parse_internal_field(self.path_dir + path_p)
        rho_data = Ofpp.parse_internal_field(self.path_dir + path_rho)

        # Calculate temperature
        t_data = 1.4 * p_data / rho_data

        self.n_cell = u_data.shape[0]
        # self.data = np.hstack((rho_data[:, np.newaxis], u_data, p_data[:, np.newaxis]))
        self.data = np.hstack(
            (rho_data[:, np.newaxis], u_data, t_data[:, np.newaxis]))
Пример #4
0
def getfeatures(path):
    import os
    import Ofpp
    dir_xyz = '0'
    meshx_test = Ofpp.parse_internal_field(path + dir_xyz + '/ccx')
    meshy_test = Ofpp.parse_internal_field(path + dir_xyz + '/ccy')
    meshz_test = Ofpp.parse_internal_field(path + dir_xyz + '/ccz')
    meshx_test = meshx_test + 0.02
    V = Ofpp.parse_internal_field(path + dir_xyz + '/V')
    mesh_test = np.vstack([meshx_test.T, meshy_test.T, meshz_test.T]).T
    folders = next(os.walk(path))[1]
    new_folders = [folder for folder in folders if folder.isdigit()]
    num_folders = [int(folder) for folder in new_folders]
    dir_result = str(max(num_folders))
    U = Ofpp.parse_internal_field(path + dir_result + '/U')
    gradU = Ofpp.parse_internal_field(path + dir_result + '/gradU')
    dwall = Ofpp.parse_internal_field(path + dir_result + '/dwall')
    if os.path.isfile(path + dir_result + '/k'):
        k = Ofpp.parse_internal_field(path + dir_result + '/k')
    else:
        k = np.copy(meshx_test)
        k[:] = 0
    feature = np.vstack([U.T, gradU.T, dwall.T, k.T, V.T]).T
    return feature, mesh_test
            current_path = join(thisTime_path, column)

            this_time_dir = os.listdir(thisTime_path)
            # # print(this_time_dir)
            # if 'PV' in this_time_dir:
            #     PV_FLAG = True
            # else:
            #     PV_FLAG = False

            if 'f_Bilger' in this_time_dir:
                f_Bilger_FLAG = True
            else:
                f_Bilger_FLAG = False

            if os.path.exists(current_path):
                this_df[column] = Ofpp.parse_internal_field(
                    current_path)  # column is also the field name here
            else:
                #raise FileNotFoundError
                print('%s Not Found!' % column)
                this_df[column] = 0

        # f_Bilger computation
        Y = this_df[species_lu19].values
        f_Bilger = compute_fBilger(Y)
        # print('f_Bilger: ',f_Bilger)
        this_df['f_Bilger'] = f_Bilger

        print(' ')
        print(this_df.head())
        print('  ')
# u_np = VN.vtk_to_numpy(data.GetCellData().GetArray('U'))
#
#
#
# myArr = vtk.vtkPassArrays()
# myArr.SetInputDataObject(reader.GetInputDataObject(0, 0))

# p2c = vtk.vtkCellDataToPointData()
# p2c.SetInputConnection(reader.GetOutputPort())
# p2c.Update()

import Ofpp as of
import numpy as np
import matplotlib.pyplot as plt
# From low to high x, then low to high y, lastly, low to high z
U = of.parse_internal_field('./ABL_N_H/Field/20000.9038025/U')

ccx = of.parse_internal_field('./ABL_N_H/Field/20000.9038025/ccx')

ccy = of.parse_internal_field('./ABL_N_H/Field/20000.9038025/ccy')

ccz = of.parse_internal_field('./ABL_N_H/Field/20000.9038025/ccz')

cc = np.vstack((ccx, ccy, ccz))

sliceOrigin = (0, 0, 90)
sliceNormal = (0, 0, 1)

idx = np.argwhere((ccz > 94) & (ccz < 96))

Uground = U[0:90000]
Пример #7
0
                    help="The path of all merlin runs")

args = parser.parse_args()

DATA_DIR = args.data_dir
X = args.merlin_paths

dir_names = [DATA_DIR + "/" + Xi + "/cavity" for Xi in X]

num_of_timesteps = 10
U = []
enstrophy = []

for i, dir_name in enumerate(dir_names):
    for name in glob.glob(dir_name + "/[0-9]*/U"):
        if name[-4:] == "/0/U":
            continue
        U.append(Ofpp.parse_internal_field(name))

    for name in glob.glob(dir_name + "/[0-9]*/enstrophy"):
        if name[-12:] == "/0/enstrophy":
            continue
        enstrophy.append(Ofpp.parse_internal_field(name))

resolution = np.array(enstrophy).shape[-1]
U = np.array(U).reshape(len(dir_names), num_of_timesteps, resolution, 3)
enstrophy = np.array(enstrophy).reshape(len(dir_names), num_of_timesteps,
                                        resolution) / float(resolution)

np.savez("data.npz", U, enstrophy)