ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_FFTUtils.H
Go to the documentation of this file.
1 #ifndef ERF_FFT_UTILS_H_
2 #define ERF_FFT_UTILS_H_
3 
4 #ifdef ERF_USE_FFT
5 
6 using namespace amrex;
7 
8 inline Array<std::pair<FFT::Boundary,FFT::Boundary>,AMREX_SPACEDIM>
9 get_fft_bc (Geometry const& lev_geom,
10  Array<std::string,2*AMREX_SPACEDIM> l_domain_bc_type,
11  Box const& bounding_box) noexcept
12 {
13  Array<std::pair<FFT::Boundary,FFT::Boundary>,AMREX_SPACEDIM> r;
14 
15  for (int dir = 0; dir <= 1; dir++)
16  {
17  auto bc_type_lo = l_domain_bc_type[Orientation(dir,Orientation::low)];
18  auto bc_type_hi = l_domain_bc_type[Orientation(dir,Orientation::high)];
19 
20  if ( lev_geom.isPeriodic(dir) &&
21  (lev_geom.Domain().smallEnd(dir) == bounding_box.smallEnd(dir)) &&
22  (lev_geom.Domain().bigEnd(dir) == bounding_box.bigEnd(dir)) ) {
23  r[dir] = std::make_pair(FFT::Boundary::periodic,FFT::Boundary::periodic);
24  // amrex::Print() << "SETTING " << dir << " TO PERIODIC " << std::endl;
25  }
26 
27  else if ( (lev_geom.Domain().smallEnd(dir) == bounding_box.smallEnd(dir)) &&
28  (lev_geom.Domain().bigEnd(dir) == bounding_box.bigEnd(dir)) &&
29  (bc_type_lo != "Outflow" && bc_type_lo != "Open") &&
30  (bc_type_hi != "Outflow" && bc_type_hi != "Open") )
31  {
32  r[dir] = std::make_pair(FFT::Boundary::even,FFT::Boundary::even);
33  // amrex::Print() << "SETTING " << dir << " TO EVEN EVEN " << std::endl;
34  }
35 
36  else if ( (lev_geom.Domain().smallEnd(dir) == bounding_box.smallEnd(dir)) &&
37  (lev_geom.Domain().bigEnd(dir) == bounding_box.bigEnd(dir)) &&
38  (bc_type_lo == "Outflow" || bc_type_lo == "Open") &&
39  (bc_type_hi == "Outflow" || bc_type_hi == "Open") )
40  {
41  r[dir] = std::make_pair(FFT::Boundary::odd,FFT::Boundary::odd);
42  // amrex::Print() << "SETTING " << dir << " TO ODD ODD " << std::endl;
43  }
44 
45  else if ( (lev_geom.Domain().smallEnd(dir) == bounding_box.smallEnd(dir)) &&
46  (bc_type_lo == "Outflow" || bc_type_lo == "Open") )
47  {
48  r[dir] = std::make_pair(FFT::Boundary::odd,FFT::Boundary::even);
49  // amrex::Print() << "SETTING " << dir << " TO ODD EVEN " << std::endl;
50  }
51 
52  else if ( (lev_geom.Domain().bigEnd(dir) == bounding_box.bigEnd(dir)) &&
53  (bc_type_hi == "Outflow" || bc_type_hi == "Open") )
54  {
55  r[dir] = std::make_pair(FFT::Boundary::even,FFT::Boundary::odd);
56  // amrex::Print() << "SETTING " << dir << " TO EVEN ODD " << std::endl;
57  }
58  else
59  {
60  r[dir] = std::make_pair(FFT::Boundary::even,FFT::Boundary::even);
61  // amrex::Print() << "SETTING " << dir << " TO EVEN EVEN " << std::endl;
62  }
63  } // dir
64 
65  //
66  // Always Neumann in the vertical
67  //
68  r[2] = std::make_pair(FFT::Boundary::even,FFT::Boundary::even);
69 
70  return r;
71 }
72 #endif
73 #endif
Definition: ERF_ConsoleIO.cpp:12