LCOV - code coverage report
Current view: top level - src/controls - WebServerControlTypeRegistration.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 7edd10 Lines: 1 1 100.0 %
Date: 2025-11-11 08:32:45 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             : #include "WebServerControlTypeRegistration.h"
      11             : 
      12             : #include <string>
      13             : 
      14             : #include "libmesh/parallel_eigen.h"
      15             : 
      16             : /**
      17             :  * Registers the base parameter types that are controllable
      18             :  * in the WebServerControl.
      19             :  *
      20             :  * You can use the common macros from the header file
      21             :  * to register custom types as controllable in your
      22             :  * own application or derived WebServerControl.
      23             :  */
      24             : namespace Moose::WebServerControlTypeRegistration
      25             : {
      26             : // Scalar types
      27             : registerWebServerControlScalar(bool);
      28             : registerWebServerControlScalar(Real);
      29             : registerWebServerControlScalar(int);
      30             : registerWebServerControlScalar(std::string);
      31             : 
      32             : // Vector types
      33             : registerWebServerControlVector(Real);
      34             : registerWebServerControlVector(int);
      35             : registerWebServerControlVector(std::string);
      36             : 
      37             : // RealEigenMatrix
      38         232 : registerWebServerControlType(RealEigenMatrix,
      39             :                              [](const nlohmann::json & json_value) -> RealEigenMatrix
      40             :                              {
      41             :                                const auto vec_of_vec =
      42             :                                    json_value.get<std::vector<std::vector<double>>>();
      43             :                                const auto nrows = vec_of_vec.size();
      44             :                                if (nrows == 0)
      45             :                                  return RealEigenMatrix::Zero(0, 0);
      46             :                                const auto ncols = vec_of_vec[0].size();
      47             : 
      48             :                                RealEigenMatrix matrix;
      49             :                                matrix.resize(nrows, ncols);
      50             :                                for (const auto i : make_range(nrows))
      51             :                                {
      52             :                                  const auto & row = vec_of_vec[i];
      53             :                                  if (row.size() != ncols)
      54             :                                    throw std::runtime_error("Matrix is jagged");
      55             : 
      56             :                                  for (const auto j : index_range(row))
      57             :                                    matrix(i, j) = row[j];
      58             :                                }
      59             : 
      60             :                                return matrix;
      61             :                              });
      62             : }

Generated by: LCOV version 1.14