https://mooseframework.inl.gov
ExternalPetscSolverApp.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "ExternalPetscSolverApp.h"
11 #include "Moose.h"
12 #include "AppFactory.h"
13 #include "MooseSyntax.h"
14 #include "PETScDiffusionFDM.h"
15 #include "libmesh/petsc_vector.h"
16 #include "ExternalPETScProblem.h"
17 #include "Executioner.h"
18 
19 #include "libmesh/petsc_solver_exception.h"
20 
23 {
25 
26  params.set<bool>("use_legacy_material_output") = false;
27  params.set<bool>("use_legacy_initial_residual_evaluation_behavior") = false;
28  return params;
29 }
30 
32  : MooseApp(parameters), _ts(nullptr), _is_petsc_app(false)
33 {
35 }
36 
37 TS &
39 {
40  if (!_ts)
41  {
42  // Create an external PETSc solver
43  LibmeshPetscCall(PETScExternalSolverCreate(_comm->get(), &_ts));
44  _is_petsc_app = true;
45  }
46  return _ts;
47 }
48 
50 {
51  // Destroy PETSc solver
52  auto ierr = PETScExternalSolverDestroy(_ts);
53  libmesh_ignore(ierr);
54 }
55 
56 void
58 {
59  Registry::registerObjectsTo(f, {"ExternalPetscSolverApp"});
60  Registry::registerActionsTo(af, {"ExternalPetscSolverApp"});
61 
62  /* register custom execute flags, action syntax, etc. here */
63 }
64 
65 void
67 {
68  registerApp(ExternalPetscSolverApp);
69 }
70 
71 /***************************************************************************************************
72  *********************** Dynamic Library Entry Points - DO NOT MODIFY ******************************
73  **************************************************************************************************/
74 extern "C" void
76 {
78 }
79 extern "C" void
81 {
83 }
ExternalPetscSolverApp(const InputParameters &parameters)
static void registerAll(Factory &f, ActionFactory &af, Syntax &s)
PETSC_EXTERN PetscErrorCode PETScExternalSolverCreate(MPI_Comm, TS *)
void ExternalPetscSolverApp__registerAll(Factory &f, ActionFactory &af, Syntax &s)
T & set(const std::string &name, bool quiet_mode=false)
static void registerObjectsTo(Factory &f, const std::set< std::string > &labels)
Syntax _syntax
This is a demo used to demonstrate how to couple an external app through the MOOSE wrapper APP...
static InputParameters validParams()
PETSC_EXTERN PetscErrorCode PETScExternalSolverDestroy(TS)
static InputParameters validParams()
void ExternalPetscSolverApp__registerApps()
void libmesh_ignore(const Args &...)
static void registerActionsTo(ActionFactory &f, const std::set< std::string > &labels)
Real f(Real x)
Test function for Brents method.
ActionFactory _action_factory
Factory _factory
const std::shared_ptr< libMesh::Parallel::Communicator > _comm