LCOV - code coverage report
Current view: top level - include/problems - DumpObjectsProblem.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 8601ad Lines: 13 50 26.0 %
Date: 2025-07-18 13:27:08 Functions: 13 49 26.5 %
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 "FEProblemBase.h"
      13             : 
      14             : class DumpObjectsNonlinearSystem;
      15             : 
      16             : #define captureDump(method_name, path)                                                             \
      17             :   void method_name(                                                                                \
      18             :       const std::string & type, const std::string & name, InputParameters & parameters) override   \
      19             :   {                                                                                                \
      20             :     dumpObjectHelper(path, type, name, parameters);                                                \
      21             :     FEProblemBase::method_name(type, name, parameters);                                            \
      22             :   }
      23             : 
      24             : #define captureDumpUO(method_name, path)                                                           \
      25             :   std::vector<std::shared_ptr<UserObject>> method_name(                                            \
      26             :       const std::string & type, const std::string & name, InputParameters & parameters) override   \
      27             :   {                                                                                                \
      28             :     dumpObjectHelper(path, type, name, parameters);                                                \
      29             :     FEProblemBase::method_name(type, name, parameters);                                            \
      30             :     return std::vector<std::shared_ptr<UserObject>>();                                             \
      31             :   }
      32             : 
      33             : /**
      34             :  * Specialization of SubProblem for dumping generated objects as input file syntax
      35             :  */
      36             : class DumpObjectsProblem : public FEProblemBase
      37             : {
      38             : public:
      39             :   static InputParameters validParams();
      40             : 
      41             :   DumpObjectsProblem(const InputParameters & parameters);
      42             : 
      43             :   using FEProblemBase::addAuxVariable;
      44             :   using FEProblemBase::addVariable;
      45             : 
      46             :   /// output input blocks for a given action path
      47             :   void dumpGeneratedSyntax(const std::string path);
      48             :   /// output input blocks for all paths
      49             :   void dumpAllGeneratedSyntax() const;
      50             : 
      51             :   /// output data in solve (if ever called)
      52          20 :   virtual void solve(unsigned int /*nl_sys_num*/) override {}
      53           0 :   virtual void solveLinearSystem(unsigned int /*linear_sys_num*/,
      54             :                                  const Moose::PetscSupport::PetscOptions *) override
      55             :   {
      56           0 :   }
      57             : 
      58             :   // output data (we expect to call this from the DumpObjectsAction)
      59             :   void printObjects();
      60             : 
      61             :   virtual void initialSetup() override;
      62          20 :   virtual void advanceState() override {}
      63          20 :   virtual void timestepSetup() override {}
      64         120 :   virtual void execute(const ExecFlagType & /*exec_type*/) override {}
      65         120 :   virtual void outputStep(ExecFlagType /*type*/) override {}
      66          20 :   virtual void updateActiveObjects() override {}
      67          20 :   virtual void onTimestepEnd() override {}
      68          20 :   virtual void computeIndicators() override {}
      69          20 :   virtual void computeMarkers() override {}
      70           0 :   virtual bool adaptMesh() override { return false; }
      71           0 :   virtual void addLineSearch(const InputParameters & /*parameters*/) override {}
      72             : 
      73             : protected:
      74             :   void dumpObjectHelper(const std::string & system,
      75             :                         const std::string & type,
      76             :                         const std::string & name,
      77             :                         const InputParameters & parameters);
      78             : 
      79             :   void dumpVariableHelper(const std::string & system,
      80             :                           const std::string & var_name,
      81             :                           libMesh::FEFamily family,
      82             :                           Order order,
      83             :                           Real scale_factor,
      84             :                           const std::set<SubdomainID> * const active_subdomains);
      85             : 
      86             :   /// build a text snippet of the minimal set of parameters that need to be specified
      87             :   std::string deduceNecessaryParameters(const std::string & type,
      88             :                                         const InputParameters & parameters);
      89             : 
      90             :   /// create a string map form parameter names to stringified parameter values
      91             :   std::map<std::string, std::string> stringifyParameters(const InputParameters & parameters);
      92             : 
      93             :   /// store input syntax to build objects generated by a specific action
      94             :   std::map<std::string, std::map<std::string, std::string>> _generated_syntax;
      95             : 
      96             :   /// Whether to include all user-specified parameters in the dump or only parameters that differ from the default value
      97             :   const bool _include_all_user_specified_params;
      98             : 
      99             : public:
     100             :   // clang-format off
     101           0 :   captureDump(addAuxKernel,           "AuxKernels")
     102           0 :   captureDump(addAuxScalarKernel,     "AuxScalarKernels")
     103           0 :   captureDump(addAuxVariable,         "AuxVariables")
     104           0 :   captureDump(addBoundaryCondition,   "BCs")
     105           0 :   captureDump(addConstraint,          "Constraints")
     106          40 :   captureDump(addConvergence,         "Convergence")
     107           0 :   captureDump(addDamper,              "Dampers")
     108           0 :   captureDump(addDGKernel,            "DGKernels")
     109           0 :   captureDump(addDiracKernel,         "DiracKernels")
     110           0 :   captureDump(addDistribution,        "Distributions")
     111           0 :   captureDump(addFunction,            "Functions")
     112           0 :   captureDump(addFunctorMaterial,     "FunctorMaterials")
     113           0 :   captureDump(addFVBC,                "FVBCs")
     114           0 :   captureDump(addFVInitialCondition,  "FVICs")
     115           0 :   captureDump(addFVInterfaceKernel,   "FVInterfaceKernels")
     116           0 :   captureDump(addFVKernel,            "FVKernels")
     117           0 :   captureDump(addHDGKernel,           "HDGKernels")
     118           0 :   captureDump(addIndicator,           "Adaptivity/Indicators")
     119           0 :   captureDump(addInitialCondition,    "ICs")
     120           0 :   captureDump(addInterfaceKernel,     "InterfaceKernels")
     121          20 :   captureDump(addKernel,              "Kernels")
     122           0 :   captureDump(addLinearFVBC,          "LinearFVBCs")
     123           0 :   captureDump(addLinearFVKernel,      "LinearFVKernels")
     124           0 :   captureDump(addMarker,              "Adaptivity/Markers")
     125          20 :   captureDump(addMaterial,            "Materials")
     126           0 :   captureDump(addMeshDivision,        "MeshDivisions")
     127           0 :   captureDump(addMultiApp,            "MultiApps")
     128           0 :   captureDump(addNodalKernel,         "NodalKernels")
     129           0 :   captureDump(addPostprocessor,       "Postprocessors")
     130           0 :   captureDump(addPredictor,           "Executioner/Predictor")
     131           0 :   captureDump(addSampler,             "Samplers")
     132           0 :   captureDump(addScalarKernel,        "ScalarKernels")
     133           0 :   captureDump(addTransfer,            "Transfers")
     134           0 :   captureDump(addTimeIntegrator,      "Executioner/TimeIntegrators")
     135           0 :   captureDumpUO(addUserObject,        "UserObjects")
     136          20 :   captureDump(addVariable,            "Variables")
     137           0 :   captureDump(addVectorPostprocessor, "VectorPostprocessors")
     138             :   // clang-format off
     139             : };

Generated by: LCOV version 1.14