Logbook  (07-04-2025)
Static problems
StaticScalarSolver::ProjectHgradToHdiv< dim, stage > Class Template Reference

Projects from \(H(\text{grad})\) to \(H(\text{div})\). More...

#include <project_Hgrad_to_Hdiv.hpp>

Public Member Functions

 ProjectHgradToHdiv (unsigned int p, unsigned int mapping_degree, const Triangulation< dim > &triangulation_Hgrad, const DoFHandler< dim > &dof_handler_Hgrad, const Vector< double > &solution_Hgrad, std::string fname="Hdiv", const Function< dim > *exact_solution=nullptr, bool axisymmetric=false, bool vector_potential=false, bool print_time_tables=false, bool project_exact_solution=false, bool log_cg_convergence=false, bool write_higher_order_cells=false)
 The only constructor. More...
 
double get_L2_norm ()
 Returns \(L^2\) error norm.
 
double get_Linfty_norm ()
 Returns \(L^{\infty}\) error norm.
 
unsigned int get_n_cells () const
 Returns the number of active cells in the mesh.
 
unsigned int get_n_dofs () const
 Returns the total amount of the degrees of freedom.
 
void clear ()
 Releases computer memory associated with system matrix and right-hand side.
 
const Triangulation< dim > & get_tria () const
 Returns a reference to triangulation.
 
const DoFHandler< dim > & get_dof_handler () const
 Returns a reference to dof handler associated with the Raviart-Thomas finite elements.
 
const Vector< double > & get_solution () const
 Returns a reference to solution, i.e., the result of the projection.
 
void save_matrix_and_rhs_to_csv (std::string fname) const
 Saves the system matrix and the right-hand side into a csv file. More...
 

Detailed Description

template<int dim, int stage = 1>
class StaticScalarSolver::ProjectHgradToHdiv< dim, stage >

Projects from \(H(\text{grad})\) to \(H(\text{div})\).

This class template is not supposed to be used directly. Instead, one of the wrap-around class templates, i.e., StaticScalarSolver::ProjectPHItoD, StaticScalarSolver::ProjectPSItoB, etc., must be used. The names of the wrap-around class templates are assumed to be more familiar to readers in electromagnetics.

Implements the following recipes:

  • (1) Recipes for projections from H(grad) to H(div) nr. 6 and 7
  • (2) Recipes for projections from H(grad) to H(div) nr. 8 and 9 (planar)
  • (3) Recipes for projections from H(grad) to H(div) nr. 8 and 9 (axisym.)
  • (4) Recipes for projections from H(grad) to H(div) nr. 10 and 11 (planar)
  • (5) Recipes for projections from H(grad) to H(div) nr. 10 (axisym.)

This class template is supposed to be used in pair with StaticScalarSolver::Solver. In some problems the numerically calculated scalar potential needs to be converted into a vector field. For example, an electric scalar potential, \(\Phi\), calculated with a help of StaticScalarSolver::Solver may need to be converted into displacement as

\[ \vec{D} = - \epsilon \vec{\nabla} \Phi. \]

The electric scalar potential belongs to the H(grad) function space. The displacement belongs to the H(div) function space. Therefore, one needs to compute the equation above such that the input, \(\Phi\), is in H(grad) and the output, \(\vec{D}\), is in H(div). Such computation can be envisioned as a some kind of projection from one function space into another. This class template does such projections. The Bossavit's diagrams below illustrate the projections that can be made with a help of this class template.

The table below lists the recommended settings for switching between different types of projections. The six letters in the first column of the table correspond to the six diagrams above. The dim parameter is the input parameter of the class template. The other two parameters, axisymmetric and vector_potential, are passed as input parameters to the constructor of the class.

Insert dim axisymmetric vector_potential
A), C) 3 false false
B), D) 2 true/false false
E) 2 true/false true
F) 2 false true

The dim template parameter is, as per usual, the amount of spatial dimensions. The purpose of the stage template parameter is discussed in here.

