LCOV - code coverage report
Current view: top level - include/interfaces - BoundaryRestrictable.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 4 4 100.0 %
Date: 2025-07-17 01:28:37 Functions: 2 3 66.7 %
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             : // MOOSE includes
      13             : #include "InputParameters.h"
      14             : #include "MaterialData.h"
      15             : 
      16             : class MooseMesh;
      17             : 
      18             : /**
      19             :  * /class BoundaryRestrictable
      20             :  * /brief Provides functionality for limiting the object to certain boundary ids
      21             :  * The is class the inheriting class with methods useful for limiting an object
      22             :  * to certain boundaries. The parameters "_boundary_id" and "boundary", which are
      23             :  * created with BoundaryRestrictable::validParams() are used the framework.
      24             :  */
      25             : class BoundaryRestrictable
      26             : {
      27             : public:
      28             :   /// A flag changing the behavior of hasBoundary
      29             :   enum TEST_TYPE
      30             :   {
      31             :     ALL,
      32             :     ANY
      33             :   };
      34             : 
      35             :   /**
      36             :    * Class constructor
      37             :    * Populates the _bnd_ids for the given boundary names supplied
      38             :    * with the 'boundary' input parameter
      39             :    * @param parameters The input parameters
      40             :    * @param nodal True indicates that the object is operating on nodesets, false for sidesets
      41             :    */
      42             :   BoundaryRestrictable(const MooseObject * moose_object, bool nodal);
      43             : 
      44             :   static InputParameters validParams();
      45             : 
      46             :   /**
      47             :    * Class constructor
      48             :    * Populates the 'block' input parameters when an object is also block restricted,
      49             :    * see the general class documentation for details.
      50             :    * @param parameters The input parameters (see the detailed help for additional information)
      51             :    * @param block_ids The block ids that the object is restricted to
      52             :    * @param nodal True indicates that the object is operating on nodesets, false for sidesets
      53             :    */
      54             :   BoundaryRestrictable(const MooseObject * moose_object,
      55             :                        const std::set<SubdomainID> & block_ids,
      56             :                        bool nodal);
      57             : 
      58             :   /**
      59             :    * Helper for determining if the object is boundary restricted. This is needed for the
      60             :    * MaterialPropertyInterface.
      61             :    */
      62             :   static bool restricted(const std::set<BoundaryID> & ids);
      63             : 
      64             :   /**
      65             :    * Empty class destructor
      66             :    */
      67             :   virtual ~BoundaryRestrictable();
      68             : 
      69             :   /**
      70             :    * Return the boundary IDs for this object
      71             :    * @return A set of all boundary ids for which the object is restricted
      72             :    */
      73             :   const virtual std::set<BoundaryID> & boundaryIDs() const;
      74             : 
      75             :   /**
      76             :    * Return the boundary names for this object
      77             :    * @return A set of all boundary names for which the object is restricted
      78             :    */
      79             :   const std::vector<BoundaryName> & boundaryNames() const;
      80             : 
      81             :   /**
      82             :    * Return the number of boundaries for this object
      83             :    * @return The number of boundary ids
      84             :    */
      85             :   unsigned int numBoundaryIDs() const;
      86             : 
      87             :   /**
      88             :    * Test if the supplied boundary name is valid for this object
      89             :    * @param name A BoundaryName to check
      90             :    * @return True if the given id is valid for this object
      91             :    */
      92             :   bool hasBoundary(const BoundaryName & name) const;
      93             : 
      94             :   /**
      95             :    * Test if the supplied vector of boundary names are valid for this object
      96             :    * @param names A vector of BoundaryNames to check
      97             :    * @return True if the given ids are valid for this object
      98             :    */
      99             :   bool hasBoundary(const std::vector<BoundaryName> & names) const;
     100             : 
     101             :   /**
     102             :    * Test if the supplied boundary ids are valid for this object
     103             :    * @param id A BoundaryID to check
     104             :    * @return True if the given id is valid for this object
     105             :    */
     106             :   bool hasBoundary(const BoundaryID & id) const;
     107             : 
     108             :   /**
     109             :    * Test if the supplied vector boundary ids are valid for this object
     110             :    * @param ids A vector of BoundaryIDs ids to check
     111             :    * @param type A flag for the type of matching to perform: ALL requires that all supplied
     112             :    * ids must match those of the object; ANY requires that any one of the supplied ids must
     113             :    * match those of the object
     114             :    * @return True if the all of the given ids are found within the ids for this object
     115             :    */
     116             :   bool hasBoundary(const std::vector<BoundaryID> & ids, TEST_TYPE type = ALL) const;
     117             : 
     118             :   /**
     119             :    * Test if the supplied set of boundary ids are valid for this object
     120             :    * @param ids A std::set of BoundaryIDs to check
     121             :    * @param type A flag for the type of matching to perform: ALL requires that all supplied
     122             :    * ids must match those of the object; ANY requires that any one of the supplied ids must
     123             :    * match those of the object
     124             :    *
     125             :    * @return True if the all of the given ids are found within the ids for this object
     126             :    * \see isSubset
     127             :    */
     128             :   bool hasBoundary(const std::set<BoundaryID> & ids, TEST_TYPE type = ALL) const;
     129             : 
     130             :   /**
     131             :    * Test if the class boundary ids are a subset of the supplied objects
     132             :    * @param ids A std::set of boundaries to check
     133             :    * @return True if all of the boundary ids for this class are found within the given ids (opposite
     134             :    * of hasBoundary)
     135             :    * \see hasBoundary
     136             :    */
     137             :   bool isBoundarySubset(const std::set<BoundaryID> & ids) const;
     138             : 
     139             :   /*
     140             :    * Test if the class boundary ids are a subset of the supplied objects
     141             :    * @param ids A std::set of Boundary IDs to check
     142             :    * @return True if all of the boundary ids for this class are found within the given ids (opposite
     143             :    * of hasBoundary)
     144             :    * \see hasBoundary
     145             :    */
     146             :   bool isBoundarySubset(const std::vector<BoundaryID> & ids) const;
     147             : 
     148             :   /**
     149             :    * Check if a material property is valid for all boundaries of this object
     150             :    *
     151             :    * This method returns true if the supplied property name has been declared
     152             :    * in a Material object on the boundary ids for this object.
     153             :    *
     154             :    * @tparam T The type of material property
     155             :    * @param prop_name the name of the property to query
     156             :    * @return true if the property exists for all boundary ids of the object, otherwise false
     157             :    */
     158             :   template <typename T, bool is_ad = false>
     159             :   bool hasBoundaryMaterialProperty(const std::string & prop_name) const;
     160             : 
     161             :   /**
     162             :    * Returns true if this object has been restricted to a boundary
     163             :    * @see MooseObject
     164             :    */
     165             :   virtual bool boundaryRestricted() const;
     166             : 
     167             :   /**
     168             :    * Returns the set of all boundary ids for the entire mesh
     169             :    * @return A const reference the the boundary ids for the entire mesh
     170             :    */
     171             :   const std::set<BoundaryID> & meshBoundaryIDs() const;
     172             : 
     173             :   /**
     174             :    * Whether integrity/coverage checking should be conducted for moose variables used in this
     175             :    * object. This should return true if variables are only evaluated locally, e.g. on the current
     176             :    * node or element. This should return false if evaluation of this object entails non-local
     177             :    * variable evaluations
     178             :    */
     179     1186549 :   virtual bool checkVariableBoundaryIntegrity() const { return true; }
     180             : 
     181             : private:
     182             :   /// Pointer to FEProblemBase
     183             :   FEProblemBase * _bnd_feproblem;
     184             : 
     185             :   /// Point to mesh
     186             :   MooseMesh * _bnd_mesh;
     187             : 
     188             :   /// Set of the boundary ids
     189             :   std::set<BoundaryID> _bnd_ids;
     190             : 
     191             :   /// Vector of the boundary ids
     192             :   std::vector<BoundaryID> _vec_ids;
     193             : 
     194             :   /// Vector the the boundary names
     195             :   std::vector<BoundaryName> _boundary_names;
     196             : 
     197             :   /// Flag for allowing dual restriction with BlockRestrictable
     198             :   const bool _bnd_dual_restrictable;
     199             : 
     200             :   /// An empty set for referencing when block_ids is not included
     201             :   const std::set<SubdomainID> _empty_block_ids;
     202             : 
     203             :   /// Reference to the block_ids, defaults to an empty set if not provided
     204             :   const std::set<SubdomainID> & _block_ids;
     205             : 
     206             :   /// Thread id for this object
     207             :   THREAD_ID _bnd_tid;
     208             : 
     209             :   /// Pointer to MaterialData for boundary (@see hasBoundaryMaterialProperty)
     210             :   const MaterialData & _bnd_material_data;
     211             : 
     212             :   /// Whether or not this object is restricted to nodesets
     213             :   bool _bnd_nodal;
     214             : 
     215             :   /// The moose object that this is an interface for
     216             :   const MooseObject & _moose_object;
     217             : 
     218             :   /**
     219             :    * An initialization routine needed for dual constructors
     220             :    */
     221             :   void initializeBoundaryRestrictable();
     222             : 
     223             : protected:
     224             :   /**
     225             :    * A helper method to avoid circular #include problems.
     226             :    * @see hasBoundaryMaterialProperty
     227             :    */
     228             :   bool hasBoundaryMaterialPropertyHelper(const std::string & prop_name) const;
     229             : };
     230             : 
     231             : template <typename T, bool is_ad>
     232             : bool
     233          25 : BoundaryRestrictable::hasBoundaryMaterialProperty(const std::string & prop_name) const
     234             : {
     235             :   // If you get here the supplied property is defined on all boundaries, but is still subject
     236             :   // existence in the MateialData class
     237          42 :   return hasBoundaryMaterialPropertyHelper(prop_name) &&
     238          42 :          _bnd_material_data.haveGenericProperty<T, is_ad>(prop_name);
     239             : }

Generated by: LCOV version 1.14