// Incompressible - A linear solver for incompressible problems using FEM
// Copyright (C) 2010-2026 Eric Bechet
//
// See the LICENSE file for license information and contributions.
// Please report all bugs and problems to <bechet@cadxfem.org>.


#include "GmshGlobal.h"
#if defined(HAVE_POST)
#include "PView.h"
#include "PViewData.h"
#endif
#include "incompSolver.h"

int main (int argc, char* argv[])
{
  if (argc != 2)
  {
    printf("usage : incompressible input_file_name\n");
    return -1;
  }

  GmshInitialize(argc, argv);

  // instanciate a solver
  IncompSolver mySolver;

  // read the input file
  mySolver.readInputFile(argv[1]);

  // solve the problem
  mySolver.solve();

  // post process the results
#if defined(HAVE_POST)
  PView* pv;
  pv = mySolver.buildDisplacementView("displacement");
  pv->getData()->writeMSH("disp.msh", 3);
  delete pv;
  pv = mySolver.buildPressureView("pressure");
  pv->getData()->writeMSH("pressure.msh", 3);
  delete pv;
  pv = mySolver.buildElasticEnergyView("elastic energy");
  pv->getData()->writeMSH("eenerg.msh", 3);
  delete pv;
#endif

  // stop gmsh
  GmshFinalize();
}
