1 #include "build_NNLS_problem.h" 2 #include "reduced_order/pod_basis_offline.h" 3 #include "parameters/all_parameters.h" 4 #include "flow_solver/flow_solver.h" 5 #include "flow_solver/flow_solver_factory.h" 6 #include "ode_solver/ode_solver_factory.h" 7 #include "reduced_order/assemble_ECSW_residual.h" 8 #include "linear_solver/NNLS_solver.h" 9 #include "linear_solver/helper_functions.h" 10 #include "reduced_order/pod_adaptive_sampling.h" 11 #include "reduced_order/adaptive_sampling_base.h" 17 template <
int dim,
int nstate>
19 const dealii::ParameterHandler ¶meter_handler_input)
21 , parameter_handler(parameter_handler_input)
26 if(ode_solver_type == ODEEnum::pod_galerkin_solver){
27 return std::make_shared<Epetra_CrsMatrix>(pod_basis);
29 else if(ode_solver_type == ODEEnum::pod_petrov_galerkin_solver){
30 Epetra_Map system_matrix_rowmap = system_matrix.RowMap();
31 Epetra_CrsMatrix petrov_galerkin_basis(Epetra_DataAccess::Copy, system_matrix_rowmap, pod_basis.NumGlobalCols());
32 EpetraExt::MatrixMatrix::Multiply(system_matrix,
false, pod_basis,
false, petrov_galerkin_basis,
true);
34 return std::make_shared<Epetra_CrsMatrix>(petrov_galerkin_basis);
42 template <
int dim,
int nstate>
45 Epetra_MpiComm Comm( MPI_COMM_WORLD );
48 auto ode_solver_type = Parameters::ODESolverParam::ODESolverEnum::pod_petrov_galerkin_solver;
52 parameter_sampling->configureInitialParameterSpace();
53 parameter_sampling->placeInitialSnapshots();
54 parameter_sampling->current_pod->computeBasis();
55 MatrixXd snapshot_parameters = parameter_sampling->snapshot_parameters;
58 std::cout <<
"Construct instance of Assembler..."<< std::endl;
62 constructor_NNLS_problem.
fom_locations = parameter_sampling->fom_locations;
64 std::cout <<
"Build Problem..."<< std::endl;
130 std::cout <<
"Load Matlab Results" << std::endl;
131 Eigen::MatrixXd C_MAT = load_csv<MatrixXd>(
"C.csv");
132 Eigen::MatrixXd d_MAT = load_csv<MatrixXd>(
"d.csv");
133 Eigen::MatrixXd x_MAT = load_csv<MatrixXd>(
"x.csv");
135 const int rank = Comm.MyPID();
136 int rows = (constructor_NNLS_problem.
A_T->trilinos_matrix()).NumGlobalCols();
137 Epetra_Map bMap(rows, (rank == 0) ? rows: 0, 0, Comm);
138 Epetra_Vector b_Epetra(bMap);
139 auto b = constructor_NNLS_problem.
b;
140 unsigned int local_length = bMap.NumMyElements();
141 for(
unsigned int i = 0 ; i < local_length ; i++){
147 std::cout <<
"Create NNLS problem..."<< std::endl;
148 std::cout << all_parameters->hyper_reduction_param.NNLS_tol << std::endl;
149 std::cout << all_parameters->hyper_reduction_param.NNLS_max_iter << std::endl;
151 std::cout <<
"Solve NNLS problem..."<< std::endl;
153 bool exit_con = NNLS_prob.
solve();
156 Epetra_Vector weights = NNLS_prob.get_solution();
157 Eigen::MatrixXd weights_eig(weights.GlobalLength(),1);
158 epetra_to_eig_vec(weights.GlobalLength(), weights , weights_eig);
161 exit_con &= x_MAT.isApprox(weights_eig, 1E-2);
163 std::cout <<
"ECSW Weights"<< std::endl;
164 std::cout << weights << std::endl;
std::vector< dealii::LinearAlgebra::distributed::Vector< double > > fom_locations
Vector of parameter-ROMTestLocation pairs.
std::shared_ptr< dealii::TrilinosWrappers::SparseMatrix > A_T
Matrix for the NNLS Problem.
Files for the baseline physics.
ODESolverEnum
Types of ODE solver.
Main parameter class that contains the various other sub-parameter classes.
static std::unique_ptr< FlowSolver< dim, nstate > > select_flow_case(const Parameters::AllParameters *const parameters_input, const dealii::ParameterHandler ¶meter_handler_input)
Factory to return the correct flow solver given input file.
const Parameters::AllParameters *const all_parameters
Pointer to all parameters.
dealii::LinearAlgebra::ReadWriteVector< double > b
RHS Vector for the NNLS Problem.
const dealii::ParameterHandler & parameter_handler
Dummy parameter handler because flowsolver requires it.
bool solve()
Call to solve NNLS problem.
BuildNNLSProblem(const Parameters::AllParameters *const parameters_input, const dealii::ParameterHandler ¶meter_handler_input)
Constructor.
int run_test() const override
Run Assemble Problem ECSW.
Base class of all the tests.
void build_problem() override
Fill entries of A and b.