diff --git a/src/poly/coeff/private/polyCoeff.cpp b/src/poly/coeff/private/polyCoeff.cpp index ad4d117..c4076a0 100644 --- a/src/poly/coeff/private/polyCoeff.cpp +++ b/src/poly/coeff/private/polyCoeff.cpp @@ -3,16 +3,38 @@ #include "coeff.h" -double xi_coeff_func(const mfem::Vector &x) { +/** + * @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); } -void vec_xi_coeff_func(const mfem::Vector &x, mfem::Vector &v) { +/** + * @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); } -double theta_initial_guess(const mfem::Vector &x, double root) { +/** + * @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); + return 1 - std::pow(xi / root, 2); } \ No newline at end of file diff --git a/src/poly/utils/private/polyIO.cpp b/src/poly/utils/private/polyIO.cpp index 8eaf25b..d540cb0 100644 --- a/src/poly/utils/private/polyIO.cpp +++ b/src/poly/utils/private/polyIO.cpp @@ -2,7 +2,7 @@ #include #include -#include "io.h" +#include "polyIO.h" void write_solution_to_csv(const mfem::GridFunction &u, const mfem::Mesh &mesh, const std::string &filename) { std::ofstream file(filename); diff --git a/src/poly/utils/public/polyIO.h b/src/poly/utils/public/polyIO.h index e69de29..9ca7ceb 100644 --- a/src/poly/utils/public/polyIO.h +++ b/src/poly/utils/public/polyIO.h @@ -0,0 +1,16 @@ +#ifndef POLY_IO_H +#define POLY_IO_H + +#include "mfem.hpp" +#include + +/** + * @brief Writes the solution to a CSV file. + * + * @param u The GridFunction containing the solution. + * @param mesh The mesh associated with the solution. + * @param filename The name of the CSV file to write to. + */ +void write_solution_to_csv(const mfem::GridFunction &u, const mfem::Mesh &mesh, const std::string &filename); + +#endif // POLY_IO_H \ No newline at end of file diff --git a/src/poly/utils/public/polyMFEMUtils.h b/src/poly/utils/public/polyMFEMUtils.h index 33985aa..ac07264 100644 --- a/src/poly/utils/public/polyMFEMUtils.h +++ b/src/poly/utils/public/polyMFEMUtils.h @@ -4,40 +4,125 @@ void write_solution_to_csv(const mfem::GridFunction &u, const mfem::Mesh &mesh, const std::string &filename); +/** + * @brief A class for nonlinear power integrator. + */ class NonlinearPowerIntegrator: public mfem::NonlinearFormIntegrator { private: mfem::FunctionCoefficient coeff_; double polytropicIndex; public: + /** + * @brief Constructor for NonlinearPowerIntegrator. + * + * @param coeff The function coefficient. + * @param n The polytropic index. + */ NonlinearPowerIntegrator(mfem::FunctionCoefficient &coeff, double n); + /** + * @brief Assembles the element vector. + * + * @param el The finite element. + * @param Trans The element transformation. + * @param elfun The element function. + * @param elvect The element vector to be assembled. + */ virtual void AssembleElementVector(const mfem::FiniteElement &el, mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::Vector &elvect) override; + + /** + * @brief Assembles the element gradient. + * + * @param el The finite element. + * @param Trans The element transformation. + * @param elfun The element function. + * @param elmat The element matrix to be assembled. + */ virtual void AssembleElementGrad (const mfem::FiniteElement &el, mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::DenseMatrix &elmat) override; }; +/** + * @brief A wrapper class for bilinear integrator. + */ class BilinearIntegratorWrapper : public mfem::NonlinearFormIntegrator { private: mfem::BilinearFormIntegrator *integrator; public: + /** + * @brief Constructor for BilinearIntegratorWrapper. + * + * @param integratorInput The bilinear form integrator input. + */ BilinearIntegratorWrapper(mfem::BilinearFormIntegrator *integratorInput); - virtual ~BilinearIntegratorWrapper() ; + /** + * @brief Destructor for BilinearIntegratorWrapper. + */ + virtual ~BilinearIntegratorWrapper(); + /** + * @brief Assembles the element vector. + * + * @param el The finite element. + * @param Trans The element transformation. + * @param elfun The element function. + * @param elvect The element vector to be assembled. + */ virtual void AssembleElementVector(const mfem::FiniteElement &el, mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::Vector &elvect) override; - virtual void AssembleElementGrad(const mfem::FiniteElement &el,mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::DenseMatrix &elmat) override; + + /** + * @brief Assembles the element gradient. + * + * @param el The finite element. + * @param Trans The element transformation. + * @param elfun The element function. + * @param elmat The element matrix to be assembled. + */ + virtual void AssembleElementGrad(const mfem::FiniteElement &el, mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::DenseMatrix &elmat) override; }; +/** + * @brief A class for composite nonlinear integrator. + */ class CompositeNonlinearIntegrator: public mfem::NonlinearFormIntegrator { private: std::vector integrators; public: + /** + * @brief Constructor for CompositeNonlinearIntegrator. + */ CompositeNonlinearIntegrator(); + /** + * @brief Destructor for CompositeNonlinearIntegrator. + */ virtual ~CompositeNonlinearIntegrator(); + /** + * @brief Adds an integrator to the composite integrator. + * + * @param integrator The nonlinear form integrator to add. + */ void add_integrator(mfem::NonlinearFormIntegrator *integrator); + /** + * @brief Assembles the element vector. + * + * @param el The finite element. + * @param Trans The element transformation. + * @param elfun The element function. + * @param elvect The element vector to be assembled. + */ virtual void AssembleElementVector(const mfem::FiniteElement &el, mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::Vector &elvect) override; + + /** + * @brief Assembles the element gradient. + * + * @param el The finite element. + * @param Trans The element transformation. + * @param elfun The element function. + * @param elmat The element matrix to be assembled. + */ virtual void AssembleElementGrad(const mfem::FiniteElement &el, mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::DenseMatrix &elmat) override; }; \ No newline at end of file