Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Source/FerroX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,11 @@ int FerroX::plot_PhiDiff;

// multimaterial stack geometry
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::DE_lo;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::DE1_lo;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::FE_lo;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::SC_lo;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::DE_hi;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::DE1_hi;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::FE_hi;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::SC_hi;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::Channel_hi;
Expand Down Expand Up @@ -233,6 +235,8 @@ AMREX_GPU_MANAGED amrex::Real FerroX::lambda;
AMREX_GPU_MANAGED amrex::GpuArray<int, AMREX_SPACEDIM> FerroX::P_BC_flag_lo;
AMREX_GPU_MANAGED amrex::GpuArray<int, AMREX_SPACEDIM> FerroX::P_BC_flag_hi;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::Remnant_P;
AMREX_GPU_MANAGED amrex::Real FerroX::noise_amplitude;
AMREX_GPU_MANAGED amrex::Real FerroX::theta_dep;

//problem type : initialization of P for 2D/3D/convergence problems
AMREX_GPU_MANAGED int FerroX::prob_type;
Expand Down Expand Up @@ -400,6 +404,12 @@ void InitializeFerroXNamespace(const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM
num_Vapp_max = 1;
pp.query("num_Vapp_max",num_Vapp_max);

noise_amplitude = 0.0;
pp.query("noise_amplitude",noise_amplitude);

theta_dep = 1.0;
pp.query("theta_dep",theta_dep);

//stack dimensions in 3D. This is an alternate way of initializing the device geometry, which works in simpler scenarios.
//A more general way of initializing device geometry is accomplished through masks which use function parsers

Expand Down Expand Up @@ -447,6 +457,18 @@ void InitializeFerroXNamespace(const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM
}
}

if (pp.queryarr("DE1_lo",temp)) {
for (int i=0; i<AMREX_SPACEDIM; ++i) {
DE1_lo[i] = temp[i];
}
}

if (pp.queryarr("DE1_hi",temp)) {
for (int i=0; i<AMREX_SPACEDIM; ++i) {
DE1_hi[i] = temp[i];
}
}

