SERiF 0.0.1a
3+1D Stellar Structure and Evolution
Loading...
Searching...
No Matches
serif::polytrope::PolySolver Class Referencefinal

Solves the Lane-Emden equation for a polytropic star using a mixed finite element method. More...

#include <polySolver.h>

Public Member Functions

 PolySolver (const double n, const double order)
 
 ~PolySolver ()
 Destructor for PolySolver.
 
void solve () const
 Solves the polytropic system.
 
double getN () const
 Gets the polytropic index $n$.
 
double getOrder () const
 Gets the finite element order used for the $\theta$ variable.
 
mfem::Mesh & getMesh () const
 Gets a reference to the computational mesh.
 
mfem::GridFunction & getTheta () const
 Gets a reference to the solution grid function for $\theta$.
 
mfem::GridFunction & getPhi () const
 Gets a reference to the solution grid function for $\phi$.
 

Private Member Functions

 PolySolver (mfem::Mesh &mesh, double n, double order)
 Private constructor that takes an existing mesh.
 
void assembleBlockSystem ()
 Assembles the block system operator m_polytropOperator.
 
mfem::Array< int > computeBlockOffsets () const
 Compute the block offsets for the operator. These are the offsets that define which dofs belong to which variable.
 
std::unique_ptr< formBundlebuildIndividualForms (const mfem::Array< int > &blockOffsets)
 Build the individual forms for the block operator (M, Q, D, S, and f).
 
serif::types::MFEMArrayPairSet getEssentialTrueDof () const
 Computes the essential true degrees of freedom (DOFs) and their values for boundary conditions.
 
std::pair< mfem::Array< int >, mfem::Array< int > > findCenterElement () const
 Finds the degrees of freedom (DOFs) associated with the geometric center (origin) of the mesh.
 
void setInitialGuess () const
 Sets the initial guess for the solution variables $\theta$ and $\boldsymbol{\phi}$.
 
void saveAndViewSolution (const mfem::BlockVector &state_vector) const
 Saves the 1D radial solution and optionally displays the 2D/3D solution using GLVis.
 
solverBundle setupNewtonSolver () const
 Sets up the Newton solver and its associated linear solver (GMRES).
 
void setOperatorEssentialTrueDofs () const
 Sets the essential true DOFs on the PolytropeOperator.
 
void LoadSolverUserParams (double &newtonRelTol, double &newtonAbsTol, int &newtonMaxIter, int &newtonPrintLevel, double &gmresRelTol, double &gmresAbsTol, int &gmresMaxIter, int &gmresPrintLevel) const
 Loads Newton and GMRES solver parameters from the configuration.
 

Static Private Member Functions

static mfem::Mesh & prepareMesh (double n)
 Prepares the mesh for the simulation.
 
static void assembleAndFinalizeForm (auto &f)
 Assemble and finalize a given MFEM form.
 
static void GetDofCoordinates (const mfem::FiniteElementSpace &fes, const std::string &filename)
 Utility function to get and save the coordinates of degrees of freedom for a finite element space.
 

Private Attributes

serif::config::Config & m_config
 Reference to the global configuration manager instance.
 
serif::probe::LogManagerm_logManager
 Reference to the global log manager instance.
 
quill::Logger * m_logger
 Pointer to the specific logger instance for this class.
 
double m_polytropicIndex
 The polytropic index $n$.
 
double m_feOrder
 The polynomial order for H1 elements ( $\theta$). RT elements for $\boldsymbol{\phi}$ are of order m_feOrder - 1.
 
mfem::Mesh & m_mesh
 Reference to the computational mesh (owned by ResourceManager).
 
std::unique_ptr< mfem::H1_FECollection > m_fecH1
 Finite Element Collection for $\theta$ (H1 elements).
 
std::unique_ptr< mfem::RT_FECollection > m_fecRT
 Finite Element Collection for $\boldsymbol{\phi}$ (Raviart-Thomas elements).
 
std::unique_ptr< mfem::FiniteElementSpace > m_feTheta
 Finite Element Space for $\theta$.
 
std::unique_ptr< mfem::FiniteElementSpace > m_fePhi
 Finite Element Space for $\boldsymbol{\phi}$.
 
