feat(main): initial commit

This commit is contained in:
2026-02-03 08:15:49 -05:00
parent f810a9fc1d
commit 4d507738bf
15 changed files with 300009 additions and 1 deletions

63
main.cpp Normal file
View File

@@ -0,0 +1,63 @@
#include "mfem.hpp"
#include "fourdst/config/config.h"
#include "CLI/CLI.hpp"
#include <functional>
struct Options {
std::string input_mesh = "stroid.mesh";
std::string vishost = "localhost";
int visport = 19916;
};
void ViewMesh(
const std::string& vishost,
int visport,
const mfem::Mesh& mesh,
mfem::GridFunction& gf,
const std::string& title,
bool first_step = true
) {
mfem::socketstream sol_sock(vishost.c_str(), visport);
if (!sol_sock.is_open()) {
std::cerr << "Unable to connect to GLVis server at "
<< vishost << ':' << visport << std::endl;
std::exit(1);
}
sol_sock.precision(8);
sol_sock << "solution\n" << mesh << gf;
if (first_step) {
sol_sock << "window_title '" << title << "'\n";
sol_sock << "keys 'iIzzMaagpmtppc'";
}
sol_sock << std::flush;
}
std::unique_ptr<mfem::Mesh> load_mesh(const std::string& filename) {
return std::make_unique<mfem::Mesh>(filename.c_str());
}
void project_radial_function(mfem::GridFunction& gf, std::function<double(const mfem::Vector& x)> g) {
mfem::FunctionCoefficient density_coeff([g](const mfem::Vector& x) {
return g(x);
});
gf.ProjectCoefficient(density_coeff);
}
int main(const int argc, char** argv) {
CLI::App app("MFEM_EXAMPLE");
fourdst::config::Config<Options> config;
fourdst::config::register_as_cli(config, app);
CLI11_PARSE(app, argc, argv);
auto mesh = load_mesh(config->input_mesh);
const mfem::H1_FECollection fec(1, mesh->Dimension());
mfem::FiniteElementSpace fes(mesh.get(), &fec);
mfem::GridFunction rho_gf(&fes);
}