Snapshot optimized solver and audit diagnostics before numerical experiments
This commit is contained in:
23
sandbox.cpp
23
sandbox.cpp
@@ -3,6 +3,7 @@
|
||||
#include <iostream>
|
||||
#include <numbers>
|
||||
#include <stdexcept>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include <mfem.hpp>
|
||||
@@ -52,6 +53,20 @@ int main(
|
||||
int argc,
|
||||
char **argv
|
||||
) {
|
||||
bool geometryPreflight = true;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
const std::string_view option(argv[i]);
|
||||
if (option == "--skip-preflight") geometryPreflight = false;
|
||||
else if (option == "--preflight") geometryPreflight = true;
|
||||
else if (option == "--help") {
|
||||
std::cout << "Usage: sandbox [--skip-preflight|--preflight]\n"
|
||||
"Trial geometry validation and backtracking remain enabled.\n";
|
||||
return 0;
|
||||
} else {
|
||||
std::cerr << "Unknown sandbox option: " << option << '\n';
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
mfem::Mpi::Init(argc, argv);
|
||||
int exitCode = 0;
|
||||
|
||||
@@ -77,13 +92,16 @@ int main(
|
||||
|
||||
constexpr double radius = utils::RADIUS;
|
||||
constexpr double mass = utils::MASS;
|
||||
constexpr double angularMomentum = 0.1;
|
||||
constexpr double angularMomentum = 0.00;
|
||||
constexpr double gravitationalConstant = utils::G;
|
||||
const double polytropicConstant =
|
||||
2.0 * gravitationalConstant * radius * radius / std::numbers::pi_v<double>;
|
||||
// const double polytropicConstant = 0.3639391; // Use for n=3 test
|
||||
|
||||
std::println("K = {}", polytropicConstant);
|
||||
const double centralDensity =
|
||||
std::numbers::pi_v<double> * mass / (4.0 * radius * radius * radius);
|
||||
//const double centralDensity =12.9351146; // use for n=3 test
|
||||
|
||||
auto stellarModel = model::StellarModel(
|
||||
eos::Polytrope({.n = 1.0, .K = polytropicConstant}),
|
||||
@@ -201,9 +219,10 @@ int main(
|
||||
.absoluteTolerance = 0.0,
|
||||
.maximumIterations = 200
|
||||
},
|
||||
.backtracking = {}
|
||||
.backtracking = {.geometryPreflight = geometryPreflight}
|
||||
});
|
||||
|
||||
if (rank == 0) std::cout << "Geometry preflight: " << (geometryPreflight ? "enabled" : "skipped") << '\n';
|
||||
auto equilibriumSolver = solver::make(context, nonlinearSolver, observer);
|
||||
const auto evaluateStart = std::chrono::steady_clock::now();
|
||||
auto report = equilibriumSolver.evaluate();
|
||||
|
||||
Reference in New Issue
Block a user