Skip to content

Commit

Permalink
Avoid unnecessary matrix update
Browse files Browse the repository at this point in the history
Specifically in chemistry substepping, avoid reevaluating the
density-weighted mass matrix b/c it is not needed.
  • Loading branch information
trevilo committed Dec 5, 2024
1 parent bdaa23d commit 8e99343
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/reactingFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ void ReactingFlow::step() {
// update wdot quantities at full substep in Yn/Tn state
updateMixture();
updateThermoP();
updateDensity(0.0);
updateDensity(0.0, false);
speciesProduction();
heatOfFormation();

Expand Down Expand Up @@ -2503,7 +2503,7 @@ void ReactingFlow::evaluatePlasmaConductivityGF() {
sigma_gf_.SetFromTrueDofs(sigma_);
}

void ReactingFlow::updateDensity(double tStep) {
void ReactingFlow::updateDensity(double tStep, bool update_mass_matrix) {
Array<int> empty;
Rmix_gf_.GetTrueDofs(tmpR0a_);

Expand Down Expand Up @@ -2541,9 +2541,11 @@ void ReactingFlow::updateDensity(double tStep) {
}
rn_gf_.SetFromTrueDofs(rn_);

MsRho_form_->Update();
MsRho_form_->Assemble();
MsRho_form_->FormSystemMatrix(empty, MsRho_);
if (update_mass_matrix) {
MsRho_form_->Update();
MsRho_form_->Assemble();
MsRho_form_->FormSystemMatrix(empty, MsRho_);
}

// project to p-space in case not same as vel-temp
R0PM0_gf_.SetFromTrueDofs(rn_);
Expand Down
2 changes: 1 addition & 1 deletion src/reactingFlow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class ReactingFlow : public ThermoChemModelBase {
void updateMixture();
void updateThermoP();
void extrapolateState();
void updateDensity(double tStep);
void updateDensity(double tStep, bool update_mass_matrix = true);
void updateBC(int current_step);
void updateDiffusivity();
void computeSystemMass();
Expand Down

0 comments on commit 8e99343

Please sign in to comment.