MFEM  v4.0
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 #include "electromagnetics.hpp"
17 
18 #ifdef MFEM_USE_MPI
19 
20 #include <string>
21 #include <map>
22 
23 namespace mfem
24 {
25 
26 using miniapps::H1_ParFESpace;
27 using miniapps::ND_ParFESpace;
28 using miniapps::RT_ParFESpace;
29 using miniapps::ParDiscreteGradOperator;
30 
31 namespace electromagnetics
32 {
33 
35 {
36 public:
37  VoltaSolver(ParMesh & pmesh, int order,
38  Array<int> & dbcs, Vector & dbcv,
39  Array<int> & nbcs, Vector & nbcv,
40  Coefficient & epsCoef,
41  double (*phi_bc )(const Vector&),
42  double (*rho_src)(const Vector&),
43  void (*p_src )(const Vector&, Vector&),
44  Vector & point_charges);
45  ~VoltaSolver();
46 
47  HYPRE_Int GetProblemSize();
48 
49  void PrintSizes();
50 
51  void Assemble();
52 
53  void Update();
54 
55  void Solve();
56 
57  void GetErrorEstimates(Vector & errors);
58 
60 
61  void WriteVisItFields(int it = 0);
62 
63  void InitializeGLVis();
64 
65  void DisplayToGLVis();
66 
67  const ParGridFunction & GetVectorPotential() { return *phi_; }
68 
69 private:
70 
71  int myid_; // Local processor rank
72  int num_procs_; // Number of processors
73  int order_; // Basis function order
74 
75  ParMesh * pmesh_;
76 
77  Array<int> * dbcs_; // Dirichlet BC Surface Attribute IDs
78  Vector * dbcv_; // Corresponding Dirichlet Values
79  Array<int> * nbcs_; // Neumann BC Surface Attribute IDs
80  Vector * nbcv_; // Corresponding Neumann Values
81 
82  VisItDataCollection * visit_dc_; // To prepare fields for VisIt viewing
83 
84  H1_ParFESpace * H1FESpace_; // Continuous space for phi
85  ND_ParFESpace * HCurlFESpace_; // Tangentially continuous space for E
86  RT_ParFESpace * HDivFESpace_; // Normally continuous space for D
87 
88  ParBilinearForm * divEpsGrad_; // Laplacian operator
89  ParBilinearForm * h1Mass_; // For Volumetric Charge Density Source
90  ParBilinearForm * h1SurfMass_; // For Surface Charge Density Source
91  ParBilinearForm * hDivMass_; // For Computing D from E
92 
93  ParMixedBilinearForm * hCurlHDivEps_; // For computing D from E
94  ParMixedBilinearForm * hCurlHDiv_; // For computing D from E and P
95  ParMixedBilinearForm * weakDiv_; // For computing the source term from P
96 
97  ParLinearForm * rhod_; // Dual of Volumetric Charge Density
98 
99  ParDiscreteGradOperator * grad_; // For Computing E from phi
100 
101  ParGridFunction * phi_; // Electric Scalar Potential
102  ParGridFunction * rho_; // Volumetric Charge Density
103  ParGridFunction * sigma_; // Surface Charge Density
104  ParGridFunction * e_; // Electric Field
105  ParGridFunction * d_; // Electric Flux Density (aka Dielectric Flux)
106  ParGridFunction * p_; // Polarization Field
107 
108  Coefficient * epsCoef_; // Dielectric Permittivity Coefficient
109  Coefficient * phiBCCoef_; // Scalar Potential Boundary Condition
110  Coefficient * rhoCoef_; // Charge Density Coefficient
111  VectorCoefficient * pCoef_; // Polarization Vector Field Coefficient
112 
113  // Source functions
114  double (*phi_bc_ )(const Vector&); // Scalar Potential BC
115  double (*rho_src_)(const Vector&); // Volumetric Charge Density
116  void (*p_src_ )(const Vector&, Vector&); // Polarization Field
117 
118  const Vector & point_charge_params_;
119 
120  std::vector<DeltaCoefficient*> point_charges_;
121 
122  std::map<std::string,socketstream*> socks_; // Visualization sockets
123 
124  Array<int> ess_bdr_, ess_bdr_tdofs_; // Essential Boundary Condition DoFs
125 };
126 
127 } // namespace electromagnetics
128 
129 } // namespace mfem
130 
131 #endif // MFEM_USE_MPI
132 
133 #endif // MFEM_VOLTA_SOLVER
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 &), Vector &point_charges)
void RegisterVisItFields(VisItDataCollection &visit_dc)
void GetErrorEstimates(Vector &errors)
Class for parallel linear form.
Definition: plinearform.hpp:26
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:48
Class for parallel grid function.
Definition: pgridfunc.hpp:32
Class for parallel meshes.
Definition: pmesh.hpp:32