Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update initialization from pltfile #80

Merged
merged 10 commits into from
Aug 8, 2022
242 changes: 242 additions & 0 deletions Exec/RegTests/SI_crossflow/EBUserDefined.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
#ifndef _EBUSERDEFINED_H_
#define _EBUSERDEFINED_H_

using namespace amrex;

#ifdef AMREX_USE_EB
#include <AMReX_EB2.H>
#include <AMReX_EB2_IF.H>
void
EBUserDefined(const Geometry& geom,
const int required_coarsening_level,
const int max_coarsening_level)
{
// ParmParse your geometry parameters
// --> fixed geometry of the challenge problem

const amrex::Real *problo = geom.ProbLo();
const amrex::Real *probhi = geom.ProbHi();
amrex::Real dy = geom.CellSize()[1]; //* pow(2.0,max_coarsening_level);
amrex::Real dx = geom.CellSize()[0]; //* pow(2.0,max_coarsening_level);

// The cell_id step is done to have the vertical and horizontal planes
// exactly at the cell face and avoid numerical problems with small volume cells
int cell_id = 0.15875e-2 / dx;
amrex::EB2::PlaneIF cathode_vert_left({AMREX_D_DECL(-cell_id*dx,0.,0.)},
{AMREX_D_DECL(1.,0.,0.)});

amrex::EB2::PlaneIF cathode_vert_right({AMREX_D_DECL(cell_id*dx,0.,0.)},
{AMREX_D_DECL(-1.,0.,0.)});

cell_id = 2.121e-2 / dy;
amrex::EB2::PlaneIF insulator_tip({AMREX_D_DECL(0.,2.1e-2,0.)},
{AMREX_D_DECL(0.,1.,0.)});

amrex::EB2::PlaneIF insulator_vert_left({AMREX_D_DECL(-0.225e-2,0.,0.)},
{AMREX_D_DECL(1.,0.,0)});

amrex::EB2::PlaneIF insulator_vert_right({AMREX_D_DECL(0.225e-2,0.,0.)},
{AMREX_D_DECL(-1.,0.,0.)});

cell_id = 0.077e-2 / dx;
amrex::EB2::PlaneIF anode_vert_left({AMREX_D_DECL(-cell_id*dx,0.,0.)},
{AMREX_D_DECL(1.,0.,0.)});

amrex::EB2::PlaneIF anode_vert_right({AMREX_D_DECL(cell_id*dx,0.,0.)},
{AMREX_D_DECL(-1.,0.,0.)});


// Real radius = 0.001;
// // pp.get("sphere_radius", radius);

// bool has_fluid_inside = true;
// // pp.get("sphere_has_fluid_inside", has_fluid_inside);

// RealArray center;
// center[0] = cell_id*dx+radius;
// cell_id = 2.121e-2 / dy;
// center[1] = 2.121e-2-radius-1.e-5;
// center[2] = 0.0;
// EB2::SphereIF sf_right(radius, center, has_fluid_inside);

// center[0] = -cell_id*dx-radius;
// cell_id = 2.121e-2 / dy;
// center[1] = 2.121e-2-radius+1.e-5;
// center[2] = 0.0;
// EB2::SphereIF sf_left(radius, center, has_fluid_inside);

/* ---------- Cathode cone ---------- */
amrex::Array<amrex::Real,AMREX_SPACEDIM> point0_cat;
amrex::Array<amrex::Real,AMREX_SPACEDIM> point1_cat;

point1_cat[0] = -0.15875e-2; //x-coordinate
point1_cat[1] = 1.8122e-2; //y-coordinate

point0_cat[0] = 0.00000e-2; //x-coordinate
point0_cat[1] = 1.87000e-2; //y-coordinate

amrex::Array<amrex::Real,AMREX_SPACEDIM> norm0;

norm0[0] = (point0_cat[0]-point1_cat[0]);
norm0[1] = (point0_cat[1]-point1_cat[1]);
norm0[2] = 0.0;

amrex::Real norm = sqrt(norm0[0]*norm0[0]+norm0[1]*norm0[1]);
norm0[0] = norm0[0]/norm;
norm0[1] = norm0[1]/norm;

amrex::EB2::PlaneIF cone_cathode_angle_left({AMREX_D_DECL(point1_cat[0],1.46147e-2,0)},
{AMREX_D_DECL(norm0[0],-norm0[1],0)});

amrex::EB2::PlaneIF cone_cathode_angle_right({AMREX_D_DECL(-point1_cat[0],1.46147e-2,0)},
{AMREX_D_DECL(-norm0[0],-norm0[1],0)});

// Anode tip is cut based on grid spacing in y to avoid numerical problems
//get the cathode tip plane based on grid spacing to avoid cutting through a cell
cell_id = (point0_cat[1]-1.80e-2-0.001e-2) / dy;

amrex::EB2::PlaneIF cathode_tip({AMREX_D_DECL(0.,(1.8e-2 + cell_id*dy),0)},
{AMREX_D_DECL(0.,-1.,0)});

// This is adding a shallower cone angle close to the cathode tip
amrex::Array<amrex::Real,AMREX_SPACEDIM> p0_cat;
amrex::Array<amrex::Real,AMREX_SPACEDIM> p1_cat;

// p1_cat[0] = -4.1955e-03; //x-coordinate 40 degrees
// p1_cat[0] = -1.8198e-03; //x-coordinate 20 degrees
p1_cat[0] = -2.88675e-05; //x-coordinate 30 degrees
p1_cat[1] = 1.87000e-2-0.005e-2; //y-coordinate

p0_cat[0] = 0.00000; //x-coordinate
p0_cat[1] = 1.87000e-2; //y-coordinate

amrex::Array<amrex::Real,AMREX_SPACEDIM> n0;

n0[0] = (p0_cat[0]-p1_cat[0]);
n0[1] = (p0_cat[1]-p1_cat[1]);
n0[2] = 0.0;

amrex::Real n = sqrt(n0[0]*n0[0]+n0[1]*n0[1]);
n0[0] = n0[0]/n;
n0[1] = n0[1]/n;

amrex::EB2::PlaneIF cathode_chamfer_left({AMREX_D_DECL(p1_cat[0],1.872e-2,0)},
{AMREX_D_DECL(n0[0],-n0[1],0)});

amrex::EB2::PlaneIF cathode_chamfer_right({AMREX_D_DECL(-p1_cat[0],1.872e-2,0)},
{AMREX_D_DECL(-n0[0],-n0[1],0)});

// Making intersections
//auto intersection05 = amrex::EB2::makeIntersection(cathode_vert_left ,cone_cathode_angle_left);
//auto intersection105 = amrex::EB2::makeIntersection(intersection05 ,cathode_chamfer_left);
//auto intersection1 = amrex::EB2::makeIntersection(intersection105 ,cathode_tip);
//auto intersection2 = amrex::EB2::makeIntersection(cathode_vert_right,cone_cathode_angle_right);
//auto intersection205 = amrex::EB2::makeIntersection(intersection2 ,cathode_chamfer_right);

auto intersection05 = amrex::EB2::makeIntersection(cathode_vert_left ,cone_cathode_angle_left);
auto intersection1 = amrex::EB2::makeIntersection(intersection05 ,cathode_tip);
auto intersection2 = amrex::EB2::makeIntersection(cathode_vert_right,cone_cathode_angle_right);

auto cathode = amrex::EB2::makeIntersection(intersection1,intersection2);


auto intersection4 = amrex::EB2::makeIntersection(insulator_vert_left ,insulator_tip);
auto intersection5 = amrex::EB2::makeIntersection(insulator_vert_right,insulator_tip);
auto insulator = amrex::EB2::makeIntersection(intersection4,intersection5);

// amrex::EB2::PlaneIF insulator_tip2({AMREX_D_DECL(0.,2.121e-2-radius,0.)},
// {AMREX_D_DECL(0.,1.,0.)});

// auto intersection4 = amrex::EB2::makeIntersection(insulator_vert_left ,insulator_tip);
// auto insul1 = amrex::EB2::makeIntersection(intersection4,sf_left);
// auto insul2 = amrex::EB2::makeIntersection(insul1,insulator_tip2);
// auto insul = amrex::EB2::makeIntersection(insul2,sf_right);
// auto insulator = amrex::EB2::makeIntersection(insul,insulator_tip);



/* ---------- Anode cone ---------- */
amrex::Array<amrex::Real,AMREX_SPACEDIM> point0_anode;
amrex::Array<amrex::Real,AMREX_SPACEDIM> point1_anode;


cell_id = 0.07700e-2 / dx;
point1_anode[0] = -cell_id*dx; //x-coordinate
cell_id = 2.05960e-2 / dy;
point1_anode[1] = cell_id*dy; //y-coordinate

cell_id = 0.00000 / dx;
point0_anode[0] = cell_id*dx; //x-coordinate
cell_id = 1.97500e-2 / dy;
point0_anode[1] = cell_id*dy; //y-coordinate

amrex::Array<amrex::Real,AMREX_SPACEDIM> norm1;

norm1[0] = (point0_anode[0]-point1_anode[0]);
norm1[1] = (point0_anode[1]-point1_anode[1]);
norm1[2] = 0.0;

norm = sqrt(norm1[0]*norm1[0]+norm1[1]*norm1[1]);
norm1[0] = norm1[0]/norm;
norm1[1] = norm1[1]/norm;

// amrex::Print() << " Anode norm " << norm1[0] << norm1[1];
// amrex::Abort();

cell_id = 2.03793e-2 / dy;
amrex::EB2::PlaneIF cone_anode_angle_left({AMREX_D_DECL(point1_anode[0],cell_id*dy,0)},
{AMREX_D_DECL(norm1[0],-norm1[1],0)});

cell_id = 2.03793e-2 / dy;
amrex::EB2::PlaneIF cone_anode_angle_right({AMREX_D_DECL(-point1_anode[0],cell_id*dy,0)},
{AMREX_D_DECL(-norm1[0],-norm1[1],0)});

cell_id = (1.98e-2 - 5.0e-05) / dy;
amrex::EB2::PlaneIF anode_tip({AMREX_D_DECL(0.,cell_id*dy,0)},
{AMREX_D_DECL(0.,1.,0)});

//cell_id = 1.98 / dy;
//amrex::EB2::PlaneIF anode_tip({AMREX_D_DECL(0.,cell_id*dy,0)},
// {AMREX_D_DECL(0.,1.,0)});

auto intersection6_5 = amrex::EB2::makeIntersection(anode_vert_left ,cone_anode_angle_left);
// auto intersection6 = amrex::EB2::makeIntersection(intersection6_5,anode_tip);
auto intersection7 = amrex::EB2::makeIntersection(anode_vert_right,cone_anode_angle_right);
auto anode = amrex::EB2::makeIntersection(intersection6_5,intersection7);

// ----> Squared anode tip
dy = geom.CellSize()[1];
dx = geom.CellSize()[0];
cell_id = 1;
amrex::EB2::PlaneIF cone_anode_vert_left({AMREX_D_DECL(-cell_id*dx,0.,0)},
{AMREX_D_DECL(1.,0.,0)});

amrex::EB2::PlaneIF cone_anode_vert_right({AMREX_D_DECL(cell_id*dx,0.,0)},
{AMREX_D_DECL(-1.,0.,0)});

cell_id = (1.98e-2 - 1*dy) / dy;
amrex::EB2::PlaneIF tip({AMREX_D_DECL(0.,cell_id*dy,0)},
{AMREX_D_DECL(0.,1.,0)});

auto intersect1 = amrex::EB2::makeIntersection(cone_anode_vert_left,tip);
auto intersect2 = amrex::EB2::makeIntersection(cone_anode_vert_right,intersect1);
// ----> End of squared anode tip

auto polys = amrex::EB2::makeUnion(cathode,anode,insulator);
// auto polys = amrex::EB2::makeUnion(cathode,insulator);
// auto polys = amrex::EB2::makeUnion(cathode);

int dir = 0;
// pp.get("rot_dir",dir);
amrex::Real angle = 270;
// pp.get("rot_angle",angle);

auto pr = amrex::EB2::lathe(polys);
auto pr_rot = amrex::EB2::rotate(amrex::EB2::lathe(polys), angle*3.1415/180., dir);
auto shop = amrex::EB2::makeShop(pr_rot);

EB2::Build(shop, geom, required_coarsening_level,
max_coarsening_level);
}
#endif
#endif
39 changes: 39 additions & 0 deletions Exec/RegTests/SI_crossflow/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
TOP = ../../../..
PELELMEX_HOME ?= ${TOP}/PeleLMeX
AMREX_HOME ?= ${PELELMEX_HOME}/Submodules/amrex
# AMREX_HOME ?= ${PELELMEX_HOME}/Submodules/amrex_original
PELE_PHYSICS_HOME ?= ${PELELMEX_HOME}/Submodules/PelePhysics
AMREX_HYDRO_HOME ?= ${PELELMEX_HOME}/Submodules/AMReX-Hydro
# HYPRE_HOME ?= ${PELELMEX_HOME}/Submodules/hypre
HYPRE_HOME = /lustre/scratch/bsouzas/PeleLMeX/Submodules/hypre/install

