Peano
Loading...
Searching...
No Matches
13_euler-with-amr Namespace Reference

Functions

 create_solver (adaptive, dynamic=False, gradient=False)
 The tutorial's solver over a regular, an adaptive or a dynamically adaptive mesh.
 
 build_and_run (directory, adaptive=False, dynamic=False, gradient=False)
 Generate, compile and run the tutorial setup within directory.
 
 build_and_run_fd4 (directory, init_point_wisely)
 Generate, compile and run the fourth-order Finite Differences over the regular mesh within directory.
 
 read_snapshot (directory, snapshot, patch_file=PatchFile)
 Return the time stamp and all patches (offset, size, values) of a snapshot.
 
 number_of_snapshots (directory, patch_file=PatchFile)
 
 density_along_x_axis (directory, snapshot, patch_file=PatchFile)
 Return time stamp plus volume centres and densities along y=0, x>=0.
 
 plot_mesh (directory)
 Initial density plus the patch boundaries.
 
 plot_snapshots (directory)
 Density at three time stamps side by side.
 
 plot_profile (directory)
 Density along the positive x-axis at a few time stamps.
 
 plot_active_patches (directory)
 Highlight the patches which hold steep density gradients at the end.
 
 plot_adaptive_mesh (directory)
 Initial density on the adaptive mesh plus the patch boundaries.
 
 plot_adaptive_snapshots (directory)
 Density at three time stamps on the adaptive mesh plus patch boundaries.
 
 plot_profile_comparison (regular_directory, adaptive_directory)
 Density along the positive x-axis: regular against adaptive mesh.
 
 print_conservation (directory)
 Total mass and energy of the first and the last snapshot.
 
 plot_setup_task_graph ()
 Construct the setup task graph with the refinement criterion and draw it.
 
 patch_counts (directory)
 Time stamps and numbers of patches of all snapshots.
 
 plot_dynamic_patch_count (directory)
 Number of patches per snapshot of the dynamically adaptive run.
 
 plot_dynamic_mesh_change (directory)
 Density and patch boundaries right before the first mesh change and at the end.
 
 gradient_snapshots (directory)
 Snapshots for the comparison of the point-wise and the gradient-based criterion: t=0.1, 0.2 and 0.25.
 
 plot_gradient_profile_comparison (pointwise_directory, gradient_directory)
 Density along the positive x-axis: point-wise against gradient-based criterion.
 
 plot_gradient_patch_counts (pointwise_directory, gradient_directory)
 Number of patches per snapshot of both dynamically adaptive runs.
 
 plot_gradient_mesh (pointwise_directory, gradient_directory)
 Density and patch boundaries of both runs at t=0.2.
 
 create_gradient_pictures (dynamic_directory, gradient_directory, skip_run)
 Run the gradient-based criterion and compare it to the point-wise one.
 
 plot_fd4_explosion_time_step_sizes (directory)
 Time step sizes of the fourth-order Finite Differences for the point explosion.
 
 plot_fd4_snapshots (directory)
 Density of the Gaussian pulse at three time stamps side by side.
 
 plot_fd4_profile (directory)
 Density of the Gaussian pulse along the positive x-axis at a few time stamps.
 
 plot_mesh_adaptation_task_graph ()
 Construct the mesh adaptation task graph of the dynamically adaptive setup and draw it.
 

Variables

 Here = os.path.dirname(os.path.abspath(__file__))
 
 PeanoRoot = os.path.abspath(os.path.join(Here, "..", "..", ".."))
 
str Flux
 
str MaxEigenvalue
 
str InitPointWisely
 
float VolumeSize = 0.005
 
float AdaptiveVolumeSize = 0.02
 
float AdaptiveMinVolumeSize = 0.002
 
str RefineErasePointwisely
 
str DynamicRefineErasePointwisely
 
str GradientRefinement
 
float EndTime = 0.2
 
float DynamicEndTime = 0.3
 
float TimeInBetweenPlots = 0.01
 
str PatchFile = "solution-EulerFV.peano-patch-file"
 
str FD4InitPointWisely
 
str FD4PatchFile = "solution-EulerFD4.peano-patch-file"
 
 parser
 
 default
 
 help
 
 action
 
 args = parser.parse_args()
 
 work_directory
 
 dynamic_directory = os.path.join(work_directory, "dynamic-mesh")
 
 gradient_directory = os.path.join(work_directory, "gradient-mesh")
 
 exist_ok
 
 adaptive
 
 True
 
 dynamic
 
 fd4_explosion_directory = os.path.join(work_directory, "fd4-explosion")
 
 fd4_pulse_directory = os.path.join(work_directory, "fd4-pulse")
 
 directory = os.path.join(work_directory, "regular-grid")
 
 adaptive_directory = os.path.join(work_directory, "adaptive-mesh")
 

