MFEM  v3.3
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
volta_solver.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_VOLTA_SOLVER
13 #define MFEM_VOLTA_SOLVER
14 
15 #include "../common/pfem_extras.hpp"
16 
17 #ifdef MFEM_USE_MPI
18 
19 #include <string>
20 #include <map>
21 
22 namespace mfem
23 {
24 
25 using miniapps::H1_ParFESpace;
26 using miniapps::ND_ParFESpace;
27 using miniapps::RT_ParFESpace;
28 using miniapps::ParDiscreteGradOperator;
29 
30 namespace electromagnetics
31 {
32 
34 {
35 public:
36  VoltaSolver(ParMesh & pmesh, int order,
37  Array<int> & dbcs, Vector & dbcv,
38  Array<int> & nbcs, Vector & nbcv,
39  Coefficient & epsCoef,
40  double (*phi_bc )(const Vector&),
41  double (*rho_src)(const Vector&),
42  void (*p_src )(const Vector&, Vector&));
43  ~VoltaSolver();
44 
45  HYPRE_Int GetProblemSize();
46 
47  void PrintSizes();
48 
49  void Assemble();
50 
51  void Update();
52 
53  void Solve();
54 
55  void GetErrorEstimates(Vector & errors);
56 
58 
59  void WriteVisItFields(int it = 0);
60 
61  void InitializeGLVis();
62 
63  void DisplayToGLVis();
64 
65  const ParGridFunction & GetVectorPotential() { return *phi_; }
66 
67 private:
68 
69  int myid_; // Local processor rank
70  int num_procs_; // Number of processors
71  int order_; // Basis function order
72 
73  ParMesh * pmesh_;
74 
75  Array<int> * dbcs_; // Dirichlet BC Surface Attribute IDs
76  Vector * dbcv_; // Corresponding Dirichlet Values
77  Array<int> * nbcs_; // Neumann BC Surface Attribute IDs
78  Vector * nbcv_; // Corresponding Neumann Values
79 
80  VisItDataCollection * visit_dc_; // To prepare fields for VisIt viewing
81 
82  H1_ParFESpace * H1FESpace_; // Continuous space for phi
83  ND_ParFESpace * HCurlFESpace_; // Tangentially continuous space for E
84  RT_ParFESpace * HDivFESpace_; // Normally continuous space for D
85 
86  ParBilinearForm * divEpsGrad_; // Laplacian operator
87  ParBilinearForm * h1Mass_; // For Volumetric Charge Density Source
88  ParBilinearForm * h1SurfMass_; // For Surface Charge Density Source
89  ParBilinearForm * hDivMass_; // For Computing D from E
90 
91  ParMixedBilinearForm * hCurlHDivEps_; // For computing D from E
92  ParMixedBilinearForm * hCurlHDiv_; // For computing D from E and P
93  ParMixedBilinearForm * weakDiv_; // For computing the source term from P
94 
95  ParDiscreteGradOperator * grad_; // For Computing E from phi
96 
97  ParGridFunction * phi_; // Electric Scalar Potential
98  ParGridFunction * rho_; // Volumetric Charge Density
99  ParGridFunction * rhod_; // Dual of Volumetric Charge Density
100  ParGridFunction * sigma_; // Surface Charge Density
101  ParGridFunction * e_; // Electric Field
102  ParGridFunction * d_; // Electric Flux Density (aka Dielectric Flux)
103  ParGridFunction * p_; // Polarization Field
104 
105  Coefficient * epsCoef_; // Dielectric Permittivity Coefficient
106  Coefficient * phiBCCoef_; // Scalar Potential Boundary Condition
107  Coefficient * rhoCoef_; // Charge Density Coefficient
108  VectorCoefficient * pCoef_; // Polarization Vector Field Coefficient
109 
110  // Source functions
111  double (*phi_bc_ )(const Vector&); // Scalar Potential BC
112  double (*rho_src_)(const Vector&); // Volumetric Charge Density
113  void (*p_src_ )(const Vector&, Vector&); // Polarization Field
114 
115  std::map<std::string,socketstream*> socks_; // Visualization sockets
116 
117  Array<int> ess_bdr_, ess_bdr_tdofs_; // Essential Boundary Condition DoFs
118 };
119 
120 } // namespace electromagnetics
121 
122 } // namespace mfem
123 
124 #endif // MFEM_USE_MPI
125 
126 #endif // MFEM_VOLTA_SOLVER
void RegisterVisItFields(VisItDataCollection &visit_dc)
void GetErrorEstimates(Vector &errors)
Data collection with VisIt I/O routines.
Base class Coefficient that may optionally depend on time.
Definition: coefficient.hpp:31
Class for parallel bilinear form using different test and trial FE spaces.
const ParGridFunction & GetVectorPotential()
Class for parallel bilinear form.
Vector data type.
Definition: vector.hpp:36
Class for parallel grid function.
Definition: pgridfunc.hpp:31
Class for parallel meshes.
Definition: pmesh.hpp:28
VoltaSolver(ParMesh &pmesh, int order, Array< int > &dbcs, Vector &dbcv, Array< int > &nbcs, Vector &nbcv, Coefficient &epsCoef, double(*phi_bc)(const Vector &), double(*rho_src)(const Vector &), void(*p_src)(const Vector &, Vector &))