# AMReX
DIM = 3
DEBUG = FALSE
PRECISION = DOUBLE
VERBOSE = FALSE
TINY_PROFILE = FALSE

# Compilation
COMP = gnu
USE_MPI = TRUE
USE_OMP = FALSE
USE_CUDA = TRUE
USE_HIP = FALSE

# PeleLMeX
USE_EFIELD = FALSE
USE_EB = TRUE
USE_HYPRE = TRUE
CEXE_headers += EBUserDefined.H

# PelePhysics
Chemistry_Model = air
Eos_Model = Fuego
Transport_Model = Simple

ifeq ($(USE_CUDA),TRUE)
DEFINES += -DAMREX_GPUS_PER_NODE=2
endif

include $(PELELMEX_HOME)/Utils/Make.PeleLMeX
108 changes: 108 additions & 0 deletions Exec/RegTests/SI_crossflow/inputs-3d
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#----------------------DOMAIN DEFINITION------------------------
geometry.is_periodic = 0 0 0 # For each dir, 0: non-perio, 1: periodic
geometry.coord_sys = 0 # 0 => cart, 1 => RZ
geometry.prob_lo = -0.4e-2 1.47e-2 -0.4e-2
geometry.prob_hi = 1.2e-2 2.27e-2 0.4e-2

