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:
@@ -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
|
||||
Reference in New Issue
Block a user