Function Documentation

◆ build_and_run()

13_euler-with-amr.build_and_run (   directory,
  adaptive = False,
  dynamic = False,
  gradient = False 
)

Generate, compile and run the tutorial setup within directory.

Definition at line 185 of file 13_euler-with-amr.py.

References create_solver().

Referenced by create_gradient_pictures().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ build_and_run_fd4()

13_euler-with-amr.build_and_run_fd4 (   directory,
  init_point_wisely 
)

Generate, compile and run the fourth-order Finite Differences over the regular mesh within directory.

The run writes its output into directory/run.log, so we can parse the time step sizes afterwards. A run of the point explosion breaks down early, so we do not check its exit code.

Definition at line 211 of file 13_euler-with-amr.py.

◆ create_gradient_pictures()

13_euler-with-amr.create_gradient_pictures (   dynamic_directory,
  gradient_directory,
  skip_run 
)

Run the gradient-based criterion and compare it to the point-wise one.

Expects the point-wise dynamically adaptive run within dynamic_directory.

Definition at line 755 of file 13_euler-with-amr.py.

References build_and_run(), plot_gradient_mesh(), plot_gradient_patch_counts(), plot_gradient_profile_comparison(), and print_conservation().

Here is the call graph for this function:

◆ create_solver()

13_euler-with-amr.create_solver (   adaptive,
  dynamic = False,
  gradient = False 
)

The tutorial's solver over a regular, an adaptive or a dynamically adaptive mesh.

With gradient, the solver refines and erases with the gradient-based criterion instead of the point-wise one. The flag implies a dynamically adaptive mesh.

Definition at line 126 of file 13_euler-with-amr.py.

Referenced by build_and_run(), plot_mesh_adaptation_task_graph(), and plot_setup_task_graph().

Here is the caller graph for this function:

◆ density_along_x_axis()

13_euler-with-amr.density_along_x_axis (   directory,
  snapshot,
  patch_file = PatchFile 
)

Return time stamp plus volume centres and densities along y=0, x>=0.

Definition at line 281 of file 13_euler-with-amr.py.

References read_snapshot().

Referenced by plot_fd4_profile(), plot_gradient_profile_comparison(), plot_profile(), and plot_profile_comparison().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gradient_snapshots()

13_euler-with-amr.gradient_snapshots (   directory)

Snapshots for the comparison of the point-wise and the gradient-based criterion: t=0.1, 0.2 and 0.25.

We stop before t=0.3, as the shock then reaches the periodic boundary.

Definition at line 632 of file 13_euler-with-amr.py.

References patch_counts().

Referenced by plot_gradient_mesh(), and plot_gradient_profile_comparison().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ number_of_snapshots()

13_euler-with-amr.number_of_snapshots (   directory,
  patch_file = PatchFile 
)

Definition at line 275 of file 13_euler-with-amr.py.

References tarch.plotter.api.notebook.read_snapshots().

Referenced by patch_counts(), plot_active_patches(), plot_adaptive_snapshots(), plot_fd4_profile(), plot_fd4_snapshots(), plot_profile(), plot_profile_comparison(), plot_snapshots(), and print_conservation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ patch_counts()

13_euler-with-amr.patch_counts (   directory)

Time stamps and numbers of patches of all snapshots.

Definition at line 565 of file 13_euler-with-amr.py.

References number_of_snapshots(), and read_snapshot().

Referenced by gradient_snapshots(), plot_dynamic_mesh_change(), plot_dynamic_patch_count(), and plot_gradient_patch_counts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plot_active_patches()

13_euler-with-amr.plot_active_patches (   directory)

Highlight the patches which hold steep density gradients at the end.

A patch counts as active if the largest density jump between two neighbouring volumes within the patch exceeds 20% of the largest such jump in the whole domain. This is the kind of quantity a refinement criterion would look at.

Definition at line 371 of file 13_euler-with-amr.py.

References number_of_snapshots(), tarch.plotter.api.notebook.plot_snapshot(), and read_snapshot().

Here is the call graph for this function:

◆ plot_adaptive_mesh()

13_euler-with-amr.plot_adaptive_mesh (   directory)

Initial density on the adaptive mesh plus the patch boundaries.

Definition at line 425 of file 13_euler-with-amr.py.

References tarch.plotter.api.notebook.plot_snapshot(), and read_snapshot().

Here is the call graph for this function:

◆ plot_adaptive_snapshots()

13_euler-with-amr.plot_adaptive_snapshots (   directory)

Density at three time stamps on the adaptive mesh plus patch boundaries.

Definition at line 455 of file 13_euler-with-amr.py.

References number_of_snapshots(), tarch.plotter.api.notebook.plot_snapshot(), and read_snapshot().

Here is the call graph for this function:

◆ plot_dynamic_mesh_change()

13_euler-with-amr.plot_dynamic_mesh_change (   directory)

Density and patch boundaries right before the first mesh change and at the end.

Definition at line 592 of file 13_euler-with-amr.py.

References patch_counts(), tarch.plotter.api.notebook.plot_snapshot(), and read_snapshot().

Here is the call graph for this function:

◆ plot_dynamic_patch_count()

13_euler-with-amr.plot_dynamic_patch_count (   directory)

Number of patches per snapshot of the dynamically adaptive run.

Definition at line 575 of file 13_euler-with-amr.py.

References patch_counts().

Here is the call graph for this function:

◆ plot_fd4_explosion_time_step_sizes()

13_euler-with-amr.plot_fd4_explosion_time_step_sizes (   directory)

Time step sizes of the fourth-order Finite Differences for the point explosion.

Definition at line 772 of file 13_euler-with-amr.py.

◆ plot_fd4_profile()

13_euler-with-amr.plot_fd4_profile (   directory)

Density of the Gaussian pulse along the positive x-axis at a few time stamps.

Definition at line 819 of file 13_euler-with-amr.py.

References density_along_x_axis(), and number_of_snapshots().

Here is the call graph for this function:

◆ plot_fd4_snapshots()

13_euler-with-amr.plot_fd4_snapshots (   directory)

Density of the Gaussian pulse at three time stamps side by side.

Definition at line 799 of file 13_euler-with-amr.py.

References number_of_snapshots(), and tarch.plotter.api.notebook.plot_snapshot().

Here is the call graph for this function:

◆ plot_gradient_mesh()

13_euler-with-amr.plot_gradient_mesh (   pointwise_directory,
  gradient_directory 
)

Density and patch boundaries of both runs at t=0.2.

We zoom into the upper right quadrant, as the boundaries of the fine patches would otherwise hide the solution.

Definition at line 705 of file 13_euler-with-amr.py.

References gradient_snapshots(), tarch.plotter.api.notebook.plot_snapshot(), and read_snapshot().

Referenced by create_gradient_pictures().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plot_gradient_patch_counts()

13_euler-with-amr.plot_gradient_patch_counts (   pointwise_directory,
  gradient_directory 
)

Number of patches per snapshot of both dynamically adaptive runs.

Definition at line 683 of file 13_euler-with-amr.py.

References patch_counts().

Referenced by create_gradient_pictures().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plot_gradient_profile_comparison()

13_euler-with-amr.plot_gradient_profile_comparison (   pointwise_directory,
  gradient_directory 
)

Density along the positive x-axis: point-wise against gradient-based criterion.

Definition at line 647 of file 13_euler-with-amr.py.

References density_along_x_axis(), and gradient_snapshots().

Referenced by create_gradient_pictures().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plot_mesh()

13_euler-with-amr.plot_mesh (   directory)

Initial density plus the patch boundaries.

Definition at line 299 of file 13_euler-with-amr.py.

References tarch.plotter.api.notebook.plot_snapshot(), and read_snapshot().

Here is the call graph for this function:

◆ plot_mesh_adaptation_task_graph()

13_euler-with-amr.plot_mesh_adaptation_task_graph ( )

Construct the mesh adaptation task graph of the dynamically adaptive setup and draw it.

Definition at line 854 of file 13_euler-with-amr.py.

References create_solver().

Here is the call graph for this function:

◆ plot_profile()

13_euler-with-amr.plot_profile (   directory)

Density along the positive x-axis at a few time stamps.

Definition at line 341 of file 13_euler-with-amr.py.

References density_along_x_axis(), and number_of_snapshots().

Here is the call graph for this function:

◆ plot_profile_comparison()

13_euler-with-amr.plot_profile_comparison (   regular_directory,
  adaptive_directory 
)

Density along the positive x-axis: regular against adaptive mesh.

Definition at line 487 of file 13_euler-with-amr.py.

References density_along_x_axis(), and number_of_snapshots().

Here is the call graph for this function:

◆ plot_setup_task_graph()

13_euler-with-amr.plot_setup_task_graph ( )

Construct the setup task graph with the refinement criterion and draw it.

Definition at line 541 of file 13_euler-with-amr.py.

References create_solver().

Here is the call graph for this function:

◆ plot_snapshots()

13_euler-with-amr.plot_snapshots (   directory)

