feat(poly): added NonlinearPowerIntegrator and PolytropeOperator

A custom integrator is required to handle the theta^n term in the lane emden equation, that is written as NonlinearPowerIntegrator which is a mfem::NonlinearFormIntegrator and defines methods to assemble its element vector (function value) and element gradient matrix (jacobian). This is then, along with built in mfem vectors for M Q and D, incorporated into the PolytropeOperator which defines methods for Mult (calculate the residuals of the variational form) and GetGradient (find the jacobian of the system)
This commit is contained in:
2025-04-25 11:41:08 -04:00
parent a2a003efcb
commit 56f596500c
14 changed files with 695 additions and 522 deletions

View File

@@ -1,23 +0,0 @@
polyCoeff_sources = files(
'private/coeff.cpp'
)
polyCoeff_headers = files(
'public/coeff.h'
)
libPolyCoeff = static_library('polyCoeff',
polyCoeff_sources,
include_directories : include_directories('.'),
cpp_args: ['-fvisibility=default'],
dependencies: [mfem_dep],
install: true
)
polyCoeff_dep = declare_dependency(
include_directories : include_directories('.'),
link_with : libPolyCoeff,
sources : polyCoeff_sources,
dependencies : [mfem_dep]
)

View File

@@ -1,60 +0,0 @@
/* ***********************************************************************
//
// Copyright (C) 2025 -- The 4D-STAR Collaboration
// File Author: Emily Boudreaux
// Last Modified: February 14, 2025
//
// 4DSSE is free software; you can use it and/or modify
// it under the terms and restrictions the GNU General Library Public
// License version 3 (GPLv3) as published by the Free Software Foundation.
//
// 4DSSE is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public License
// along with this software; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// *********************************************************************** */
#include "mfem.hpp"
#include <cmath>
#include "coeff.h"
/**
* @brief Computes the xi coefficient function.
*
* @param x Input vector.
* @return double The computed xi coefficient.
*/
double xi_coeff_func(const mfem::Vector &x)
{
return std::pow(x(0), 2);
}
/**
* @brief Computes the vector xi coefficient function.
*
* @param x Input vector.
* @param v Output vector to store the computed xi coefficient.
*/
void vec_xi_coeff_func(const mfem::Vector &x, mfem::Vector &v)
{
v.SetSize(1);
v[0] = -std::pow(x(0), 2);
}
/**
* @brief Computes the initial guess for theta.
*
* @param x Input vector.
* @param root Root value used in the computation.
* @return double The initial guess for theta.
*/
double theta_initial_guess(const mfem::Vector &x, double root)
{
double xi = x[0];
return 1 - std::pow(xi / root, 2);
}

View File

@@ -1,28 +0,0 @@
/* ***********************************************************************
//
// Copyright (C) 2025 -- The 4D-STAR Collaboration
// File Author: Emily Boudreaux
// Last Modified: February 12, 2025
//
// 4DSSE is free software; you can use it and/or modify
// it under the terms and restrictions the GNU General Library Public
// License version 3 (GPLv3) as published by the Free Software Foundation.
//
// 4DSSE is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public License
// along with this software; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// *********************************************************************** */
#include "mfem.hpp"
#include <cmath>
double xi_coeff_func(const mfem::Vector &x);
void vec_xi_coeff_func(const mfem::Vector &x, mfem::Vector &v);
double theta_initial_guess(const mfem::Vector &x, double root);