LCOV - code coverage report
Current view: top level - include/functions - ChainControlParsedFunctionWrapper.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 2 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             : #include "MooseError.h"
      13             : #include "MooseTypes.h"
      14             : #include "ChainControlData.h"
      15             : #include "libmesh/parsed_function.h"
      16             : #include <string>
      17             : #include <vector>
      18             : 
      19             : class MooseApp;
      20             : class FEProblemBase;
      21             : class Function;
      22             : class ChainControlDataSystem;
      23             : 
      24             : /**
      25             :  * Wraps libMesh::ParsedFunction for use in ChainControls
      26             :  */
      27             : class ChainControlParsedFunctionWrapper
      28             : {
      29             : public:
      30             :   /**
      31             :    * Constructor
      32             :    *
      33             :    * @param moose_app App
      34             :    * @param fe_problem Problem
      35             :    * @param function_str Function expression
      36             :    * @param symbol_names Symbols used in the function expression string
      37             :    * @param symbol_values Values pairing with \c symbol_names
      38             :    */
      39             :   ChainControlParsedFunctionWrapper(MooseApp & moose_app,
      40             :                                     FEProblemBase & fe_problem,
      41             :                                     const std::string & function_str,
      42             :                                     const std::vector<std::string> & symbol_names,
      43             :                                     const std::vector<std::string> & symbol_values,
      44             :                                     const THREAD_ID tid = 0);
      45             : 
      46             :   /**
      47             :    * Evaluates the libMesh::ParsedFunction
      48             :    *
      49             :    * @param t Time
      50             :    * @param p Spatial point
      51             :    */
      52             :   Real evaluate(Real t, const Point & p);
      53             : 
      54             :   /**
      55             :    * Get list of Real-valued control data objects
      56             :    */
      57          36 :   std::vector<ChainControlData<Real> *> getRealChainControlData()
      58             :   {
      59          36 :     return _real_control_data_values;
      60             :   }
      61             : 
      62             :   /**
      63             :    * Get list of boolean-valued control data objects
      64             :    */
      65          36 :   std::vector<ChainControlData<bool> *> getBoolChainControlData()
      66             :   {
      67          36 :     return _bool_control_data_values;
      68             :   }
      69             : 
      70             : private:
      71             :   /// App
      72             :   MooseApp & _moose_app;
      73             :   /// Problem
      74             :   FEProblemBase & _fe_problem;
      75             : 
      76             :   /// Function expression
      77             :   const std::string & _function_str;
      78             :   /// Symbols used in the function expression string
      79             :   const std::vector<std::string> & _symbol_names;
      80             :   /// Values pairing with \c symbol_names
      81             :   const std::vector<std::string> & _symbol_values;
      82             : 
      83             :   /// Initial value for each function input
      84             :   std::vector<Real> _initial_values;
      85             : 
      86             :   /// Wrapped libMesh::ParsedFunction
      87             :   std::unique_ptr<ParsedFunction<Real>> _function_ptr;
      88             : 
      89             :   /// _input_values index for each Real control data value
      90             :   std::vector<unsigned int> _real_control_data_indices;
      91             :   /// Real control data values
      92             :   std::vector<ChainControlData<Real> *> _real_control_data_values;
      93             : 
      94             :   /// _input_values index for each bool control data value
      95             :   std::vector<unsigned int> _bool_control_data_indices;
      96             :   /// bool control data values
      97             :   std::vector<ChainControlData<bool> *> _bool_control_data_values;
      98             : 
      99             :   /// _input_values index for each scalar variable value
     100             :   std::vector<unsigned int> _scalar_indices;
     101             :   /// Scalar variable values
     102             :   std::vector<const VariableValue *> _scalar_values;
     103             : 
     104             :   /// _input_values index for each function value
     105             :   std::vector<unsigned int> _function_indices;
     106             :   /// Function values
     107             :   std::vector<const Function *> _function_values;
     108             : 
     109             :   /// libMesh::ParsedFunction input values
     110             :   std::vector<Real *> _input_values;
     111             : 
     112             :   /// Thread id passed from owning object
     113             :   const THREAD_ID _tid;
     114             : 
     115             :   /// Chain control data system
     116             :   ChainControlDataSystem & _chain_control_data_system;
     117             : 
     118             :   /**
     119             :    * Gets initial value, address, and input index for each function input
     120             :    */
     121             :   void initializeFunctionInputs();
     122             : 
     123             :   /**
     124             :    * Updates scalar values in wrapped function
     125             :    */
     126             :   void updateScalarVariableValues();
     127             : 
     128             :   /**
     129             :    * Updates function values in wrapped function
     130             :    *
     131             :    * @param t Time
     132             :    * @param p Spatial point
     133             :    */
     134             :   void updateFunctionValues(Real t, const Point & pt);
     135             : 
     136             :   /**
     137             :    * Updates control data values in wrapped function
     138             :    */
     139             :   void updateChainControlDataValues();
     140             : };

Generated by: LCOV version 1.14