18 static constexpr
const char*
name =
"ellipse";
22 Ellipse (amrex::Vector<amrex::Geometry> &_geom) :
IC(_geom) {}
29 amrex::IndexType type = a_field[lev]->ixType();
30 int ncomp = a_field[lev]->nComp();
32 for (amrex::MFIter mfi(*a_field[lev],amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
35 if (type == amrex::IndexType::TheNodeType()) bx = mfi.grownnodaltilebox();
36 if (type == amrex::IndexType::TheCellType()) bx = mfi.growntilebox();
38 amrex::Array4<Set::Scalar>
const& field = a_field[lev]->array(mfi);
39 amrex::ParallelFor (bx,[=] AMREX_GPU_DEVICE(
int i,
int j,
int k) {
43 if (type == amrex::IndexType::TheNodeType())
45 AMREX_D_TERM(x(0) =
geom[lev].ProbLo()[0] + ((amrex::Real)(i)) *
geom[lev].CellSize()[0];,
46 x(1) =
geom[lev].ProbLo()[1] + ((amrex::Real)(j)) *
geom[lev].CellSize()[1];,
47 x(2) =
geom[lev].ProbLo()[2] + ((amrex::Real)(k)) *
geom[lev].CellSize()[2];);
49 else if (type == amrex::IndexType::TheCellType())
51 AMREX_D_TERM(x(0) =
geom[lev].ProbLo()[0] + ((amrex::Real)(i) + 0.5) *
geom[lev].CellSize()[0];,
52 x(1) =
geom[lev].ProbLo()[1] + ((amrex::Real)(j) + 0.5) *
geom[lev].CellSize()[1];,
53 x(2) =
geom[lev].ProbLo()[2] + ((amrex::Real)(k) + 0.5) *
geom[lev].CellSize()[2];);
59 field(i,j,k,0) = 0.5 - 0.5*std::erf(((x-
center[0]).transpose() *
A[0] * (x-
center[0]) - 1.0) /
eps[0] / norm);
60 if (
invert) field(i,j,k,0) = 1.0 - field(i,j,k,0);
61 if (ncomp > 1) field(i,j,k,1) = 1.0 - field(i,j,k,0);
70 value += 0.5 - 0.5*std::erf(((x-
center[m]).transpose() *
A[m] * (x-
center[m]) - 1.0) /
eps[m] / norm);
75 field (i,j,k,
invert) = 1.0 - value;
76 field (i,j,k,1-
invert) = value;
79 if (field(i,j,k,1-
invert) < 0.) field(i,j,k,1-
invert) = 0.;
80 if (field(i,j,k,1-
invert) > 1.) field(i,j,k,1-
invert) = 1.;
85 a_field[lev]->FillBoundary();
91 amrex::Vector<Set::Matrix>
A;
92 amrex::Vector<Set::Scalar>
eps;
98 amrex::Vector<Set::Scalar> x0;
99 if(!(pp.
contains(
"number_of_inclusions")))
111 value.
eps.push_back(_eps);
117 value.
A.push_back(_A);
124 for (
int d = 0; d < AMREX_SPACEDIM; d++) _A(d,d) = 1./a(d)/a(d);
125 value.
A.push_back(_A);
145 for (
int i = 0; i < x0.size(); i+= AMREX_SPACEDIM)
150 amrex::Vector<Set::Scalar> _A;
152 if(_A.size() != value.
number_of_inclusions*AMREX_SPACEDIM*AMREX_SPACEDIM && _A.size() != AMREX_SPACEDIM*AMREX_SPACEDIM)
154 if(_A.size() == AMREX_SPACEDIM*AMREX_SPACEDIM)
159 value.
A.push_back(_A1);
166 AMREX_D_PICK( _A1(0,0) = _A[i];
168 _A1(0,0) = _A[i]; _A1(0,1) = _A[i+1];
169 _A1(1,0) = _A[i+2]; _A1(1,1) = _A[i+3];
171 _A1(0,0) = _A[i+0]; _A1(0,1) = _A[i+1]; _A1(0,2) = _A[i+2];
172 _A1(1,0) = _A[i+3]; _A1(1,1) = _A[i+4]; _A1(1,2) = _A[i+5];
173 _A1(2,0) = _A[i+6]; _A1(2,1) = _A[i+7]; _A1(2,2) = _A[i+8];
175 value.
A.push_back(_A1);
181 amrex::Vector<Set::Scalar> _r;
185 Util::Abort(
INFO,
"Invalid value of radius for ellipse initialization");
186 if(_r.size() == AMREX_SPACEDIM)
189 for (
int i = 0; i< AMREX_SPACEDIM; i++) _A1(i,i) = 1.0/(_r[i]*_r[i]);
191 value.
A.push_back(_A1);
198 for (
int d = 0; d < AMREX_SPACEDIM; d++) _A1(d,d) = 1.0/_r[i+d]/_r[i+d];
199 value.
A.push_back(_A1);
204 amrex::Vector<Set::Scalar> _eps;
207 Util::Abort(
INFO,
"Incorrect eps. Check the number of values specified");
209 if (_eps.size() == 1)