2025-02-12 16:44:10 -05:00
|
|
|
#include "mfem.hpp"
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void write_solution_to_csv(const mfem::GridFunction &u, const mfem::Mesh &mesh, const std::string &filename);
|
|
|
|
|
|
2025-02-14 10:50:07 -05:00
|
|
|
/**
|
|
|
|
|
* @brief A class for nonlinear power integrator.
|
|
|
|
|
*/
|
2025-02-12 16:44:10 -05:00
|
|
|
class NonlinearPowerIntegrator: public mfem::NonlinearFormIntegrator {
|
|
|
|
|
private:
|
|
|
|
|
mfem::FunctionCoefficient coeff_;
|
|
|
|
|
double polytropicIndex;
|
|
|
|
|
public:
|
2025-02-14 10:50:07 -05:00
|
|
|
/**
|
|
|
|
|
* @brief Constructor for NonlinearPowerIntegrator.
|
|
|
|
|
*
|
|
|
|
|
* @param coeff The function coefficient.
|
|
|
|
|
* @param n The polytropic index.
|
|
|
|
|
*/
|
2025-02-12 16:44:10 -05:00
|
|
|
NonlinearPowerIntegrator(mfem::FunctionCoefficient &coeff, double n);
|
|
|
|
|
|
2025-02-14 10:50:07 -05:00
|
|
|
/**
|
|
|
|
|
* @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.
|
|
|
|
|
*/
|
2025-02-12 16:44:10 -05:00
|
|
|
virtual void AssembleElementVector(const mfem::FiniteElement &el, mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::Vector &elvect) override;
|
2025-02-14 10:50:07 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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.
|
|
|
|
|
*/
|
2025-02-12 16:44:10 -05:00
|
|
|
virtual void AssembleElementGrad (const mfem::FiniteElement &el, mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::DenseMatrix &elmat) override;
|
|
|
|
|
};
|
|
|
|
|
|
2025-02-14 10:50:07 -05:00
|
|
|
/**
|
|
|
|
|
* @brief A wrapper class for bilinear integrator.
|
|
|
|
|
*/
|
2025-02-12 16:44:10 -05:00
|
|
|
class BilinearIntegratorWrapper : public mfem::NonlinearFormIntegrator
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
mfem::BilinearFormIntegrator *integrator;
|
|
|
|
|
public:
|
2025-02-14 10:50:07 -05:00
|
|
|
/**
|
|
|
|
|
* @brief Constructor for BilinearIntegratorWrapper.
|
|
|
|
|
*
|
|
|
|
|
* @param integratorInput The bilinear form integrator input.
|
|
|
|
|
*/
|
2025-02-12 16:44:10 -05:00
|
|
|
BilinearIntegratorWrapper(mfem::BilinearFormIntegrator *integratorInput);
|
|
|
|
|
|
2025-02-14 10:50:07 -05:00
|
|
|
/**
|
|
|
|
|
* @brief Destructor for BilinearIntegratorWrapper.
|
|
|
|
|
*/
|
|
|
|
|
virtual ~BilinearIntegratorWrapper();
|
2025-02-12 16:44:10 -05:00
|
|
|
|
2025-02-14 10:50:07 -05:00
|
|
|
/**
|
|
|
|
|
* @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.
|
|
|
|
|
*/
|
2025-02-12 16:44:10 -05:00
|
|
|
virtual void AssembleElementVector(const mfem::FiniteElement &el, mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::Vector &elvect) override;
|
2025-02-14 10:50:07 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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;
|
2025-02-12 16:44:10 -05:00
|
|
|
};
|
|
|
|
|
|
2025-02-14 10:50:07 -05:00
|
|
|
/**
|
|
|
|
|
* @brief A class for composite nonlinear integrator.
|
|
|
|
|
*/
|
2025-02-12 16:44:10 -05:00
|
|
|
class CompositeNonlinearIntegrator: public mfem::NonlinearFormIntegrator {
|
|
|
|
|
private:
|
|
|
|
|
std::vector<mfem::NonlinearFormIntegrator*> integrators;
|
|
|
|
|
public:
|
2025-02-14 10:50:07 -05:00
|
|
|
/**
|
|
|
|
|
* @brief Constructor for CompositeNonlinearIntegrator.
|
|
|
|
|
*/
|
2025-02-12 16:44:10 -05:00
|
|
|
CompositeNonlinearIntegrator();
|
|
|
|
|
|
2025-02-14 10:50:07 -05:00
|
|
|
/**
|
|
|
|
|
* @brief Destructor for CompositeNonlinearIntegrator.
|
|
|
|
|
*/
|
2025-02-12 16:44:10 -05:00
|
|
|
virtual ~CompositeNonlinearIntegrator();
|
|
|
|
|
|
2025-02-14 10:50:07 -05:00
|
|
|
/**
|
|
|
|
|
* @brief Adds an integrator to the composite integrator.
|
|
|
|
|
*
|
|
|
|
|
* @param integrator The nonlinear form integrator to add.
|
|
|
|
|
*/
|
2025-02-12 16:44:10 -05:00
|
|
|
void add_integrator(mfem::NonlinearFormIntegrator *integrator);
|
|
|
|
|
|
2025-02-14 10:50:07 -05:00
|
|
|
/**
|
|
|
|
|
* @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.
|
|
|
|
|
*/
|
2025-02-12 16:44:10 -05:00
|
|
|
virtual void AssembleElementVector(const mfem::FiniteElement &el, mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::Vector &elvect) override;
|
2025-02-14 10:50:07 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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.
|
|
|
|
|
*/
|
2025-02-12 16:44:10 -05:00
|
|
|
virtual void AssembleElementGrad(const mfem::FiniteElement &el, mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::DenseMatrix &elmat) override;
|
|
|
|
|
};
|