Line data Source code
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 : // MOOSE includes 11 : #include "PIMPLE.h" 12 : #include "FEProblem.h" 13 : #include "AuxiliarySystem.h" 14 : #include "LinearSystem.h" 15 : 16 : using namespace libMesh; 17 : 18 : registerMooseObject("NavierStokesApp", PIMPLE); 19 : 20 : InputParameters 21 140 : PIMPLE::validParams() 22 : { 23 140 : InputParameters params = TransientBase::validParams(); 24 140 : params.addClassDescription( 25 : "Solves the transient Navier-Stokes equations using the PIMPLE algorithm and " 26 : "linear finite volume variables."); 27 140 : params += PIMPLESolve::validParams(); 28 : 29 140 : return params; 30 0 : } 31 : 32 70 : PIMPLE::PIMPLE(const InputParameters & parameters) : TransientBase(parameters), _pimple_solve(*this) 33 : { 34 70 : _fixed_point_solve->setInnerSolve(_pimple_solve); 35 70 : } 36 : 37 : void 38 69 : PIMPLE::init() 39 : { 40 69 : _pimple_solve.initialSetup(); 41 69 : TransientBase::init(); 42 69 : _pimple_solve.linkRhieChowUserObject(); 43 69 : _pimple_solve.setupPressurePin(); 44 69 : } 45 : 46 : Real 47 0 : PIMPLE::relativeSolutionDifferenceNorm(bool check_aux) const 48 : { 49 0 : if (check_aux) 50 0 : return _aux.solution().l2_norm_diff(_aux.solutionOld()) / _aux.solution().l2_norm(); 51 : else 52 : { 53 : // Default criterion for now until we add a "steady-state-convergence-object" option 54 : Real residual = 0; 55 0 : for (const auto sys : _pimple_solve.systemsToSolve()) 56 0 : residual += 57 0 : std::pow(sys->solution().l2_norm_diff(sys->solutionOld()) / sys->solution().l2_norm(), 2); 58 0 : return std::sqrt(residual); 59 : } 60 : } 61 : 62 : std::set<TimeIntegrator *> 63 1002 : PIMPLE::getTimeIntegrators() const 64 : { 65 : // We use a set because time integrators were added to every system, and we want a unique 66 : std::set<TimeIntegrator *> tis; 67 : // Get all time integrators from the systems in the FEProblemSolve 68 4833 : for (const auto sys : _pimple_solve.systemsToSolve()) 69 7662 : for (const auto & ti : sys->getTimeIntegrators()) 70 4833 : tis.insert(ti.get()); 71 1002 : return tis; 72 : }