Skip to content
Permalink
Browse files

Merge pull request #12957 from YaqiWang/simple_feproblem_solve

Create a simple solve object to wrap FEProblem solve
  • Loading branch information...
permcody committed Mar 5, 2019
2 parents 88608e6 + 5d645d3 commit c50ba8cc2a146e3a1a7902fee2fa9dd572771bfb
@@ -15,6 +15,7 @@
#include "PostprocessorInterface.h"
#include "Restartable.h"
#include "PerfGraphInterface.h"
#include "FEProblemSolve.h"
#include "PicardSolve.h"

// System includes
@@ -28,12 +29,6 @@ InputParameters validParams<Executioner>();

/**
* Executioners are objects that do the actual work of solving your problem.
*
* In general there are two "sets" of Executioners: Steady and Transient.
*
* The Difference is that a Steady Executioner usually only calls "solve()"
* for the NonlinearSystem once... where Transient Executioners call solve()
* multiple times... i.e. once per timestep.
*/
class Executioner : public MooseObject,
public UserObjectInterface,
@@ -49,12 +44,12 @@ class Executioner : public MooseObject,
*/
Executioner(const InputParameters & parameters);

virtual ~Executioner();
virtual ~Executioner() {}

/**
* Initialize the executioner
*/
virtual void init();
virtual void init() {}

/**
* Pure virtual execute function MUST be overridden by children classes.
@@ -65,22 +60,22 @@ class Executioner : public MooseObject,
/**
* Override this for actions that should take place before execution
*/
virtual void preExecute();
virtual void preExecute() {}

/**
* Override this for actions that should take place after execution
*/
virtual void postExecute();
virtual void postExecute() {}

/**
* Override this for actions that should take place before execution
* Override this for actions that should take place before execution, called by PicardSolve
*/
virtual void preSolve();
virtual void preSolve() {}

/**
* Override this for actions that should take place after execution
* Override this for actions that should take place after execution, called by PicardSolve
*/
virtual void postSolve();
virtual void postSolve() {}

/**
* Deprecated:
@@ -97,7 +92,7 @@ class Executioner : public MooseObject,
* This is an empty string for non-Transient executioners
* @return A string of giving the TimeStepper name
*/
virtual std::string getTimeStepperName();
virtual std::string getTimeStepperName() { return std::string(); }

/**
* Can be used by subsclasses to call parentOutputPositionChanged()
@@ -110,10 +105,13 @@ class Executioner : public MooseObject,
*/
virtual bool lastSolveConverged() const = 0;

/// Return the underlining FEProblemSolve object.
FEProblemSolve & feProblemSolve() { return _feproblem_solve; }

/// Return underlining PicardSolve object.
PicardSolve & picardSolve() { return _picard_solve; }

/// Augmented Picard convergence check that can be overridden by derived executioners
/// Augmented Picard convergence check that to be called by PicardSolve and can be overridden by derived executioners
virtual bool augmentedPicardConvergenceCheck() const { return false; }

protected:
@@ -129,17 +127,11 @@ class Executioner : public MooseObject,

FEProblemBase & _fe_problem;

FEProblemSolve _feproblem_solve;
PicardSolve _picard_solve;

/// Initial Residual Variables
Real _initial_residual_norm;
Real _old_initial_residual_norm;

// Restart
std::string _restart_file_base;

// Splitting
std::vector<std::string> _splitting;
};

#endif // EXECUTIONER_H
@@ -0,0 +1,40 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#ifndef FEPROBLEMSOLVE_H
#define FEPROBLEMSOLVE_H

#include "SolveObject.h"

class FEProblemSolve;

template <>
InputParameters validParams<FEProblemSolve>();

class FEProblemSolve : public SolveObject
{
public:
FEProblemSolve(Executioner * ex);

/**
* Picard solve the FEProblem.
* @return True if solver is converged.
*/
virtual bool solve() override;

virtual void setInnerSolve(SolveObject &) override
{
mooseError("Cannot set inner solve for FEProblemSolve");
}

protected:
/// Splitting
std::vector<std::string> _splitting;
};
#endif // FEPROBLEMSOLVE_H
@@ -10,17 +10,17 @@
#ifndef PICARDSOLVE_H
#define PICARDSOLVE_H

#include "MooseObject.h"
#include "PerfGraphInterface.h"
#include "SolveObject.h"

// System includes
#include <string>

class Executioner;
class FEProblemBase;
class NonlinearSystemBase;
class PicardSolve;

class PicardSolve : public MooseObject, public PerfGraphInterface
template <>
InputParameters validParams<PicardSolve>();

class PicardSolve : public SolveObject
{
public:
PicardSolve(Executioner * ex);
@@ -29,7 +29,7 @@ class PicardSolve : public MooseObject, public PerfGraphInterface
* Picard solve the FEProblem.
* @return True if solver is converged.
*/
bool solve();
virtual bool solve() override;

/// Enumeration for Picard convergence reasons
enum class MoosePicardConvergenceReason
@@ -100,13 +100,6 @@ class PicardSolve : public MooseObject, public PerfGraphInterface
bool relax,
const std::set<dof_id_type> & relaxed_dofs);

/// Executioner used to construct this
Executioner & _executioner;
/// Reference to FEProblem
FEProblemBase & _problem;
/// Reference to nonlinear system base for faster access
NonlinearSystemBase & _nl;

/// Maximum Picard iterations
unsigned int _picard_max_its;
/// Whether or not we activate Picard iteration
@@ -0,0 +1,56 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#ifndef SOLVEOBJECT_H
#define SOLVEOBJECT_H

#include "MooseObject.h"
#include "PerfGraphInterface.h"

class SolveObject;
class Executioner;
class FEProblemBase;
class DisplacedProblem;
class MooseMesh;
class NonlinearSystemBase;
class AuxiliarySystem;

class SolveObject : public MooseObject, public PerfGraphInterface
{
public:
SolveObject(Executioner * ex);

/**
* Solve routine provided by this object.
* @return True if solver is converged.
*/
virtual bool solve() = 0;

/// Set the inner solve object wrapped by this object.
virtual void setInnerSolve(SolveObject & solve) { _inner_solve = &solve; }

protected:
/// Executioner used to construct this
Executioner & _executioner;
/// Reference to FEProblem
FEProblemBase & _problem;
/// Displaced problem
std::shared_ptr<DisplacedProblem> _displaced_problem;
/// Mesh
MooseMesh & _mesh;
/// Displaced mesh
MooseMesh * _displaced_mesh;
/// Reference to nonlinear system base for faster access
NonlinearSystemBase & _nl;
/// Reference to auxiliary system for faster access
AuxiliarySystem & _aux;
/// SolveObject wrapped by this solve object
SolveObject * _inner_solve;
};
#endif // SOLVEOBJECT_H
Oops, something went wrong.

0 comments on commit c50ba8c

Please sign in to comment.
You can’t perform that action at this time.