Skip to content

Commit 949ae89

Browse files
committed
Add tests #30655
1 parent 6963b5c commit 949ae89

File tree

63 files changed

+1894
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1894
-5
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//* This file is part of the MOOSE framework
2+
//* https://mooseframework.inl.gov
3+
//*
4+
//* All rights reserved, see COPYRIGHT for full restrictions
5+
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6+
//*
7+
//* Licensed under LGPL 2.1, please see LICENSE for details
8+
//* https://www.gnu.org/licenses/lgpl-2.1.html
9+
10+
#pragma once
11+
12+
#include "KokkosAuxKernel.h"
13+
14+
class KokkosCoupledAux : public Moose::Kokkos::AuxKernel
15+
{
16+
public:
17+
static InputParameters validParams();
18+
19+
KokkosCoupledAux(const InputParameters & parameters);
20+
21+
KOKKOS_FUNCTION Real computeValue(const unsigned int qp, Datum & datum) const;
22+
23+
protected:
24+
const Real _value;
25+
const int _operator;
26+
27+
const unsigned int _coupled;
28+
const Moose::Kokkos::VariableValue _coupled_val;
29+
};
30+
31+
KOKKOS_FUNCTION inline Real
32+
KokkosCoupledAux::computeValue(const unsigned int qp, Datum & datum) const
33+
{
34+
if (_operator == 0)
35+
return _coupled_val(datum, qp) + _value;
36+
else if (_operator == 1)
37+
return _coupled_val(datum, qp) - _value;
38+
else if (_operator == 2)
39+
return _coupled_val(datum, qp) * _value;
40+
else if (_operator == 3)
41+
// We are going to do division for this operation
42+
// This is useful for testing evalutation order
43+
// when we attempt to divide by zero!
44+
{
45+
KOKKOS_ASSERT(_coupled_val(datum, qp) != 0);
46+
47+
return _value / _coupled_val(datum, qp);
48+
}
49+
50+
// Won't reach this statement
51+
return 0;
52+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//* This file is part of the MOOSE framework
2+
//* https://mooseframework.inl.gov
3+
//*
4+
//* All rights reserved, see COPYRIGHT for full restrictions
5+
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6+
//*
7+
//* Licensed under LGPL 2.1, please see LICENSE for details
8+
//* https://www.gnu.org/licenses/lgpl-2.1.html
9+
10+
#include "KokkosCoupledAux.h"
11+
12+
registerKokkosAuxKernel("MooseTestApp", KokkosCoupledAux);
13+
14+
InputParameters
15+
KokkosCoupledAux::validParams()
16+
{
17+
InputParameters params = AuxKernel::validParams();
18+
19+
MooseEnum operators("+ - * /", "+");
20+
21+
params.addRequiredCoupledVar("coupled", "Coupled Value for Calculation");
22+
23+
params.addParam<Real>(
24+
"value", 0.0, "A value to use in the binary arithmetic operation of this coupled auxkernel");
25+
params.addParam<MooseEnum>(
26+
"operator", operators, "The binary operator to use in the calculation");
27+
return params;
28+
}
29+
30+
KokkosCoupledAux::KokkosCoupledAux(const InputParameters & parameters)
31+
: AuxKernel(parameters),
32+
_value(getParam<Real>("value")),
33+
_operator(getParam<MooseEnum>("operator")),
34+
_coupled(coupled("coupled")),
35+
_coupled_val(kokkosCoupledValue("coupled"))
36+
{
37+
}

test/tests/kokkos/auxkernels/copy_value_aux/kokkos_copy_old_aux.i

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@
5656

5757
[Postprocessors]
5858
[T]
59-
type = ElementAverageValue
59+
type = KokkosElementAverageValue
6060
variable = T
6161
execute_on = 'timestep_end'
6262
[]
6363
[T_old]
64-
type = ElementAverageValue
64+
type = KokkosElementAverageValue
6565
variable = T_old
6666
execute_on = 'timestep_end'
6767
[]
6868
[T_older]
69-
type = ElementAverageValue
69+
type = KokkosElementAverageValue
7070
variable = T_older
7171
execute_on = 'timestep_end'
7272
[]

test/tests/kokkos/functions/piecewise_constant/kokkos_piecewise_constant.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282

8383
[Postprocessors]
8484
[coef]
85-
type = ElementIntegralVariablePostprocessor
85+
type = KokkosElementIntegralVariablePostprocessor
8686
variable = coef
8787
[]
8888
[]

test/tests/kokkos/materials/stateful_prop/kokkos_stateful_prop_test.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
[Postprocessors]
7373
[integral]
74-
type = ElementAverageValue
74+
type = KokkosElementAverageValue
7575
variable = prop1
7676
execute_on = 'initial timestep_end'
7777
[]
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
time,max_v_from_proxy_x,max_v_from_proxy_y,min_v_from_proxy_x,min_v_from_proxy_y
2+
0,0,0,0,0
3+
1,0.50528312163513,0.60528312163513,0.69471687836487,0.79471687836487
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[Mesh]
2+
type = GeneratedMesh
3+
dim = 2
4+
nx = 10
5+
ny = 10
6+
[]
7+
8+
[Variables]
9+
[u]
10+
[]
11+
[]
12+
13+
[Kernels]
14+
[diff]
15+
type = KokkosDiffusion
16+
variable = u
17+
[]
18+
[]
19+
20+
[BCs]
21+
[left]
22+
type = KokkosDirichletBC
23+
variable = u
24+
boundary = left
25+
value = 0
26+
[]
27+
[right]
28+
type = KokkosDirichletBC
29+
variable = u
30+
boundary = right
31+
value = 1
32+
[]
33+
[]
34+
35+
[Postprocessors]
36+
[max]
37+
type = KokkosElementExtremeValue
38+
variable = u
39+
[]
40+
[min]
41+
type = KokkosElementExtremeValue
42+
variable = u
43+
value_type = min
44+
[]
45+
[]
46+
47+
[Executioner]
48+
type = Steady
49+
solve_type = PJFNK
50+
petsc_options_iname = '-pc_type -pc_hypre_type'
51+
petsc_options_value = 'hypre boomeramg'
52+
[]
53+
54+
[Outputs]
55+
exodus = true
56+
[]
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
[Problem]
2+
type = FEProblem
3+
solve = false
4+
[]
5+
6+
[Mesh]
7+
type = GeneratedMesh
8+
dim = 2
9+
nx = 40
10+
ny = 40
11+
[]
12+
13+
[AuxVariables]
14+
[u]
15+
[]
16+
[w]
17+
[]
18+
[v_x]
19+
[]
20+
[v_y]
21+
[]
22+
[]
23+
24+
[AuxKernels]
25+
[u]
26+
type = FunctionAux
27+
variable = u
28+
function = u
29+
[]
30+
[w]
31+
type = FunctionAux
32+
variable = w
33+
function = w
34+
[]
35+
[v_x]
36+
type = FunctionAux
37+
variable = v_x
38+
function = v_x
39+
[]
40+
[v_y]
41+
type = FunctionAux
42+
variable = v_y
43+
function = v_y
44+
[]
45+
[]
46+
47+
[Functions]
48+
[u] # reaches a maximum value at (0.5, 0.6)
49+
type = ParsedFunction
50+
expression = 'sin(pi*x)*sin(pi*y/1.2)'
51+
[]
52+
[w] # reaches a minium expression at (0.7, 0.8)
53+
type = ParsedFunction
54+
expression = '-sin(pi*x/1.4)*sin(pi*y/1.6)'
55+
[]
56+
[v_x]
57+
type = ParsedFunction
58+
expression = 'x'
59+
[]
60+
[v_y]
61+
type = ParsedFunction
62+
expression = 'y'
63+
[]
64+
[]
65+
66+
[Postprocessors]
67+
# because we set v_x and v_y equal to the x and y coordinates, these two postprocessors
68+
# should just return the point at which u reaches a maximum value
69+
[max_v_from_proxy_x]
70+
type = KokkosElementExtremeValue
71+
variable = v_x
72+
proxy_variable = u
73+
value_type = max
74+
[]
75+
[max_v_from_proxy_y]
76+
type = KokkosElementExtremeValue
77+
variable = v_y
78+
proxy_variable = u
79+
value_type = max
80+
[]
81+
82+
# because we set v_x and v_y equal to the x and y coordinates, these two postprocessors
83+
# should just return the point at which w reaches a minimum value
84+
[min_v_from_proxy_x]
85+
type = KokkosElementExtremeValue
86+
variable = v_x
87+
proxy_variable = w
88+
value_type = min
89+
[]
90+
[min_v_from_proxy_y]
91+
type = KokkosElementExtremeValue
92+
variable = v_y
93+
proxy_variable = w
94+
value_type = min
95+
[]
96+
[]
97+
98+
[Executioner]
99+
type = Steady
100+
101+
# increase the quadrature order to get more quadrature points so that were closer
102+
# to hitting the expect max/min
103+
[Quadrature]
104+
type = GAUSS
105+
order = SECOND
106+
[]
107+
[]
108+
109+
[Outputs]
110+
exodus = true
111+
csv = true
112+
[]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[Tests]
2+
design = 'ElementExtremeValue.md'
3+
issues = '#30655'
4+
5+
[elemental_extreme]
6+
requirement = 'The Kokkos system shall compute the value of an elemental field variable at the point where'
7+
[value]
8+
type = 'Exodiff'
9+
input = 'kokkos_element_extreme_value.i'
10+
exodiff = 'kokkos_element_extreme_value_out.e'
11+
detail = 'the variable reaches the extreme (max/min) value and'
12+
capabilities = 'kokkos'
13+
compute_devices = 'cpu cuda'
14+
[]
15+
[proxy]
16+
type = 'CSVDiff'
17+
input = 'kokkos_element_proxy_extreme_value.i'
18+
csvdiff = 'kokkos_element_proxy_extreme_value_out.csv'
19+
detail = 'the proxy variable reaches the extreme (max/min) value.'
20+
capabilities = 'kokkos'
21+
compute_devices = 'cpu cuda'
22+
[]
23+
[]
24+
[]

0 commit comments

Comments
 (0)