The main class that basically runs everything. More...
#include <Solver.hpp>
Public Member Functions | |
| Solver (int n_dim, int row_size, double root_mesh_size, Time_scheme time_scheme, Transport_model viscosity_model=inviscid, Transport_model thermal_conductivity_model=inviscid, Turbulence_model turbulence_model=laminar, std::shared_ptr< Namespace > space=std::make_shared< Namespace >()) | |
| Transport_model | viscosity_model () const |
| Transport_model | conductivity_model () const |
| Turbulence_model | turbulence_model () const |
setup | |
| Namespace & | nspace () |
| Mesh & | mesh () |
| Reference to the namespace which can be used to edit user-defined parameters. | |
| void | read_mesh (std::string file_name, std::vector< std::shared_ptr< Flow_bc > > extremal_bcs, std::shared_ptr< Surface_geom >={}, std::shared_ptr< Flow_bc > surface_bc={}) |
| reads mesh from file | |
| void | read_state (std::string file_name) |
| Reads flow state from file. | |
| Storage_params | storage_params () |
| void | calc_jacobian () |
| compute the Jacobian of all elements based on the current position of the vertices and value of any face warping. | |
| void | init_wall_dist () |
| void | update_wall_dist (Int n_iter) |
| void | initialize (std::string expression) |
| set the flow state from an HIL expression | |
| bool | using_art_visc () |
returns true if artificial viscosity is currently turned on | |
| void | set_art_visc_off () |
| turns off artificial viscosity | |
| void | set_art_visc_constant (double) |
| turns on artificial viscosity and initializes coefficient to a uniform value | |
| void | set_art_visc_row_size (int) |
| modify the polynomial order of smoothness-based artificial viscosity | |
| void | set_fix_nonphysical (bool) |
| turns on/off the nonphysical-state-fixing scheme | |
| void | set_uncertainty (const Element_func &func) |
set Element::uncertainty for each element according to func. | |
| void | set_uncertainty (double) |
set Element::uncertainty to a uniform constant | |
| void | set_uncert_surface_rep (int bc_sn) |
| Set uncertainty metric based on surface representation quality. | |
time marching | |
| void | smooth_init_cond (Int n_iter) |
| void | update () |
| int | next_time_stage () |
| Switch to the next implicit unsteady time integration stage. | |
| void | compute_residual (bool unsteady_implicit) |
| void | update_preti_iters () |
| void | print_preti_iters () |
| void | compute_spectral_uncertainty () |
| void | update_bound_conds () |
| void | compute_lts_constraints () |
| Computes the minimum ratio between the local diffusive and convective time steps. | |
| Is_physical_result | is_physical () |
| check whether flowfield is physically admissible (e.g. density and energy are positive) | |
| void | update_art_visc_smoothness () |
| updates the aritificial viscosity coefficient based on smoothness of the flow variables | |
| void | update_art_visc_elwise (double width, bool pde_based=false) |
| (experimental) sets artificial viscosity based on elementwise smoothness | |
| Iteration_status | iteration_status () |
| an object providing all available information about the status of the time marching iteration. | |
| void | reset_counters () |
output | |
functions that compute some form of output data | |
| std::vector< double > | sample (int ref_level, bool is_deformed, int serial_n, int i_qpoint, const Qpoint_func &) |
| evaluate arbitrary functions at arbitrary locations | |
| std::vector< double > | sample (int ref_level, bool is_deformed, int serial_n, const Element_func &) |
| void | bounds_surface (std::string expression, int bc_sn, int n_sample) |
| compute bounds of an expression over a boundary surface | |
| const Stopwatch_tree & | stopwatch_tree () |
| obtain performance data | |
| std::vector< double > | integral_field (const Qpoint_func &integrand) |
| compute an integral over the entire flow field at the current time | |
| void | integrate_field (std::string expression) |
| void | integrate_surface (std::string expression, int bc_sn) |
| compute an integral over all surfaces where a particular boundary condition has been enforced | |
| void | visualize_field (std::string format, std::string name, std::string expression, int n_sample=10, bool wireframe=false) |
| write a visualization file describing the entire flow field (but not identifying surfaces) | |
| void | visualize_surface (std::string format, std::string name, int bc_sn, std::string expression, int n_sample=10, bool wireframe=false) |
| write a visualization file describing all surfaces where a particular boundary condition has been enforced. | |
| void | visualize_contour (std::string format, std::string name, std::string contour_expression, std::string vis_expression, double const_tol=1e-10, int n_sample=10) |
| void | vis_lts_constraints (std::string format, std::string name, int n_sample=10) |
| visualize the local time step constraints imposed by convection and diffusion, respectively | |
| void | write_state (std::string file_name) |
| Writes flow state to file. | |
| Array< double > | skews () |
| get a list of the Equiangle_skewness for each element | |
The main class that basically runs everything.
If you want to run a simulation with hexed through the C++ API, your workflow should be roughly the following:
Solver objectmesh() object to build the mesh topology and/or snap verticescalc_jacobian() to initialize internal parameters based on the meshinitialize() to initialize the flow stateupdate() repeatedly to progress the simulation| hexed::Solver::Solver | ( | int | n_dim, |
| int | row_size, | ||
| double | root_mesh_size, | ||
| Time_scheme | time_scheme, | ||
| Transport_model | viscosity_model = inviscid, | ||
| Transport_model | thermal_conductivity_model = inviscid, | ||
| Turbulence_model | turbulence_model = laminar, | ||
| std::shared_ptr< Namespace > | space = std::make_shared<Namespace>() ) |
| n_dim | number of dimensions |
| row_size | row size of the basis (see Terminology) |
| root_mesh_size | sets the value of Mesh::root_mesh_size() |
| time_scheme | what numerical scheme to use for time integration |
| viscosity_model | determines whether the flow has viscosity (natural, not artificial) and if so, how it depends on temperature |
| thermal_conductivity_model | determines whether the flow has thermal conductivity and if so, how it depends on temperature |
| turbulence_model | How and if to model turbulence. |
| space | Namespace containing any user-defined parameters affecting the behavior of the solver. If no namespace is provided, a new blank namespace is creqated. Any optional parameters which are not found in the namespace shall be created with their default values. |
If viscosity_model and thermal_conductivity_model are both inviscid and you don't turn on artificial viscosity, you will be solving the pure inviscid flow equations. Otherwise, you will be solving the viscous flow equations using the LDG scheme, potentially with some of the diffusion coefficients (artificial viscosity, natural viscosity, thermal conductivity) set to zero.
| void hexed::Solver::calc_jacobian | ( | ) |
compute the Jacobian of all elements based on the current position of the vertices and value of any face warping.
Mesh topology must be valid (no duplicate or missing connections) before calling this function.
| void hexed::Solver::compute_lts_constraints | ( | ) |
Computes the minimum ratio between the local diffusive and convective time steps.
Assumes no Chebyshev acceleration. Result is written to min_lts_dc_ratio in the HIL namespace.
| void hexed::Solver::initialize | ( | std::string | expression | ) |
set the flow state from an HIL expression
espression must set the variables momentum0, ..., momentum[n_dim - 1], density, energy
| Iteration_status hexed::Solver::iteration_status | ( | ) |
an object providing all available information about the status of the time marching iteration.
The Iteration_status::start_time member will refer to when the Solver object was created (specifically at the start of the Solver::Solver body).
| Mesh & hexed::Solver::mesh | ( | ) |
Reference to the namespace which can be used to edit user-defined parameters.
fetch the Mesh.
An object the user can use to build the mesh. Note that whenever elements are added, the flow state, and Jacobian are uninitialized, the time step scale is uniformly 1, and the mesh quality may be poor. The functions below must be used to complete the setup before any flow calculation can begin.
| int hexed::Solver::next_time_stage | ( | ) |
Switch to the next implicit unsteady time integration stage.
| void hexed::Solver::read_mesh | ( | std::string | file_name, |
| std::vector< std::shared_ptr< Flow_bc > > | extremal_bcs, | ||
| std::shared_ptr< Surface_geom > | geom = {}, | ||
| std::shared_ptr< Flow_bc > | surface_bc = {} ) |
reads mesh from file
Wipes old mesh and flow state. File must be in the native (HDF5-based) mesh format, which you can generate from a previous simulation with Mesh::write. .mesh.h5 will be automatically appended to file_name. New mesh must match the Storage_params of the current one, but the root mesh size will be replaced with that of the new mesh. You still have to initialize (even if you already did before reading the new mesh), but you don't have to calc_jacobian unless you further modify the mesh.
| void hexed::Solver::read_state | ( | std::string | file_name | ) |
Reads flow state from file.
Essentially a substitute for initialize. .state.h5 will be appended to file name
| void hexed::Solver::reset_counters | ( | ) |
reset any variables in iteration_status() that count something since the last call to reset_counters() (e.g. number of artificial viscosity iterations)
| std::vector< double > hexed::Solver::sample | ( | int | ref_level, |
| bool | is_deformed, | ||
| int | serial_n, | ||
| const Element_func & | func ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hexed::Solver::set_art_visc_row_size | ( | int | row_size | ) |
modify the polynomial order of smoothness-based artificial viscosity
must be <= row size of discretization (which is the default)
| void hexed::Solver::set_fix_nonphysical | ( | bool | value | ) |
turns on/off the nonphysical-state-fixing scheme
increases robustness at some computational overhead
| void hexed::Solver::set_uncert_surface_rep | ( | int | bc_sn | ) |
Set uncertainty metric based on surface representation quality.
For all deformed elements contacting the boundary specified by bc_sn, computes the unit surface normals at the faces and compares to neighboring elements. Element::uncertainty is set to the total difference between unit normals with all neighbors, where in 3D the total on each edge is computed by Gaussian quadrature in reference space.
| void hexed::Solver::set_uncertainty | ( | const Element_func & | func | ) |
set Element::uncertainty for each element according to func.
Uncertainty metric can be evaluated via sample(ref_level, is_deformed, serial_n, Uncertainty()). This function does some additional work to enforce some conditions on the uncertainty of neighboring elements. Thus, use this function rather than just sample(ref_level, is_deformed, serial_n, func) directly.
| void hexed::Solver::update | ( | ) |
March the simulation forward by a time step equal to time_step or max_safety times the estimated maximum stable time step, whichever is smaller. Also, the safety factor is not the same as the CFL number (it is scaled by the max allowable CFL for the chosen DG scheme which is often O(1e-2)).
| void hexed::Solver::update_art_visc_elwise | ( | double | width, |
| bool | pde_based = false ) |
(experimental) sets artificial viscosity based on elementwise smoothness
Based on the work of Persson et al. on artificial viscosity with elementwise smoothness indicators. Implemented primarily for evaluating the difference between grid-independent artificial viscosity and conventional methods.
Solver::update_art_visc_smoothness, which was developed to supplant this type of approach. | void hexed::Solver::vis_lts_constraints | ( | std::string | format, |
| std::string | name, | ||
| int | n_sample = 10 ) |
visualize the local time step constraints imposed by convection and diffusion, respectively
update is called again. | void hexed::Solver::visualize_field | ( | std::string | format, |
| std::string | name, | ||
| std::string | expression, | ||
| int | n_sample = 10, | ||
| bool | wireframe = false ) |
write a visualization file describing the entire flow field (but not identifying surfaces)
| format | Which format to write the visualization file in. Accepted values are "xdmf" and "tecplot" |
| name | name of file to write (not including extension) |
| expression | HIL expression specifying variables to visualize. Each variable assigned to in expression will be visualized. |
| n_sample | each element will contain an n_sample by n_sample array of uniformly-spaced sample points |
| wireframe | if true, visualize the mesh edges as a wireframe instead of the filled surface/solid |
| void hexed::Solver::write_state | ( | std::string | file_name | ) |
Writes flow state to file.
.state.h5 will be appended to file_name.