Skip to content

Commit a62a673

Browse files
JacobianFunctionJFNK.H ==> JacobianFunctionMF.H
1 parent e69535f commit a62a673

File tree

2 files changed

+22
-52
lines changed

2 files changed

+22
-52
lines changed

Source/NonlinearSolvers/JacobianFunctionJFNK.H Source/NonlinearSolvers/JacobianFunctionMF.H

+17-47
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
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+
*/
39

410
template <class T, class Ops>
5-
class JacobianFunctionJFNK
11+
class JacobianFunctionMF
612
{
713
public:
814

915
using RT = typename T::value_type;
1016

11-
JacobianFunctionJFNK<T,Ops>()
17+
JacobianFunctionMF<T,Ops>()
1218
{
1319
m_is_defined = false;
1420
m_is_linear = false;
15-
m_epsJFNK = 1.0e-6;
21+
m_epsJFNK = RT(1.0e-6);
1622
m_usePreCond = false;
17-
//m_pc_type = _EM_MATRIX_PC_;
1823
}
1924

20-
~JacobianFunctionJFNK<T,Ops>()
25+
~JacobianFunctionMF<T,Ops>()
2126
{
22-
//delete m_preCond;
2327
return;
2428
}
2529

@@ -30,7 +34,6 @@ class JacobianFunctionJFNK
3034
{
3135
if (m_usePreCond) {
3236
a_U.zero();
33-
//m_precond->apply(a_U, a_X);
3437
} else {
3538
a_U.Copy(a_X);
3639
}
@@ -41,7 +44,6 @@ class JacobianFunctionJFNK
4144
void updatePreCondMat ( const T& a_X )
4245
{
4346
amrex::ignore_unused(a_X);
44-
//if (m_usePreCond) { m_preCond->update( a_X ); }
4547
return;
4648
}
4749

@@ -111,42 +113,36 @@ class JacobianFunctionJFNK
111113
{
112114
m_Y0.Copy(a_U);
113115
m_normY0 = norm2(m_Y0);
114-
//if (m_usePreCond) m_preCond->setBaseSolution(a_U);
115116
}
116117

117118
inline
118119
void setBaseRHS (const T& a_R)
119120
{
120121
m_R0.Copy(a_R);
121-
//if (m_usePreCond) m_preCond->setBaseRHS(a_R);
122122
}
123123

124124
inline
125125
void setJFNKEps (const RT a_eps)
126126
{
127127
m_epsJFNK = a_eps;
128-
//if (m_usePreCond) m_preCond->setJFNKEps(a_eps);
129128
}
130129

131130
inline
132131
void setIsLinear (bool a_isLinear)
133132
{
134133
m_is_linear = a_isLinear;
135-
//if (m_usePreCond) m_preCond->setIsLinear(true);
136134
}
137135

138136
inline
139137
void curTime ( const RT a_time )
140138
{
141139
m_cur_time = a_time;
142-
//if (m_usePreCond) m_preCond->curTime( a_time );
143140
}
144141

145142
inline
146143
void curTimeStep ( const RT a_dt )
147144
{
148145
m_dt = a_dt;
149-
//if (m_usePreCond) m_preCond->curTimeStep( a_dt );
150146
}
151147

152148
void define(const T&, Ops* const);
@@ -160,21 +156,11 @@ class JacobianFunctionJFNK
160156

161157
T m_Z, m_Y0, m_R0, m_R;
162158
Ops* m_ops;
163-
//Preconditioner<T,Ops>* m_preCond;
164159

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-
//}
174160
};
175161

176162
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,
178164
Ops* const a_ops )
179165
{
180166
m_Z.Define(a_U);
@@ -184,46 +170,30 @@ void JacobianFunctionJFNK<T,Ops>::define ( const T& a_U,
184170

185171
m_ops = a_ops;
186172

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-
203173
m_is_defined = true;
204174
return;
205175
}
206176

207177
template <class T, class Ops>
208-
auto JacobianFunctionJFNK<T,Ops>::makeVecRHS () const -> T
178+
auto JacobianFunctionMF<T,Ops>::makeVecRHS () const -> T
209179
{
210180
T Vec;
211181
Vec.Define(m_R);
212182
return Vec;
213183
}
214184

215185
template <class T, class Ops>
216-
auto JacobianFunctionJFNK<T,Ops>::makeVecLHS () const -> T
186+
auto JacobianFunctionMF<T,Ops>::makeVecLHS () const -> T
217187
{
218188
T Vec;
219189
Vec.Define(m_R);
220190
return Vec;
221191
}
222192

223193
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)
225195
{
226-
BL_PROFILE("JacobianFunctionJFNK::apply()");
196+
BL_PROFILE("JacobianFunctionMF::apply()");
227197
using namespace amrex::literals;
228198
RT normY = norm2(a_dU); // always 1 when called from GMRES
229199

Source/NonlinearSolvers/NewtonSolver.H

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define _NEWTON_SOLVER_H_
33

44
#include "NonlinearSolver.H"
5-
#include "JacobianFunctionJFNK.H"
5+
#include "JacobianFunctionMF.H"
66

77
#include <AMReX_GMRES.H>
88
#include <AMReX_ParmParse.H>
@@ -92,8 +92,8 @@ protected:
9292

9393
private:
9494

95-
std::unique_ptr<JacobianFunctionJFNK<Vec,Ops>> m_linear_function;
96-
std::unique_ptr<amrex::GMRES<Vec,JacobianFunctionJFNK<Vec,Ops>>> m_linear_solver;
95+
std::unique_ptr<JacobianFunctionMF<Vec,Ops>> m_linear_function;
96+
std::unique_ptr<amrex::GMRES<Vec,JacobianFunctionMF<Vec,Ops>>> m_linear_solver;
9797

9898
void ParseParameters ();
9999

@@ -134,10 +134,10 @@ void NewtonSolver<Vec,Ops>::Define ( const Vec& a_U,
134134

135135
m_ops = a_ops;
136136

137-
m_linear_function = std::make_unique<JacobianFunctionJFNK<Vec,Ops>>();
137+
m_linear_function = std::make_unique<JacobianFunctionMF<Vec,Ops>>();
138138
m_linear_function->define(m_F, m_ops);
139139

140-
m_linear_solver = std::make_unique<amrex::GMRES<Vec,JacobianFunctionJFNK<Vec,Ops>>>();
140+
m_linear_solver = std::make_unique<amrex::GMRES<Vec,JacobianFunctionMF<Vec,Ops>>>();
141141
m_linear_solver->define(*m_linear_function);
142142
m_linear_solver->setVerbose( m_gmres_verbose_int );
143143

0 commit comments

Comments
 (0)