// elastic_genTerm_dfloat - A solver for non linear elastic 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>.

#ifndef _ELASTIC_SOLVER_DFLOAT_H_
#define _ELASTIC_SOLVER_DFLOAT_H_

#include <memory>
#include "dofManager.h"
#include "genTerm.h"
#include "genSolver.h"
#include "elasticDomainDfloat.h"
#include "genCache.h"
#include "savedGenTermManager.h"
#include "genFSpace.h"
#include "dfloat.h"



class ElasticSolverDfloat : public genSolver
{
protected :
  dofManager<double>* pAssembler;
  // function spaces
  genFSpace<genTensor1<double> >::Handle FSpaceDisp;

  // supports for elastic
  std::vector<MechanicsDomain*> MDomains;

  // model name
  std::string modelname;

  // genTerm manager
  SavedGenTermManager savedGenTermManager;
  
  int totalsteps;

  PView* pvDisplacement;
  PView* pvStress;
  PView* pvVonMises;
  PView* pvStrain;

public :
  ElasticSolverDfloat() : genSolver(), pAssembler(0), totalsteps(100), pvDisplacement(0),pvStress(0),pvVonMises(0),pvStrain(0) {}
  virtual ~ElasticSolverDfloat();
  //read data file
  virtual void readInputFile(const std::string &fileName);
  // builds local supports
  virtual void CheckProperties();
  // build the problem function spaces
  virtual void BuildFunctionSpaces();
  // assemble the problem
  double AssembleRHS(int loadstep);
  virtual void AssembleLHS(int loadstep);
  double BuildLinearSystem(int loadstep);

  // export K.txt b.txt in file
  virtual void exportKb();
  virtual void solve();
  virtual PView* buildDisplacementView(const std::string &postFileName, double step);
  virtual PView* buildStrainView(const std::string &postFileName, double step);
  virtual PView* buildStressView(const std::string &postFileName, double step);
  virtual PView* buildVonMisesView(const std::string &postFileName, double step);
};

#endif //_ELASTIC_SOLVER_DFLOAT_H_