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