LCOV - code coverage report
Current view: top level - include/relationshipmanagers - RelationshipManager.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 10 15 66.7 %
Date: 2025-07-17 01:28:37 Functions: 9 11 81.8 %
Legend: Lines: hit not hit

          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             : #pragma once
      11             : 
      12             : #include "MooseObject.h"
      13             : #include "InputParameters.h"
      14             : #include "MooseMesh.h"
      15             : 
      16             : #include "libmesh/ghosting_functor.h"
      17             : 
      18             : class MooseMesh;
      19             : 
      20             : /**
      21             :  * RelationshipManagers are used for describing what kinds of non-local resources are needed for an
      22             :  * object's calculations. Non-local resources include geometric element information, or solution
      23             :  * information that may be more than a single side-neighbor away in a mesh. This includes
      24             :  * physically disconnected elements that might be needed for contact or mortar calculations.
      25             :  */
      26             : class RelationshipManager : public MooseObject, public libMesh::GhostingFunctor
      27             : {
      28             : public:
      29             :   static InputParameters validParams();
      30             : 
      31             :   RelationshipManager(const InputParameters & parameters);
      32             : 
      33             :   RelationshipManager(const RelationshipManager & other);
      34             : 
      35             :   /**
      36             :    * Called before this RM is attached
      37             :    */
      38             :   void
      39             :   init(MooseMesh & moose_mesh, const MeshBase & mesh, const libMesh::DofMap * dof_map = nullptr);
      40             : 
      41             :   /**
      42             :    * Whether or not this RM has been init-ed. NOTE that this just indicates that the \p init method
      43             :    * has been called at least once. Conceivably this could have been during the early geometric
      44             :    * setup phase and if this relationship manager is also algebraic/coupling, we are not assured
      45             :    * that this RelationshipManager is fully initialized until the \p init call during the
      46             :    * algebraic/coupling/late-geometric setup phase
      47             :    */
      48             :   bool inited() { return _inited; }
      49             : 
      50             :   /**
      51             :    * The object (or Action) this RelationshipManager was built for
      52             :    */
      53      904086 :   virtual const std::vector<std::string> & forWhom() const { return _for_whom; }
      54             : 
      55             :   /**
      56             :    * Add another name to for_whom
      57             :    */
      58       92054 :   void addForWhom(const std::string & for_whom) { _for_whom.push_back(for_whom); }
      59             : 
      60             :   /**
      61             :    * Method for returning relationship manager information (suitable for console output).
      62             :    */
      63             :   virtual std::string getInfo() const = 0;
      64             : 
      65             :   /**
      66             :    * Getter for returning the enum type for this RM.
      67             :    */
      68         292 :   Moose::RelationshipManagerType getType() const { return _rm_type; }
      69             : 
      70             :   /**
      71             :    * Check to see if an RM is of a given type
      72             :    *
      73             :    * This is here so that the Boolean logic doesn't have to get spread everywhere in the world
      74             :    */
      75      925449 :   bool isType(const Moose::RelationshipManagerType & type) const
      76             :   {
      77      925449 :     return (_rm_type & type) == type;
      78             :   }
      79             : 
      80           0 :   virtual bool operator==(const RelationshipManager & /*rhs*/) const
      81             :   {
      82           0 :     mooseError("RelationshipManager::operator>= must be overridden");
      83             :   }
      84             : 
      85             :   /**
      86             :    * Whether this relationship manager provides more or the same amount and type of ghosting as the
      87             :    * \p rhs
      88             :    */
      89           0 :   virtual bool operator>=(const RelationshipManager & rhs) const
      90             :   {
      91           0 :     mooseDeprecated(
      92             :         "Are you overriding RelationshipManager::operator==? We are transitioning to make "
      93             :         "operator>= "
      94             :         "the required override. If you are not overriding operator>= or operator==, you are about "
      95             :         "to get an error message saying that operator>= must be overridden.");
      96             : 
      97           0 :     return *this == rhs;
      98             :   }
      99             : 
     100             :   /**
     101             :    * Whether the base class provides more or the same amount and type of ghosting as the
     102             :    * \p rhs
     103             :    */
     104             :   virtual bool baseGreaterEqual(const RelationshipManager & rhs) const;
     105             : 
     106             :   /**
     107             :    * Whether or not this RM can be attached to the Mesh early if it's geometric.
     108             :    *
     109             :    * Note: this is unused if this RM is purely Algebraic
     110             :    */
     111      135208 :   bool attachGeometricEarly() { return _attach_geometric_early; }
     112             : 
     113             :   /**
     114             :    * Whether this should be placed on the undisplaced or displaced systems
     115             :    *
     116             :    * Note: this says 'mesh' but that's just to match the colloquial term
     117             :    * in MOOSE.  If this thing is algebraic then it's going to the DofMap
     118             :    */
     119       74447 :   bool useDisplacedMesh() const { return _use_displaced_mesh; }
     120             : 
     121      155129 :   const libMesh::DofMap * dofMap() { return _dof_map; }
     122             : 
     123             : protected:
     124             :   /**
     125             :    * Called before this RM is attached.  Only called once
     126             :    */
     127       26099 :   virtual void internalInitWithMesh(const MeshBase &) { internalInit(); }
     128       26099 :   virtual void internalInit() {}
     129             : 
     130             :   /// Whether or not this has been initialized
     131             :   bool _inited = false;
     132             : 
     133             :   /// Pointer to the \p MooseMesh object. This must be non-const because we have derived classes
     134             :   /// that call to methods like \p nodeToElemMap which are non-const
     135             :   MooseMesh * _moose_mesh;
     136             : 
     137             :   /// Pointer to DofMap (may be null if this is geometric only). This is useful for setting coupling
     138             :   /// matrices in call-backs from DofMap::reinit
     139             :   const libMesh::DofMap * _dof_map = nullptr;
     140             : 
     141             :   /// Boolean indicating whether this RM can be attached early (e.g. all parameters are known
     142             :   /// without the need for inspecting things like variables or other parts of the system that
     143             :   /// are not available.
     144             :   const bool _attach_geometric_early;
     145             : 
     146             :   /// The type of RM this object is. Note that the underlying enum is capable of holding
     147             :   /// multiple values simultaneously, so you must use bitwise operators to test values.
     148             :   Moose::RelationshipManagerType _rm_type;
     149             : 
     150             :   /// The name of the object that requires this RelationshipManager
     151             :   std::vector<std::string> _for_whom;
     152             : 
     153             :   /// Which system this should go to (undisplaced or displaced)
     154             :   const bool _use_displaced_mesh;
     155             : 
     156             : public:
     157             :   /**
     158             :    * Whether \p input_rm is geometric
     159             :    */
     160             :   static bool isGeometric(Moose::RelationshipManagerType input_rm);
     161             : 
     162             :   /**
     163             :    * Whether \p input_rm is algebraic
     164             :    */
     165             :   static bool isAlgebraic(Moose::RelationshipManagerType input_rm);
     166             : 
     167             :   /**
     168             :    * Whether \p input_rm is coupling
     169             :    */
     170             :   static bool isCoupling(Moose::RelationshipManagerType input_rm);
     171             : 
     172             :   /**
     173             :    * A relationship manager type that is geometric and algebraic
     174             :    */
     175             :   static Moose::RelationshipManagerType geo_and_alg;
     176             : 
     177             :   /**
     178             :    * A relationship manager type that is geometric, algebraic, and coupling
     179             :    */
     180             :   static Moose::RelationshipManagerType geo_alg_and_coupl;
     181             : 
     182             :   /**
     183             :    * This returns an \p InputParameters object containing an \p ElementSideNeighborLayers
     184             :    * relationship manager with zero layers of ghosting. While zero layers may seem foolish, this is
     185             :    * actually very useful for building the correct sparsity pattern between intra-element degrees of
     186             :    * freedom. Since this object only has meaning for building the sparsity pattern, the relationship
     187             :    * manager type contained within the returned \p InputParameters object will be COUPLING
     188             :    */
     189             :   static InputParameters zeroLayerGhosting();
     190             : 
     191             :   /**
     192             :    * This returns an \p InputParameters object containing an \p ElementSideNeighborLayers
     193             :    * relationship manager with one side layer of ghosting.
     194             :    * @param rm_type The type of relationship manager that should be added. This can be GEOMETRIC,
     195             :    *                ALGEBRAIC, COUPLING or a combination of the three
     196             :    */
     197             :   static InputParameters oneLayerGhosting(Moose::RelationshipManagerType rm_type);
     198             : };

Generated by: LCOV version 1.14