fix(poly): working on solving polytrope

This commit is contained in:
2025-03-14 09:12:40 -04:00
parent 5300fa88a9
commit b4615fc0aa
4 changed files with 42 additions and 34 deletions

View File

@@ -104,26 +104,6 @@ void PolySolver::solve(){
centerPoint(1, 0) = 0.0;
centerPoint(2, 0) = 0.0;
// double controlPoint = 0.25;
// int sign;
// for (int i = 1; i < 7; i++) {
// sign = i % 2 == 0 ? -1 : 1;
// if (i == 1 || i == 2) {
// centerPoint(0, i) = controlPoint * sign;
// centerPoint(1, i) = 0.0;
// centerPoint(2, i) = 0.0;
// } else if (i == 3 || i == 4) {
// centerPoint(0, i) = 0.0;
// centerPoint(1, i) = controlPoint * sign;
// centerPoint(2, i) = 0.0;
// } else {
// centerPoint(0, i) = 0.0;
// centerPoint(1, i) = 0.0;
// centerPoint(2, i) = controlPoint * sign;
// }
// }
mfem::Array<int> elementIDs;
mfem::Array<mfem::IntegrationPoint> ips;
mesh.FindPoints(centerPoint, elementIDs, ips);
@@ -142,19 +122,32 @@ void PolySolver::solve(){
nonlinearForm->SetEssentialTrueDofs(ess_tdof_list);
// Set the center elemID to be the Dirichlet boundary
double alpha = config.get<double>("Poly:Solver:Alpha", 1e2);
double alpha = config.get<double>("Poly:Solver:Newton:Alpha", 1e2);
double newtonRelTol = config.get<double>("Poly:Solver:Newton:RelTol", 1e-7);
double newtonAbsTol = config.get<double>("Poly:Solver:Newton:AbsTol", 1e-7);
int newtonMaxIter = config.get<int>("Poly:Solver:Newton:MaxIter", 200);
int newtonPrintLevel = config.get<int>("Poly:Solver:Newton:PrintLevel", 1);
double gmresRelTol = config.get<double>("Poly:Solver:GMRES:RelTol", 1e-10);
double gmresAbsTol = config.get<double>("Poly:Solver:GMRES:AbsTol", 1e-12);
int gmresMaxIter = config.get<int>("Poly:Solver:GMRES:MaxIter", 2000);
int gmresPrintLevel = config.get<int>("Poly:Solver:GMRES:PrintLevel", 0);
LOG_INFO(logger, "Newton Solver (relTol: {:0.2E}, absTol: {:0.2E}, maxIter: {}, printLevel: {})", newtonRelTol, newtonAbsTol, newtonMaxIter, newtonPrintLevel);
LOG_INFO(logger, "GMRES Solver (relTol: {:0.2E}, absTol: {:0.2E}, maxIter: {}, printLevel: {})", gmresRelTol, gmresAbsTol, gmresMaxIter, gmresPrintLevel);
std::vector<double> zeroSlopeCoordinate = {0.0, 0.0, 0.0};
polyMFEMUtils::ZeroSlopeNewtonSolver newtonSolver(alpha, zeroSlopeCoordinate);
newtonSolver.SetRelTol(1e-8);
newtonSolver.SetAbsTol(1e-10);
newtonSolver.SetMaxIter(200);
newtonSolver.SetPrintLevel(1);
newtonSolver.SetRelTol(newtonRelTol);
newtonSolver.SetAbsTol(newtonAbsTol);
newtonSolver.SetMaxIter(newtonMaxIter);
newtonSolver.SetPrintLevel(newtonPrintLevel);
newtonSolver.SetOperator(*nonlinearForm);
mfem::GMRESSolver gmresSolver;
gmresSolver.SetRelTol(1e-10);
gmresSolver.SetAbsTol(1e-12);
gmresSolver.SetMaxIter(2000);
gmresSolver.SetPrintLevel(0);
gmresSolver.SetRelTol(gmresRelTol);
gmresSolver.SetAbsTol(gmresAbsTol);
gmresSolver.SetMaxIter(gmresMaxIter);
gmresSolver.SetPrintLevel(gmresPrintLevel);
newtonSolver.SetSolver(gmresSolver);
// newtonSolver.SetAdaptiveLinRtol();