83 using namespace mfem::common;
84 using namespace mfem::electromagnetics;
87 static Vector ds_params_(0);
93 static Vector ms_params_(0);
99 static Vector cs_params_(0);
105 static Vector dp_params_(0);
120 static double tScale_ = 1e-9;
122 int SnapTimeStep(
double tmax,
double dtmax,
double & dt);
127 int main(
int argc,
char *argv[])
135 const char *mesh_file =
"../../data/ball-nurbs.mesh";
138 int serial_ref_levels = 0;
139 int parallel_ref_levels = 0;
140 bool visualization =
true;
152 args.
AddOption(&mesh_file,
"-m",
"--mesh",
153 "Mesh file to use.");
154 args.
AddOption(&sOrder,
"-so",
"--spatial-order",
155 "Finite element order (polynomial degree).");
156 args.
AddOption(&tOrder,
"-to",
"--temporal-order",
157 "Time integration order.");
158 args.
AddOption(&serial_ref_levels,
"-rs",
"--serial-ref-levels",
159 "Number of serial refinement levels.");
160 args.
AddOption(¶llel_ref_levels,
"-rp",
"--parallel-ref-levels",
161 "Number of parallel refinement levels.");
162 args.
AddOption(&dtsf,
"-sf",
"--dt-safety-factor",
163 "Used to reduce the time step below the upper bound.");
164 args.
AddOption(&ti,
"-ti",
"--initial-time",
165 "Beginning of time interval to simulate (ns).");
166 args.
AddOption(&tf,
"-tf",
"--final-time",
167 "End of time interval to simulate (ns).");
168 args.
AddOption(&ts,
"-ts",
"--snapshot-time",
169 "Time between snapshots (ns).");
170 args.
AddOption(&ds_params_,
"-ds",
"--dielectric-sphere-params",
171 "Center, Radius, and Permittivity of Dielectric Sphere");
172 args.
AddOption(&ms_params_,
"-ms",
"--magnetic-shell-params",
173 "Center, Inner Radius, Outer Radius, and Permeability "
174 "of Magnetic Shell");
175 args.
AddOption(&cs_params_,
"-cs",
"--conductive-sphere-params",
176 "Center, Radius, and Conductivity of Conductive Sphere");
177 args.
AddOption(&dp_params_,
"-dp",
"--dipole-pulse-params",
178 "Axis End Points, Radius, Amplitude, "
179 "Pulse Center (ns), Pulse Width (ns)");
180 args.
AddOption(&abcs,
"-abcs",
"--absorbing-bc-surf",
181 "Absorbing Boundary Condition Surfaces");
182 args.
AddOption(&dbcs,
"-dbcs",
"--dirichlet-bc-surf",
183 "Dirichlet Boundary Condition Surfaces");
184 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
185 "--no-visualization",
186 "Enable or disable GLVis visualization.");
187 args.
AddOption(&visit,
"-visit",
"--visit",
"-no-visit",
188 "--no-visualization",
189 "Enable or disable VisIt visualization.");
208 ifstream imesh(mesh_file);
213 cerr <<
"\nCan not open mesh file: " << mesh_file <<
'\n' << endl;
217 mesh =
new Mesh(imesh, 1, 1);
224 if (serial_ref_levels > 0) { serial_ref_levels--; }
231 for (
int l = 0; l < serial_ref_levels; l++)
239 ParMesh pmesh(MPI_COMM_WORLD, *mesh);
243 for (
int l = 0; l < parallel_ref_levels; l++)
251 ( ms_params_.
Size() > 0 ) ?
muInv : NULL,
252 ( cs_params_.
Size() > 0 ) ?
sigma : NULL,
253 ( dp_params_.
Size() > 0 ) ?
j_src : NULL,
272 cout <<
"Energy(" << ti <<
"ns): " << energy <<
"J" << endl;
285 cout <<
"Maximum Time Step: " << dtmax / tScale_ <<
"ns" << endl;
292 cout <<
"Number of Time Steps: " << nsteps << endl;
293 cout <<
"Time Step Size: " << dt / tScale_ <<
"ns" << endl;
336 max(t + dt, ti + ts * it));
342 cout <<
"Energy(" << t/tScale_ <<
"ns): " << energy <<
"J" << endl;
369 os <<
" ___ ____ " << endl
370 <<
" / | / / __ __ " << endl
371 <<
" / |_/ _ /__ ___ _____ _ __ ____ | | | | " << endl
372 <<
" / \\__ \\ \\ \\/ /\\ \\/ \\/ // __ \\| | | | "
374 <<
" / /|_/ // __ \\_> < \\ /\\ ___/| |_| |__ " << endl
375 <<
"/___/ /_ /(____ /__/\\_ \\ \\/\\_/ \\___ >____/____/ " << endl
376 <<
" \\/ \\/ \\/ \\/ " << endl
386 for (
int i=0; i<x.
Size(); i++)
388 r2 += (x(i)-ds_params_(i))*(x(i)-ds_params_(i));
391 if ( sqrt(r2) <= ds_params_(x.
Size()) )
393 return ds_params_(x.
Size()+1) * epsilon0_;
405 for (
int i=0; i<x.
Size(); i++)
407 r2 += (x(i)-ms_params_(i))*(x(i)-ms_params_(i));
410 if ( sqrt(r2) >= ms_params_(x.
Size()) &&
411 sqrt(r2) <= ms_params_(x.
Size()+1) )
413 return mu0_*ms_params_(x.
Size()+2);
424 for (
int i=0; i<x.
Size(); i++)
426 r2 += (x(i)-cs_params_(i))*(x(i)-cs_params_(i));
429 if ( sqrt(r2) <= cs_params_(x.
Size()) )
431 return cs_params_(x.
Size()+1);
441 MFEM_ASSERT(x.
Size() == 3,
"current source requires 3D space.");
451 for (
int i=0; i<x.
Size(); i++)
453 xu[i] -= dp_params_[i];
454 v[i] = dp_params_[x.
Size()+i] - dp_params_[i];
465 double r = dp_params_[2*x.
Size()+0];
466 double a = dp_params_[2*x.
Size()+1] * tScale_;
467 double b = dp_params_[2*x.
Size()+2] * tScale_;
468 double c = dp_params_[2*x.
Size()+3] * tScale_;
477 if ( xv >= 0.0 && xv <= h && xp <= r )
482 j *= a * (t -
b) * exp(-0.5 * pow((t-b)/c, 2.0)) / (c * c);
509 double dsteps = tmax/dtmax;
511 int nsteps =
static_cast<int>(pow(10,(
int)ceil(log10(dsteps))));
513 for (
int i=1; i<=5; i++)
515 int a = (int)ceil(log10(dsteps/pow(5.0,i)));
516 int nstepsi = (int)pow(5,i)*max(1,(
int)pow(10,a));
518 nsteps = min(nsteps,nstepsi);
int Size() const
Return the logical size of the array.
virtual void Init(Operator &P, TimeDependentOperator &F)
void SetSize(int s)
Resize the vector to size s.
double Norml2() const
Returns the l2 norm of the vector.
double dielectric_sphere(const Vector &)
int Size() const
Returns the size of the vector.
void EFieldFunc(const Vector &, Vector &)
virtual void SetTime(const double t_)
Set the current time.
void SetInitialBField(VectorCoefficient &BFieldCoef)
double GetMaximumTimeStep() const
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void RegisterVisItFields(VisItDataCollection &visit_dc)
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void dEdtBCFunc(const Vector &x, double t, Vector &E)
Data collection with VisIt I/O routines.
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
double muInv(const Vector &x)
void dipole_pulse(const Vector &x, double t, Vector &j)
int SnapTimeStep(double tmax, double dtmax, double &dt)
void PrintUsage(std::ostream &out) const
Print the usage message.
A general vector function coefficient.
void j_src(const Vector &x, double t, Vector &j)
void WriteVisItFields(int it=0)
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...
NURBSExtension * NURBSext
Optional NURBS mesh extension.
Vector & Add(const double a, const Vector &Va)
(*this) += a * Va
double conductive_sphere(const Vector &)
void PrintOptions(std::ostream &out) const
Print the options.
double magnetic_shell(const Vector &)
virtual void Run(Vector &q, Vector &p, double &t, double &dt, double tf)
void BFieldFunc(const Vector &, Vector &)
void display_banner(ostream &os)
Class for parallel meshes.
void SetInitialEField(VectorCoefficient &EFieldCoef)
Variable order Symplectic Integration Algorithm (orders 1-4)
double sigma(const Vector &x)
bool Good() const
Return true if the command line options were parsed successfully.