Skip to content

Commit 89a52df

Browse files
committed
Add setGreensFunction
1 parent 0703ede commit 89a52df

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

Src/Base/AMReX.H

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ namespace amrex
102102
* classes to clean up any "global" state that they maintain when we're
103103
* exiting from AMReX.
104104
*/
105-
void ExecOnFinalize (PTR_TO_VOID_FUNC);
106-
void ExecOnInitialize (PTR_TO_VOID_FUNC);
105+
void ExecOnFinalize (std::function<void()>);
106+
void ExecOnInitialize (std::function<void()>);
107107

108108
//! This shuts up the compiler about unused variables
109109
template <class... Ts>

Src/Base/AMReX.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,20 +302,20 @@ amrex::Assert_host (const char* EX, const char* file, int line, const char* msg)
302302

303303
namespace
304304
{
305-
std::stack<amrex::PTR_TO_VOID_FUNC> The_Finalize_Function_Stack;
306-
std::stack<amrex::PTR_TO_VOID_FUNC> The_Initialize_Function_Stack;
305+
std::stack<std::function<void()>> The_Finalize_Function_Stack;
306+
std::stack<std::function<void()>> The_Initialize_Function_Stack;
307307
}
308308

309309
void
310-
amrex::ExecOnFinalize (PTR_TO_VOID_FUNC fp)
310+
amrex::ExecOnFinalize (std::function<void()> f)
311311
{
312-
The_Finalize_Function_Stack.push(fp);
312+
The_Finalize_Function_Stack.push(std::move(f));
313313
}
314314

315315
void
316-
amrex::ExecOnInitialize (PTR_TO_VOID_FUNC fp)
316+
amrex::ExecOnInitialize (std::function<void()> f)
317317
{
318-
The_Initialize_Function_Stack.push(fp);
318+
The_Initialize_Function_Stack.push(std::move(f));
319319
}
320320

321321
amrex::AMReX*
@@ -391,7 +391,7 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse,
391391
//
392392
// Call the registered function.
393393
//
394-
(*The_Initialize_Function_Stack.top())();
394+
The_Initialize_Function_Stack.top()();
395395
//
396396
// And then remove it from the stack.
397397
//
@@ -756,7 +756,7 @@ amrex::Finalize (amrex::AMReX* pamrex)
756756
//
757757
// Call the registered function.
758758
//
759-
(*The_Finalize_Function_Stack.top())();
759+
The_Finalize_Function_Stack.top()();
760760
//
761761
// And then remove it from the stack.
762762
//

Src/FFT/AMReX_FFT_OpenBCSolver.H

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,39 @@ public:
1515
using MF = typename R2C<T>::MF;
1616
using cMF = typename R2C<T>::cMF;
1717

18+
explicit OpenBCSolver (Box const& domain);
19+
1820
template <class F>
19-
OpenBCSolver (Box const& domain, F const& greens_function);
21+
void setGreensFunction (F const& greens_function);
2022

2123
void solve (MF& phi, MF const& rho);
2224

25+
[[nodiscard]] Box const& Domain () const { return m_domain; }
26+
2327
private:
28+
Box m_domain;
2429
R2C<T> m_r2c;
2530
cMF m_G_fft;
2631
};
2732

33+
template <typename T>
34+
OpenBCSolver<T>::OpenBCSolver (Box const& domain)
35+
: m_domain(domain),
36+
m_r2c(Box(domain.smallEnd(), domain.bigEnd()+domain.length(), domain.ixType()))
37+
{
38+
auto [sd, ord] = m_r2c.getSpectralData();
39+
amrex::ignore_unused(ord);
40+
m_G_fft.define(sd->boxArray(), sd->DistributionMap(), 1, 0);
41+
}
42+
2843
template <typename T>
2944
template <class F>
30-
OpenBCSolver<T>::OpenBCSolver (Box const& domain, F const& greens_function)
31-
: m_r2c(Box(domain.smallEnd(), domain.bigEnd()+domain.length(), domain.ixType()))
45+
void OpenBCSolver<T>::setGreensFunction (F const& greens_function)
3246
{
3347
auto* infab = detail::get_fab(m_r2c.m_rx);
34-
auto const& lo = domain.smallEnd();
48+
auto const& lo = m_domain.smallEnd();
3549
auto const& lo3 = lo.dim3();
36-
auto const& len = domain.length3d();
50+
auto const& len = m_domain.length3d();
3751
if (infab) {
3852
auto const& a = infab->array();
3953
auto box = infab->box();
@@ -76,7 +90,6 @@ OpenBCSolver<T>::OpenBCSolver (Box const& domain, F const& greens_function)
7690

7791
auto [sd, ord] = m_r2c.getSpectralData();
7892
amrex::ignore_unused(ord);
79-
m_G_fft.define(sd->boxArray(), sd->DistributionMap(), 1, 0);
8093
auto const* srcfab = detail::get_fab(*sd);
8194
if (srcfab) {
8295
auto* dstfab = detail::get_fab(m_G_fft);

0 commit comments

Comments
 (0)