std::unique_ptr< mfem::GridFunction > m_theta
 Grid function for the scalar potential $\theta$.
 
std::unique_ptr< mfem::GridFunction > m_phi
 Grid function for the vector flux $\boldsymbol{\phi}$.
 
std::unique_ptr< PolytropeOperatorm_polytropOperator
 The main nonlinear operator for the mixed system.
 
std::unique_ptr< mfem::OperatorJacobiSmoother > m_prec
 Preconditioner (currently seems unused in polySolver.cpp).
 

Detailed Description

Solves the Lane-Emden equation for a polytropic star using a mixed finite element method.

This class sets up and solves the system of equations describing a polytropic stellar model. The Lane-Emden equation, in its second-order form, is:

\[\frac{1}{\xi^2} \frac{d}{d\xi} \left( \xi^2 \frac{d\theta}{d\xi} \right) = -\theta^n
\]

where $\xi$ is a dimensionless radius, $\theta$ is a dimensionless temperature/potential related to density ( $\rho = \rho_c \theta^n$), and $n$ is the polytropic index.

This solver uses a mixed formulation by introducing $\boldsymbol{\phi} = -\nabla \theta$:

\[\begin{aligned}
  \boldsymbol{\phi} + \nabla \theta &= \mathbf{0} \\
  \nabla \cdot \boldsymbol{\phi} - \theta^n &= 0
\end{aligned}
\]

These equations are discretized using H1 finite elements for $\theta$ and RT (Raviart-Thomas) finite elements for $\boldsymbol{\phi}$. The resulting nonlinear system is solved using a Newton method, with the PolytropeOperator class defining the system residual and Jacobian.

Boundary conditions typically include $\theta(\xi_c) = 1$ at the center ( $\xi_c \approx 0$), $\theta(\xi_1) = 0$ at the surface ( $\xi_1$ is the first root of $\theta$), and $\boldsymbol{\phi} \cdot \mathbf{n} = -\frac{d\theta}{d\xi}$ at the surface, which is related to the surface gravity. At the center, $\boldsymbol{\phi}(\xi_c) = \mathbf{0}$ due to symmetry.

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 203 of file polySolver.h.

Constructor & Destructor Documentation

◆ PolySolver() [1/2]

serif::polytrope::PolySolver::PolySolver ( const double n,
const double order )

◆ ~PolySolver()

serif::polytrope::PolySolver::~PolySolver ( )
default

Destructor for PolySolver.

Defaulted, handles cleanup of owned resources like std::unique_ptr members.

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

◆ PolySolver() [2/2]

serif::polytrope::PolySolver::PolySolver ( mfem::Mesh & mesh,
double n,
double order )
private

Private constructor that takes an existing mesh.

Initializes FE collections, spaces, grid functions, and assembles the block system. This is called by the public constructor after prepareMesh.

Parameters
meshA reference to an initialized mfem::Mesh.
nThe polytropic index.
orderThe polynomial order for H1 finite elements.

Definition at line 76 of file polySolver.cpp.

Member Function Documentation

◆ assembleAndFinalizeForm()

void serif::polytrope::PolySolver::assembleAndFinalizeForm ( auto & f)
staticprivate

Assemble and finalize a given MFEM form.

This template function calls Assemble() and Finalize() on the provided form. Assemble() computes local element matrices and adds them to the global matrix. Finalize() builds the sparsity pattern and allows the SparseMatrix representation to be extracted.

Template Parameters
FormTypeThe type of the MFEM form (e.g., mfem::BilinearForm, mfem::MixedBilinearForm).
Parameters
fA reference to the form to be assembled and finalized.
Precondition
f must be a valid form object that supports Assemble() and Finalize() methods.
Postcondition
f is assembled and finalized, and its sparse matrix representation is available.
Note
Nonlinear forms like mfem::NonlinearForm are typically not "finalized" in this sense, as they don't directly produce a sparse matrix but are evaluated. This function is intended for linear forms.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 182 of file polySolver.cpp.

◆ assembleBlockSystem()

void serif::polytrope::PolySolver::assembleBlockSystem ( )
private

Assembles the block system operator m_polytropOperator.

