12 #include "../../config/config.hpp"
21 using namespace miniapps;
23 namespace electromagnetics
26 VoltaSolver::VoltaSolver(
ParMesh & pmesh,
int order,
29 double (*eps )(
const Vector&),
30 double (*phi_bc )(
const Vector&),
31 double (*rho_src)(
const Vector&),
69 MPI_Comm_size(pmesh_->
GetComm(), &num_procs_);
70 MPI_Comm_rank(pmesh_->
GetComm(), &myid_);
82 for (
int i=0; i<dbcs_->
Size(); i++)
84 ess_bdr_[(*dbcs_)[i]-1] = 1;
90 if ( phi_bc_ != NULL )
106 if ( rho_src_ != NULL )
112 if ( p_src_ != NULL )
171 if ( nbcs_->
Size() > 0 )
203 delete hCurlHDivEps_;
207 delete HCurlFESpace_;
209 map<string,socketstream*>::iterator mit;
210 for (mit=socks_.begin(); mit!=socks_.end(); mit++)
230 cout <<
"Number of H1 unknowns: " << size_h1 << endl;
231 cout <<
"Number of H(Curl) unknowns: " << size_nd << endl;
232 cout <<
"Number of H(Div) unknowns: " << size_rt << endl;
239 if (myid_ == 0) { cout <<
" Assembly ... " << flush; }
250 if ( rho_ ) { rho_->
Update(); }
251 if ( sigma_ ) { sigma_->
Update(); }
252 if ( p_ ) { p_->
Update(); }
298 if (myid_ == 0) { cout <<
"done." << flush; }
304 if (myid_ == 0) { cout <<
"Running solver ... " << endl << flush; }
309 if ( dbcs_->
Size() > 0 )
320 for (
int i=0; i<dbcs_->
Size(); i++)
324 dbc_bdr_attr[(*dbcs_)[i]-1] = 1;
342 MassH1->
Mult(*Rho,*RHS);
358 MassHCurl->
Mult(*P,*PD);
372 for (
int i=0; i<nbcs_->
Size(); i++)
376 nbc_bdr_attr[(*nbcs_)[i]-1] = 1;
383 MassS->
Mult(*Sigma,*RHS,1.0,1.0);
394 if ( dbcs_->
Size() > 0 )
421 pcg->
Mult(*RHS, *Phi);
437 Grad_->
Mult(*Phi,*E,-1.0);
443 if (myid_ == 0) { cout <<
"Computing D ... " << flush; }
449 HCurlHDivEps->
Mult(*E,*ED);
454 HCurlHDiv->
Mult(*P,*ED,-1.0,1.0);
470 if (myid_ == 0) { cout <<
"done." << flush; }
481 if (myid_ == 0) { cout <<
" Solver done. " << flush; }
487 if (myid_ == 0) { cout <<
"Estimating Error ... " << flush; }
501 smooth_flux_fes, flux_fes, errors, norm_p);
503 if (myid_ == 0) { cout <<
"done." << flush; }
509 visit_dc_ = &visit_dc;
524 if (myid_ == 0) { cout <<
"Writing VisIt files ..." << flush; }
531 if (myid_ == 0) { cout <<
" " << flush; }
538 if ( myid_ == 0 ) { cout <<
"Opening GLVis sockets." << endl << flush; }
541 socks_[
"Phi"]->precision(8);
544 socks_[
"D"]->precision(8);
547 socks_[
"E"]->precision(8);
552 socks_[
"Rho"]->precision(8);
557 socks_[
"P"]->precision(8);
562 socks_[
"Sigma"]->precision(8);
564 if ( myid_ == 0 ) { cout <<
"GLVis sockets open." << endl << flush; }
570 if (myid_ == 0) { cout <<
"Sending data to GLVis ..." << flush; }
572 char vishost[] =
"localhost";
576 int Ww = 350, Wh = 350;
577 int offx = Ww+10, offy = Wh+45;
580 *phi_,
"Electric Potential (Phi)", Wx, Wy, Ww, Wh);
584 *d_,
"Electric Displacement (D)", Wx, Wy, Ww, Wh);
588 *e_,
"Electric Field (E)", Wx, Wy, Ww, Wh);
595 *rho_,
"Charge Density (Rho)", Wx, Wy, Ww, Wh);
601 *p_,
"Electric Polarization (P)", Wx, Wy, Ww, Wh);
607 *sigma_,
"Surface Charge Density (Sigma)", Wx, Wy, Ww, Wh);
610 if (myid_ == 0) { cout <<
" " << flush; }
617 #endif // MFEM_USE_MPI
void WriteVisItFields(int it=0)
int Size() const
Logical size of the array.
void EliminateRowsCols(const Array< int > &rows_cols, const HypreParVector &X, HypreParVector &B)
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
virtual void RegisterField(const char *field_name, GridFunction *gf)
Add a grid function to the collection and update the root file.
Subclass constant coefficient.
HYPRE_Int GetProblemSize()
HYPRE_Int GlobalTrueVSize()
HYPRE_Int MultTranspose(HypreParVector &x, HypreParVector &y, double alpha=1.0, double beta=0.0)
Computes y = alpha * A^t * x + beta * y.
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)
HYPRE_Int Mult(HypreParVector &x, HypreParVector &y, double alpha=1.0, double beta=0.0)
Computes y = alpha * A * x + beta * y.
void SetPrintLevel(int print_lvl)
void GetErrorEstimates(Vector &errors)
The BoomerAMG solver in hypre.
HYPRE_Int Mult(HypreParVector &x, HypreParVector &y, double alpha=1.0, double beta=0.0)
Computes y = alpha * A * x + beta * y.
void VisualizeField(socketstream &sock, const char *vishost, int visport, ParGridFunction &gf, const char *title, int x, int y, int w, int h)
Jacobi preconditioner in hypre.
Data collection with VisIt I/O routines.
void L2ZZErrorEstimator(BilinearFormIntegrator &flux_integrator, ParGridFunction &x, ParFiniteElementSpace &smooth_flux_fes, ParFiniteElementSpace &flux_fes, Vector &errors, int norm_p, double solver_tol, int solver_max_it)
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
void SetSize(int nsize)
Change logical size of the array, keep existing entries.
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
Abstract class for hypre's solvers and preconditioners.
class for C-function coefficient
Class for parallel grid function.
Wrapper for hypre's ParCSR matrix class.
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)
void ParallelProject(Vector &tv) const
Returns the vector restricted to the true dofs.
Arbitrary order "L2-conforming" discontinuous finite elements.