MFEM  v4.1.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-2020, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
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 common::H1_ParFESpace;
27 using common::ND_ParFESpace;
28 using common::RT_ParFESpace;
29 using common::L2_ParFESpace;
30 using common::ParDiscreteGradOperator;
31 using common::ParDiscreteDivOperator;
32 
33 namespace electromagnetics
34 {
35 
37 {
38 public:
39  VoltaSolver(ParMesh & pmesh, int order,
40  Array<int> & dbcs, Vector & dbcv,
41  Array<int> & nbcs, Vector & nbcv,
42  Coefficient & epsCoef,
43  double (*phi_bc )(const Vector&),
44  double (*rho_src)(const Vector&),
45  void (*p_src )(const Vector&, Vector&),
46  Vector & point_charges);
47  ~VoltaSolver();
48 
49  HYPRE_Int GetProblemSize();
50 
51  void PrintSizes();
52 
53  void Assemble();
54 
55  void Update();
56 
57  void Solve();
58 
59  void GetErrorEstimates(Vector & errors);
60 
62 
63  void WriteVisItFields(int it = 0);
64 
65  void InitializeGLVis();
66 
67  void DisplayToGLVis();
68 
69  const ParGridFunction & GetVectorPotential() { return *phi_; }
70 
71 private:
72 
73  int myid_; // Local processor rank
74  int num_procs_; // Number of processors
75  int order_; // Basis function order
76 
77  ParMesh * pmesh_;
78 
79  Array<int> * dbcs_; // Dirichlet BC Surface Attribute IDs
80  Vector * dbcv_; // Corresponding Dirichlet Values
81  Array<int> * nbcs_; // Neumann BC Surface Attribute IDs
82  Vector * nbcv_; // Corresponding Neumann Values
83 
84  VisItDataCollection * visit_dc_; // To prepare fields for VisIt viewing
85 
86  H1_ParFESpace * H1FESpace_; // Continuous space for phi
87  ND_ParFESpace * HCurlFESpace_; // Tangentially continuous space for E
88  RT_ParFESpace * HDivFESpace_; // Normally continuous space for D
89  L2_ParFESpace * L2FESpace_; // Discontinuous space for rho
90 
91  ParBilinearForm * divEpsGrad_; // Laplacian operator
92  ParBilinearForm * h1Mass_; // For Volumetric Charge Density Source
93  ParBilinearForm * h1SurfMass_; // For Surface Charge Density Source
94  ParBilinearForm * hDivMass_; // For Computing D from E
95 
96  ParMixedBilinearForm * hCurlHDivEps_; // For computing D from E
97  ParMixedBilinearForm * hCurlHDiv_; // For computing D from E and P
98  ParMixedBilinearForm * weakDiv_; // For computing the source term from P
99 
100  ParLinearForm * rhod_; // Dual of Volumetric Charge Density Source
101 
102  ParLinearForm * l2_vol_int_; // Integral of L2 field
103  ParLinearForm * rt_surf_int_; // Integral of H(Div) field over boundary
104 
105  ParDiscreteGradOperator * grad_; // For Computing E from phi
106  ParDiscreteDivOperator * div_; // For Computing rho from D
107 
108  ParGridFunction * phi_; // Electric Scalar Potential
109  ParGridFunction * rho_src_; // Volumetric Charge Density Source
110  ParGridFunction * rho_; // Volumetric Charge Density (Div(D))
111  ParGridFunction * sigma_src_; // Surface Charge Density Source
112  ParGridFunction * e_; // Electric Field
113  ParGridFunction * d_; // Electric Flux Density (aka Dielectric Flux)
114  ParGridFunction * p_src_; // Polarization Field Source
115 
116  ConstantCoefficient oneCoef_; // Coefficient equal to 1
117  Coefficient * epsCoef_; // Dielectric Permittivity Coefficient
118  Coefficient * phiBCCoef_; // Scalar Potential Boundary Condition
119  Coefficient * rhoCoef_; // Charge Density Coefficient
120  VectorCoefficient * pCoef_; // Polarization Vector Field Coefficient
121 
122  // Source functions
123  double (*phi_bc_func_ )(const Vector&); // Scalar Potential BC
124  double (*rho_src_func_)(const Vector&); // Volumetric Charge Density
125  void (*p_src_func_ )(const Vector&, Vector&); // Polarization Field
126 
127  const Vector & point_charge_params_;
128 
129  std::vector<DeltaCoefficient*> point_charges_;
130 
131  std::map<std::string,socketstream*> socks_; // Visualization sockets
132 
133  Array<int> ess_bdr_, ess_bdr_tdofs_; // Essential Boundary Condition DoFs
134 };
135 
136 } // namespace electromagnetics
137 
138 } // namespace mfem
139 
140 #endif // MFEM_USE_MPI
141 
142 #endif // MFEM_VOLTA_SOLVER
Subclass constant coefficient.
Definition: coefficient.hpp:67
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