The user is supposed to derive an object from this class template. All usual computations, i.e., setup, assembling the linear system, etc., happen automatically.

Definition at line 114 of file project_Hgrad_to_Hdiv.hpp.

Constructor & Destructor Documentation

◆ ProjectHgradToHdiv()

template<int dim, int stage>
StaticScalarSolver::ProjectHgradToHdiv< dim, stage >::ProjectHgradToHdiv ( unsigned int  p,
unsigned int  mapping_degree,
const Triangulation< dim > &  triangulation_Hgrad,
const DoFHandler< dim > &  dof_handler_Hgrad,
const Vector< double > &  solution_Hgrad,
std::string  fname = "Hdiv",
const Function< dim > *  exact_solution = nullptr,
bool  axisymmetric = false,
bool  vector_potential = false,
bool  print_time_tables = false,
bool  project_exact_solution = false,
bool  log_cg_convergence = false,
bool  write_higher_order_cells = false 
)

The only constructor.

Parameters
[in]p- The degree of the FE_RaviartThomas finite elements.
[in]mapping_degree- The degree of the interpolating polynomials used for mapping. Setting it to 1 will do in the most of the cases. Note, that it makes sense to attach a meaningful manifold to the triangulation if this parameter is greater than 1.
[in]triangulation_Hgrad- Reference to the triangulation inside the object of the class StaticScalarSolver::Solver that has yielded the scalar potential in the H(grad) function space.
[in]dof_handler_Hgrad- Reference to the dof handler inside the class StaticScalarSolver::Solver that has yielded the scalar potential in the H(grad) function space.
[in]solution_Hgrad- Vector filled with the degrees of freedom that together with the shape functions of the FE_Q finite elements model the scalar potential in the H(grad) function space.
[in]fname- The name of the output files without extension.
[in]exact_solution- Points to an object that describes the exact solution to the problem. It is needed for calculating error norms.
[in]axisymmetric- If true, assumes that the problem is axisymmetric. If axisymmetric=true, dim must equal 2.
[in]vector_potential- If true, assumes that the problem is two-dimensional and formulated in terms of the magnitude of vector potential, \(A\), or in terms of the scaled magnitude of vector potential, \(A'\), or current vector potential, \(T\). If vector_potential=true, dim must equal 2.
[in]print_time_tables- If true, prints time tables on the screen.
[in]project_exact_solution- If true, projects the exact solution onto the space spanned by the Raviart-Thomas finite elements and saves the result into the vtk file next to the solution. This may be useful for debugging purposes.
[in]log_cg_convergence- If true, logs convergence of the conjugate gradient solver into a file. The name of the file is generated by appending "_cg_convergence.csv" to fname.
[in]write_higher_order_cells- If false, the data is saved in the file fname.vtk. Higher-order cells are not saved. If true, the data is saved into fname.vtu file preserving the higher-order cells. In this case the file can be viewed with a help of Paraview version 5.5.0 or higher.

Definition at line 361 of file project_Hgrad_to_Hdiv.hpp.

Member Function Documentation

◆ save_matrix_and_rhs_to_csv()

template<int dim, int stage>
void StaticScalarSolver::ProjectHgradToHdiv< dim, stage >::save_matrix_and_rhs_to_csv ( std::string  fname) const

Saves the system matrix and the right-hand side into a csv file.

All the zeros included into the csv files. This is a very dumb and inefficient way of saving sparse matrices. On the positive side - it is very easy and straightforward to read the csv files. This function may be useful for debugging. One can assemble the system on a coarse mesh (so there are a few mesh cells and the system matrix is small) and export the system matrix together with the right-hand side into another program such as Matlab or GNU Octave for an analysis.

Parameters
[in]fname- A stem of the names of the output files. The matrix will be saved into fname_matrix.csv file. The right-hand side will be save into fname_rhs.csv file.

Definition at line 447 of file project_Hgrad_to_Hdiv.hpp.


The documentation for this class was generated from the following file: