RayTracingMeshOutput
RayTracingMeshOutput
is the base class for the output of rays traced with the Ray Tracing Module as 1D elements in a mesh format. Exodus and Nemesis mesh formats are currently supported and are found in RayTracingExodus and RayTracingNemesis, respectively. The information that follows pertains to both Exodus and Nemesis output—the only difference is the format in which the mesh is output. In order to output traced rays, you must enable the caching of the trace information in the RayTracingStudy (see Trace Caching).
Each segment of the Ray (the portion of the trace within an element) is represented as a 1D, edge element. This enables the overlaying of the traced rays on the actual mesh with ease using visualization software such as Paraview.
Ray Information Output
Information on each segment can also be output. In the most general form, the information is output as a constant value on the Ray segment. The supported output for information on a Ray is as follows:
All of the data on the Ray, enabled by "output_data".
All of the auxiliary data on the Ray, enabled by "output_aux_data".
The Ray ID, enabled by appending
ray_id
to the "output_properties" parameter.The number of intersections the Ray has encountered up to a segment, enabled by appending
intersections
to the "output_properties" parameter.The processor ID that the segment was executed on, enabled by appending
pid
to the "output_properties" parameter.The number of processor crossings that the Ray has encountered up to a segment, enabled by appending
processor_crossings
to the "output_properties" parameter.The number of trajectory changes that the Ray has encountered up to a segment, enabled by appending
trajectory_changes
to the "output_properties" parameter.
Note that the representation of data on a Ray segment as a constant value is an approximation. When this data is a represented as a constant value, the data is sampled at the furthest point of the trace after RayKernels and RayBCs are executed on it. Another form of approximation available is the output of this data in a nodal sense, where the data are sampled at both points on the segments and represented linearly. This is enabled by the "output_data_nodal" parameter.
Trace Caching
RayTracingMeshOutput
uses cached information about the traces to produce this output. By default, this caching is not enabled in the RayTracingStudy.
The default method in RayTracingStudy makes use of the "always_cache_traces" parameter, which enables the caching of all traces. In addition, if you wish to output Ray data or auxiliary data, you must set true the "data_on_cache_traces" and "aux_data_on_cache_traces" parameters, respectively.
In simulations in which many rays are traced, storing and outputting each segment could be constrained by memory or could be computationally expensive. With this, there is also an option to represent the traces with as little information as possible. This option stores the cached information about the traces only when the Ray trajectory has changed or when the Ray has crossed a processor. This functionality is enabled by the "segments_on_cache_traces" parameter in the RayTracingStudy.
Example
As an example, we are going to output the segment-wise accumulated integral for the simple diffusion variable integral example described in Computing Line Integrals.
To recap, we begin with the "simple diffusion" problem:
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 5
ny = 5
xmax = 5
ymax = 5
[]
[]
[Variables/u]
[]
[Kernels/diff]
type = Diffusion
variable = u
[]
[BCs]
[left]
type = DirichletBC
variable = u
boundary = left
value = 0
[]
[right]
type = DirichletBC
variable = u
boundary = right
value = 1
[]
[]
[Executioner]
type = Steady
solve_type = 'PJFNK'
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]
(moose/modules/ray_tracing/test/tests/raykernels/variable_integral_ray_kernel/simple_diffusion_line_integral.i)A RepeatableRayStudy is utilized that computes the integral of the variable from to and from to :
[UserObjects/study]
type = RepeatableRayStudy
names = 'diag
right_up'
start_points = '0 0 0
5 0 0'
end_points = '5 5 0
5 5 0'
execute_on = TIMESTEP_END
# Needed to cache trace information for RayTracingMeshOutput
# always_cache_traces = true
# Needed to cache Ray data for RayTracingMeshOutput
# data_on_cache_traces = true
[]
[RayKernels/u_integral]
type = VariableIntegralRayKernel
variable = u
[]
(moose/modules/ray_tracing/test/tests/raykernels/variable_integral_ray_kernel/simple_diffusion_line_integral.i)Take note that we must enable the commented out parameters "always_cache_traces" and "data_on_cache_traces" in order to enable the caching of information needed for the output.
Lastly, we are going to add a RayTracingExodus output object that will output the traces in Exodus format. For Nemesis format, simply use RayTracingNemesis.
[Outputs]
exodus = false
csv = true
[rays]
type = RayTracingExodus
study = study
output_data = false # enable for data output
output_data_nodal = false # enable for nodal data output
execute_on = NONE # TIMESTEP_END for Ray mesh output
[]
[]
(moose/modules/ray_tracing/test/tests/raykernels/variable_integral_ray_kernel/simple_diffusion_line_integral.i)In order to enable this output, we will set "execute_on" to TIMESTEP_END
as per the comment.
Running the Example
First, we will run the example with constant data for the integrated value on each segment:
./ray_tracing-opt -i test/tests/raykernels/variable_integral_ray_kernel/simple_diffusion_line_integral.i UserObjects/study/always_cache_traces=true UserObjects/study/data_on_cache_traces=true Outputs/rays/output_data=true Outputs/rays/execute_on=TIMESTEP_END
Overlaying the standard output of the problem, simple_diffusion_line_integral_out.e
, with the ray output, simple_diffusion_line_integral_rays.e
and visualizing the u_integral_value
variable on the ray output mesh, we obtain the result below in Figure 1.
Second, we will instead plot the ray data in a nodal sense, in which the value on a segment is represented in a linear fashion with its start and end point values. This is done by enabling enabling "output_data_nodal", as:
./ray_tracing-opt -i test/tests/raykernels/variable_integral_ray_kernel/simple_diffusion_line_integral.iUserObjects/study/always_cache_traces=true UserObjects/study/data_on_cache_traces=true Outputs/rays/output_data_nodal=true Outputs/rays/execute_on=TIMESTEP_END
Again, overlaying the ray mesh result on the problem result we obtain the result below in Figure 2.