5
5
/* Copyright 2017 Battelle Energy Alliance, LLC */
6
6
/* ALL RIGHTS RESERVED */
7
7
/**********************************************************************/
8
+
8
9
#include "FFTBufferBase.h"
9
10
#include "MooseTypes.h"
10
11
#include "MyTRIMMesh.h"
14
15
15
16
#include <type_traits>
16
17
17
- // template <>
18
- // InputParameters
19
- // validParams<FFTBufferBase>()
20
- // {
21
- // InputParameters params = validParams<GeneralUserObject>();
22
- // params.addClassDescription("");
23
- // return params;
24
- // }
25
-
26
18
template < typename T >
27
19
InputParameters
28
20
FFTBufferBase < T > ::validParams ()
@@ -34,8 +26,13 @@ FFTBufferBase<T>::validParams()
34
26
"grid > 0" ,
35
27
"Number of grid cells in each dimension to compute "
36
28
"the FFT on (can be omitted when using MyTRIMMesh)" );
37
- params .addParam < unsigned int > (
38
- "max_h_level" , 0 , "Further grid refinement to apply when using MyTRIMMesh with adaptivity" );
29
+ if (std ::is_same < T , Real > ::value )
30
+ params .addParam < AuxVariableName > (
31
+ "moose_variable" , "Optional AuxVariable to take the initial condition of the buffer from." );
32
+
33
+ // make sure we run the object on initial to apply the initial conditions
34
+ params .set < ExecFlagEnum > ("execute_on" ) = EXEC_INITIAL ;
35
+
39
36
return params ;
40
37
}
41
38
@@ -45,8 +42,8 @@ FFTBufferBase<T>::FFTBufferBase(const InputParameters & parameters)
45
42
_mesh (_subproblem .mesh ()),
46
43
_dim (_mesh .dimension ()),
47
44
_cell_volume (1.0 ),
48
- _buffer_size (1 )
49
-
45
+ _buffer_size (1 ),
46
+ _moose_variable ( nullptr )
50
47
{
51
48
// make sure Real is double
52
49
static_assert (
@@ -56,6 +53,12 @@ FFTBufferBase<T>::FFTBufferBase(const InputParameters & parameters)
56
53
// FFT needs a regular grid of values to operate on
57
54
if (isParamValid ("grid" ))
58
55
{
56
+ // cannot specify a corresponding MOOSE Variable when running mesh-less
57
+ if (isParamValid ("moose_variable" ))
58
+ paramError ("moose_variable" ,
59
+ "You cannot specify a corresponding MOOSE Variable when running mesh-less, i.e. "
60
+ "using the 'grid' parameter." );
61
+
59
62
// if valid use the user-supplied sampling grid
60
63
_grid = getParam < std ::vector < int >>("grid" );
61
64
if (_grid .size () != _dim )
@@ -72,10 +75,24 @@ FFTBufferBase<T>::FFTBufferBase(const InputParameters & parameters)
72
75
_grid .push_back (mytrim_mesh -> getCellCountInDimension (i ));
73
76
}
74
77
75
- // refine grid by max_h_level powers of two
76
- auto max_h_level = getParam < unsigned int > ("max_h_level" );
77
- for (auto & count : _grid )
78
- count = count << max_h_level ;
78
+ // check optional coupled MOOSE variable (only for Real valued buffers)
79
+ if (std ::is_same < T , Real > ::value && isParamValid ("moose_variable" ))
80
+ {
81
+ auto name = getParam < AuxVariableName > ("moose_variable" );
82
+ if (!_subproblem .hasVariable (name ))
83
+ paramError ("moose_variable" , "Variable '" , name , "' does not exist." );
84
+
85
+ // get variable
86
+ _moose_variable = dynamic_cast < MooseVariable * > (& _subproblem .getVariable (
87
+ 0 , name , Moose ::VarKindType ::VAR_AUXILIARY , Moose ::VarFieldType ::VAR_FIELD_STANDARD ));
88
+ if (!_moose_variable )
89
+ paramError (
90
+ "moose_variable" , "Variable '" , name , "' is not a regular auxiliary field variable." );
91
+ if (_moose_variable -> order () != 0 )
92
+ paramError ("moose_variable" , "Variable '" , name , "' needs to have CONSTANT order." );
93
+ if (_moose_variable -> isNodal ())
94
+ paramError ("moose_variable" , "Variable '" , name , "' must be elemental." );
95
+ }
79
96
80
97
// get mesh extents and calculate space required and estimate spectrum bins
81
98
for (unsigned int i = 0 ; i < _dim ; ++ i )
@@ -98,6 +115,13 @@ FFTBufferBase<T>::FFTBufferBase(const InputParameters & parameters)
98
115
istride /= sizeof (Real );
99
116
}
100
117
118
+ template < >
119
+ void
120
+ FFTBufferBase < Real > ::initialize ()
121
+ {
122
+ mooseInfo ("Real valued buffer" );
123
+ }
124
+
101
125
template < >
102
126
Real *
103
127
FFTBufferBase < Real > ::start (std ::size_t i )
0 commit comments