feat(poly): constraint integrator

The NewtonSolver has been subclassed to try to auto enforce the zero boundary central condition by modifying the residual vector and the gradient matrix. This is a work in progress

BREAKING CHANGE:
This commit is contained in:
2025-03-05 12:55:53 -05:00
parent cd6da7065b
commit 59162a1a54
4 changed files with 435 additions and 202 deletions

View File

@@ -3,7 +3,11 @@
#include "mfem.hpp"
#include <string>
#include <array>
#include <vector>
#include "config.h"
#include "probe.h"
#include "quill/LogMacros.h"
@@ -213,6 +217,33 @@ namespace polyMFEMUtils {
* @return The Gaussian integral.
*/
double calculateGaussianIntegral(mfem::Mesh &mesh, polyMFEMUtils::GaussianCoefficient &gaussianCoeff);
class ZeroSlopeNewtonSolver : public mfem::NewtonSolver {
private:
Config& config = Config::getInstance();
Probe::LogManager& logManager = Probe::LogManager::getInstance();
quill::Logger* logger = logManager.getLogger("log");
double alpha; // The penalty term for the flat slope at zero
std::vector<double> zeroSlopeCoordinate; // The coordinate of the zero slope point
int zeroSlopeElemID = -1;
mfem::Array<int> zeroSlopeDofs;
mfem::IntegrationPoint zeroSlopeIP;
std::unique_ptr<mfem::GridFunction> u_gf;
mutable mfem::SparseMatrix *grad = nullptr;
void ComputeConstrainedResidual(const mfem::Vector &x, mfem::Vector &r) const;
void ComputeConstrainedGradient(const mfem::Vector &x) const;
public:
ZeroSlopeNewtonSolver(double alpha_, std::vector<double> zeroSlopeCoordinate_);
~ZeroSlopeNewtonSolver();
// virtual void ProcessNewState(const mfem::Vector &x) const;
virtual void SetOperator(const mfem::Operator &op) override;
void Mult(const mfem::Vector &b, mfem::Vector &x) const override;
};
} // namespace polyMFEMUtils
#endif // POLYMFEMUTILS_H