Density at three time stamps side by side.

Definition at line 321 of file 13_euler-with-amr.py.

References number_of_snapshots(), and tarch.plotter.api.notebook.plot_snapshot().

Here is the call graph for this function:

◆ print_conservation()

13_euler-with-amr.print_conservation (   directory)

Total mass and energy of the first and the last snapshot.

Definition at line 526 of file 13_euler-with-amr.py.

References number_of_snapshots(), and read_snapshot().

Referenced by create_gradient_pictures().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_snapshot()

13_euler-with-amr.read_snapshot (   directory,
  snapshot,
  patch_file = PatchFile 
)

Return the time stamp and all patches (offset, size, values) of a snapshot.

Definition at line 263 of file 13_euler-with-amr.py.

References tarch.plotter.api.notebook.read_patches(), and tarch.plotter.api.notebook.read_snapshots().

Referenced by density_along_x_axis(), patch_counts(), plot_active_patches(), plot_adaptive_mesh(), plot_adaptive_snapshots(), plot_dynamic_mesh_change(), plot_gradient_mesh(), plot_mesh(), and print_conservation().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ action

13_euler-with-amr.action

Definition at line 894 of file 13_euler-with-amr.py.

◆ adaptive

13_euler-with-amr.adaptive

Definition at line 923 of file 13_euler-with-amr.py.

◆ adaptive_directory

13_euler-with-amr.adaptive_directory = os.path.join(work_directory, "adaptive-mesh")

Definition at line 958 of file 13_euler-with-amr.py.

◆ AdaptiveMinVolumeSize

float 13_euler-with-amr.AdaptiveMinVolumeSize = 0.002

Definition at line 94 of file 13_euler-with-amr.py.

◆ AdaptiveVolumeSize

float 13_euler-with-amr.AdaptiveVolumeSize = 0.02

Definition at line 93 of file 13_euler-with-amr.py.

◆ args

13_euler-with-amr.args = parser.parse_args()

Definition at line 907 of file 13_euler-with-amr.py.

◆ default

13_euler-with-amr.default

Definition at line 889 of file 13_euler-with-amr.py.

◆ directory

13_euler-with-amr.directory = os.path.join(work_directory, "regular-grid")

Definition at line 947 of file 13_euler-with-amr.py.

◆ dynamic

13_euler-with-amr.dynamic

Definition at line 923 of file 13_euler-with-amr.py.

◆ dynamic_directory

13_euler-with-amr.dynamic_directory = os.path.join(work_directory, "dynamic-mesh")

Definition at line 912 of file 13_euler-with-amr.py.

◆ DynamicEndTime

float 13_euler-with-amr.DynamicEndTime = 0.3

Definition at line 108 of file 13_euler-with-amr.py.

◆ DynamicRefineErasePointwisely

str 13_euler-with-amr.DynamicRefineErasePointwisely
Initial value:
1= """
2 if (Q[0] > 0.8) *refinementCommand = ::exahype2::RefinementCommand::Refine;
3 else if (Q[0] < 0.1) *refinementCommand = ::exahype2::RefinementCommand::Erase;
4"""

Definition at line 98 of file 13_euler-with-amr.py.

◆ EndTime

float 13_euler-with-amr.EndTime = 0.2

Definition at line 107 of file 13_euler-with-amr.py.

◆ exist_ok

13_euler-with-amr.exist_ok

Definition at line 915 of file 13_euler-with-amr.py.

◆ fd4_explosion_directory

13_euler-with-amr.fd4_explosion_directory = os.path.join(work_directory, "fd4-explosion")

Definition at line 928 of file 13_euler-with-amr.py.

◆ fd4_pulse_directory

13_euler-with-amr.fd4_pulse_directory = os.path.join(work_directory, "fd4-pulse")

Definition at line 929 of file 13_euler-with-amr.py.

◆ FD4InitPointWisely

str 13_euler-with-amr.FD4InitPointWisely
Initial value:
1= """
2 constexpr double gamma = 1.4;
3 constexpr double width = 0.05;
4 const double r2 = x[0] * x[0] + x[1] * x[1];
5 const double rho = 1.0 + 0.5 * std::exp(-r2 / (width * width));
6 const double p = std::pow(rho, gamma);
7 Q[0] = rho;
8 Q[1] = 0.0;
9 Q[2] = 0.0;
10 Q[3] = p / (gamma - 1.0);
11"""

Definition at line 112 of file 13_euler-with-amr.py.

◆ FD4PatchFile

str 13_euler-with-amr.FD4PatchFile = "solution-EulerFD4.peano-patch-file"

Definition at line 123 of file 13_euler-with-amr.py.

