https://mooseframework.inl.gov
WebServerControlTypeRegistration.C
Go to the documentation of this file.
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 
11 
12 #include <string>
13 
14 #include "libmesh/parallel_eigen.h"
15 
25 {
26 // Scalar types
31 
32 // Vector types
36 
37 // 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 }
registerWebServerControlType(RealEigenMatrix, [](const nlohmann::json &json_value) -> RealEigenMatrix { const auto vec_of_vec=json_value.get< std::vector< std::vector< double >>>();const auto nrows=vec_of_vec.size();if(nrows==0) return RealEigenMatrix::Zero(0, 0);const auto ncols=vec_of_vec[0].size();RealEigenMatrix matrix;matrix.resize(nrows, ncols);for(const auto i :make_range(nrows)) { const auto &row=vec_of_vec[i];if(row.size() !=ncols) throw std::runtime_error("Matrix is jagged");for(const auto j :index_range(row)) matrix(i, j)=row[j];} return matrix;})
Defines classes for registering values that can be parsed, communicated, and stored in the WebServerC...
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealEigenMatrix
Definition: MooseTypes.h:151
IntRange< T > make_range(T beg, T end)
auto index_range(const T &sizable)