This involves:

  1. Computing block offsets for $\theta$ and $\boldsymbol{\phi}$ variables.
  2. Building individual bilinear and nonlinear forms (M, Q, D, S, f) using buildIndividualForms.
  3. Constructing the PolytropeOperator with these forms and offsets.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 114 of file polySolver.cpp.

◆ buildIndividualForms()

std::unique_ptr< formBundle > serif::polytrope::PolySolver::buildIndividualForms ( const mfem::Array< int > & blockOffsets)
private

Build the individual forms for the block operator (M, Q, D, S, and f).

Parameters
blockOffsetsThe offsets for the blocks in the operator, computed by computeBlockOffsets.
Returns
A std::unique_ptr<formBundle> containing the assembled forms.
Note
These forms are built exactly how they are defined in the derivation. For example, Mform corresponds to $+M$, not $-M$. The PolytropeOperator handles any necessary sign changes for the final system assembly.

This method initializes and assembles the discrete forms corresponding to the weak formulation of the mixed polytropic system:

\[  M = \int_\Omega \nabla\psi^\theta \cdot N^\phi \,dV \quad (\text{from } \nabla\theta \text{ term})
\]

\[  Q = \int_\Omega \psi^\phi \cdot \nabla N^\theta \,dV \quad (\text{from } \boldsymbol{\phi} \text{ term, related to } -M^T)
\]

\[  D = \int_\Omega \psi^\phi \cdot N^\phi \,dV \quad (\text{mass matrix for } \boldsymbol{\phi})
\]

\[  S = \int_\Omega \nabla\psi^\theta \cdot \nabla N^\theta \,dV \quad (\text{stiffness matrix for } \theta \text{, for stabilization})
\]

\[  f(\theta)(\psi^\theta) = \int_\Omega \psi^\theta \cdot \theta^n \,dV \quad (\text{from nonlinear term } \theta^n)
\]

The PolytropeOperator will then use these to form a system like:

\[  R(X) = \begin{pmatrix}
      \text{nonlin_op}(\theta) + M\,\boldsymbol{\phi} \\
      D\,\boldsymbol{\phi}   - Q\,\theta
    \end{pmatrix}
  = \mathbf{0}
\]

