5 #ifndef ERF_EBSLOPES_H_
6 #define ERF_EBSLOPES_H_
8 #include <AMReX_EBCellFlag.H>
26 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
27 amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>
31 amrex::RealVect
const& bcent_eb,
33 amrex::Array4<amrex::Real const>
const& state,
34 amrex::Array4<amrex::Real const>
const& ccent,
35 amrex::Array4<amrex::EBCellFlag const>
const& flag)
37 constexpr
int dim_a = 27;
39 int ii_lo = -1;
int jj_lo = -1;
int kk_lo = -1;
40 int ii_hi = 1;
int jj_hi = 1;
int kk_hi = 1;
46 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
47 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
48 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
50 if (flag(i,j,k).isConnected(ii,jj,kk) && !(ii==0 && jj==0 && kk==0)) {
51 A[ll][0] = (
amrex::Real(ii) + ccent(i+ii,j+jj,k+kk,0) - bcent_eb[0] ) *
dx;
52 A[ll][1] = (
amrex::Real(jj) + ccent(i+ii,j+jj,k+kk,1) - bcent_eb[1] ) *
dy;
53 A[ll][2] = (
amrex::Real(kk) + ccent(i+ii,j+jj,k+kk,2) - bcent_eb[2] ) *
dz;
68 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
69 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
70 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
72 if (flag(i,j,k).isConnected(ii,jj,kk) && !(ii==0 && jj==0 && kk==0)) {
73 du[ll] = state(i+ii,j+jj,k+kk) - state_eb;
83 for(
int jj(0); jj<AMREX_SPACEDIM; ++jj){
84 for(
int ii(0); ii<AMREX_SPACEDIM; ++ii){
90 for(
int lc(0); lc < dim_a; ++lc)
92 AtA[0][0] += A[lc][0]* A[lc][0];
93 AtA[0][1] += A[lc][0]* A[lc][1];
94 AtA[0][2] += A[lc][0]* A[lc][2];
95 AtA[1][1] += A[lc][1]* A[lc][1];
96 AtA[1][2] += A[lc][1]* A[lc][2];
97 AtA[2][2] += A[lc][2]* A[lc][2];
99 Atb[0] += A[lc][0]*du[lc];
100 Atb[1] += A[lc][1]*du[lc];
101 Atb[2] += A[lc][2]*du[lc];
105 AtA[1][0] = AtA[0][1];
106 AtA[2][0] = AtA[0][2];
107 AtA[2][1] = AtA[1][2];
110 AtA[0][0]*(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[2][1]) -
111 AtA[0][1]*(AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
112 AtA[0][2]*(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
115 Atb[0] *(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[1][2]) -
116 AtA[0][1]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) +
117 AtA[0][2]*(Atb[1] * AtA[2][1] - AtA[1][1]*Atb[2] );
123 AtA[0][0]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) -
124 Atb[0] * (AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
125 AtA[0][2]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]);
131 AtA[0][0]*(AtA[1][1]*Atb[2] - Atb[1] *AtA[1][2]) -
132 AtA[0][1]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]) +
133 Atb[0] *(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
138 return {xslope,yslope,zslope};
158 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
159 amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>
164 amrex::RealVect
const& bcent_eb,
166 amrex::Array4<amrex::Real const>
const& state,
167 amrex::Array4<amrex::Real const>
const& ccent,
168 amrex::Array4<amrex::EBCellFlag const>
const& flag)
172 constexpr
int dim_a = 48;
199 bias[igrid_query-1] =
myhalf;
200 bias[igrid_data-1] = -
myhalf;
206 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
207 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
208 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
210 if (!flag(i+ii,j+jj,k+kk).isCovered()) {
211 A[ll][0] = (
amrex::Real(ii) + ccent(i+ii,j+jj,k+kk,0) + bias[0] - bcent_eb[0] ) *
dx;
212 A[ll][1] = (
amrex::Real(jj) + ccent(i+ii,j+jj,k+kk,1) + bias[1] - bcent_eb[1] ) *
dy;
213 A[ll][2] = (
amrex::Real(kk) + ccent(i+ii,j+jj,k+kk,2) + bias[2] - bcent_eb[2] ) *
dz;
228 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
229 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
230 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
232 if (!flag(i+ii,j+jj,k+kk).isCovered()) {
233 du[ll] = state(i+ii,j+jj,k+kk) - state_eb;
243 for(
int jj(0); jj<AMREX_SPACEDIM; ++jj){
244 for(
int ii(0); ii<AMREX_SPACEDIM; ++ii){
250 for(
int lc(0); lc < dim_a; ++lc)
252 AtA[0][0] += A[lc][0]* A[lc][0];
253 AtA[0][1] += A[lc][0]* A[lc][1];
254 AtA[0][2] += A[lc][0]* A[lc][2];
255 AtA[1][1] += A[lc][1]* A[lc][1];
256 AtA[1][2] += A[lc][1]* A[lc][2];
257 AtA[2][2] += A[lc][2]* A[lc][2];
259 Atb[0] += A[lc][0]*du[lc];
260 Atb[1] += A[lc][1]*du[lc];
261 Atb[2] += A[lc][2]*du[lc];
265 AtA[1][0] = AtA[0][1];
266 AtA[2][0] = AtA[0][2];
267 AtA[2][1] = AtA[1][2];
270 AtA[0][0]*(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[2][1]) -
271 AtA[0][1]*(AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
272 AtA[0][2]*(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
275 Atb[0] *(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[1][2]) -
276 AtA[0][1]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) +
277 AtA[0][2]*(Atb[1] * AtA[2][1] - AtA[1][1]*Atb[2] );
283 AtA[0][0]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) -
284 Atb[0] * (AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
285 AtA[0][2]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]);
291 AtA[0][0]*(AtA[1][1]*Atb[2] - Atb[1] *AtA[1][2]) -
292 AtA[0][1]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]) +
293 Atb[0] *(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
298 return {xslope,yslope,zslope};
316 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
317 amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>
322 amrex::Array4<amrex::Real const>
const& state,
323 amrex::Array4<amrex::Real const>
const& ccent,
324 amrex::Array4<amrex::EBCellFlag const>
const& flag)
330 constexpr
int dim_a = 36;
357 bias[igrid_query-1] =
myhalf;
363 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
364 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
365 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
368 if (!flag(i+ii,j+jj,k+kk).isCovered()) {
369 A[ll][0] = (
amrex::Real(ii) + ccent(i+ii,j+jj,k+kk,0) + bias[0] - ccent(i,j,k,0) ) *
dx;
370 A[ll][1] = (
amrex::Real(jj) + ccent(i+ii,j+jj,k+kk,1) + bias[1] - ccent(i,j,k,1) ) *
dy;
371 A[ll][2] = (
amrex::Real(kk) + ccent(i+ii,j+jj,k+kk,2) + bias[2] - ccent(i,j,k,2) ) *
dz;
386 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
387 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
388 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
391 if (!flag(i+ii,j+jj,k+kk).isCovered()) {
392 du[ll] = state(i+ii,j+jj,k+kk) - state(i,j,k);
402 for(
int jj(0); jj<AMREX_SPACEDIM; ++jj){
403 for(
int ii(0); ii<AMREX_SPACEDIM; ++ii){
409 for(
int lc(0); lc < dim_a; ++lc)
411 AtA[0][0] += A[lc][0]* A[lc][0];
412 AtA[0][1] += A[lc][0]* A[lc][1];
413 AtA[0][2] += A[lc][0]* A[lc][2];
414 AtA[1][1] += A[lc][1]* A[lc][1];
415 AtA[1][2] += A[lc][1]* A[lc][2];
416 AtA[2][2] += A[lc][2]* A[lc][2];
418 Atb[0] += A[lc][0]*du[lc];
419 Atb[1] += A[lc][1]*du[lc];
420 Atb[2] += A[lc][2]*du[lc];
424 AtA[1][0] = AtA[0][1];
425 AtA[2][0] = AtA[0][2];
426 AtA[2][1] = AtA[1][2];
429 AtA[0][0]*(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[2][1]) -
430 AtA[0][1]*(AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
431 AtA[0][2]*(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
434 Atb[0] *(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[1][2]) -
435 AtA[0][1]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) +
436 AtA[0][2]*(Atb[1] * AtA[2][1] - AtA[1][1]*Atb[2] );
442 AtA[0][0]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) -
443 Atb[0] * (AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
444 AtA[0][2]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]);
450 AtA[0][0]*(AtA[1][1]*Atb[2] - Atb[1] *AtA[1][2]) -
451 AtA[0][1]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]) +
452 Atb[0] *(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
457 return {xslope,yslope,zslope};
476 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
477 amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>
479 [[maybe_unused]]
int igrid_data,
482 const amrex::Array4<const amrex::Real>& vel_arr,
483 amrex::Array4<amrex::Real const>
const& state,
484 amrex::Array4<amrex::Real const>
const& ccent,
485 amrex::Array4<amrex::EBCellFlag const>
const& flag)
513 bias[igrid_query-1] =
myhalf;
515 constexpr
int dim_a = 27;
521 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
522 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
523 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
525 if (!flag(i+ii,j+jj,k+kk).isCovered() && !(ii==0 && jj==0 && kk==0)) {
526 A[ll][0] = (
amrex::Real(ii) + ccent(i+ii,j+jj,k+kk,0) + bias[0] - ccent(i,j,k,0) ) *
dx;
527 A[ll][1] = (
amrex::Real(jj) + ccent(i+ii,j+jj,k+kk,1) + bias[1] - ccent(i,j,k,1) ) *
dy;
528 A[ll][2] = (
amrex::Real(kk) + ccent(i+ii,j+jj,k+kk,2) + bias[2] - ccent(i,j,k,2) ) *
dz;
543 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
544 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
545 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
547 if (!flag(i+ii,j+jj,k+kk).isCovered() && !(ii==0 && jj==0 && kk==0)) {
548 du[ll] = state(i+ii,j+jj,k+kk) - state(i,j,k);
558 for(
int jj(0); jj<AMREX_SPACEDIM; ++jj){
559 for(
int ii(0); ii<AMREX_SPACEDIM; ++ii){
565 for(
int lc(0); lc < dim_a; ++lc)
567 AtA[0][0] += A[lc][0]* A[lc][0];
568 AtA[0][1] += A[lc][0]* A[lc][1];
569 AtA[0][2] += A[lc][0]* A[lc][2];
570 AtA[1][1] += A[lc][1]* A[lc][1];
571 AtA[1][2] += A[lc][1]* A[lc][2];
572 AtA[2][2] += A[lc][2]* A[lc][2];
574 Atb[0] += A[lc][0]*du[lc];
575 Atb[1] += A[lc][1]*du[lc];
576 Atb[2] += A[lc][2]*du[lc];
580 AtA[1][0] = AtA[0][1];
581 AtA[2][0] = AtA[0][2];
582 AtA[2][1] = AtA[1][2];
585 AtA[0][0]*(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[2][1]) -
586 AtA[0][1]*(AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
587 AtA[0][2]*(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
590 Atb[0] *(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[1][2]) -
591 AtA[0][1]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) +
592 AtA[0][2]*(Atb[1] * AtA[2][1] - AtA[1][1]*Atb[2] );
598 AtA[0][0]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) -
599 Atb[0] * (AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
600 AtA[0][2]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]);
606 AtA[0][0]*(AtA[1][1]*Atb[2] - Atb[1] *AtA[1][2]) -
607 AtA[0][1]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]) +
608 Atb[0] *(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
613 return {xslope,yslope,zslope};
constexpr amrex::Real zero
Definition: ERF_Constants.H:8
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:13
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > erf_calc_slopes_eb_Dirichlet(amrex::Real dx, amrex::Real dy, amrex::Real dz, int i, int j, int k, amrex::RealVect const &bcent_eb, amrex::Real const state_eb, amrex::Array4< amrex::Real const > const &state, amrex::Array4< amrex::Real const > const &ccent, amrex::Array4< amrex::EBCellFlag const > const &flag)
Compute least-squares slopes using EB Dirichlet data.
Definition: ERF_EBSlopes.H:28
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > erf_calc_slopes_eb_Dirichlet_staggered(int igrid_query, int igrid_data, amrex::Real dx, amrex::Real dy, amrex::Real dz, int i, int j, int k, amrex::RealVect const &bcent_eb, amrex::Real const state_eb, amrex::Array4< amrex::Real const > const &state, amrex::Array4< amrex::Real const > const &ccent, amrex::Array4< amrex::EBCellFlag const > const &flag)
Compute least-squares slopes from staggered data using EB Dirichlet data.
Definition: ERF_EBSlopes.H:160
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > erf_calc_slopes_eb_staggered_upwind(int igrid_query, [[maybe_unused]] int igrid_data, amrex::Real dx, amrex::Real dy, amrex::Real dz, int i, int j, int k, const amrex::Array4< const amrex::Real > &vel_arr, amrex::Array4< amrex::Real const > const &state, amrex::Array4< amrex::Real const > const &ccent, amrex::Array4< amrex::EBCellFlag const > const &flag)
Compute upwind-biased least-squares slopes for staggered EB advection.
Definition: ERF_EBSlopes.H:478
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > erf_calc_slopes_eb_staggered(int igrid_query, int igrid_data, amrex::Real dx, amrex::Real dy, amrex::Real dz, int i, int j, int k, amrex::Array4< amrex::Real const > const &state, amrex::Array4< amrex::Real const > const &ccent, amrex::Array4< amrex::EBCellFlag const > const &flag)
Compute centered least-squares slopes from cell data to a staggered query grid.
Definition: ERF_EBSlopes.H:318
const Real dy
Definition: ERF_InitCustomPert_ABL.H:24
const Real dx
Definition: ERF_InitCustomPert_ABL.H:23
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ xvel
Definition: ERF_IndexDefines.H:177
@ cons
Definition: ERF_IndexDefines.H:176
@ zvel
Definition: ERF_IndexDefines.H:179
@ yvel
Definition: ERF_IndexDefines.H:178
@ dz
Definition: ERF_AdvanceWSM6.cpp:104