76static Vector ds_params_(0);
82static Vector ms_params_(0);
88static Vector cs_params_(0);
94static Vector dp_params_(0);
109static real_t tScale_ = 1e-9;
116int main(
int argc,
char *argv[])
118#ifdef MFEM_USE_SINGLE
119 cout <<
"This miniapp is not supported in single precision.\n\n";
120 return MFEM_SKIP_RETURN_VALUE;
129 const char *mesh_file =
"../../data/ball-nurbs.mesh";
132 int serial_ref_levels = 0;
133 int parallel_ref_levels = 0;
135 bool visualization =
true;
147 args.
AddOption(&mesh_file,
"-m",
"--mesh",
148 "Mesh file to use.");
149 args.
AddOption(&sOrder,
"-so",
"--spatial-order",
150 "Finite element order (polynomial degree).");
151 args.
AddOption(&tOrder,
"-to",
"--temporal-order",
152 "Time integration order.");
153 args.
AddOption(&serial_ref_levels,
"-rs",
"--serial-ref-levels",
154 "Number of serial refinement levels.");
155 args.
AddOption(¶llel_ref_levels,
"-rp",
"--parallel-ref-levels",
156 "Number of parallel refinement levels.");
157 args.
AddOption(&dtsf,
"-sf",
"--dt-safety-factor",
158 "Used to reduce the time step below the upper bound.");
159 args.
AddOption(&ti,
"-ti",
"--initial-time",
160 "Beginning of time interval to simulate (ns).");
161 args.
AddOption(&tf,
"-tf",
"--final-time",
162 "End of time interval to simulate (ns).");
163 args.
AddOption(&ts,
"-ts",
"--snapshot-time",
164 "Time between snapshots (ns).");
165 args.
AddOption(&ds_params_,
"-ds",
"--dielectric-sphere-params",
166 "Center, Radius, and Permittivity of Dielectric Sphere");
167 args.
AddOption(&ms_params_,
"-ms",
"--magnetic-shell-params",
168 "Center, Inner Radius, Outer Radius, and Permeability "
169 "of Magnetic Shell");
170 args.
AddOption(&cs_params_,
"-cs",
"--conductive-sphere-params",
171 "Center, Radius, and Conductivity of Conductive Sphere");
172 args.
AddOption(&dp_params_,
"-dp",
"--dipole-pulse-params",
173 "Axis End Points, Radius, Amplitude, "
174 "Pulse Center (ns), Pulse Width (ns)");
175 args.
AddOption(&abcs,
"-abcs",
"--absorbing-bc-surf",
176 "Absorbing Boundary Condition Surfaces");
177 args.
AddOption(&dbcs,
"-dbcs",
"--dirichlet-bc-surf",
178 "Dirichlet Boundary Condition Surfaces");
179 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
180 "--no-visualization",
181 "Enable or disable GLVis visualization.");
182 args.
AddOption(&visit,
"-visit",
"--visit",
"-no-visit",
183 "--no-visualization",
184 "Enable or disable VisIt visualization.");
185 args.
AddOption(&visport,
"-p",
"--send-port",
"Socket for GLVis.");
204 ifstream imesh(mesh_file);
209 cerr <<
"\nCan not open mesh file: " << mesh_file <<
'\n' << endl;
213 mesh =
new Mesh(imesh, 1, 1);
220 if (serial_ref_levels > 0) { serial_ref_levels--; }
227 for (
int l = 0; l < serial_ref_levels; l++)
235 ParMesh pmesh(MPI_COMM_WORLD, *mesh);
239 for (
int l = 0; l < parallel_ref_levels; l++)
247 ( ms_params_.
Size() > 0 ) ?
muInv : NULL,
248 ( cs_params_.
Size() > 0 ) ?
sigma : NULL,
249 ( dp_params_.
Size() > 0 ) ?
j_src : NULL,
268 cout <<
"Energy(" << ti <<
"ns): " << energy <<
"J" << endl;
281 cout <<
"Maximum Time Step: " << dtmax / tScale_ <<
"ns" << endl;
288 cout <<
"Number of Time Steps: " << nsteps << endl;
289 cout <<
"Time Step Size: " << dt / tScale_ <<
"ns" << endl;
332 max(t + dt, ti + ts * it));
338 cout <<
"Energy(" << t/tScale_ <<
"ns): " << energy <<
"J" << endl;
365 os <<
" ___ ____ " << endl
366 <<
" / | / / __ __ " << endl
367 <<
" / |_/ _ /__ ___ _____ _ __ ____ | | | | " << endl
368 <<
" / \\__ \\ \\ \\/ /\\ \\/ \\/ // __ \\| | | | "
370 <<
" / /|_/ // __ \\_> < \\ /\\ ___/| |_| |__ " << endl
371 <<
"/___/ /_ /(____ /__/\\_ \\ \\/\\_/ \\___ >____/____/ " << endl
372 <<
" \\/ \\/ \\/ \\/ " << endl
382 for (
int i=0; i<x.
Size(); i++)
384 r2 += (x(i)-ds_params_(i))*(x(i)-ds_params_(i));
387 if ( sqrt(r2) <= ds_params_(x.
Size()) )
389 return ds_params_(x.
Size()+1) * epsilon0_;
401 for (
int i=0; i<x.
Size(); i++)
403 r2 += (x(i)-ms_params_(i))*(x(i)-ms_params_(i));
406 if ( sqrt(r2) >= ms_params_(x.
Size()) &&
407 sqrt(r2) <= ms_params_(x.
Size()+1) )
409 return mu0_*ms_params_(x.
Size()+2);
420 for (
int i=0; i<x.
Size(); i++)
422 r2 += (x(i)-cs_params_(i))*(x(i)-cs_params_(i));
425 if ( sqrt(r2) <= cs_params_(x.
Size()) )
427 return cs_params_(x.
Size()+1);
437 MFEM_ASSERT(x.
Size() == 3,
"current source requires 3D space.");
447 for (
int i=0; i<x.
Size(); i++)
449 xu[i] -= dp_params_[i];
450 v[i] = dp_params_[x.
Size()+i] - dp_params_[i];
464 real_t c = dp_params_[2*x.
Size()+3] * tScale_;
473 if ( xv >= 0.0 && xv <= h && xp <= r )
478 j *=
a * (t -
b) *
exp(-0.5 * pow((t-
b)/c, 2.0)) / (c * c);
505 real_t dsteps = tmax/dtmax;
507 int nsteps =
static_cast<int>(pow(10,(
int)ceil(log10(dsteps))));
509 for (
int i=1; i<=5; i++)
511 int a = (int)ceil(log10(dsteps/pow(5.0,i)));
512 int nstepsi = (int)pow(5,i)*max(1,(
int)pow(10,
a));
514 nsteps = min(nsteps,nstepsi);
int Size() const
Return the logical size of the array.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
NURBSExtension * NURBSext
Optional NURBS mesh extension.
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
Set the curvature of the mesh nodes using the given polynomial degree.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
static bool Root()
Return true if the rank in MPI_COMM_WORLD is zero.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
bool Good() const
Return true if the command line options were parsed successfully.
Class for parallel meshes.
virtual void Init(Operator &P, TimeDependentOperator &F)
virtual void Run(Vector &q, Vector &p, real_t &t, real_t &dt, real_t tf)
Variable order Symplectic Integration Algorithm (orders 1-4)
virtual void SetTime(const real_t t_)
Set the current time.
A general vector function coefficient.
real_t Norml2() const
Returns the l2 norm of the vector.
int Size() const
Returns the size of the vector.
void SetSize(int s)
Resize the vector to size s.
Vector & Add(const real_t a, const Vector &Va)
(*this) += a * Va
Data collection with VisIt I/O routines.
real_t GetMaximumTimeStep() const
void WriteVisItFields(int it=0)
void SetInitialEField(VectorCoefficient &EFieldCoef)
void RegisterVisItFields(VisItDataCollection &visit_dc)
void SetInitialBField(VectorCoefficient &BFieldCoef)
void DisplayToGLVis(int visport=19916)
real_t sigma(const Vector &x)
void dipole_pulse(const Vector &x, real_t t, Vector &j)
real_t magnetic_shell(const Vector &)
void EFieldFunc(const Vector &, Vector &)
real_t muInv(const Vector &x)
int SnapTimeStep(real_t tmax, real_t dtmax, real_t &dt)
void j_src(const Vector &x, real_t t, Vector &j)
void dEdtBCFunc(const Vector &x, real_t t, Vector &E)
real_t dielectric_sphere(const Vector &)
void display_banner(ostream &os)
void BFieldFunc(const Vector &, Vector &)
real_t conductive_sphere(const Vector &)
MFEM_HOST_DEVICE Complex exp(const Complex &q)