19 using namespace miniapps;
21 namespace electromagnetics
24 VoltaSolver::VoltaSolver(
ParMesh & pmesh,
int order,
28 double (*phi_bc )(
const Vector&),
29 double (*rho_src)(
const Vector&),
67 MPI_Comm_size(pmesh_->
GetComm(), &num_procs_);
68 MPI_Comm_rank(pmesh_->
GetComm(), &myid_);
80 for (
int i=0; i<dbcs_->
Size(); i++)
82 ess_bdr_[(*dbcs_)[i]-1] = 1;
88 if ( phi_bc_ != NULL )
94 if ( rho_src_ != NULL )
100 if ( p_src_ != NULL )
145 if ( nbcs_->
Size() > 0 )
174 delete hCurlHDivEps_;
179 delete HCurlFESpace_;
182 map<string,socketstream*>::iterator mit;
183 for (mit=socks_.begin(); mit!=socks_.end(); mit++)
203 cout <<
"Number of H1 unknowns: " << size_h1 << endl;
204 cout <<
"Number of H(Curl) unknowns: " << size_nd << endl;
205 cout <<
"Number of H(Div) unknowns: " << size_rt << endl;
211 if (myid_ == 0) { cout <<
"Assembling ... " << flush; }
246 if (myid_ == 0) { cout <<
"done." << endl << flush; }
252 if (myid_ == 0) { cout <<
"Updating ..." << endl; }
257 H1FESpace_->
Update(
false);
258 HCurlFESpace_->
Update(
false);
259 HDivFESpace_->
Update(
false);
266 if ( rho_ ) { rho_->
Update(); }
267 if ( sigma_ ) { sigma_->
Update(); }
268 if ( p_ ) { p_->
Update(); }
275 if ( h1Mass_ ) { h1Mass_->
Update(); }
276 if ( h1SurfMass_ ) { h1SurfMass_->
Update(); }
277 if ( hCurlHDiv_ ) { hCurlHDiv_->
Update(); }
278 if ( weakDiv_ ) { weakDiv_->
Update(); }
287 if (myid_ == 0) { cout <<
"Running solver ... " << endl; }
295 if ( dbcs_->
Size() > 0 )
306 for (
int i=0; i<dbcs_->
Size(); i++)
310 dbc_bdr_attr[(*dbcs_)[i]-1] = 1;
320 h1Mass_->
AddMult(*rho_, *rhod_);
327 weakDiv_->
AddMult(*p_, *rhod_);
336 for (
int i=0; i<nbcs_->
Size(); i++)
340 nbc_bdr_attr[(*nbcs_)[i]-1] = 1;
343 h1SurfMass_->
AddMult(*sigma_, *rhod_);
347 if ( dbcs_->
Size() > 0 )
358 ess_bdr_tdofs_[0] = 0;
388 grad_->
Mult(*phi_, *e_); *e_ *= -1.0;
391 if (myid_ == 0) { cout <<
"Computing D ..." << flush; }
394 hCurlHDivEps_->
Mult(*e_, ed);
397 hCurlHDiv_->
AddMult(*p_, ed, -1.0);
416 if (myid_ == 0) { cout <<
"done." << flush; }
418 if (myid_ == 0) { cout <<
"Solver done. " << endl; }
424 if (myid_ == 0) { cout <<
"Estimating Error ... " << flush; }
438 smooth_flux_fes, flux_fes, errors, norm_p);
440 if (myid_ == 0) { cout <<
"done." << endl; }
446 visit_dc_ = &visit_dc;
461 if (myid_ == 0) { cout <<
"Writing VisIt files ..." << flush; }
468 if (myid_ == 0) { cout <<
" done." << endl; }
475 if ( myid_ == 0 ) { cout <<
"Opening GLVis sockets." << endl; }
478 socks_[
"Phi"]->precision(8);
481 socks_[
"D"]->precision(8);
484 socks_[
"E"]->precision(8);
489 socks_[
"Rho"]->precision(8);
494 socks_[
"P"]->precision(8);
499 socks_[
"Sigma"]->precision(8);
506 if (myid_ == 0) { cout <<
"Sending data to GLVis ..." << flush; }
508 char vishost[] =
"localhost";
512 int Ww = 350, Wh = 350;
513 int offx = Ww+10, offy = Wh+45;
516 *phi_,
"Electric Potential (Phi)", Wx, Wy, Ww, Wh);
520 *d_,
"Electric Displacement (D)", Wx, Wy, Ww, Wh);
524 *e_,
"Electric Field (E)", Wx, Wy, Ww, Wh);
531 *rho_,
"Charge Density (Rho)", Wx, Wy, Ww, Wh);
537 *p_,
"Electric Polarization (P)", Wx, Wy, Ww, Wh);
543 *sigma_,
"Surface Charge Density (Sigma)", Wx, Wy, Ww, Wh);
546 if (myid_ == 0) { cout <<
" done." << endl; }
553 #endif // MFEM_USE_MPI
void WriteVisItFields(int it=0)
int Size() const
Logical size of the array.
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
Subclass constant coefficient.
HYPRE_Int GetProblemSize()
virtual void Update(bool want_transform=true)
HYPRE_Int GlobalTrueVSize()
virtual void Save()
Save the collection and a VisIt root file.
Abstract parallel finite element space.
void RegisterVisItFields(VisItDataCollection &visit_dc)
void ProjectCoefficient(Coefficient &coeff)
void SetPrintLevel(int print_lvl)
void GetErrorEstimates(Vector &errors)
The BoomerAMG solver in hypre.
Jacobi preconditioner in hypre.
Data collection with VisIt I/O routines.
void VisualizeField(socketstream &sock, const char *vishost, int visport, GridFunction &gf, const char *title, int x, int y, int w, int h, bool vec)
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void SetTime(double t)
Set physical time (for time-dependent simulations)
void SetMaxIter(int max_iter)
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
int SpaceDimension() const
Wrapper for hypre's parallel vector class.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
Base class Coefficient that may optionally depend on time.
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list)
void SetSize(int nsize)
Change logical size of the array, keep existing entries.
double L2ZZErrorEstimator(BilinearFormIntegrator &flux_integrator, const ParGridFunction &x, ParFiniteElementSpace &smooth_flux_fes, ParFiniteElementSpace &flux_fes, Vector &errors, int norm_p, double solver_tol, int solver_max_it)
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection and update the root file.
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
class for C-function coefficient
Class for parallel grid function.
Wrapper for hypre's ParCSR matrix class.
virtual void Assemble(int skip_zeros=1)
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve Ax=b with hypre's PCG.
Class for parallel meshes.
Integrator for (Q u, v) for VectorFiniteElements.
void ProjectBdrCoefficient(Coefficient &coeff, Array< int > &attr)
Arbitrary order "L2-conforming" discontinuous finite elements.