-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2700 from nilsdeppe/boundary_correction_random
Add python test function for boundary corrections
- Loading branch information
Showing
3 changed files
with
365 additions
and
18 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
tests/Unit/Evolution/DiscontinuousGalerkin/BoundaryCorrectionsHelper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Distributed under the MIT License. | ||
# See LICENSE.txt for details. | ||
|
||
import numpy as np | ||
|
||
|
||
def dg_package_data_var1(var1, var2, flux_var1, flux_var2, normal_covector, | ||
mesh_velocity, normal_dot_mesh_velocity, | ||
volume_double): | ||
return var1 | ||
|
||
|
||
def dg_package_data_var1_normal_dot_flux(var1, var2, flux_var1, flux_var2, | ||
normal_covector, mesh_velocity, | ||
normal_dot_mesh_velocity, | ||
volume_double): | ||
return np.einsum("i,i->", flux_var1, normal_covector) | ||
|
||
|
||
def dg_package_data_var2(var1, var2, flux_var1, flux_var2, normal_covector, | ||
mesh_velocity, normal_dot_mesh_velocity, | ||
volume_double): | ||
return var2 | ||
|
||
|
||
def dg_package_data_var2_normal_dot_flux(var1, var2, flux_var1, flux_var2, | ||
normal_covector, mesh_velocity, | ||
normal_dot_mesh_velocity, | ||
volume_double): | ||
return np.einsum("ij,j->i", flux_var2, normal_covector) | ||
|
||
|
||
def dg_package_data_abs_char_speed(var1, var2, flux_var1, flux_var2, | ||
normal_covector, mesh_velocity, | ||
normal_dot_mesh_velocity, volume_double): | ||
if not isinstance(volume_double, float): | ||
volume_double = volume_double[0] | ||
if normal_dot_mesh_velocity is None: | ||
return np.abs(volume_double * var1) | ||
else: | ||
return np.abs(volume_double * var1 - normal_dot_mesh_velocity) | ||
|
||
|
||
def dg_boundary_terms_var1(var1_int, normal_dot_flux_var1_int, var2_int, | ||
normal_dot_flux_var2_int, abs_char_speed_int, | ||
var1_ext, normal_dot_flux_var1_ext, var2_ext, | ||
normal_dot_flux_var2_ext, abs_char_speed_ext, | ||
use_strong_form): | ||
if use_strong_form: | ||
return (-0.5 * (normal_dot_flux_var1_int + normal_dot_flux_var1_ext) - | ||
0.5 * np.maximum(abs_char_speed_int, abs_char_speed_ext) * | ||
(var1_ext - var1_int)) | ||
else: | ||
return (0.5 * (normal_dot_flux_var1_int - normal_dot_flux_var1_ext) - | ||
0.5 * np.maximum(abs_char_speed_int, abs_char_speed_ext) * | ||
(var1_ext - var1_int)) | ||
|
||
|
||
def dg_boundary_terms_var2(var1_int, normal_dot_flux_var1_int, var2_int, | ||
normal_dot_flux_var2_int, abs_char_speed_int, | ||
var1_ext, normal_dot_flux_var1_ext, var2_ext, | ||
normal_dot_flux_var2_ext, abs_char_speed_ext, | ||
use_strong_form): | ||
if use_strong_form: | ||
return (-0.5 * (normal_dot_flux_var2_int + normal_dot_flux_var2_ext) - | ||
0.5 * np.maximum(abs_char_speed_int, abs_char_speed_ext) * | ||
(var2_ext - var2_int)) | ||
else: | ||
return (0.5 * (normal_dot_flux_var2_int - normal_dot_flux_var2_ext) - | ||
0.5 * np.maximum(abs_char_speed_int, abs_char_speed_ext) * | ||
(var2_ext - var2_int)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.