Skip to content

Commit 3a72586

Browse files
Interfacing 1D CurlCurl from AMReX (#5662)
1 parent 1d33888 commit 3a72586

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

Source/NonlinearSolvers/CurlCurlMLMGPC.H

+7-18
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
#include <AMReX_Array.H>
1919
#include <AMReX_Vector.H>
2020
#include <AMReX_MultiFab.H>
21-
#ifndef WARPX_DIM_1D_Z // currently not implemented in 1D
2221
#include <AMReX_MLLinOp.H>
2322
#include <AMReX_MLCurlCurl.H>
2423
#include <AMReX_MLMG.H>
2524
#include <AMReX_GMRES_MLMG.H>
26-
#endif
2725

2826
/**
2927
* \brief Curl-curl Preconditioner
@@ -131,16 +129,13 @@ class CurlCurlMLMGPC : public Preconditioner<T,Ops>
131129
amrex::Vector<amrex::DistributionMapping> m_dmap;
132130
amrex::IntVect m_gv;
133131

134-
// currently not implemented in 1D
135-
#ifndef WARPX_DIM_1D_Z
136132
amrex::Array<amrex::LinOpBCType, AMREX_SPACEDIM> m_bc_lo;
137133
amrex::Array<amrex::LinOpBCType, AMREX_SPACEDIM> m_bc_hi;
138134

139135
std::unique_ptr<amrex::LPInfo> m_info;
140136
std::unique_ptr<amrex::MLCurlCurl> m_curl_curl;
141137
std::unique_ptr<amrex::MLMGT<MFArr>> m_solver;
142138
std::unique_ptr<amrex::GMRESMLMGT<MFArr>> m_gmres_solver;
143-
#endif
144139

145140
/**
146141
* \brief Read parameters
@@ -208,10 +203,6 @@ void CurlCurlMLMGPC<T,Ops>::Define ( const T& a_U,
208203
// read preconditioner parameters
209204
readParameters();
210205

211-
// currently not implemented in 1D
212-
#ifdef WARPX_DIM_1D_Z
213-
WARPX_ABORT_WITH_MESSAGE("CurlCurlMLMGPC not yet implemented for 1D");
214-
#else
215206
// create info object for curl-curl op
216207
m_info = std::make_unique<LPInfo>();
217208
m_info->setAgglomeration(m_agglomeration);
@@ -256,7 +247,6 @@ void CurlCurlMLMGPC<T,Ops>::Define ( const T& a_U,
256247
m_gmres_solver->setPrecondNumIters(m_max_iter);
257248
m_gmres_solver->setVerbose(static_cast<int>(m_verbose));
258249
}
259-
#endif
260250

261251
m_is_defined = true;
262252
}
@@ -276,10 +266,7 @@ void CurlCurlMLMGPC<T,Ops>::Update (const T& a_U)
276266
const RT alpha = (this->m_dt*PhysConst::c) * (this->m_dt*PhysConst::c);
277267
const RT beta = RT(1.0);
278268

279-
// currently not implemented in 1D
280-
#ifndef WARPX_DIM_1D_Z
281269
m_curl_curl->setScalars(alpha, beta);
282-
#endif
283270

284271
if (m_verbose) {
285272
amrex::Print() << "Updating " << amrex::getEnumNameString(PreconditionerType::pc_curl_curl_mlmg)
@@ -322,8 +309,13 @@ void CurlCurlMLMGPC<T,Ops>::Apply (T& a_x, const T& a_b)
322309

323310
// Copy initial guess to local object
324311
#if defined(WARPX_DIM_1D_Z)
325-
// Missing dimensions is x,y in WarpX and y,z in AMReX
326-
WARPX_ABORT_WITH_MESSAGE("CurlCurlMLMGPC not yet implemented for 1D");
312+
// Missing dimensions are x,y in WarpX and y,z in AMReX
313+
Array<MultiFab,3> solution { MultiFab(*x_mfarrvec[n][2], make_alias, 0, 1),
314+
MultiFab(*x_mfarrvec[n][1], make_alias, 0, 1),
315+
MultiFab(*x_mfarrvec[n][0], make_alias, 0, 1) };
316+
Array<MultiFab,3> rhs { MultiFab(*b_mfarrvec[n][2], make_alias, 0, 1),
317+
MultiFab(*b_mfarrvec[n][1], make_alias, 0, 1),
318+
MultiFab(*b_mfarrvec[n][0], make_alias, 0, 1) };
327319
#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
328320
// Missing dimension is y in WarpX and z in AMReX
329321
Array<MultiFab,3> solution { MultiFab(*x_mfarrvec[n][0], make_alias, 0, 1),
@@ -341,15 +333,12 @@ void CurlCurlMLMGPC<T,Ops>::Apply (T& a_x, const T& a_b)
341333
MultiFab(*b_mfarrvec[n][2], make_alias, 0, 1) };
342334
#endif
343335

344-
// currently not implemented in 1D
345-
#ifndef WARPX_DIM_1D_Z
346336
m_curl_curl->prepareRHS({&rhs});
347337
if (m_use_gmres) {
348338
m_gmres_solver->solve(solution, rhs, m_rtol, m_atol);
349339
} else {
350340
m_solver->solve({&solution}, {&rhs}, m_rtol, m_atol);
351341
}
352-
#endif
353342
}
354343
}
355344

0 commit comments

Comments
 (0)