-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Francesco Rizzi
committed
Nov 13, 2024
1 parent
fbc8dc2
commit fc02ae9
Showing
3 changed files
with
89 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
|
||
#include <gtest/gtest.h> | ||
#include "pressio/rom_subspaces.hpp" | ||
#include "pressio/rom_galerkin_steady.hpp" | ||
|
||
namespace{ | ||
|
||
struct MyFom | ||
{ | ||
using state_type = Eigen::VectorXd; | ||
using residual_type = state_type; | ||
int N_ = {}; | ||
|
||
MyFom(int N): N_(N){} | ||
residual_type createResidual() const{ return residual_type(N_); } | ||
|
||
Eigen::MatrixXd createResultOfJacobianActionOn(const Eigen::MatrixXd & B) const{ | ||
Eigen::MatrixXd A(N_, B.cols()); | ||
return A; | ||
} | ||
|
||
void residual(const state_type & u, | ||
residual_type & r) const | ||
{} | ||
|
||
template<class OperandType, class ResultType> | ||
void jacobianAction(const state_type &, | ||
OperandType const &, | ||
ResultType &) const | ||
{} | ||
|
||
void residualAndJacobianAction(const state_type & u, | ||
residual_type & r, | ||
const Eigen::MatrixXd & B, | ||
std::optional<Eigen::MatrixXd *> Ain) const | ||
{ | ||
} | ||
|
||
}; | ||
|
||
} | ||
|
||
TEST(rom_galerkin_steady, default_matrix_free) | ||
{ | ||
using namespace pressio; | ||
|
||
/* | ||
just supposed to compile for now | ||
*/ | ||
|
||
log::initialize(logto::terminal); | ||
log::setVerbosity({log::level::debug}); | ||
|
||
constexpr int N = 8; | ||
using fom_t = MyFom; | ||
fom_t fomSystem(N); | ||
|
||
using phi_t = Eigen::Matrix<double, -1,-1>; | ||
phi_t phi(N, 3); | ||
|
||
using reduced_state_type = Eigen::VectorXd; | ||
typename fom_t::state_type shift(N); | ||
auto space = rom::create_trial_column_subspace<reduced_state_type>(phi, shift, false); | ||
|
||
auto problem = rom::galerkin::create_steady_problem(space, fomSystem); | ||
|
||
using tag = linearsolvers::iterative::GMRES; | ||
auto nonLinSolver = experimental::create_matrixfree_newtonkrylov_solver<tag>(problem); | ||
|
||
auto romState = space.createReducedState(); | ||
nonLinSolver.solve(romState); | ||
|
||
log::finalize(); | ||
} |