1 #include "test_location_base.h"     4 #include <deal.II/base/conditional_ostream.h>     5 #include <deal.II/lac/trilinos_sparse_matrix.h>     6 #include "parameters/all_parameters.h"     7 #include "pod_basis_base.h"     8 #include "reduced_order_solution.h"     9 #include "linear_solver/linear_solver.h"    10 #include <Epetra_Vector.h>    11 #include <EpetraExt_MatrixMatrix.h>    12 #include <Epetra_LinearProblem.h>    14 #include <Amesos_Lapack.h>    15 #include "flow_solver/flow_solver.h"    16 #include "flow_solver/flow_solver_factory.h"    17 #include <deal.II/base/parameter_handler.h>    20 namespace ProperOrthogonalDecomposition {
    22 template <
int dim, 
int nstate>
    24         : parameter(parameter)
    25         , rom_solution(
std::move(rom_solution))
    26         , mpi_communicator(MPI_COMM_WORLD)
    27         , mpi_rank(dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD))
    28         , pcout(
std::cout, mpi_rank==0)
    30     pcout << 
"Creating ROM test location..." << std::endl;
    35     pcout << 
"ROM test location created. Error estimate updated." << std::endl;
    38 template <
int dim, 
int nstate>
    40     pcout << 
"Computing adjoint-based error estimate between ROM and FOM..." << std::endl;
    42     dealii::ParameterHandler dummy_handler;
    45     const bool compute_dRdW = 
true;
    46     flow_solver->dg->assemble_residual(compute_dRdW);
    47     dealii::TrilinosWrappers::SparseMatrix system_matrix_transpose = dealii::TrilinosWrappers::SparseMatrix();
    48     system_matrix_transpose.copy_from(flow_solver->dg->system_matrix_transpose);
    51     dealii::LinearAlgebra::distributed::Vector<double> adjoint(flow_solver->dg->right_hand_side);
    53     dealii::LinearAlgebra::distributed::Vector<double> gradient(
rom_solution->gradient);
    57     if (
rom_solution->params.reduced_order_param.FOM_error_linear_solver_type == Parameters::ReducedOrderModelParam::LinearSolverEnum::gmres){
    65         linear_solver_param.
linear_solver_type = Parameters::LinearSolverParam::LinearSolverEnum::gmres;
    70     if (
rom_solution->params.reduced_order_param.residual_error_bool == 
true){
    75         solve_linear(system_matrix_transpose, gradient*=-1.0, adjoint, linear_solver_param);
    85 template <
int dim, 
int nstate>
    87     pcout << 
"Computing total error estimate between FOM and updated ROM..." << std::endl;
    89     pcout << 
"Parameter: " << 
parameter <<  
". Total error estimate between FOM and updated ROM: " << 
total_error << std::endl;
 double ilut_drop
Threshold to drop terms close to zero. 
Parameters related to the linear solver. 
double fom_to_initial_rom_error
Error between FOM and initial ROM. 
Base class for a ROM/HROM point, differences would be in the second DWR error indicator. 
std::pair< unsigned int, double > solve_linear(const dealii::TrilinosWrappers::SparseMatrix &system_matrix, dealii::LinearAlgebra::distributed::Vector< double > &right_hand_side, dealii::LinearAlgebra::distributed::Vector< double > &solution, const Parameters::LinearSolverParam ¶m)
double ilut_atol
Add ilu_rtol to diagonal for more diagonal dominance. 
Files for the baseline physics. 
int restart_number
Number of iterations before restarting GMRES. 
TestLocationBase(const RowVectorXd ¶meter, std::unique_ptr< ROMSolution< dim, nstate >> rom_solution)
Constructor. 
double linear_residual
Tolerance for linear residual. 
RowVectorXd parameter
Parameter. 
void compute_FOM_to_initial_ROM_error()
Compute adjoint error estimate between FOM and initial ROM. 
dealii::ConditionalOStream pcout
ConditionalOStream. 
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. 
LinearSolverEnum linear_solver_type
direct or gmres. 
double ilut_rtol
Multiplies diagonal by ilut_rtol for more diagonal dominance. 
int max_iterations
Maximum number of linear iteration. 
double initial_rom_to_final_rom_error
Error from initial ROM to final ROM. 
double total_error
Total error. 
int ilut_fill
ILU fill-in. 
std::unique_ptr< ROMSolution< dim, nstate > > rom_solution
ROM solution. 
Class to hold information about the reduced-order solution. 
void compute_total_error()
Compute total error between final ROM and FOM.