(The exact structure depends on the PolytropeOperator's internal assembly, which might involve stabilization terms using S).

Precondition
m_feTheta and m_fePhi must be valid, populated mfem::FiniteElementSpace objects. m_polytropicIndex must be set.
Postcondition
The returned formBundle contains unique pointers to assembled (and finalized where appropriate) MFEM forms.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 152 of file polySolver.cpp.

◆ computeBlockOffsets()

mfem::Array< int > serif::polytrope::PolySolver::computeBlockOffsets ( ) const
private

Compute the block offsets for the operator. These are the offsets that define which dofs belong to which variable.

Create the block offsets. These define the start of each block in the combined vector. Block offsets will be $[0, N_\theta, N_\theta + N_\phi]$, where $N_\theta$ is the number of degrees of freedom for $\theta$ and $N_\phi$ is for $\boldsymbol{\phi}$. The interpretation of this is that each block tells the operator where in the flattened (1D) vector the degrees of freedom or coefficients for that free parameter start and end. I.e. we know that in any flattened vector will have a size $N_\theta + N_\phi$. The $\theta$ dofs will span from blockOffsets[0] to blockOffsets[1] and the $\boldsymbol{\phi}$ dofs will span from blockOffsets[1] to blockOffsets[2].

This is the same for matrices only in 2D (rows and columns).

The key point here is that this is fundamentally an accounting structure, it is here to keep track of what parts of vectors and matrices belong to which variable.

Also note that we use VSize rather than Size. Size refers to the number of true dofs (after eliminating boundary conditions). VSize refers to the total number of dofs before BC elimination, which is needed here.

Returns
mfem::Array<int> The offsets for the blocks in the operator.
Precondition
m_feTheta and m_fePhi must be valid, populated mfem::FiniteElementSpace objects.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 142 of file polySolver.cpp.

◆ findCenterElement()

std::pair< mfem::Array< int >, mfem::Array< int > > serif::polytrope::PolySolver::findCenterElement ( ) const
private

Finds the degrees of freedom (DOFs) associated with the geometric center (origin) of the mesh.

This method identifies:

  1. The mesh vertex located at coordinates (0,0,0).
  2. The H1 DOFs ( $\theta$) associated with this center vertex.
  3. The RT DOFs ( $\boldsymbol{\phi}$) associated with mesh elements that share this center vertex.

These DOFs are used to apply boundary conditions at the center of the polytrope, such as $\theta(\xi_c)=1$ and $\boldsymbol{\phi}(\xi_c)=\mathbf{0}$.

Returns
A std::pair of mfem::Array<int>:
  • first: Array of $\theta$ (H1) DOF indices at the center.
  • second: Array of $\boldsymbol{\phi}$ (RT) DOF indices associated with central elements.
Exceptions
`mfem::ErrorException`(via MFEM_ABORT) if no vertex is found at the origin (within tolerance).

For RT elements, DOFs are typically associated with faces (or edges in 2D). This method collects DOFs from all elements connected to the center vertex. For H1 elements, DOFs can be directly associated with vertices.

Precondition
m_mesh, m_feTheta, m_fePhi must be initialized.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 269 of file polySolver.cpp.

◆ GetDofCoordinates()

void serif::polytrope::PolySolver::GetDofCoordinates ( const mfem::FiniteElementSpace & fes,
const std::string & filename )
staticprivate

Utility function to get and save the coordinates of degrees of freedom for a finite element space.

For each element in the mesh:

  1. Gets the DOFs associated with that element from the given fes.
  2. Gets the physical coordinates of the element's center (or a reference point).
  3. Writes the DOF indices, mesh radius, element center radius, and element center x,y,z coordinates to the specified output file in CSV format.

This can be useful for debugging or analyzing the distribution of DOFs.

Parameters
fesThe mfem::FiniteElementSpace for which to get DOF coordinates.
filenameThe name of the output CSV file.
Precondition
fes must be a valid, initialized mfem::FiniteElementSpace. The mesh associated with fes must be valid.
Postcondition
A CSV file named filename is created/truncated and populated with DOF coordinate information.
Note
For DOFs shared by multiple elements, this function might list them multiple times, associated with each element they belong to. The output format lists all DOFs for an element on one line, pipe-separated, followed by coordinate data for that element.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 435 of file polySolver.cpp.

◆ getEssentialTrueDof()

serif::types::MFEMArrayPairSet serif::polytrope::PolySolver::getEssentialTrueDof ( ) const
private

Computes the essential true degrees of freedom (DOFs) and their values for boundary conditions.

This method determines the DOFs that correspond to:

  1. $\theta = 1$ at the center of the star.
  2. $\theta = 0$ on the surface of the star (boundary attribute 1).
  3. $\boldsymbol{\phi} \cdot \mathbf{n} = \text{surface\_flux}$ on the surface, where the flux is derived from $\theta'(\xi_1)$. (This is applied to the normal component of $\boldsymbol{\phi}$).
  4. Potentially $\boldsymbol{\phi} = \mathbf{0}$ at the center (though the current implementation in polySolver.cpp seems to set components of $\boldsymbol{\phi}$ to zero at DOFs associated with the center element(s)).
Returns
An serif::types::MFEMArrayPairSet containing two pairs:
  • The first pair is for $\theta$: (mfem::Array<int> of essential TDOF indices, mfem::Array<double> of corresponding values).
  • The second pair is for $\boldsymbol{\phi}$: (mfem::Array<int> of essential TDOF indices, mfem::Array<double> of corresponding values).

"True DOFs" (tdof) in MFEM refer to the actual degrees of freedom in the global system, as opposed to local DOFs within an element. Essential boundary conditions fix the values of these DOFs. The center condition for $\theta$ is applied to DOFs identified by findCenterElement(). Surface conditions are applied to boundary attributes marked as essential (typically attribute 1). The surface flux for $\boldsymbol{\phi}$ is obtained from polycoeff::thetaSurfaceFlux(m_polytropicIndex).

Precondition
m_mesh, m_feTheta, m_fePhi must be initialized. m_polytropicIndex must be set.
Exceptions
`mfem::ErrorException`(via MFEM_ABORT) if findCenterElement() fails to locate the center vertex.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 230 of file polySolver.cpp.

◆ getMesh()

mfem::Mesh & serif::polytrope::PolySolver::getMesh ( ) const
inline

Gets a reference to the computational mesh.

Returns
A reference to the mfem::Mesh object.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 267 of file polySolver.h.

◆ getN()

double serif::polytrope::PolySolver::getN ( ) const
inline

Gets the polytropic index $n$.

Returns
The polytropic index.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 255 of file polySolver.h.

◆ getOrder()

double serif::polytrope::PolySolver::getOrder ( ) const
inline

Gets the finite element order used for the $\theta$ variable.

Returns
The polynomial order of the H1 finite elements.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 261 of file polySolver.h.

◆ getPhi()

mfem::GridFunction & serif::polytrope::PolySolver::getPhi ( ) const
inline

Gets a reference to the solution grid function for $\phi$.

Returns
A reference to the mfem::GridFunction storing the $\phi$ solution.
Note
The solution is populated after solve() has been successfully called.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 281 of file polySolver.h.

◆ getTheta()

mfem::GridFunction & serif::polytrope::PolySolver::getTheta ( ) const
inline

Gets a reference to the solution grid function for $\theta$.

Returns
A reference to the mfem::GridFunction storing the $\theta$ solution.
Note
The solution is populated after solve() has been successfully called.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 274 of file polySolver.h.

◆ LoadSolverUserParams()

void serif::polytrope::PolySolver::LoadSolverUserParams ( double & newtonRelTol,
double & newtonAbsTol,
int & newtonMaxIter,
int & newtonPrintLevel,
double & gmresRelTol,
double & gmresAbsTol,
int & gmresMaxIter,
int & gmresPrintLevel ) const
private

Loads Newton and GMRES solver parameters from the configuration.

Retrieves relative tolerance, absolute tolerance, maximum iterations, and print level for both the Newton solver and the GMRES linear solver from the Config instance. Default values are used if specific configuration keys are not found.

Configuration keys are typically prefixed with Poly:Solver:Newton: and Poly:Solver:GMRES:. Example keys: Poly:Solver:Newton:RelTol, Poly:Solver:GMRES:MaxIter.

Parameters
[out]newtonRelTolRelative tolerance for Newton solver.
[out]newtonAbsTolAbsolute tolerance for Newton solver.
[out]newtonMaxIterMaximum iterations for Newton solver.
[out]newtonPrintLevelPrint level for Newton solver.
[out]gmresRelTolRelative tolerance for GMRES solver.
[out]gmresAbsTolAbsolute tolerance for GMRES solver.
[out]gmresMaxIterMaximum iterations for GMRES solver.
[out]gmresPrintLevelPrint level for GMRES solver.
Precondition
m_config must be a valid reference to a Config object. m_logger should be initialized if debug logging is enabled.
Postcondition
Output parameters are populated with values from configuration or defaults. Solver parameters are logged at DEBUG level.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 419 of file polySolver.cpp.

◆ prepareMesh()

mfem::Mesh & serif::polytrope::PolySolver::prepareMesh ( double n)
staticprivate

Prepares the mesh for the simulation.

Loads a generic sphere mesh from the ResourceManager and scales it to the dimensionless radius $\xi_1(n)$ (the first zero of the Lane-Emden function for the given polytropic index $n$).

Parameters
nThe polytropic index.
Returns
A reference to the prepared mfem::Mesh (owned by ResourceManager).
Exceptions
std::runtime_errorIf $n \ge 5.0$ or $n < 0.0$, as $\xi_1(n)$ is typically undefined or infinite outside this range for physical polytropes.
std::runtime_errorIf the mesh resource "mesh:polySphere" cannot be found or loaded.

The scaling factor $\xi_1(n)$ is obtained from polycoeff::x1(n). The mesh is expected to be a unit sphere initially.

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 101 of file polySolver.cpp.

◆ saveAndViewSolution()

void serif::polytrope::PolySolver::saveAndViewSolution ( const mfem::BlockVector & state_vector) const
private

Saves the 1D radial solution and optionally displays the 2D/3D solution using GLVis.

Extracts the $\theta$ and $\boldsymbol{\phi}$ components from the converged state_vector.

  • If configured (Poly:Output:1D:Save), it extracts a 1D solution along a specified ray (defined by co-latitude and longitude) using Probe::getRaySolution and saves it to a CSV file.
  • If configured (Poly:Output:View), it displays $\theta$ and $\boldsymbol{\phi}$ using Probe::glVisView.
Parameters
state_vectorThe full solution vector (block vector containing $\theta$ and $\boldsymbol{\phi}$) obtained from the Newton solver, typically after reconstruction by PolytropeOperator.
Precondition
m_polytropOperator, m_feTheta, m_fePhi must be initialized. Configuration settings for output and viewing must be loaded.
Postcondition
Solution data is saved and/or visualized according to configuration.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 388 of file polySolver.cpp.

◆ setInitialGuess()

void serif::polytrope::PolySolver::setInitialGuess ( ) const
private

Sets the initial guess for the solution variables $\theta$ and $\boldsymbol{\phi}$.

  • For $\theta$:
    • The interior initial guess is based on the Lane-Emden series expansion: $\theta(\xi) = \sum a_k \xi^k$ (using laneEmden::thetaSeriesExpansion).
    • The boundary condition $\theta(\xi_1) = 0$ is projected onto the surface.
  • For $\boldsymbol{\phi}$:
    • The initial guess is $\boldsymbol{\phi} = -\nabla \theta_{\text{init}}$, where $\theta_{\text{init}}$ is the initial guess for $\theta$.
    • The boundary condition for the normal component $\boldsymbol{\phi} \cdot \mathbf{n}$ at the surface is projected. This value is $\theta'(\xi_1)$, obtained from polycoeff::thetaSurfaceFlux.
    • $\boldsymbol{\phi}$ components corresponding to central DOFs (from findCenterElement) are set to 0.

The method uses mfem::GridFunction::ProjectCoefficient and ProjectBdrCoefficient (or ProjectBdrCoefficientNormal) for these projections.

Note
The projection of boundary conditions for $\boldsymbol{\phi}$ (RT elements) might not be exact due to H(div) continuity requirements. Inhomogeneous BC enforcement in PolytropeOperator handles this more robustly.
Precondition
m_theta, m_phi, m_mesh, m_feTheta, m_fePhi must be initialized. m_polytropicIndex must be set. Configuration settings for viewing initial guess should be loaded if desired.
Postcondition
m_theta and m_phi grid functions are populated with the initial guess.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 328 of file polySolver.cpp.

◆ setOperatorEssentialTrueDofs()

void serif::polytrope::PolySolver::setOperatorEssentialTrueDofs ( ) const
private

Sets the essential true DOFs on the PolytropeOperator.

Calls getEssentialTrueDof() to compute the boundary condition DOFs and values, and then passes them to m_polytropOperator->set_essential_true_dofs(). This step is crucial for the PolytropeOperator to correctly handle boundary conditions when forming reduced systems and applying residuals/Jacobians.

Precondition
m_polytropOperator must be initialized. m_mesh, m_feTheta, m_fePhi, m_polytropicIndex must be set (for getEssentialTrueDof).
Postcondition
Essential boundary conditions are registered with the m_polytropOperator. The PolytropeOperator will likely be marked as not finalized after this call.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 414 of file polySolver.cpp.

◆ setupNewtonSolver()

solverBundle serif::polytrope::PolySolver::setupNewtonSolver ( ) const
private

Sets up the Newton solver and its associated linear solver (GMRES).

  1. Loads solver parameters (tolerances, max iterations, print levels) for both Newton and GMRES from the configuration file (via LoadSolverUserParams).
  2. Creates a solverBundle to manage the lifetimes of mfem::GMRESSolver and mfem::NewtonSolver.
  3. Configures the GMRES solver with its parameters.
  4. Configures the Newton solver with its parameters, sets the PolytropeOperator as the nonlinear system operator, and sets the configured GMRES solver as the linear solver for inverting Jacobians.
Returns
A solverBundle struct containing the configured Newton and GMRES solvers. The ownership of the solvers within the bundle is managed by the bundle itself.
Precondition
m_polytropOperator must be initialized and finalized. Configuration settings for solver parameters must be available.
Postcondition
A fully configured solverBundle is returned, ready for newton.Mult().
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 472 of file polySolver.cpp.

◆ solve()

void serif::polytrope::PolySolver::solve ( ) const

Solves the polytropic system.

This method orchestrates the solution process:

  1. Sets the initial guess for $\theta$ and $\boldsymbol{\phi}$.
  2. Applies essential boundary conditions to the PolytropeOperator.
  3. Finalizes the PolytropeOperator with the initial state.
  4. Sets up the Newton solver (including the GMRES linear solver for Jacobian systems).
  5. Runs the Newton iteration to find the solution for the free DOFs.
  6. Reconstructs the full solution vector from the free DOFs.
  7. Saves and/or views the solution based on configuration.
Exceptions
std::runtime_erroror mfem::ErrorException if the solver fails to converge or encounters numerical issues.
Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 190 of file polySolver.cpp.

Member Data Documentation

◆ m_config

serif::config::Config& serif::polytrope::PolySolver::m_config
private

Reference to the global configuration manager instance.

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 285 of file polySolver.h.

◆ m_fecH1

std::unique_ptr<mfem::H1_FECollection> serif::polytrope::PolySolver::m_fecH1
private

Finite Element Collection for $\theta$ (H1 elements).

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 295 of file polySolver.h.

◆ m_fecRT

std::unique_ptr<mfem::RT_FECollection> serif::polytrope::PolySolver::m_fecRT
private

Finite Element Collection for $\boldsymbol{\phi}$ (Raviart-Thomas elements).

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 296 of file polySolver.h.

◆ m_feOrder

double serif::polytrope::PolySolver::m_feOrder
private

The polynomial order for H1 elements ( $\theta$). RT elements for $\boldsymbol{\phi}$ are of order m_feOrder - 1.

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 291 of file polySolver.h.

◆ m_fePhi

std::unique_ptr<mfem::FiniteElementSpace> serif::polytrope::PolySolver::m_fePhi
private

Finite Element Space for $\boldsymbol{\phi}$.

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 299 of file polySolver.h.

◆ m_feTheta

std::unique_ptr<mfem::FiniteElementSpace> serif::polytrope::PolySolver::m_feTheta
private

Finite Element Space for $\theta$.

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 298 of file polySolver.h.

◆ m_logger

quill::Logger* serif::polytrope::PolySolver::m_logger
private

Pointer to the specific logger instance for this class.

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 287 of file polySolver.h.

◆ m_logManager

serif::probe::LogManager& serif::polytrope::PolySolver::m_logManager
private

Reference to the global log manager instance.

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 286 of file polySolver.h.

◆ m_mesh

mfem::Mesh& serif::polytrope::PolySolver::m_mesh
private

Reference to the computational mesh (owned by ResourceManager).

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 294 of file polySolver.h.

◆ m_phi

std::unique_ptr<mfem::GridFunction> serif::polytrope::PolySolver::m_phi
private

Grid function for the vector flux $\boldsymbol{\phi}$.

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 303 of file polySolver.h.

◆ m_polytropicIndex

double serif::polytrope::PolySolver::m_polytropicIndex
private

The polytropic index $n$.

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 290 of file polySolver.h.

◆ m_polytropOperator

std::unique_ptr<PolytropeOperator> serif::polytrope::PolySolver::m_polytropOperator
private

The main nonlinear operator for the mixed system.

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 306 of file polySolver.h.

◆ m_prec

std::unique_ptr<mfem::OperatorJacobiSmoother> serif::polytrope::PolySolver::m_prec
private

Preconditioner (currently seems unused in polySolver.cpp).

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 307 of file polySolver.h.

◆ m_theta

std::unique_ptr<mfem::GridFunction> serif::polytrope::PolySolver::m_theta
private

Grid function for the scalar potential $\theta$.

Examples
/Users/tboudreaux/Programming/SERiF/src/polytrope/solver/public/polySolver.h.

Definition at line 302 of file polySolver.h.


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