◆ Flux

str 13_euler-with-amr.Flux
Initial value:
1= """
2 const double irho = 1.0 / Q[0];
3 constexpr double gamma = 1.4;
4 const double p = (gamma - 1.0) * (Q[3] - 0.5 * irho * (Q[1] * Q[1] + Q[2] * Q[2]));
5 switch (normal) {
6 case 0:
7 F[0] = Q[1];
8 F[1] = irho * Q[1] * Q[1] + p;
9 F[2] = irho * Q[1] * Q[2];
10 F[3] = irho * Q[1] * (Q[3] + p);
11 break;
12 case 1:
13 F[0] = Q[2];
14 F[1] = irho * Q[2] * Q[1];
15 F[2] = irho * Q[2] * Q[2] + p;
16 F[3] = irho * Q[2] * (Q[3] + p);
17 break;
18 }
19"""

Definition at line 51 of file 13_euler-with-amr.py.

◆ gradient_directory

13_euler-with-amr.gradient_directory = os.path.join(work_directory, "gradient-mesh")

Definition at line 913 of file 13_euler-with-amr.py.

◆ GradientRefinement

str 13_euler-with-amr.GradientRefinement
Initial value:
1= """
2 const double densityGradient = std::abs(gradient[0]);
3 if (densityGradient > 5.0) *refinementCommand = ::exahype2::RefinementCommand::Refine;
4 else if (densityGradient < 1.0) *refinementCommand = ::exahype2::RefinementCommand::Erase;
5"""

Definition at line 102 of file 13_euler-with-amr.py.

◆ help

13_euler-with-amr.help

Definition at line 890 of file 13_euler-with-amr.py.

◆ Here

13_euler-with-amr.Here = os.path.dirname(os.path.abspath(__file__))

Definition at line 35 of file 13_euler-with-amr.py.

◆ InitPointWisely

str 13_euler-with-amr.InitPointWisely
Initial value:
1= """
2 constexpr double gamma = 1.4;
3 constexpr double radius = 0.1;
4 const bool inside = x[0] * x[0] + x[1] * x[1] < radius * radius;
5 const double rho = inside ? 1.0 : 0.125;
6 const double p = inside ? 1.0 : 0.1;
7 Q[0] = rho;
8 Q[1] = 0.0;
9 Q[2] = 0.0;
10 Q[3] = p / (gamma - 1.0);
11"""

Definition at line 80 of file 13_euler-with-amr.py.

◆ MaxEigenvalue

str 13_euler-with-amr.MaxEigenvalue
Initial value:
1= """
2 const double irho = 1.0 / Q[0];
3 constexpr double gamma = 1.4;
4 const double p = (gamma - 1.0) * (Q[3] - 0.5 * irho * (Q[1] * Q[1] + Q[2] * Q[2]));
5 const double c = std::sqrt(gamma * p * irho);
6 const double u = Q[1 + normal] * irho;
7 lambdaMax[0] = std::max(std::abs(u + c), std::abs(u - c));
8"""

Definition at line 71 of file 13_euler-with-amr.py.

◆ parser

13_euler-with-amr.parser
Initial value:
1= argparse.ArgumentParser(
2 description="Create the PNGs of the tutorial 13_euler-with-amr.ipynb"
3 )

Definition at line 884 of file 13_euler-with-amr.py.

◆ PatchFile

str 13_euler-with-amr.PatchFile = "solution-EulerFV.peano-patch-file"

Definition at line 110 of file 13_euler-with-amr.py.

◆ PeanoRoot

13_euler-with-amr.PeanoRoot = os.path.abspath(os.path.join(Here, "..", "..", ".."))

Definition at line 36 of file 13_euler-with-amr.py.

◆ RefineErasePointwisely

str 13_euler-with-amr.RefineErasePointwisely
Initial value:
1= """
2 if (Q[0] > 0.8) *refinementCommand = ::exahype2::RefinementCommand::Refine;
3"""

Definition at line 95 of file 13_euler-with-amr.py.

◆ TimeInBetweenPlots

float 13_euler-with-amr.TimeInBetweenPlots = 0.01

Definition at line 109 of file 13_euler-with-amr.py.

◆ True

13_euler-with-amr.True

Definition at line 923 of file 13_euler-with-amr.py.

◆ VolumeSize

float 13_euler-with-amr.VolumeSize = 0.005

Definition at line 92 of file 13_euler-with-amr.py.

◆ work_directory

13_euler-with-amr.work_directory
Initial value:
1= args.work_directory or tempfile.mkdtemp(
2 prefix="13_euler-with-amr-"
3 )

Definition at line 909 of file 13_euler-with-amr.py.