19 "computed from PODReducedBasisTrainer.");
20 params.
addParam<std::vector<std::string>>(
"change_rank",
21 std::vector<std::string>(0),
22 "Names of variables whose rank should be changed.");
23 params.
addParam<std::vector<unsigned int>>(
25 std::vector<unsigned int>(0),
26 "The new ranks that each variable in 'change_rank' shall have.");
27 params.
addParam<
Real>(
"penalty", 1e5,
"The penalty parameter for Dirichlet BCs.");
33 _change_rank(getParam<
std::vector<
std::string>>(
"change_rank")),
34 _new_ranks(getParam<
std::vector<unsigned
int>>(
"new_ranks")),
35 _var_names(getModelData<
std::vector<
std::string>>(
"_var_names")),
36 _tag_types(getModelData<
std::vector<
std::string>>(
"_tag_types")),
37 _base(getModelData<
std::vector<
std::vector<DenseVector<
Real>>>>(
"_base")),
38 _red_operators(getModelData<
std::vector<DenseMatrix<
Real>>>(
"_red_operators")),
39 _penalty(getParam<
Real>(
"penalty")),
44 "The size of 'new_ranks' is not equal to the ",
45 "size of 'change_rank' ",
50 for (
unsigned int var_i = 0; var_i <
_new_ranks.size(); ++var_i)
52 paramError(
"new_ranks",
"The values should be greater than 0!");
75 DenseVector<Real> & inp_vector,
98 unsigned int sum_ranks = 0;
102 for (
unsigned int var_i = 0; var_i <
_var_names.size(); ++var_i)
105 for (
unsigned int var_j = 0; var_j <
_change_rank.size(); ++var_j)
115 "' is higher than the original rank (",
117 ")! Switched to original rank.");
130 _rhs = DenseVector<Real>(sum_ranks);
131 _coeffs = DenseVector<Real>(sum_ranks);
138 for (
unsigned int var_i = 0; var_i <
_var_names.size(); var_i++)
155 unsigned int row_start = 0;
165 for (
unsigned int var_i = 0; var_i <
_var_names.size(); ++var_i)
172 unsigned int col_start = 0;
174 for (
unsigned int var_j = 0; var_j <
_var_names.size(); ++var_j)
178 if (i < params.size())
189 if (i < params.size())
206 unsigned int counter = 0;
207 for (
unsigned int var_i = 0; var_i <
_var_names.size(); var_i++)
213 for (
unsigned int base_i = 0; base_i <
_final_ranks[var_i]; ++base_i)
215 for (
unsigned int dof_i = 0; dof_i <
_base[var_i][base_i].size(); ++dof_i)
224 std::string var_name)
228 mooseError(
"Variable '", var_name,
"' does not exist in the POD-RB surrogate!");
230 unsigned int var_i = std::distance(
_var_names.begin(), it);
232 if (inp_vector.size() !=
_base[var_i][0].size())
237 "' does not match the size of the stored base vector (",
238 _base[var_i][0].size(),
239 ") in POD-RB surrogate!");
243 unsigned int base_begin = 0;
247 for (
unsigned int base_i = 0; base_i <
_final_ranks[var_i]; ++base_i)
249 for (
unsigned int dof_i = 0; dof_i < inp_vector.size(); ++dof_i)
250 inp_vector(dof_i) +=
_coeffs(base_i + base_begin) *
_base[var_i][base_i](dof_i);
261 mooseError(
"Variable '", var_name,
"' not found!");
PODReducedBasisSurrogate(const InputParameters ¶meters)
std::vector< DenseVector< Real > > _approx_solution
Reconstructed solution for each variable.
void reconstructApproximateSolution()
Reconstruct the approximate solution vector using the stored coefficients.
virtual void zero() override final
Real getNodalQoI(std::string var_name, unsigned int qoi_type) const
Get the nodal QoI of the reconstructed solution for a given variable.
DenseVector< Real > _rhs
The reduced right hand side.
const Real _penalty
Penalty parameter for Dirichlet BCs.
void mooseWarning(Args &&... args) const
std::vector< unsigned int > _final_ranks
The final rank that should be used for every variable.
const std::vector< std::string > & _tag_types
Strings describing which operator is indepedent of the solution and which corresponds to a reduced Di...
static InputParameters validParams()
const std::vector< std::vector< DenseVector< Real > > > & _base
The basis vectors for all the variables.
registerMooseObject("StochasticToolsApp", PODReducedBasisSurrogate)
const std::vector< DenseMatrix< Real > > & _red_operators
The reduced operators in the same order as given in tag_types.
void paramError(const std::string ¶m, Args... args) const
DenseMatrix< Real > _sys_mx
The reduced system matrix.
void evaluateSolution(const std::vector< Real > ¶ms)
Get the reduced solution for a given parameter sample.
const std::vector< std::string > & _var_names
Vector containing the names of the variables we want to reconstruct.
void lu_solve(const DenseVector< Real > &b, DenseVector< Real > &x)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void initializeApproximateSolution()
Initialize approximate solution vector.
DenseVector< Real > _coeffs
Coefficients of the reduced order model.
void mooseError(Args &&... args) const
bool _initialized
Switch that is set to see if the ROM matrices and vectors are initialized.
void initializeReducedSystem()
Initialize reduced matrices, vectors and additional containers.
void solveReducedSystem(const std::vector< Real > ¶ms)
Assemble and solve the reduced equation system.
std::vector< std::string > _change_rank
A vector containing the number of basis functions each variable should use.
void ErrorVector unsigned int
std::vector< unsigned int > _new_ranks
The new rank the variable should have.
static InputParameters validParams()
std::vector< unsigned int > _comulative_ranks
Comulative ranks of the system. Used for indexing only.