if (pp.queryarr("SC_lo",temp)) {
for (int i=0; i<AMREX_SPACEDIM; ++i) {
SC_lo[i] = temp[i];
Expand Down
5 changes: 4 additions & 1 deletion Source/FerroX_namespace.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ namespace FerroX {

// multimaterial stack geometry
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> DE_lo;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> DE1_lo;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FE_lo;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> SC_lo;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> DE_hi;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> DE1_hi;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FE_hi;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> SC_hi;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> Channel_hi;
Expand Down Expand Up @@ -73,7 +75,8 @@ namespace FerroX {
extern AMREX_GPU_MANAGED amrex::GpuArray<int, AMREX_SPACEDIM> P_BC_flag_lo;
extern AMREX_GPU_MANAGED amrex::GpuArray<int, AMREX_SPACEDIM> P_BC_flag_hi;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> Remnant_P;

extern AMREX_GPU_MANAGED amrex::Real noise_amplitude;
extern AMREX_GPU_MANAGED amrex::Real theta_dep;

//problem type : initialization of P for 2D/3D/convergence problems
extern AMREX_GPU_MANAGED int prob_type;
Expand Down
20 changes: 12 additions & 8 deletions Source/Solver/DerivativeAlgorithm.H
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ using namespace FerroX;

} else if (P_BC_flag_lo[2] == 1){

Real F_lo = F(i,j,k)/(1 + dx[2]/2/lambda);
return (dx[2]*F_lo/lambda - F(i,j,k) + F(i,j,k+1))/(2.*dx[2]); // dP/dz = P_lo/lambda;
//Real F_lo = F(i,j,k)/(1 + dx[2]/2/lambda);
Real dF_lo = F(i,j,k)/lambda;
return (dx[2]*dF_lo - F(i,j,k) + F(i,j,k+1))/(2.*dx[2]); // dP/dz = P_lo/lambda;

// Real F_lo = (9. * F(i,j,k) - F(i,j,k+1)) / (3. * dx[2] / lambda + 8.); // derived with 2nd order one-sided 1st derivative
// return -(dx[2]*F_lo/lambda - F(i,j,k) + F(i,j,k+1))/(2.*dx[2]);// dP/dz = P_lo/lambda;
Expand Down Expand Up @@ -222,8 +223,9 @@ using namespace FerroX;

} else if (P_BC_flag_hi[2] == 1){

Real F_hi = F(i,j,k)/(1 - dx[2]/2/lambda);
return (dx[2]*F_hi/lambda + F(i,j,k) - F(i,j,k-1))/(2.*dx[2]);//dPdz = P_hi/lambda;
//Real F_hi = F(i,j,k)/(1 - dx[2]/2/lambda);
Real dF_hi = -F(i,j,k)/lambda;
return (dx[2]*dF_hi + F(i,j,k) - F(i,j,k-1))/(2.*dx[2]);//dPdz = P_hi/lambda;

// Real F_hi = (9. * F(i,j,k) - F(i,j,k-1)) / ( - 3. * dx[2] / lambda + 8.); // derived with 2nd order one-sided 1st derivative
// return -(dx[2]*F_hi/lambda + F(i,j,k) - F(i,j,k-1))/(2.*dx[2]);//dPdz = P_hi/lambda;
Expand Down Expand Up @@ -407,8 +409,9 @@ using namespace FerroX;

} else if (P_BC_flag_lo[2] == 1){

Real F_lo = F(i,j,k)/(1 + dx[2]/2/lambda);
return (-dx[2]*F_lo/lambda - F(i,j,k) + F(i,j,k+1))/dx[2]/dx[2];//dPdz = P_lo/lambda;
//Real F_lo = F(i,j,k)/(1 + dx[2]/2/lambda);
Real dF_lo = F(i,j,k)/lambda;
return (-dx[2]*dF_lo - F(i,j,k) + F(i,j,k+1))/dx[2]/dx[2];//dPdz = P_lo/lambda;

// Real F_lo = (9. * F(i,j,k) - F(i,j,k+1)) / (3. * dx[2] / lambda + 8.); // derived with 2nd order one-sided 1st derivative
// return (-dx[2]*F_lo/lambda - F(i,j,k) + F(i,j,k+1))/dx[2]/dx[2];// dPdz = P_lo/lambda;
Expand Down Expand Up @@ -436,8 +439,9 @@ using namespace FerroX;

} else if (P_BC_flag_hi[2] == 1){

Real F_hi = F(i,j,k)/(1 - dx[2]/2/lambda);
return (dx[2]*F_hi/lambda - F(i,j,k) + F(i,j,k-1))/dx[2]/dx[2];//dPdz = P_hi/lambda;
//Real F_hi = F(i,j,k)/(1 - dx[2]/2/lambda);
Real dF_hi = -F(i,j,k)/lambda;
return (dx[2]*dF_hi - F(i,j,k) + F(i,j,k-1))/dx[2]/dx[2];//dPdz = P_hi/lambda;

// Real F_hi = (9. * F(i,j,k) - F(i,j,k-1)) / ( - 3. * dx[2] / lambda + 8.); // derived with 2nd order one-sided 1st derivative
// return (dx[2]*F_hi/lambda - F(i,j,k) + F(i,j,k-1))/dx[2]/dx[2]; // dPdz = P_hi/lambda;
Expand Down
7 changes: 6 additions & 1 deletion Source/Solver/ElectrostaticSolver.H
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,22 @@ void ComputePoissonRHS_Newton(MultiFab& PoissonRHS,
MultiFab& alpha_cc);

void SetPhiBC_z(MultiFab& PossonPhi, const amrex::GpuArray<int, AMREX_SPACEDIM>& n_cell, const Geometry& geom);
void SetPhiBC_z(MultiFab& PoissonPhi, Array<MultiFab, AMREX_SPACEDIM> &P_old, MultiFab& MaterialMask, const amrex::GpuArray<int, AMREX_SPACEDIM>& n_cell, const Geometry& geom);

void SetPoissonBC(c_FerroX& rFerroX, std::array<std::array<amrex::LinOpBCType,AMREX_SPACEDIM>,2>& LinOpBCType_2d, bool& all_homogeneous_boundaries, bool& some_functionbased_inhomogeneous_boundaries, bool& some_constant_inhomogeneous_boundaries);

void Fill_Constant_Inhomogeneous_Boundaries(c_FerroX& rFerroX, MultiFab& PoissonPhi);
void Fill_FunctionBased_Inhomogeneous_Boundaries(c_FerroX& rFerroX, MultiFab& PoissonPhi, amrex::Real& time);

void CheckSteadyState(MultiFab& PoissonPhi, MultiFab& PoissonPhi_Old, MultiFab& Phidiff, Real phi_tolerance, int step, int& steady_state_step, int& inc_step);
void SetNucleation(Array<MultiFab, AMREX_SPACEDIM> &P_old, MultiFab& NucleationMask, const amrex::GpuArray<int, AMREX_SPACEDIM>& n_cell);
void SetupMLMG(std::unique_ptr<amrex::MLMG>& pMLMG,
std::unique_ptr<amrex::MLABecLaplacian>& p_mlabec,
std::array<std::array<amrex::LinOpBCType,AMREX_SPACEDIM>,2>& LinOpBCType_2d,
const amrex::GpuArray<int, AMREX_SPACEDIM>& n_cell,
std::array< MultiFab, AMREX_SPACEDIM >& beta_face,
Array<MultiFab, AMREX_SPACEDIM>& P_old,
MultiFab& MaterialMask,
c_FerroX& rFerroX, MultiFab& PoissonPhi, amrex::Real& time, amrex::LPInfo& info);

#ifdef AMREX_USE_EB
Expand All @@ -101,7 +105,8 @@ void ComputePhi_Rho(std::unique_ptr<amrex::MLMG>& pMLMG,
MultiFab& MaterialMask,
MultiFab& angle_alpha, MultiFab& angle_beta, MultiFab& angle_theta,
const Geometry& geom,
const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& prob_lo,
const amrex::GpuArray<int, AMREX_SPACEDIM>& n_cell,
const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& prob_lo,
const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& prob_hi);

#ifdef AMREX_USE_EB
Expand Down
135 changes: 130 additions & 5 deletions Source/Solver/ElectrostaticSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "ChargeDensity.H"
#include "Utils/eXstaticUtils/eXstaticUtil.H"
#include "Utils/FerroXUtils/FerroXUtil.H"

#include "TotalEnergyDensity.H"

void ComputePoissonRHS(MultiFab& PoissonRHS,
Array<MultiFab, AMREX_SPACEDIM> &P_old,
Expand All @@ -12,6 +12,18 @@ void ComputePoissonRHS(MultiFab& PoissonRHS,
MultiFab& angle_alpha, MultiFab& angle_beta, MultiFab& angle_theta,
const Geometry& geom)
{
//Real average_P_r = 0.;
//Real total_P_r = 0.;
//Real FE_index_counter = 0.;

//Compute_P_av(P_old, total_P_r, MaterialMask, FE_index_counter, average_P_r);

//Real FE_thickness = FE_hi[2] - FE_lo[2];
//Real one_m_theta = 1.0 - theta_dep;
//Real E_dep = average_P_r/(epsilonZ_fe*epsilon_0)*one_m_theta;

//amrex::Print() << " E_dep = " << E_dep << "\n";
//amrex::Print() << " FE_thickness = " << FE_thickness << "\n";
for ( MFIter mfi(PoissonRHS); mfi.isValid(); ++mfi )
{
const Box& bx = mfi.validbox();
Expand Down Expand Up @@ -73,7 +85,7 @@ void ComputePoissonRHS(MultiFab& PoissonRHS,
} else { //mask(i,j,k) == 0.0 FE region
RHS(i,j,k) = - (R_11*DPDx(pOld_p, mask, i, j, k, dx) + R_12*DPDy(pOld_p, mask, i, j, k, dx) + R_13*DPDz(pOld_p, mask, i, j, k, dx))
- (R_21*DPDx(pOld_q, mask, i, j, k, dx) + R_22*DPDy(pOld_q, mask, i, j, k, dx) + R_23*DPDz(pOld_q, mask, i, j, k, dx))
- (R_31*DPDx(pOld_r, mask, i, j, k, dx) + R_32*DPDy(pOld_r, mask, i, j, k, dx) + R_33*DPDz(pOld_r, mask, i, j, k, dx));
- (R_31*DPDx(pOld_r, mask, i, j, k, dx) + R_32*DPDy(pOld_r, mask, i, j, k, dx) + R_33*DPDz(pOld_r, mask, i, j, k, dx));// - E_dep*FE_thickness;

}

Expand Down Expand Up @@ -499,8 +511,47 @@ void Fill_FunctionBased_Inhomogeneous_Boundaries(c_FerroX& rFerroX, MultiFab& Po
}
}

void SetPhiBC_z(MultiFab& PoissonPhi, Array<MultiFab, AMREX_SPACEDIM> &P_old, MultiFab& MaterialMask, const amrex::GpuArray<int, AMREX_SPACEDIM>& n_cell, const Geometry& geom)
{
//
// Real average_P_r = 0.;
// Real total_P_r = 0.;
// Real FE_index_counter = 0.;
//
// Compute_P_av(P_old, total_P_r, MaterialMask, FE_index_counter, average_P_r);
//
// Real FE_thickness = FE_hi[2] - FE_lo[2];
// Real one_m_theta = 1.0 - theta_dep;
// Real E_dep = -1.0*average_P_r/(epsilonZ_fe*epsilon_0)*one_m_theta;
//
// amrex::Print() << "average_P_r = " << average_P_r << ", "<< ", E_dep = " << E_dep << ", theta = " << theta_dep << ", phi_Bc_hi" << Phi_Bc_hi << "\n";
//
for (MFIter mfi(PoissonPhi); mfi.isValid(); ++mfi)
{
const Box& bx = mfi.growntilebox(1);

const Array4<Real>& Phi = PoissonPhi.array(mfi);

amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k)
{
if(k < 0) {
Phi(i,j,k) = Phi_Bc_lo;
} else if(k >= n_cell[2]){
amrex::Real Eg = bandgap;
amrex::Real Chi = affinity;
amrex::Real phi_ref = Chi + 0.5*Eg + 0.5*kb*T*log(Nc/Nv)/q;
amrex::Real phi_m = use_work_function ? metal_work_function : phi_ref; //in eV When not used, applied voltgae is set as the potential on the metal interface
Phi(i,j,k) = (Phi_Bc_hi - (phi_m - phi_ref))*theta_dep;// - E_dep*FE_thickness; //multiplying by theta_dep
//if(i == 5 && j == 5) amrex::Print() << "Phi(i,j,k) = "<< Phi(i,j,k) << std::endl;
}
});
}
PoissonPhi.FillBoundary(geom.periodicity());
}

void SetPhiBC_z(MultiFab& PoissonPhi, const amrex::GpuArray<int, AMREX_SPACEDIM>& n_cell, const Geometry& geom)
{

for (MFIter mfi(PoissonPhi); mfi.isValid(); ++mfi)
{
const Box& bx = mfi.growntilebox(1);
Expand All @@ -516,13 +567,81 @@ void SetPhiBC_z(MultiFab& PoissonPhi, const amrex::GpuArray<int, AMREX_SPACEDIM>
amrex::Real Chi = affinity;
amrex::Real phi_ref = Chi + 0.5*Eg + 0.5*kb*T*log(Nc/Nv)/q;
amrex::Real phi_m = use_work_function ? metal_work_function : phi_ref; //in eV When not used, applied voltgae is set as the potential on the metal interface
Phi(i,j,k) = Phi_Bc_hi - (phi_m - phi_ref);
Phi(i,j,k) = (Phi_Bc_hi - (phi_m - phi_ref));
//if(i == 5 && j == 5) amrex::Print() << "Phi(i,j,k) = "<< Phi(i,j,k) << std::endl;
}
});
}
PoissonPhi.FillBoundary(geom.periodicity());
}

void SetNucleation(Array<MultiFab, AMREX_SPACEDIM> &P_old, MultiFab& NucleationMask, const amrex::GpuArray<int, AMREX_SPACEDIM>& n_cell)
{
int seed = random_seed;

int nprocs = ParallelDescriptor::NProcs();

if (prob_type == 1) {
amrex::InitRandom(seed , nprocs, seed ); // give all MPI ranks the same seed
} else {
amrex::InitRandom(seed+ParallelDescriptor::MyProc(), nprocs, seed+ParallelDescriptor::MyProc()); // give all MPI ranks a different seed
}

int nrand = n_cell[0]*n_cell[2];
amrex::Gpu::ManagedVector<Real> rngs(nrand, 0.0);

// generate random numbers on the host
for (int i=0; i<nrand; ++i) {
//rngs[i] = amrex::RandomNormal(0.,1.); // zero mean, unit variance
rngs[i] = amrex::Random(); // uniform [0,1] option
}

for (MFIter mfi(P_old[0]); mfi.isValid(); ++mfi)
{
const Box& bx = mfi.tilebox();

const Array4<Real> &pOld_p = P_old[0].array(mfi);
const Array4<Real> &pOld_q = P_old[1].array(mfi);
const Array4<Real> &pOld_r = P_old[2].array(mfi);
const Array4<Real>& mask = NucleationMask.array(mfi);

Real* rng = rngs.data();

amrex::ParallelForRNG(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k, amrex::RandomEngine const& engine) noexcept
{
if (mask(i,j,k) == 0.) {
if (prob_type == 1) { //2D
if (rng[i + k*n_cell[2]] <= 0.02){
pOld_p(i,j,k) = Remnant_P[0];
pOld_q(i,j,k) = Remnant_P[1];
pOld_r(i,j,k) = Remnant_P[2];
} else if (rng[i + k*n_cell[2]] <= 0.04){
pOld_p(i,j,k) = -Remnant_P[0];
pOld_q(i,j,k) = -Remnant_P[1];
pOld_r(i,j,k) = -Remnant_P[2];
} else {
pOld_p(i,j,k) += (-1.0 + 2.0*rng[i + k*n_cell[2]])*Remnant_P[0]*noise_amplitude;
pOld_q(i,j,k) += (-1.0 + 2.0*rng[i + k*n_cell[2]])*Remnant_P[1]*noise_amplitude;
pOld_r(i,j,k) += (-1.0 + 2.0*rng[i + k*n_cell[2]])*Remnant_P[2]*noise_amplitude;
}
} else if (prob_type == 2) { //3D
Real rand = Random(engine);
if (rand <= 0.04) {
pOld_p(i,j,k) = Remnant_P[0];
pOld_q(i,j,k) = Remnant_P[1];
pOld_r(i,j,k) = Remnant_P[2];
} else {
pOld_p(i,j,k) += (-1.0 + 2.0*rand)*Remnant_P[0]*noise_amplitude;
pOld_q(i,j,k) += (-1.0 + 2.0*rand)*Remnant_P[1]*noise_amplitude;
pOld_r(i,j,k) += (-1.0 + 2.0*rand)*Remnant_P[2]*noise_amplitude;
}
}
}
});
}

}

void CheckSteadyState(MultiFab& PoissonPhi, MultiFab& PoissonPhi_Old, MultiFab& Phidiff, Real phi_tolerance, int step, int& steady_state_step, int& inc_step)
{

Expand Down Expand Up @@ -564,6 +683,8 @@ void SetupMLMG(std::unique_ptr<amrex::MLMG>& pMLMG,
std::array<std::array<amrex::LinOpBCType,AMREX_SPACEDIM>,2>& LinOpBCType_2d,
const amrex::GpuArray<int, AMREX_SPACEDIM>& n_cell,
std::array< MultiFab, AMREX_SPACEDIM >& beta_face,
Array<MultiFab, AMREX_SPACEDIM>& P_old,
MultiFab& MaterialMask,
c_FerroX& rFerroX, MultiFab& PoissonPhi, amrex::Real& time, amrex::LPInfo& info)
{
auto& rGprop = rFerroX.get_GeometryProperties();
Expand Down Expand Up @@ -597,7 +718,8 @@ void SetupMLMG(std::unique_ptr<amrex::MLMG>& pMLMG,
PoissonPhi.FillBoundary(geom.periodicity());

// set Dirichlet BC by reading in the ghost cell values
SetPhiBC_z(PoissonPhi, n_cell, geom);
SetPhiBC_z(PoissonPhi, n_cell, geom);
//SetPhiBC_z(PoissonPhi, P_old, MaterialMask, n_cell, geom);
p_mlabec->setLevelBC(amrlev, &PoissonPhi);

// (A*alpha_cc - B * div beta grad) phi = rhs
Expand Down Expand Up @@ -689,7 +811,8 @@ void ComputePhi_Rho(std::unique_ptr<amrex::MLMG>& pMLMG,
MultiFab& MaterialMask,
MultiFab& angle_alpha, MultiFab& angle_beta, MultiFab& angle_theta,
const Geometry& geom,
const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& prob_lo,
const amrex::GpuArray<int, AMREX_SPACEDIM>& n_cell,
const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& prob_lo,
const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& prob_hi)

{
Expand All @@ -714,6 +837,8 @@ void ComputePhi_Rho(std::unique_ptr<amrex::MLMG>& pMLMG,

//Initial guess for phi
PoissonPhi.setVal(0.);
SetPhiBC_z(PoissonPhi, n_cell, geom);
//SetPhiBC_z(PoissonPhi, P_old, MaterialMask, n_cell, geom);

//Poisson Solve
pMLMG->solve({&PoissonPhi}, {&PoissonRHS}, 1.e-10, -1);
Expand Down
5 changes: 4 additions & 1 deletion Source/Solver/Initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ void InitializeMaterialMask(MultiFab& MaterialMask,
mask(i,j,k) = 0.;
} else if (x <= DE_hi[0] && x >= DE_lo[0] && y <= DE_hi[1] && y >= DE_lo[1] && z <= DE_hi[2] && z >= DE_lo[2]) {
mask(i,j,k) = 1.;
} else if (x <= DE1_hi[0] && x >= DE1_lo[0] && y <= DE1_hi[1] && y >= DE1_lo[1] && z <= DE1_hi[2] && z >= DE1_lo[2]) {
mask(i,j,k) = 1.;
} else if (x <= SC_hi[0] && x >= SC_lo[0] && y <= SC_hi[1] && y >= SC_lo[1] && z <= SC_hi[2] && z >= SC_lo[2]) {
mask(i,j,k) = 2.;
if (x <= Channel_hi[0] && x >= Channel_lo[0] && y <= Channel_hi[1] && y >= Channel_lo[1] && z <= Channel_hi[2] && z >= Channel_lo[2]){
Expand All @@ -218,7 +220,8 @@ void InitializeMaterialMask(c_FerroX& rFerroX, const Geometry& geom, MultiFab& M
for (MFIter mfi(MaterialMask, TilingIfNotGPU()); mfi.isValid(); ++mfi)
{
const auto& mask_arr = MaterialMask.array(mfi);
const auto& bx = mfi.tilebox();
// const auto& bx = mfi.tilebox();
const Box& bx = mfi.growntilebox(MaterialMask.nGrow());

std::string m_mask_s;
std::unique_ptr<amrex::Parser> m_mask_parser;
Expand Down
6 changes: 6 additions & 0 deletions Source/Solver/TotalEnergyDensity.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ void CalculateTDGL_RHS(Array<MultiFab, AMREX_SPACEDIM> &GL_rhs,
const Geometry& geom,
const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& prob_lo,
const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& prob_hi);

void Compute_P_Sum(const std::array<MultiFab, AMREX_SPACEDIM>& P, Real& sum);

void Compute_P_index_Sum(const MultiFab& MaterialMask, Real& count);

void Compute_P_av(const std::array<MultiFab, AMREX_SPACEDIM>& P, Real& sum, const MultiFab& MaterialMask, Real& count, Real &P_av_z);
Loading