def MakeOperator(case_dir, time, filename, mu, pr): mesh = OfMesh(case_dir, time + 'C', time + 'V', time + 'U', time + 'p') ave_field = OfData(mesh, case_dir + time, 'UMean', 'pMean', 'rhoMean', add_e=True, add_pres=True) linear_ns = LNS(mesh, ave_field, mu=mu, pr=pr, is2d=True) # viscosity and Prandtl number mat_maker = MatMaker(linear_ns, mesh.n_cell, ave_field=ave_field) mat_maker.make_mat() mat_maker.save_mat(filename)
def CalcRandomizedResolvent(case_dir, time, operator_name, save_name, k=3, omega=None, alpha=None, mode='Both', mpi_comm=None): mesh = OfMesh(case_dir, time + 'C', time + 'V', time + 'U', time + 'p') ave_field = OfData(mesh, case_dir + time, 'UMean', 'pMean', 'rhoMean') if isinstance(omega, tuple): omega_array = np.linspace(*omega) else: omega_array = np.array([omega]) if isinstance(alpha, tuple): alpha_array = np.linspace(*alpha) else: alpha_array = np.array([alpha]) grid_list = [(o, a) for o, a in product(omega_array, alpha_array)] resolvent_mode = RandomizedResolvent(mesh, ave_field, operator_name, k=k, mode=mode, mpi_comm=mpi_comm) resolvent_mode.solve(grid_list, save_name)
def CalcStability(case_dir, time, operator_name, save_name, k=3, sigma_real=None, sigma_imag=None, which='LM'): mesh = OfMesh(case_dir, time + 'C', time + 'V', time + 'U', time + 'p') if isinstance(sigma_real, tuple): s_real_array = np.linspace(*sigma_real) else: s_real_array = np.array([sigma_real]) if isinstance(sigma_imag, tuple): s_imag_array = np.linspace(*sigma_imag) else: s_imag_array = np.array([sigma_imag]) grid_list = [(r, i) for r, i in product(s_real_array, s_imag_array)] ls_mode = LSMode(mesh, operator_name, n_grid=len(grid_list), add_pres=True, k=k, which=which) ls_mode.solve(grid_list) ls_mode.save_data(save_name + '.pickle') ls_mode.vis_tecplot(save_name + '.dat')
def main(case_dir, time, mu, pr): mesh = OfMesh(case_dir, time + 'C', time + 'V', time + 'U', time + 'p') field = OfData(mesh, case_dir + time, 'U', 'p', 'rho') rhs = RHS(mesh, field, mu, pr, is2d=True) rhs.vis_tecplot('rhs_data.dat')
from Functions.Mesh import OfMesh from Functions.FieldData import OfData from Functions.MatMaker import MatMaker # from MatMaker import TargetEq from Functions.BoundaryCondition import BoundaryCondition as BDcond from Functions.Gradient import Gradient data_dir = 'Data/cavity/' mesh = OfMesh(data_dir, '0.5/C', '0.5/V', '0.5/U', '0.5/p') field = OfData(data_dir, '0.5/U', '0.5/p', '0.5/p') bd_cond = BDcond(mesh) target_eq = Gradient(mesh, field, bd_cond, axis=0) mat_maker = MatMaker(mesh.n_cell, field.n_val, target_eq) operator_test = mat_maker.make_mat()