MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
volta_solver.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, 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
17#include "electromagnetics.hpp"
18
19#ifdef MFEM_USE_MPI
20
21#include <string>
22#include <map>
23
24namespace mfem
25{
26
27using common::H1_ParFESpace;
28using common::ND_ParFESpace;
29using common::RT_ParFESpace;
30using common::L2_ParFESpace;
31using common::ParDiscreteGradOperator;
32using common::ParDiscreteDivOperator;
33
34namespace electromagnetics
35{
36
38{
39public:
40 VoltaSolver(ParMesh & pmesh, int order,
41 Array<int> & dbcs, Vector & dbcv,
42 Array<int> & nbcs, Vector & nbcv,
43 Coefficient & epsCoef,
44 real_t (*phi_bc )(const Vector&),
45 real_t (*rho_src)(const Vector&),
46 void (*p_src )(const Vector&, Vector&),
47 Vector & point_charges);
49
51
52 void PrintSizes();
53
54 void Assemble();
55
56 void Update();
57
58 void Solve();
59
60 void GetErrorEstimates(Vector & errors);
61
63
64 void WriteVisItFields(int it = 0);
65
66 void InitializeGLVis();
67
68 void DisplayToGLVis();
69
70 const ParGridFunction & GetVectorPotential() { return *phi_; }
71
72private:
73
74 int myid_; // Local processor rank
75 int num_procs_; // Number of processors
76 int order_; // Basis function order
77
78 ParMesh * pmesh_;
79
80 Array<int> * dbcs_; // Dirichlet BC Surface Attribute IDs
81 Vector * dbcv_; // Corresponding Dirichlet Values
82 Array<int> * nbcs_; // Neumann BC Surface Attribute IDs
83 Vector * nbcv_; // Corresponding Neumann Values
84
85 VisItDataCollection * visit_dc_; // To prepare fields for VisIt viewing
86
87 H1_ParFESpace * H1FESpace_; // Continuous space for phi
88 ND_ParFESpace * HCurlFESpace_; // Tangentially continuous space for E
89 RT_ParFESpace * HDivFESpace_; // Normally continuous space for D
90 L2_ParFESpace * L2FESpace_; // Discontinuous space for rho
91
92 ParBilinearForm * divEpsGrad_; // Laplacian operator
93 ParBilinearForm * h1Mass_; // For Volumetric Charge Density Source
94 ParBilinearForm * h1SurfMass_; // For Surface Charge Density Source
95 ParBilinearForm * hDivMass_; // For Computing D from E
96
97 ParMixedBilinearForm * hCurlHDivEps_; // For computing D from E
98 ParMixedBilinearForm * hCurlHDiv_; // For computing D from E and P
99 ParMixedBilinearForm * weakDiv_; // For computing the source term from P
100
101 ParLinearForm * rhod_; // Dual of Volumetric Charge Density Source
102
103 ParLinearForm * l2_vol_int_; // Integral of L2 field
104 ParLinearForm * rt_surf_int_; // Integral of H(Div) field over boundary
105
106 ParDiscreteGradOperator * grad_; // For Computing E from phi
107 ParDiscreteDivOperator * div_; // For Computing rho from D
108
109 ParGridFunction * phi_; // Electric Scalar Potential
110 ParGridFunction * rho_src_; // Volumetric Charge Density Source
111 ParGridFunction * rho_; // Volumetric Charge Density (Div(D))
112 ParGridFunction * sigma_src_; // Surface Charge Density Source
113 ParGridFunction * e_; // Electric Field
114 ParGridFunction * d_; // Electric Flux Density (aka Dielectric Flux)
115 ParGridFunction * p_src_; // Polarization Field Source
116
117 ConstantCoefficient oneCoef_; // Coefficient equal to 1
118 Coefficient * epsCoef_; // Dielectric Permittivity Coefficient
119 Coefficient * phiBCCoef_; // Scalar Potential Boundary Condition
120 Coefficient * rhoCoef_; // Charge Density Coefficient
121 VectorCoefficient * pCoef_; // Polarization Vector Field Coefficient
122
123 // Source functions
124 real_t (*phi_bc_func_ )(const Vector&); // Scalar Potential BC
125 real_t (*rho_src_func_)(const Vector&); // Volumetric Charge Density
126 void (*p_src_func_ )(const Vector&, Vector&); // Polarization Field
127
128 const Vector & point_charge_params_;
129
130 std::vector<DeltaCoefficient*> point_charges_;
131
132 std::map<std::string,socketstream*> socks_; // Visualization sockets
133
134 Array<int> ess_bdr_, ess_bdr_tdofs_; // Essential Boundary Condition DoFs
135};
136
137} // namespace electromagnetics
138
139} // namespace mfem
140
141#endif // MFEM_USE_MPI
142
143#endif // MFEM_VOLTA_SOLVER
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
A coefficient that is constant across space and time.
Class for parallel bilinear form.
Class for parallel grid function.
Definition pgridfunc.hpp:33
Class for parallel linear form.
Class for parallel meshes.
Definition pmesh.hpp:34
Class for parallel bilinear form using different test and trial FE spaces.
Base class for vector Coefficients that optionally depend on time and space.
Vector data type.
Definition vector.hpp:80
Data collection with VisIt I/O routines.
void RegisterVisItFields(VisItDataCollection &visit_dc)
const ParGridFunction & GetVectorPotential()
VoltaSolver(ParMesh &pmesh, int order, Array< int > &dbcs, Vector &dbcv, Array< int > &nbcs, Vector &nbcv, Coefficient &epsCoef, real_t(*phi_bc)(const Vector &), real_t(*rho_src)(const Vector &), void(*p_src)(const Vector &, Vector &), Vector &point_charges)
HYPRE_Int HYPRE_BigInt
float real_t
Definition config.hpp:43