LCOV - code coverage report
Current view: top level - include/transfers - MultiAppUserObjectTransfer.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 1 1 100.0 %
Date: 2025-07-17 01:28:37 Functions: 1 1 100.0 %
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 "MultiAppConservativeTransfer.h"
      14             : 
      15             : /**
      16             :  * Loops over a target mesh and uses either node or element centroid location (based on the target
      17             :  * variable type) for sampling a user object (i.e. the object must implement `spatialValue` API).
      18             :  * This value is then stored into the target variable (either nodal or elemental).
      19             :  * Note: Higher order variables are not supported.
      20             :  *
      21             :  * This transfer can be block and boundary restricted. The BlockRestrictable and
      22             :  * BoundaryRestrictable classes cannot be used, because they would check the block, boundary and
      23             :  * target variable during object construction. At that time, the underlying sub-app is not created
      24             :  * yet, so this check would fail. That is also the reason why the block and boundary restriction are
      25             :  * pulled in during `execute` and not in the constructor. Also note, that in a sub-app setup there
      26             :  * might be multiple instances of the sub-app, so this check needs to be done on per-sub-app basis.
      27             :  */
      28             : class MultiAppUserObjectTransfer : public MultiAppConservativeTransfer
      29             : {
      30             : public:
      31             :   static InputParameters validParams();
      32             : 
      33             :   MultiAppUserObjectTransfer(const InputParameters & parameters);
      34             : 
      35             :   virtual void execute() override;
      36             : 
      37             : protected:
      38             :   /**
      39             :    * @return true if this transfer is restricted to a block, otherwise false
      40             :    */
      41             :   bool blockRestricted() const;
      42             : 
      43             :   /**
      44             :    * @return true if this transfer is restricted to a boundary, otherwise false
      45             :    */
      46             :   bool boundaryRestricted() const;
      47             : 
      48             :   /**
      49             :    * Check that element 'elem' is part of the domain this transfer is restricted to
      50             :    */
      51             :   bool hasBlocks(const Elem * elem) const;
      52             : 
      53             :   /**
      54             :    * Check that Node 'node' belongs to block this transfer is restricted to
      55             :    *
      56             :    * @param mesh The mesh this transfer is active on
      57             :    * @param node The node to check
      58             :    */
      59             :   bool hasBlocks(const MooseMesh * mesh, const Node * node) const;
      60             : 
      61             :   /**
      62             :    * Check that the node belongs to boundary this transfer is restricted to
      63             :    *
      64             :    * @return true if the node belongs to the boundary this transfer is restricted to, false
      65             :    * otherwise
      66             :    * @param mesh The mesh this transfer is active on
      67             :    * @param node The node to check
      68             :    */
      69             :   bool isBoundaryNode(const MooseMesh * mesh, const Node * node) const;
      70             : 
      71             :   /**
      72             :    * Check that the element belongs to boundary this transfer is restricted to
      73             :    *
      74             :    * @return true if the element belongs to the boundary this transfer is restricted to, false
      75             :    * otherwise
      76             :    * @param mesh The mesh this transfer is active on
      77             :    * @param elem The element to check
      78             :    */
      79             :   bool isBoundaryElem(const MooseMesh * mesh, const Elem * elem) const;
      80             : 
      81             :   /**
      82             :    * Gets the UserObject to transfer from when transferring from_multiapp
      83             :    * @param p The point in the parent app that is being transferred to
      84             :    * @return the subapp index, will return static_cast<unsigned int>(-1) if none is found
      85             :    */
      86             :   unsigned int findSubAppToTransferFrom(const Point & p);
      87             : 
      88             :   std::string _user_object_name;
      89             : 
      90             :   /**
      91             :    * Boolean variable to generate error if every parent app node
      92             :    * cannot be mapped to a subApp during from_multiapp transfer
      93             :    **/
      94             :   const bool _all_parent_nodes_contained_in_sub_app;
      95             : 
      96             :   /// whether to check the bounding box check or not
      97             :   const bool _skip_bbox_check;
      98             : 
      99             :   /// Whether to utilize the nearest sub-app to transfer from
     100             :   const bool & _nearest_sub_app;
     101             : 
     102             : private:
     103         152 :   bool usesMooseAppCoordTransform() const override { return true; }
     104             : 
     105             :   /// Set of block ids this transfer is restricted to
     106             :   std::set<SubdomainID> _blk_ids;
     107             : 
     108             :   /// Set of the boundary ids
     109             :   std::set<BoundaryID> _bnd_ids;
     110             : };

Generated by: LCOV version 1.14