# >>>>>>>>>>>>> BC FLAGS <<<<<<<<<<<<<<<<
# Interior, Inflow, Outflow, Symmetry,
# SlipWallAdiab, NoSlipWallAdiab, SlipWallIsotherm, NoSlipWallIsotherm
peleLM.lo_bc = Inflow SlipWallAdiab Symmetry
peleLM.hi_bc = Outflow Symmetry SlipWallAdiab


#-------------------------AMR CONTROL----------------------------
amr.n_cell = 256 128 128
amr.v = 1 # AMR verbose
amr.max_level = 0 # maximum level number allowed
amr.ref_ratio = 2 2 2 2 # refinement ratio
amr.regrid_int = 2 # how often to regrid
amr.n_error_buf = 1 1 2 2 # number of buffer cells in error est
amr.grid_eff = 0.7 # what constitutes an efficient grid
amr.blocking_factor = 16 # block factor in grid generation (min box size)
amr.max_grid_size = 64 # max box size


#--------------------------- Problem -------------------------------
prob.T_mean = 343.0
prob.P_mean = 5e+5
prob.flowDir = 0

prob.V_in = 10.0

#turbinflows = lowX
turbinflow.lowX.turb_file = Turb_tprf_phi1_egr10_Ka6
turbinflow.lowX.dir = 0
turbinflow.lowX.side = low
turbinflow.lowX.turb_scale_loc = 1.0
turbinflow.lowX.turb_scale_vel = 1.0
turbinflow.lowX.turb_center = 0.017 0.0
turbinflow.lowX.turb_conv_vel = 10.
turbinflow.lowX.turb_nplane = 32


