// Nonlinear_genTerm - A solver for nonlinear problems using FEM
// Copyright (C) 2010-2026 Eric Bechet, Frederic Duboeuf
//
// See the LICENSE file for license information and contributions.
// Please report all bugs and problems to <bechet@cadxfem.org> or <duboeuf@outlook.com>.


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

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

  GmshInitialize(argc, argv);

  // instanciate a solver
  NonLinearSolver 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.buildElasticEnergyView("elastic energy");
  pv->getData()->writeMSH("energ.msh", 3);
  delete pv;
  pv = mySolver.buildStressView("stress");
  pv->getData()->writeMSH("stress.msh", 3);
  delete pv;
  pv = mySolver.buildStrainView("strain");
  pv->getData()->writeMSH("strain.msh", 3);
  delete pv;
#endif

  // stop gmsh
  GmshFinalize();
}
