1 #ifndef ERF_EBSLOPES_H_
2 #define ERF_EBSLOPES_H_
4 #include <AMReX_EBCellFlag.H>
18 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
19 amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>
23 amrex::RealVect
const& bcent_eb,
25 amrex::Array4<amrex::Real const>
const& state,
26 amrex::Array4<amrex::Real const>
const& ccent,
27 amrex::Array4<amrex::EBCellFlag const>
const& flag)
29 constexpr
int dim_a = 27;
31 int ii_lo = -1;
int jj_lo = -1;
int kk_lo = -1;
32 int ii_hi = 1;
int jj_hi = 1;
int kk_hi = 1;
38 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
39 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
40 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
42 if (flag(i,j,k).isConnected(ii,jj,kk) && !(ii==0 && jj==0 && kk==0)) {
43 A[ll][0] = (
amrex::Real(ii) + ccent(i+ii,j+jj,k+kk,0) - bcent_eb[0] ) * dx;
44 A[ll][1] = (
amrex::Real(jj) + ccent(i+ii,j+jj,k+kk,1) - bcent_eb[1] ) * dy;
45 A[ll][2] = (
amrex::Real(kk) + ccent(i+ii,j+jj,k+kk,2) - bcent_eb[2] ) * dz;
60 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
61 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
62 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
64 if (flag(i,j,k).isConnected(ii,jj,kk) && !(ii==0 && jj==0 && kk==0)) {
65 du[ll] = state(i+ii,j+jj,k+kk) - state_eb;
75 for(
int jj(0); jj<AMREX_SPACEDIM; ++jj){
76 for(
int ii(0); ii<AMREX_SPACEDIM; ++ii){
82 for(
int lc(0); lc < dim_a; ++lc)
84 AtA[0][0] += A[lc][0]* A[lc][0];
85 AtA[0][1] += A[lc][0]* A[lc][1];
86 AtA[0][2] += A[lc][0]* A[lc][2];
87 AtA[1][1] += A[lc][1]* A[lc][1];
88 AtA[1][2] += A[lc][1]* A[lc][2];
89 AtA[2][2] += A[lc][2]* A[lc][2];
91 Atb[0] += A[lc][0]*du[lc];
92 Atb[1] += A[lc][1]*du[lc];
93 Atb[2] += A[lc][2]*du[lc];
97 AtA[1][0] = AtA[0][1];
98 AtA[2][0] = AtA[0][2];
99 AtA[2][1] = AtA[1][2];
102 AtA[0][0]*(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[2][1]) -
103 AtA[0][1]*(AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
104 AtA[0][2]*(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
107 Atb[0] *(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[1][2]) -
108 AtA[0][1]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) +
109 AtA[0][2]*(Atb[1] * AtA[2][1] - AtA[1][1]*Atb[2] );
115 AtA[0][0]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) -
116 Atb[0] * (AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
117 AtA[0][2]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]);
123 AtA[0][0]*(AtA[1][1]*Atb[2] - Atb[1] *AtA[1][2]) -
124 AtA[0][1]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]) +
125 Atb[0] *(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
130 return {xslope,yslope,zslope};
144 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
145 amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>
150 amrex::RealVect
const& bcent_eb,
152 amrex::Array4<amrex::Real const>
const& state,
153 amrex::Array4<amrex::Real const>
const& ccent,
154 amrex::Array4<amrex::EBCellFlag const>
const& flag)
158 constexpr
int dim_a = 48;
184 amrex::RealVect bias{0.,0.,0.};
185 bias[igrid_query-1] = 0.5;
186 bias[igrid_data-1] = -0.5;
192 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
193 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
194 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
196 if (!flag(i+ii,j+jj,k+kk).isCovered()) {
197 A[ll][0] = (
amrex::Real(ii) + ccent(i+ii,j+jj,k+kk,0) + bias[0] - bcent_eb[0] ) * dx;
198 A[ll][1] = (
amrex::Real(jj) + ccent(i+ii,j+jj,k+kk,1) + bias[1] - bcent_eb[1] ) * dy;
199 A[ll][2] = (
amrex::Real(kk) + ccent(i+ii,j+jj,k+kk,2) + bias[2] - bcent_eb[2] ) * dz;
214 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
215 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
216 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
218 if (!flag(i+ii,j+jj,k+kk).isCovered()) {
219 du[ll] = state(i+ii,j+jj,k+kk) - state_eb;
229 for(
int jj(0); jj<AMREX_SPACEDIM; ++jj){
230 for(
int ii(0); ii<AMREX_SPACEDIM; ++ii){
236 for(
int lc(0); lc < dim_a; ++lc)
238 AtA[0][0] += A[lc][0]* A[lc][0];
239 AtA[0][1] += A[lc][0]* A[lc][1];
240 AtA[0][2] += A[lc][0]* A[lc][2];
241 AtA[1][1] += A[lc][1]* A[lc][1];
242 AtA[1][2] += A[lc][1]* A[lc][2];
243 AtA[2][2] += A[lc][2]* A[lc][2];
245 Atb[0] += A[lc][0]*du[lc];
246 Atb[1] += A[lc][1]*du[lc];
247 Atb[2] += A[lc][2]*du[lc];
251 AtA[1][0] = AtA[0][1];
252 AtA[2][0] = AtA[0][2];
253 AtA[2][1] = AtA[1][2];
256 AtA[0][0]*(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[2][1]) -
257 AtA[0][1]*(AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
258 AtA[0][2]*(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
261 Atb[0] *(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[1][2]) -
262 AtA[0][1]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) +
263 AtA[0][2]*(Atb[1] * AtA[2][1] - AtA[1][1]*Atb[2] );
269 AtA[0][0]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) -
270 Atb[0] * (AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
271 AtA[0][2]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]);
277 AtA[0][0]*(AtA[1][1]*Atb[2] - Atb[1] *AtA[1][2]) -
278 AtA[0][1]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]) +
279 Atb[0] *(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
284 return {xslope,yslope,zslope};
287 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
288 amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>
293 amrex::Array4<amrex::Real const>
const& state,
294 amrex::Array4<amrex::Real const>
const& ccent,
295 amrex::Array4<amrex::EBCellFlag const>
const& flag)
301 constexpr
int dim_a = 36;
327 amrex::RealVect bias{0.,0.,0.};
328 bias[igrid_query-1] = 0.5;
334 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
335 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
336 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
339 if (!flag(i+ii,j+jj,k+kk).isCovered()) {
340 A[ll][0] = (
amrex::Real(ii) + ccent(i+ii,j+jj,k+kk,0) + bias[0] - ccent(i,j,k,0) ) * dx;
341 A[ll][1] = (
amrex::Real(jj) + ccent(i+ii,j+jj,k+kk,1) + bias[1] - ccent(i,j,k,1) ) * dy;
342 A[ll][2] = (
amrex::Real(kk) + ccent(i+ii,j+jj,k+kk,2) + bias[2] - ccent(i,j,k,2) ) * dz;
357 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
358 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
359 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
362 if (!flag(i+ii,j+jj,k+kk).isCovered()) {
363 du[ll] = state(i+ii,j+jj,k+kk) - state(i,j,k);
373 for(
int jj(0); jj<AMREX_SPACEDIM; ++jj){
374 for(
int ii(0); ii<AMREX_SPACEDIM; ++ii){
380 for(
int lc(0); lc < dim_a; ++lc)
382 AtA[0][0] += A[lc][0]* A[lc][0];
383 AtA[0][1] += A[lc][0]* A[lc][1];
384 AtA[0][2] += A[lc][0]* A[lc][2];
385 AtA[1][1] += A[lc][1]* A[lc][1];
386 AtA[1][2] += A[lc][1]* A[lc][2];
387 AtA[2][2] += A[lc][2]* A[lc][2];
389 Atb[0] += A[lc][0]*du[lc];
390 Atb[1] += A[lc][1]*du[lc];
391 Atb[2] += A[lc][2]*du[lc];
395 AtA[1][0] = AtA[0][1];
396 AtA[2][0] = AtA[0][2];
397 AtA[2][1] = AtA[1][2];
400 AtA[0][0]*(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[2][1]) -
401 AtA[0][1]*(AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
402 AtA[0][2]*(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
405 Atb[0] *(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[1][2]) -
406 AtA[0][1]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) +
407 AtA[0][2]*(Atb[1] * AtA[2][1] - AtA[1][1]*Atb[2] );
413 AtA[0][0]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) -
414 Atb[0] * (AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
415 AtA[0][2]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]);
421 AtA[0][0]*(AtA[1][1]*Atb[2] - Atb[1] *AtA[1][2]) -
422 AtA[0][1]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]) +
423 Atb[0] *(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
428 return {xslope,yslope,zslope};
431 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
432 amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>
434 [[maybe_unused]]
int igrid_data,
437 const amrex::Array4<const amrex::Real>& vel_arr,
438 amrex::Array4<amrex::Real const>
const& state,
439 amrex::Array4<amrex::Real const>
const& ccent,
440 amrex::Array4<amrex::EBCellFlag const>
const& flag)
453 if (igrid_query ==
Vars::xvel && vel_arr(i,j,k)>0.0) {
457 if (igrid_query ==
Vars::yvel && vel_arr(i,j,k)>0.0) {
461 if (igrid_query ==
Vars::zvel && vel_arr(i,j,k)>0.0) {
467 amrex::RealVect bias{0.,0.,0.};
468 bias[igrid_query-1] = 0.5;
470 constexpr
int dim_a = 27;
476 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
477 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
478 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
480 if (!flag(i+ii,j+jj,k+kk).isCovered() && !(ii==0 && jj==0 && kk==0)) {
481 A[ll][0] = (
amrex::Real(ii) + ccent(i+ii,j+jj,k+kk,0) + bias[0] - ccent(i,j,k,0) ) * dx;
482 A[ll][1] = (
amrex::Real(jj) + ccent(i+ii,j+jj,k+kk,1) + bias[1] - ccent(i,j,k,1) ) * dy;
483 A[ll][2] = (
amrex::Real(kk) + ccent(i+ii,j+jj,k+kk,2) + bias[2] - ccent(i,j,k,2) ) * dz;
498 for(
int kk(kk_lo); kk<=kk_hi; kk++) {
499 for(
int jj(jj_lo); jj<=jj_hi; jj++) {
500 for(
int ii(ii_lo); ii<=ii_hi; ii++) {
502 if (!flag(i+ii,j+jj,k+kk).isCovered() && !(ii==0 && jj==0 && kk==0)) {
503 du[ll] = state(i+ii,j+jj,k+kk) - state(i,j,k);
513 for(
int jj(0); jj<AMREX_SPACEDIM; ++jj){
514 for(
int ii(0); ii<AMREX_SPACEDIM; ++ii){
520 for(
int lc(0); lc < dim_a; ++lc)
522 AtA[0][0] += A[lc][0]* A[lc][0];
523 AtA[0][1] += A[lc][0]* A[lc][1];
524 AtA[0][2] += A[lc][0]* A[lc][2];
525 AtA[1][1] += A[lc][1]* A[lc][1];
526 AtA[1][2] += A[lc][1]* A[lc][2];
527 AtA[2][2] += A[lc][2]* A[lc][2];
529 Atb[0] += A[lc][0]*du[lc];
530 Atb[1] += A[lc][1]*du[lc];
531 Atb[2] += A[lc][2]*du[lc];
535 AtA[1][0] = AtA[0][1];
536 AtA[2][0] = AtA[0][2];
537 AtA[2][1] = AtA[1][2];
540 AtA[0][0]*(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[2][1]) -
541 AtA[0][1]*(AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
542 AtA[0][2]*(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
545 Atb[0] *(AtA[1][1]*AtA[2][2] - AtA[1][2]*AtA[1][2]) -
546 AtA[0][1]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) +
547 AtA[0][2]*(Atb[1] * AtA[2][1] - AtA[1][1]*Atb[2] );
553 AtA[0][0]*(Atb[1] * AtA[2][2] - AtA[1][2]*Atb[2] ) -
554 Atb[0] * (AtA[1][0]*AtA[2][2] - AtA[1][2]*AtA[2][0]) +
555 AtA[0][2]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]);
561 AtA[0][0]*(AtA[1][1]*Atb[2] - Atb[1] *AtA[1][2]) -
562 AtA[0][1]*(AtA[1][0]*Atb[2] - Atb[1] *AtA[2][0]) +
563 Atb[0] *(AtA[1][0]*AtA[2][1] - AtA[1][1]*AtA[2][0]);
568 return {xslope,yslope,zslope};
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)
Definition: ERF_EBSlopes.H:20
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)
Definition: ERF_EBSlopes.H:146
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)
Definition: ERF_EBSlopes.H:433
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)
Definition: ERF_EBSlopes.H:289
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ xvel
Definition: ERF_IndexDefines.H:141
@ cons
Definition: ERF_IndexDefines.H:140
@ zvel
Definition: ERF_IndexDefines.H:143
@ yvel
Definition: ERF_IndexDefines.H:142