Skip to content

Commit

Permalink
save hyperreduction operator in build rom phase.
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer2368 committed Sep 13, 2024
1 parent 247b726 commit 2440450
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/rom_workflows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ void buildROMPoissonOperator(MGmolInterface *mgmol_)
Control& ct = *(Control::instance());
Mesh* mymesh = Mesh::instance();
const pb::PEenv& myPEenv = mymesh->peenv();
MGmol_MPI& mmpi = *(MGmol_MPI::instance());
const int rank = mmpi.mypeGlobal();
const int nprocs = mmpi.size();

ROMPrivateOptions rom_options = ct.getROMOptions();
/* type of variable we intend to run POD */
Expand Down Expand Up @@ -198,6 +201,18 @@ void buildROMPoissonOperator(MGmolInterface *mgmol_)

delete col;
} // for (int c = 0; c < num_pot_basis; c++)

/* DEIM hyperreduction */
CAROM::Matrix pot_rhs_rom(num_pot_basis, num_pot_basis, false);
std::vector<int> global_sampled_row(num_pot_basis), sampled_rows_per_proc(nprocs);
DEIM(pot_basis, num_pot_basis, global_sampled_row, sampled_rows_per_proc,
pot_rhs_rom, rank, nprocs);

/* ROM rescaleTotalCharge operator */
CAROM::Vector fom_ones(pot_basis->numRows(), true);
CAROM::Vector rom_ones(num_pot_basis, false);
fom_ones = mymesh->grid().vel(); // volume element
pot_basis->transposeMult(fom_ones, rom_ones);

/* Save ROM operator */
// write the file from PE0 only
Expand All @@ -215,10 +230,20 @@ void buildROMPoissonOperator(MGmolInterface *mgmol_)
h5_helper.putDoubleArray("potential_rom_inverse", pot_rom.getData(),
num_pot_basis * num_pot_basis, false);

/* save right-hand side hyper-reduction operator */
h5_helper.putDoubleArray("potential_rhs_rom_inverse", pot_rhs_rom.getData(),
num_pot_basis * num_pot_basis, false);

/* save right-hand side rescaling operator */
h5_helper.putDoubleArray("potential_rhs_rescaler", rom_ones.getData(),
num_pot_basis, false);

h5_helper.close();
}
}

/* test routines */

template <class OrbitalsType>
void testROMPoissonOperator(MGmolInterface *mgmol_)
{
Expand Down Expand Up @@ -689,6 +714,10 @@ void computeRhoOnSamplePts(const CAROM::Matrix &dm,
and probably need to make ROM-equivalent functions with another hyper-reduction?
*/
// gatherSpin();

/*
rescaleTotalCharge is handled after hyperreduction.
*/
// rescaleTotalCharge();
}

Expand Down

0 comments on commit 2440450

Please sign in to comment.