Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DMD with shifted data #123

Merged
merged 93 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
22ead73
Initialize
Jun 15, 2022
6ebf8c5
set up shift nu dmd
Jun 15, 2022
0efb68b
Add state mean offset, and derivative mean offset for NonuniformDMD
siuwuncheung Jun 16, 2022
196e03a
save offset vectors
Jun 16, 2022
24c6dde
Merge branch 'shift-nudmd' of github.com:LLNL/libROM into shift-nudmd
Jun 16, 2022
b5dee2c
save phi inverse
Jun 16, 2022
e6dedc7
Add back in line
Jun 16, 2022
5c3536b
Fix the offset in computeDMDSnapshotPair
siuwuncheung Jun 16, 2022
a867add
fix typo
Jun 16, 2022
63b8b33
Fix a bug
siuwuncheung Jun 16, 2022
c80ce23
Remove redundant lines
siuwuncheung Jun 16, 2022
6b0fb9d
Remove redundant lines
Jun 17, 2022
54376b1
Remove redundant line
Jun 17, 2022
fdcdf35
Remove redundant lines
Jun 17, 2022
759d6e3
Remove redundant lines
Jun 17, 2022
1ec2a0d
Remove redundant lines
Jun 17, 2022
2bd142f
Remove redundant lines
Jun 17, 2022
b17ef40
Remove redundant lines
Jun 17, 2022
ebb8312
Remove redundant lines
Jun 17, 2022
2c3dbb6
Remove redundant lines
Jun 17, 2022
be1e559
Remove redundant lines
Jun 17, 2022
9948810
Remove redundant lines
Jun 17, 2022
36eb7d7
Remove redundant line
Jun 17, 2022
cc87a50
Attempt to debug
siuwuncheung Jun 17, 2022
bfba387
Add initial state as offset
siuwuncheung Jun 17, 2022
ef94984
fix adaptive dmd constructor
Jun 20, 2022
ae23eed
add new W0 columns
Jun 24, 2022
d79c49b
fix bug
Jun 24, 2022
7712f36
Q transpose mult
Jun 24, 2022
94c8655
fix transpose mult
Jun 24, 2022
e415ec4
add comment dylan requested
Jun 24, 2022
dcb5603
add comment
Jun 24, 2022
85ccd9d
Merge branch 'master' into shift-nudmd
siuwuncheung Jul 14, 2022
66d69df
Merge branch 'master' into shift-nudmd
siuwuncheung Jul 18, 2022
14a7504
Orthogonalize to play safe
siuwuncheung Jul 21, 2022
52472a5
Merge branch 'master' into shift-nudmd
Jul 26, 2022
8e7624a
Add derivative prediction
siuwuncheung Aug 5, 2022
a388738
Allow any offsets
siuwuncheung Aug 8, 2022
24f0b1d
Fix DMD derived class for working for both Adaptive DMD and Nonuniform
siuwuncheung Aug 8, 2022
b077988
Fix bug
siuwuncheung Aug 8, 2022
7f089ca
Minor fix
siuwuncheung Aug 9, 2022
e1295d0
Minor fix
siuwuncheung Aug 9, 2022
71de068
Merge branch 'shift-nudmd' of https://github.com/LLNL/libROM into shi…
siuwuncheung Aug 9, 2022
9e99d99
Merge branch 'master' into shift-nudmd
siuwuncheung Aug 9, 2022
d7a9898
Add state mean offset, and derivative mean offset for NonuniformDMD
siuwuncheung Jun 16, 2022
e543cba
save phi inverse
Jun 16, 2022
6c69afa
Add back in line
Jun 16, 2022
7d6a2f1
Fix the offset in computeDMDSnapshotPair
siuwuncheung Jun 16, 2022
476561b
fix typo
Jun 16, 2022
29d09cc
Fix a bug
siuwuncheung Jun 16, 2022
e9529df
Remove redundant lines
siuwuncheung Jun 16, 2022
c130d16
Remove redundant lines
siuwuncheung Jun 17, 2022
853384e
Remove redundant line
siuwuncheung Jun 17, 2022
7285c17
Remove redundant lines
siuwuncheung Jun 17, 2022
2b2213c
Remove redundant lines
siuwuncheung Jun 17, 2022
911a981
Remove redundant lines
siuwuncheung Jun 17, 2022
daf6efc
Remove redundant lines
siuwuncheung Jun 17, 2022
11bd882
Remove redundant lines
siuwuncheung Jun 17, 2022
9491988
Remove redundant lines
siuwuncheung Jun 17, 2022
3c6a87b
Remove redundant lines
siuwuncheung Jun 17, 2022
3fdef4f
Remove redundant lines
siuwuncheung Jun 17, 2022
1860bb6
Remove redundant lines
siuwuncheung Jun 17, 2022
b3579ef
Remove redundant line
siuwuncheung Jun 17, 2022
f63338f
Attempt to debug
siuwuncheung Jun 17, 2022
5eae39e
Add initial state as offset
siuwuncheung Jun 17, 2022
41f5582
fix adaptive dmd constructor
Jun 20, 2022
1ca0f1c
add new W0 columns
Jun 24, 2022
2fdd999
fix bug
Jun 24, 2022
99f10a0
Q transpose mult
Jun 24, 2022
351c1c8
fix transpose mult
Jun 24, 2022
9825115
add comment dylan requested
Jun 24, 2022
1b7554c
add comment
Jun 24, 2022
32b074f
updated mixed nonlinear diffusion (#121)
Jun 16, 2022
d3ea657
remove typo line
Jun 20, 2022
543b554
Add citation file (#130)
siuwuncheung Jul 14, 2022
acdd64e
move parmetis tar here (#131)
Jul 18, 2022
b664fbe
Orthogonalize to play safe
siuwuncheung Jul 21, 2022
704063c
csv databse bug (#133)
Jul 25, 2022
849715f
Add derivative prediction
siuwuncheung Aug 5, 2022
be1ed59
Allow any offsets
siuwuncheung Aug 8, 2022
62504eb
Fix DMD derived class for working for both Adaptive DMD and Nonuniform
siuwuncheung Aug 8, 2022
9baaefa
Fix bug
siuwuncheung Aug 8, 2022
8793794
Minor fix
siuwuncheung Aug 9, 2022
5a30fe2
Minor fix
siuwuncheung Aug 9, 2022
4f6474f
Differential Evolution (#132)
Jul 28, 2022
9eca66a
visualize de example (#135)
Aug 1, 2022
5cc79b9
Merge branch 'shift-nudmd' of https://github.com/LLNL/libROM into shi…
siuwuncheung Aug 10, 2022
8067818
Merge branch 'shift-nudmd' of https://github.com/LLNL/libROM into shi…
siuwuncheung Aug 10, 2022
0eee2f0
Revision to comments
siuwuncheung Aug 11, 2022
6f96816
Replace mult
siuwuncheung Aug 11, 2022
bf6402d
Minor revision
siuwuncheung Aug 15, 2022
59bd7da
Replace mult
siuwuncheung Aug 16, 2022
82309d5
Merge branch 'master' into shift-nudmd
siuwuncheung Sep 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions examples/dmd/dg_advection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ class AIR_prec : public Solver
};
#endif


class DG_Solver : public Solver
{
private:
Expand Down Expand Up @@ -195,7 +194,6 @@ class DG_Solver : public Solver
}
};


/** A time-dependent operator for the right-hand side of the ODE. The DG weak
form of du/dt = -v.grad(u) is M du/dt = K u + b, where M and K are the mass
and advection matrices, and b describes the flow on the boundary. This can
Expand All @@ -222,7 +220,6 @@ class FE_Evolution : public TimeDependentOperator
virtual ~FE_Evolution();
};


int main(int argc, char *argv[])
{
// 1. Initialize MPI.
Expand Down Expand Up @@ -465,7 +462,6 @@ int main(int argc, char *argv[])
m->Finalize();
k->Finalize(skip_zeros);


HypreParVector *B = b->ParallelAssemble();

// 9. Define the initial conditions, save the corresponding grid function to
Expand Down Expand Up @@ -798,7 +794,6 @@ int main(int argc, char *argv[])
return 0;
}


// Implementation of class FE_Evolution
FE_Evolution::FE_Evolution(ParBilinearForm &M_, ParBilinearForm &K_,
const Vector &b_, PrecType prec_type)
Expand Down Expand Up @@ -869,7 +864,6 @@ FE_Evolution::~FE_Evolution()
delete dg_solver;
}


// Velocity coefficient
void velocity_function(const Vector &x, Vector &v)
{
Expand Down
1 change: 0 additions & 1 deletion examples/dmd/dg_euler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class RiemannSolver
const Vector &nor, Vector &flux);
};


// Constant (in time) mixed bilinear form multiplying the flux grid function.
// The form is (vec(v), grad(w)) where the trial space = vector L2 space (mesh
// dim) and test space = scalar L2 space.
Expand Down
11 changes: 0 additions & 11 deletions examples/dmd/nonlinear_elasticity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ class ReducedSystemOperator : public Operator
virtual ~ReducedSystemOperator();
};


/** Function representing the elastic energy density for the given hyperelastic
model+deformation. Used in HyperelasticOperator::GetElasticEnergyDensity. */
class ElasticEnergyCoefficient : public Coefficient
Expand All @@ -201,7 +200,6 @@ void visualize(ostream &out, ParMesh *mesh, ParGridFunction *deformed_nodes,
ParGridFunction *field, const char *field_name = NULL,
bool init_vis = false);


int main(int argc, char *argv[])
{
// 1. Initialize MPI.
Expand Down Expand Up @@ -606,11 +604,6 @@ int main(int argc, char *argv[])
std::cout << "Both rdim and ef are set. ef will be ignored." << std::endl;
}

dmd_training_timer.Start();


dmd_training_timer.Stop();

Vector true_solution_x(x_gf.GetTrueVector().Size());
true_solution_x = x_gf.GetTrueVector();

Expand Down Expand Up @@ -767,7 +760,6 @@ void visualize(ostream &out, ParMesh *mesh, ParGridFunction *deformed_nodes,
out << flush;
}


ReducedSystemOperator::ReducedSystemOperator(
ParBilinearForm *M_, ParBilinearForm *S_, ParNonlinearForm *H_,
const Array<int> &ess_tdof_list_)
Expand Down Expand Up @@ -814,7 +806,6 @@ ReducedSystemOperator::~ReducedSystemOperator()
delete Jacobian;
}


HyperelasticOperator::HyperelasticOperator(ParFiniteElementSpace &f,
Array<int> &ess_bdr, double visc,
double mu, double K)
Expand Down Expand Up @@ -952,7 +943,6 @@ HyperelasticOperator::~HyperelasticOperator()
delete Mmat;
}


double ElasticEnergyCoefficient::Eval(ElementTransformation &T,
const IntegrationPoint &ip)
{
Expand All @@ -962,7 +952,6 @@ double ElasticEnergyCoefficient::Eval(ElementTransformation &T,
return model.EvalW(J)/J.Det(); // in deformed configuration
}


void InitialDeformation(const Vector &x, Vector &y)
{
// set the initial configuration to be the same as the reference, stress
Expand Down
8 changes: 0 additions & 8 deletions examples/prom/dg_advection_global_rom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ class AIR_prec : public Solver
};
#endif


class DG_Solver : public Solver
{
private:
Expand Down Expand Up @@ -222,7 +221,6 @@ class DG_Solver : public Solver
}
};


/** A time-dependent operator for the right-hand side of the ODE. The DG weak
form of du/dt = -v.grad(u) is M du/dt = K u + b, where M and K are the mass
and advection matrices, and b describes the flow on the boundary. This can
Expand All @@ -245,7 +243,6 @@ class ROM_FE_Evolution : public TimeDependentOperator
virtual ~ROM_FE_Evolution();
};


/** A time-dependent operator for the right-hand side of the ODE. The DG weak
form of du/dt = -v.grad(u) is M du/dt = K u + b, where M and K are the mass
and advection matrices, and b describes the flow on the boundary. This can
Expand All @@ -272,7 +269,6 @@ class FE_Evolution : public TimeDependentOperator
virtual ~FE_Evolution();
};


int main(int argc, char *argv[])
{
// 1. Initialize MPI.
Expand Down Expand Up @@ -548,7 +544,6 @@ int main(int argc, char *argv[])
m->Finalize();
k->Finalize(skip_zeros);


HypreParVector *B = b->ParallelAssemble();

// 9. Define the initial conditions, save the corresponding grid function to
Expand Down Expand Up @@ -955,7 +950,6 @@ int main(int argc, char *argv[])
return 0;
}


// Implementation of class ROM_FE_Evolution
ROM_FE_Evolution::ROM_FE_Evolution(DenseMatrix* M_, DenseMatrix* K_, Vector* b_,
Vector* u_init_hat_, int num_cols)
Expand Down Expand Up @@ -1011,7 +1005,6 @@ ROM_FE_Evolution::~ROM_FE_Evolution()
delete A_inv;
}


// Implementation of class FE_Evolution
FE_Evolution::FE_Evolution(ParBilinearForm &M_, ParBilinearForm &K_,
const Vector &b_, PrecType prec_type)
Expand Down Expand Up @@ -1082,7 +1075,6 @@ FE_Evolution::~FE_Evolution()
delete dg_solver;
}


// Velocity coefficient
void velocity_function(const Vector &x, Vector &v)
{
Expand Down
8 changes: 0 additions & 8 deletions examples/prom/dg_advection_local_rom_matrix_interp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ class AIR_prec : public Solver
};
#endif


class DG_Solver : public Solver
{
private:
Expand Down Expand Up @@ -234,7 +233,6 @@ class DG_Solver : public Solver
}
};


/** A time-dependent operator for the right-hand side of the ODE. The DG weak
form of du/dt = -v.grad(u) is M du/dt = K u + b, where M and K are the mass
and advection matrices, and b describes the flow on the boundary. This can
Expand All @@ -257,7 +255,6 @@ class ROM_FE_Evolution : public TimeDependentOperator
virtual ~ROM_FE_Evolution();
};


/** A time-dependent operator for the right-hand side of the ODE. The DG weak
form of du/dt = -v.grad(u) is M du/dt = K u + b, where M and K are the mass
and advection matrices, and b describes the flow on the boundary. This can
Expand All @@ -284,7 +281,6 @@ class FE_Evolution : public TimeDependentOperator
virtual ~FE_Evolution();
};


int main(int argc, char *argv[])
{
// 1. Initialize MPI.
Expand Down Expand Up @@ -570,7 +566,6 @@ int main(int argc, char *argv[])
m->Finalize();
k->Finalize(skip_zeros);


HypreParVector *B = b->ParallelAssemble();

// 9. Define the initial conditions, save the corresponding grid function to
Expand Down Expand Up @@ -1065,7 +1060,6 @@ int main(int argc, char *argv[])
return 0;
}


// Implementation of class ROM_FE_Evolution
ROM_FE_Evolution::ROM_FE_Evolution(DenseMatrix* M_, DenseMatrix* K_, Vector* b_,
Vector* u_init_hat_, int num_cols)
Expand Down Expand Up @@ -1121,7 +1115,6 @@ ROM_FE_Evolution::~ROM_FE_Evolution()
delete A_inv;
}


// Implementation of class FE_Evolution
FE_Evolution::FE_Evolution(ParBilinearForm &M_, ParBilinearForm &K_,
const Vector &b_, PrecType prec_type)
Expand Down Expand Up @@ -1192,7 +1185,6 @@ FE_Evolution::~FE_Evolution()
delete dg_solver;
}


// Velocity coefficient
void velocity_function(const Vector &x, Vector &v)
{
Expand Down
1 change: 0 additions & 1 deletion examples/prom/mixed_nonlinear_diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
#include "hyperreduction/S_OPT.h"
#include "mfem/SampleMesh.hpp"


typedef enum {ANALYTIC, INIT_STEP} PROBLEM;

typedef enum {RSPACE, WSPACE} FESPACE;
Expand Down
1 change: 0 additions & 1 deletion examples/prom/poisson_global_rom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
//
// Online phase: poisson_global_rom -online -f 1.15


#include "mfem.hpp"
#include <fstream>
#include <iostream>
Expand Down
11 changes: 6 additions & 5 deletions lib/algo/AdaptiveDMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ namespace CAROM {

AdaptiveDMD::AdaptiveDMD(int dim, double desired_dt, std::string rbf,
std::string interp_method,
double closest_rbf_val) : DMD(dim, desired_dt)
double closest_rbf_val,
Vector* state_offset) : DMD(dim, state_offset)
{
CAROM_VERIFY(rbf == "G" || rbf == "IQ" || rbf == "IMQ");
CAROM_VERIFY(interp_method == "LS" || interp_method == "IDW"
Expand All @@ -33,25 +34,25 @@ AdaptiveDMD::AdaptiveDMD(int dim, double desired_dt, std::string rbf,
d_closest_rbf_val = closest_rbf_val;
}

void AdaptiveDMD::train(double energy_fraction)
void AdaptiveDMD::train(double energy_fraction, const Matrix* W0, double linearity_tol)
{
const Matrix* f_snapshots = getInterpolatedSnapshots();
CAROM_VERIFY(f_snapshots->numColumns() > 1);
CAROM_VERIFY(energy_fraction > 0 && energy_fraction <= 1);
d_energy_fraction = energy_fraction;
constructDMD(f_snapshots, d_rank, d_num_procs);
constructDMD(f_snapshots, d_rank, d_num_procs, W0, linearity_tol);

delete f_snapshots;
}

void AdaptiveDMD::train(int k)
void AdaptiveDMD::train(int k, const Matrix* W0, double linearity_tol)
{
const Matrix* f_snapshots = getInterpolatedSnapshots();
CAROM_VERIFY(f_snapshots->numColumns() > 1);
CAROM_VERIFY(k > 0 && k <= f_snapshots->numColumns() - 1);
d_energy_fraction = -1.0;
d_k = k;
constructDMD(f_snapshots, d_rank, d_num_procs);
constructDMD(f_snapshots, d_rank, d_num_procs, W0, linearity_tol);

delete f_snapshots;
}
Expand Down
14 changes: 11 additions & 3 deletions lib/algo/AdaptiveDMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,28 @@ class AdaptiveDMD : public DMD
* "IDW" == inverse distance weighting, "LP" == lagrangian polynomials)
* @param[in] closest_rbf_val The RBF parameter determines the width of influence.
* Set the RBF value of the nearest two parameter points to a value between 0.0 to 1.0
* @param[in] state_offset The state offset.
*/
AdaptiveDMD(int dim, double desired_dt = -1.0, std::string rbf = "G",
std::string interp_method = "LS",
double closest_rbf_val = 0.9);
double closest_rbf_val = 0.9,
Vector* state_offset = NULL);

/**
* @param[in] energy_fraction The energy fraction to keep after doing SVD.
* @param[in] W0 The initial basis to prepend to W.
* @param[in] linearity_tol The tolerance for determining whether a column
of W is linearly independent with W0.
*/
void train(double energy_fraction);
void train(double energy_fraction, const Matrix* W0 = NULL, double linearity_tol = 0.0);

/**
* @param[in] k The number of modes (eigenvalues) to keep after doing SVD.
* @param[in] W0 The initial basis to prepend to W.
* @param[in] linearity_tol The tolerance for determining whether a column
of W is linearly independent with W0.
*/
void train(int k);
void train(int k, const Matrix* W0 = NULL, double linearity_tol = 0.0);

/**
* @brief Get the true dt between interpolated snapshots.
Expand Down
Loading