UM2N.generator package¶
Submodules¶
UM2N.generator.burgers_solver module¶
UM2N.generator.equation_generator module¶
UM2N.generator.equation_solver module¶
UM2N.generator.mesh_generator module¶
- class MeshGenerator(params={'eq': None, 'mesh': None, 'num_grid_x': None, 'num_grid_y': None})[source]¶
Bases:
object
- Responsible for generating and moving a mesh based on a given Helmholtz
equation.
This method is based on Pyroteus/movement.
Attributes: - eq: The Helmholtz equation object. - num_grid_x: Number of grid points in the x-dimension. - num_grid_y: Number of grid points in the y-dimension. - mesh: The initial m esh.
- move_mesh()[source]¶
Moves the mesh using the Monge-Ampere equation. Computes and stores the Jacobian and its determinant.
Returns: - The moved mesh
UM2N.generator.rand_source_generator module¶
- class RandSourceGenerator(use_iso=False, dist_params={'c_max': 0.8, 'c_min': 0.2, 'max_dist': 10, 'n_dist': None, 'sigma_eps': 0.125, 'sigma_mean_scaler': 0.25, 'sigma_sigma_scaler': 0.16666666666666666, 'w_max': 0.2, 'w_min': 0.05, 'x_end': 1, 'x_start': 0, 'y_end': 1, 'y_start': 0, 'z_max': 1, 'z_min': 0})[source]¶
Bases:
object
Class for generating a random Helmholtz equation based on a Gaussian distribution.
- Attributes:
simple_u (bool): Flag for using simpler form of u. dist_params (dict): Parameters for Gaussian distribution. u_exact: Analytical Helmholtz equation solution. f: Simulated source function. function_space: Function space for problem. LHS: Left-hand side of Helmholtz equation. RHS: Right-hand side of Helmholtz equation. bc: Dirichlet boundary condition.
UM2N.generator.swirl_demo module¶
UM2N.generator.swirl_solver module¶
- get_c(x, y, t, threshold=0.5, alpha=1.5)[source]¶
Compute the velocity field which transports the solution field u. Args:
alpha (float): coefficient for velocity magnitude.
- Return:
velocity (ufl.tensors): expression of the swirl velocity field
- get_u_0(x, y, r_0=0.2, x_0=0.5, y_0=0.75, sigma=0.016666666666666666)[source]¶
Compute the initial trace value.
- Return:
u_0 (ufl.tensors): expression of u_0
- class SwirlSolver(mesh, mesh_fine, mesh_new, mesh_model, **kwargs)[source]¶
Bases:
object
- Solver for advection swirl problem:
Solver implementation for the swirl problem
Mesh mover for the swirl problem
Error & Time evaluation
- solve_u(t)[source]¶
Solve the PDE problem using RK (SSPRK) scheme on the coarse mesh store the solution field to a varaible: self.u_cur
- solve_u_fine(t)[source]¶
Solve the PDE problem using RK (SSPRK) scheme on the fine mesh store the solution field to a varaible: self.u_cur_fine
UM2N.generator.swirl_solver_step module¶
- get_c(x, y, t, threshold=0.5, alpha=1.5)[source]¶
Compute the velocity field which transports the solution field u. Args:
alpha (float): coefficient for velocity magnitude.
- Return:
velocity (ufl.tensors): expression of the swirl velocity field
- get_u_0(x, y, r_0=0.2, x_0=0.5, y_0=0.75, sigma=0.016666666666666666)[source]¶
Compute the initial trace value.
- Return:
u_0 (ufl.tensors): expression of u_0
- class SwirlSolver(mesh, mesh_fine, mesh_new, **kwargs)[source]¶
Bases:
object
- Solver for advection swirl problem:
Solver implementation for the swirl problem
Mesh mover for the swirl problem
Error & Time evaluation
- solve_u(t)[source]¶
Solve the PDE problem using RK (SSPRK) scheme on the coarse mesh store the solution field to a varaible: self.u_cur
UM2N.generator.unstructured_mesh module¶
Module for handling generating unstructured meshes.
- class UnstructuredMeshGenerator(scale=1.0, mesh_type=2)[source]¶
Bases:
ABC
Base class for mesh generators.
- abstract property corners¶
Property defining the coordinates of the corner vertices of the domain to be meshed.
- Returns:
coordinates of the corner vertices of the domain
- Return type:
- generate_mesh(res=0.1, output_filename='./temp.msh', remove_file=False)[source]¶
Generate a mesh at a given resolution level.
- Parameters:
res (float) – mesh resolution (element diameter) (default: 0.1, suitable for mesh with scale 1.0)
output_filename (str) – filename for saving the mesh, including the path and .msh extension (default: ‘./temp.msh’)
remove_file (bool) – should the .msh file be removed after generation? (default: False)
- Returns:
mesh generated
- Return type:
- class UnstructuredSquareMeshGenerator(scale=1.0, mesh_type=2)[source]¶
Bases:
UnstructuredMeshGenerator
Generate an unstructured mesh of a 2D square domain using Gmsh.
- class UnstructuredRandomPolygonalMeshGenerator(scale=1.0, mesh_type=2)[source]¶
Bases:
UnstructuredMeshGenerator
Create a random polygonal mesh by spliting the edge of a square randomly.