#include "mfem.hpp"
#include <string>
#include <iostream>
#include <cmath>

#include "probe.h"
#include "meshIO.h"
#include "config.h"

int main(int argv, char **argc) {
    std::string CONFIG_FILENAME = std::string(getenv("MESON_SOURCE_ROOT")) + "/tests/testsConfig.yaml";
    serif::config::Config& config = serif::config::Config::getInstance();
    config.loadConfig(CONFIG_FILENAME);
    // Read the mesh from the given mesh file
    std::string meshFile = argc[1];
    serif::mesh::MeshIO meshIO(meshFile);
    mfem::Mesh& mesh = meshIO.GetMesh();
    mfem::H1_FECollection feCollection(1, mesh.SpaceDimension());
    mfem::FiniteElementSpace feSpace(&mesh, &feCollection);
    mfem::GridFunction u(&feSpace);
    mfem::FunctionCoefficient initCoeff (
        [](const mfem::Vector &x) {
            return 1.0;
        }
    );
    u.ProjectCoefficient(initCoeff);
    serif::probe::glVisView(u, mesh, meshFile);
}