#-------------------------PeleLM CONTROL----------------------------
peleLM.v = 1
peleLM.incompressible = 0
peleLM.rho = 1.17
peleLM.mu = 0.0
peleLM.sdc_iterMax = 1
peleLM.floor_species = 0
peleLM.num_divu_iter = 1
peleLM.num_init_iter = 1

# peleLM.do_temporals = 1
# peleLM.temporal_int = 2
# peleLM.mass_balance = 1

eb2.geom_type = UserDefined
eb2.small_volfrac = 1.e-2
eb2.maxiter = 100

amr.plot_int = 10
amr.max_step = 10
amr.dt_shrink = 0.1
amr.stop_time = 0.02
amr.cfl = 0.5
amr.derive_plot_vars = avg_pressure mag_vort mass_fractions


nodal_proj.verbose = 2
#nodal_proj.mg_max_coarsening_level = 0
nodal_proj.bottom_rtol = 1.0e-11
nodal_proj.bottom_atol = 1.0e-11
#nodal_proj.bottom_solver = "hypre"

#nodal_proj.bottom_verbose = 1
#nodal_proj.hypre_namespace = nodal_proj.hypre
#nodal_proj.hypre.verbose = 2
#nodal_proj.hypre.hypre_solver = GMRES
#nodal_proj.hypre.hypre_preconditioner = BoomerAMG
#nodal_proj.hypre.bamg_verbose = 1
#nodal_proj.hypre.num_krylov = 100
#nodal_proj.hypre.bamg_coarsen_type = 10
#nodal_proj.hypre.bamg_interp_type = 6
#nodal_proj.hypre.bamg_relax_type = 3
#nodal_proj.hypre.bamg_num_sweeps = 5
#nodal_proj.hypre.bamg_cycle_type = 1
#nodal_proj.hypre.bamg_relax_order = 0
#nodal_proj.hypre.bamg_trunc_factor = 0.25
#nodal_proj.hypre.bamg_max_levels = 10
#nodal_proj.hypre.bamg_pmax_elmts = 4
#nodal_proj.hypre.bamg_keep_transpose = 1
#nodal_proj.hypre.bamg_strong_threshold = .57
#nodal_proj.hypre.recompute_preconditioner = 1
#nodal_proj.hypre.write_matrix_files = 0
#nodal_proj.hypre.overwrite_existing_matrix_files = 0
#nodal_proj.hypre.adjust_singular_matrix = 1

#--------------------REFINEMENT CONTROL------------------------
# amr.refinement_indicators = O2
# amr.O2.max_level = 1
# amr.O2.value_greater = 0.4
# amr.O2.field_name = Y(O2)

# fabarray.mfiter_tile_size = 1024 1024 1024
#amrex.fpe_trap_invalid = 1
#amrex.fpe_trap_zero = 1
#amrex.fpe_trap_overflow = 1
Loading