forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
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 idaholab#28177 from gsgall/single-trace-line-source
Single trace line source
- Loading branch information
Showing
15 changed files
with
371 additions
and
92 deletions.
There are no files selected for viewing
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
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
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
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
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
28 changes: 28 additions & 0 deletions
28
modules/ray_tracing/test/include/userobjects/SingleTraceLineSourceTest.h
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,28 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "RepeatableRayStudy.h" | ||
|
||
class SingleTraceLineSourceTest : public RepeatableRayStudy | ||
{ | ||
public: | ||
SingleTraceLineSourceTest(const InputParameters & parameters); | ||
|
||
static InputParameters validParams(); | ||
|
||
virtual void execute() override; | ||
|
||
protected: | ||
/// the name of the tag that stores the residuals calculated by ray kernels | ||
const TagName & _residual_tag_name; | ||
/// whether or not the raytracing study has moved the rays on the current time step | ||
bool _has_traced; | ||
}; |
54 changes: 54 additions & 0 deletions
54
modules/ray_tracing/test/src/userobjects/SingleTraceLineSourceTest.C
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,54 @@ | ||
#include "SingleTraceLineSourceTest.h" | ||
#include "NonlinearSystemBase.h" | ||
#include "SystemBase.h" | ||
|
||
registerMooseObject("RayTracingTestApp", SingleTraceLineSourceTest); | ||
|
||
InputParameters | ||
SingleTraceLineSourceTest::validParams() | ||
{ | ||
auto params = RepeatableRayStudy::validParams(); | ||
params.addParam<TagName>("residual_vector_tag", | ||
"the vector tag for the residual tag you will accumulate into"); | ||
params.set<bool>("allow_other_flags_with_prekernels") = true; | ||
return params; | ||
} | ||
|
||
SingleTraceLineSourceTest::SingleTraceLineSourceTest(const InputParameters & parameters) | ||
: RepeatableRayStudy(parameters), | ||
_residual_tag_name(getParam<TagName>("residual_vector_tag")), | ||
_has_traced(false) | ||
{ | ||
} | ||
|
||
void | ||
SingleTraceLineSourceTest::execute() | ||
{ | ||
if (_current_execute_flag == EXEC_TIMESTEP_BEGIN) | ||
{ | ||
_has_traced = false; | ||
return; | ||
} | ||
|
||
if (_current_execute_flag == EXEC_NONLINEAR) | ||
{ | ||
mooseAssert(_fe_problem.currentlyComputingJacobian(), | ||
"Should be computing jacobian but is not."); | ||
return; | ||
} | ||
|
||
const auto contribution_tag_id = _fe_problem.getVectorTagID(_residual_tag_name); | ||
auto & nl = _fe_problem.getNonlinearSystemBase(_sys.number()); | ||
auto & contribution_vec = nl.getVector(contribution_tag_id); | ||
if (!_has_traced) | ||
{ | ||
contribution_vec.zero(); | ||
RayTracingStudy::execute(); | ||
contribution_vec.close(); | ||
_has_traced = true; | ||
} | ||
|
||
auto & residual_vec = nl.getVector(nl.residualVectorTag()); | ||
residual_vec.close(); | ||
residual_vec += contribution_vec; | ||
} |
1 change: 1 addition & 0 deletions
1
...st/tests/raykernels/line_source_ray_kernel/gold/single_trace_line_source_ray_kernel_out.e
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 @@ | ||
line_source_ray_kernel_out.e |
83 changes: 83 additions & 0 deletions
83
modules/ray_tracing/test/tests/raykernels/line_source_ray_kernel/line_source_base.i
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,83 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 2 | ||
nx = 5 | ||
ny = 5 | ||
xmax = 5 | ||
ymax = 5 | ||
[] | ||
|
||
[Variables/u] | ||
order = FIRST | ||
family = LAGRANGE | ||
[] | ||
|
||
[BCs/zero] | ||
type = DirichletBC | ||
variable = u | ||
value = 0 | ||
boundary = 'top right bottom left' | ||
[] | ||
|
||
[Kernels/diffusion] | ||
type = Diffusion | ||
variable = u | ||
[] | ||
|
||
[Postprocessors/postprocessor] | ||
type = FunctionValuePostprocessor | ||
function = 3 | ||
execute_on = initial | ||
[] | ||
|
||
[RayKernels] | ||
[constant_source] | ||
type = LineSourceRayKernel | ||
variable = u | ||
value = 5 | ||
rays = constant_source | ||
[] | ||
[pp_source] | ||
type = LineSourceRayKernel | ||
variable = u | ||
postprocessor = postprocessor | ||
rays = pp_source | ||
[] | ||
[function_source] | ||
type = LineSourceRayKernel | ||
variable = u | ||
function = 'x + 2 * y' | ||
rays = function_source | ||
[] | ||
[mixed_source] | ||
type = LineSourceRayKernel | ||
variable = u | ||
value = 5 | ||
postprocessor = postprocessor | ||
function = 'x + 2 * y' | ||
rays = mixed_source | ||
[] | ||
[data_source] | ||
type = LineSourceRayKernel | ||
variable = u | ||
ray_data_factor_names = data | ||
rays = data_source | ||
[] | ||
[aux_data_source] | ||
type = LineSourceRayKernel | ||
variable = u | ||
ray_aux_data_factor_names = aux_data | ||
rays = aux_data_source | ||
[] | ||
[] | ||
|
||
[Executioner] | ||
type = Steady | ||
solve_type = PJFNK | ||
petsc_options_iname = '-pc_type -pc_hypre_type' | ||
petsc_options_value = 'hypre boomeramg' | ||
[] | ||
|
||
[Outputs] | ||
exodus = true | ||
[] |
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.