1
- #ifndef _JacobianFunctionJFNK_H_
2
- #define _JacobianFunctionJFNK_H_
1
+ #ifndef _JacobianFunctionMF_H_
2
+ #define _JacobianFunctionMF_H_
3
+
4
+ /*
5
+ * This is a linear function class for computing the action of a Jacobian on a vector using
6
+ * a matrix-free finite-difference method. This class has all of the required functions to be
7
+ * used as the linear operator template parameter in AMReX_GMRES.
8
+ */
3
9
4
10
template <class T , class Ops >
5
- class JacobianFunctionJFNK
11
+ class JacobianFunctionMF
6
12
{
7
13
public:
8
14
9
15
using RT = typename T::value_type;
10
16
11
- JacobianFunctionJFNK <T,Ops>()
17
+ JacobianFunctionMF <T,Ops>()
12
18
{
13
19
m_is_defined = false ;
14
20
m_is_linear = false ;
15
- m_epsJFNK = 1.0e-6 ;
21
+ m_epsJFNK = RT ( 1.0e-6 ) ;
16
22
m_usePreCond = false ;
17
- // m_pc_type = _EM_MATRIX_PC_;
18
23
}
19
24
20
- ~JacobianFunctionJFNK <T,Ops>()
25
+ ~JacobianFunctionMF <T,Ops>()
21
26
{
22
- // delete m_preCond;
23
27
return ;
24
28
}
25
29
@@ -30,7 +34,6 @@ class JacobianFunctionJFNK
30
34
{
31
35
if (m_usePreCond) {
32
36
a_U.zero ();
33
- // m_precond->apply(a_U, a_X);
34
37
} else {
35
38
a_U.Copy (a_X);
36
39
}
@@ -41,7 +44,6 @@ class JacobianFunctionJFNK
41
44
void updatePreCondMat ( const T& a_X )
42
45
{
43
46
amrex::ignore_unused (a_X);
44
- // if (m_usePreCond) { m_preCond->update( a_X ); }
45
47
return ;
46
48
}
47
49
@@ -111,42 +113,36 @@ class JacobianFunctionJFNK
111
113
{
112
114
m_Y0.Copy (a_U);
113
115
m_normY0 = norm2 (m_Y0);
114
- // if (m_usePreCond) m_preCond->setBaseSolution(a_U);
115
116
}
116
117
117
118
inline
118
119
void setBaseRHS (const T& a_R)
119
120
{
120
121
m_R0.Copy (a_R);
121
- // if (m_usePreCond) m_preCond->setBaseRHS(a_R);
122
122
}
123
123
124
124
inline
125
125
void setJFNKEps (const RT a_eps)
126
126
{
127
127
m_epsJFNK = a_eps;
128
- // if (m_usePreCond) m_preCond->setJFNKEps(a_eps);
129
128
}
130
129
131
130
inline
132
131
void setIsLinear (bool a_isLinear)
133
132
{
134
133
m_is_linear = a_isLinear;
135
- // if (m_usePreCond) m_preCond->setIsLinear(true);
136
134
}
137
135
138
136
inline
139
137
void curTime ( const RT a_time )
140
138
{
141
139
m_cur_time = a_time;
142
- // if (m_usePreCond) m_preCond->curTime( a_time );
143
140
}
144
141
145
142
inline
146
143
void curTimeStep ( const RT a_dt )
147
144
{
148
145
m_dt = a_dt;
149
- // if (m_usePreCond) m_preCond->curTimeStep( a_dt );
150
146
}
151
147
152
148
void define (const T&, Ops* const );
@@ -160,21 +156,11 @@ class JacobianFunctionJFNK
160
156
161
157
T m_Z, m_Y0, m_R0, m_R;
162
158
Ops* m_ops;
163
- // Preconditioner<T,Ops>* m_preCond;
164
159
165
- // void ParseParameters ()
166
- // {
167
- // ParmParse pp_jac( "jacobian" );
168
- // a_pp.query("jfnk_eps", m_epsJFNK);
169
- // a_pp.query("with_pc", m_usePreCond);
170
- // if (m_usePreCond) {
171
- // a_pp.query("pc_type", m_pc_type);
172
- // }
173
- // }
174
160
};
175
161
176
162
template <class T , class Ops >
177
- void JacobianFunctionJFNK <T,Ops>::define ( const T& a_U,
163
+ void JacobianFunctionMF <T,Ops>::define ( const T& a_U,
178
164
Ops* const a_ops )
179
165
{
180
166
m_Z.Define (a_U);
@@ -184,46 +170,30 @@ void JacobianFunctionJFNK<T,Ops>::define ( const T& a_U,
184
170
185
171
m_ops = a_ops;
186
172
187
- // ParseParameters();
188
-
189
- // m_preCond = nullptr;
190
- // if (m_usePreCond) {
191
- // if (m_pc_type == _EM_MATRIX_PC_) {
192
- // m_preCond = new EMMatrixPreconditioner<T,Ops>;
193
- // } else {
194
- // MayDay::Error("Invalid choice of preconditioner type");
195
- // }
196
- // if (!procID()) {
197
- // printf("JacobianFunctionJFNK: preconditioner type is %s.\n", m_pc_type.c_str());
198
- // }
199
- // m_preCond->define(a_U, a_ops, a_dtfac);
200
- // m_preCond->setJFNKEps( m_epsJFNK );
201
- // }
202
-
203
173
m_is_defined = true ;
204
174
return ;
205
175
}
206
176
207
177
template <class T , class Ops >
208
- auto JacobianFunctionJFNK <T,Ops>::makeVecRHS () const -> T
178
+ auto JacobianFunctionMF <T,Ops>::makeVecRHS () const -> T
209
179
{
210
180
T Vec;
211
181
Vec.Define (m_R);
212
182
return Vec;
213
183
}
214
184
215
185
template <class T , class Ops >
216
- auto JacobianFunctionJFNK <T,Ops>::makeVecLHS () const -> T
186
+ auto JacobianFunctionMF <T,Ops>::makeVecLHS () const -> T
217
187
{
218
188
T Vec;
219
189
Vec.Define (m_R);
220
190
return Vec;
221
191
}
222
192
223
193
template <class T , class Ops >
224
- void JacobianFunctionJFNK <T,Ops>::apply (T& a_dF, const T& a_dU)
194
+ void JacobianFunctionMF <T,Ops>::apply (T& a_dF, const T& a_dU)
225
195
{
226
- BL_PROFILE (" JacobianFunctionJFNK ::apply()" );
196
+ BL_PROFILE (" JacobianFunctionMF ::apply()" );
227
197
using namespace amrex ::literals;
228
198
RT normY = norm2 (a_dU); // always 1 when called from GMRES
229
199
0 commit comments