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 : #include "CouplingFunctorCheckAction.h" 11 : #include "MooseApp.h" 12 : #include "FEProblemBase.h" 13 : #include "DisplacedProblem.h" 14 : #include "NonlinearSystemBase.h" 15 : #include "InputParameters.h" 16 : #include "RelationshipManager.h" 17 : 18 : #include "libmesh/system.h" 19 : #include "libmesh/communicator.h" 20 : 21 : registerMooseAction("MooseApp", CouplingFunctorCheckAction, "coupling_functor_check"); 22 : 23 : InputParameters 24 61934 : CouplingFunctorCheckAction::validParams() 25 : { 26 61934 : auto params = Action::validParams(); 27 61934 : params.set<std::string>("_action_name") = "coupling_functor_check"; 28 123868 : return Action::validParams(); 29 61934 : } 30 : 31 61934 : CouplingFunctorCheckAction::CouplingFunctorCheckAction(const InputParameters & parameters) 32 61934 : : Action(parameters) 33 : { 34 61934 : } 35 : 36 : void 37 56104 : CouplingFunctorCheckAction::act() 38 : { 39 109599 : for (const auto i : make_range(_problem->numNonlinearSystems())) 40 : { 41 55205 : if (_problem->solverParams(i)._type == Moose::ST_JFNK) 42 121 : continue; 43 : 44 55084 : auto & nl = _problem->getNonlinearSystemBase(i); 45 55084 : auto & dgs = nl.getDGKernelWarehouse(); 46 55084 : auto & iks = nl.getInterfaceKernelWarehouse(); 47 : 48 : // to reduce typing 49 55084 : auto algebraic = Moose::RelationshipManagerType::ALGEBRAIC; 50 55084 : auto coupling = Moose::RelationshipManagerType::COUPLING; 51 : 52 : // If we have any DGKernels or InterfaceKernels we need one layer of sparsity 53 55084 : if (dgs.size() || iks.size()) 54 : { 55 : // We are going to add the algebraic ghosting and coupling functors one at a time because then 56 : // we can keep track of whether we need to redistribute the dofs or not 57 : 58 : // Add the algebraic ghosting functors if we are running in parallel 59 2522 : if (_communicator.size() > 1 && 60 2522 : addRelationshipManagers(algebraic, RelationshipManager::oneLayerGhosting(algebraic))) 61 18 : _app.attachRelationshipManagers(algebraic); 62 : 63 : // Add the coupling functor. This plays a role regardless of whether we are running serially 64 : // or in parallel 65 1710 : if (addRelationshipManagers(coupling, RelationshipManager::oneLayerGhosting(coupling))) 66 27 : _app.attachRelationshipManagers(coupling); 67 : 68 : // If any nonlinear system added ghosting, then in our current MOOSE ghosting strategy we 69 : // added it for all systems so we can safely exit this loop 70 1710 : break; 71 : } 72 : } 73 56104 : }