Skip to content

Commit

Permalink
separated InitROMHandler from InitVariables
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer2368 committed Jun 19, 2024
1 parent 469fb2b commit 1544fde
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 28 deletions.
2 changes: 0 additions & 2 deletions include/steady_ns_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ friend class SteadyNSOperator;

using StokesSolver::GetVariableNames;

void InitVariables() override;

void BuildDomainOperators() override;

void SetupDomainBCOperators() override;
Expand Down
3 changes: 1 addition & 2 deletions include/unsteady_ns_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ friend class SteadyNSOperator;
virtual ~UnsteadyNSSolver();

using SteadyNSSolver::GetVariableNames;

void InitVariables() override;

void BuildDomainOperators() override;
void AssembleOperator() override;

Expand Down
1 change: 1 addition & 0 deletions src/advdiff_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ void AdvDiffSolver::GetFlowField(ParameterizedProblem *flow_problem)

stokes_solver = new StokesSolver;
stokes_solver->InitVariables();
if (use_rom) stokes_solver->InitROMHandler();
stokes_solver->SetSolutionSaveMode(save_flow);

bool flow_loaded = false;
Expand Down
2 changes: 0 additions & 2 deletions src/linelast_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ void LinElastSolver::InitVariables()
// Does this make any difference?
us[m]->SetTrueVector();
}
if (use_rom)
MultiBlockSolver::InitROMHandler();
}

void LinElastSolver::BuildOperators()
Expand Down
6 changes: 6 additions & 0 deletions src/main_workflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ void GenerateSamples(MPI_Comm comm)

test = InitSolver();
test->InitVariables();
if (test->UseRom())
test->InitROMHandler();

problem->SetSingleRun();
test->SetParameterizedProblem(problem);
Expand Down Expand Up @@ -264,6 +266,7 @@ void AuxiliaryTrainROM(MPI_Comm comm, SampleGenerator *sample_generator)
if (!solver->UseRom()) mfem_error("ROM must be enabled for supremizer enrichment!\n");

solver->InitVariables();
solver->InitROMHandler();
// This time needs to be ROMHandler, in order not to run StokesSolver::LoadSupremizer.
solver->GetROMHandler()->LoadReducedBasis();

Expand All @@ -289,6 +292,7 @@ void TrainEQP(MPI_Comm comm)
MultiBlockSolver *test = NULL;
test = InitSolver();
test->InitVariables();
test->InitROMHandler();

if (!test->IsNonlinear())
{
Expand Down Expand Up @@ -383,6 +387,7 @@ void BuildROM(MPI_Comm comm)
test = InitSolver();
if (!test->UseRom()) mfem_error("ROM must be enabled for BuildROM!\n");
test->InitVariables();
test->InitROMHandler();
// test->InitVisualization();

// The ROM operator will be built based on the parameter specified for single-run.
Expand Down Expand Up @@ -455,6 +460,7 @@ double SingleRun(MPI_Comm comm, const std::string output_file)
ParameterizedProblem *problem = InitParameterizedProblem();
MultiBlockSolver *test = InitSolver();
test->InitVariables();
if (test->UseRom()) test->InitROMHandler();
test->InitVisualization();

StopWatch solveTimer;
Expand Down
2 changes: 0 additions & 2 deletions src/poisson_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ void PoissonSolver::InitVariables()
}

rhs_coeffs.SetSize(0);

if (use_rom) MultiBlockSolver::InitROMHandler();
}

void PoissonSolver::BuildOperators()
Expand Down
19 changes: 6 additions & 13 deletions src/steady_ns_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,6 @@ SteadyNSSolver::~SteadyNSSolver()
}
}

void SteadyNSSolver::InitVariables()
{
StokesSolver::InitVariables();
if (use_rom)
{
rom_handler->SetNonlinearMode(nonlinear_mode);
subdomain_tensors.SetSize(numSub);
subdomain_tensors = NULL;
subdomain_eqps.SetSize(numSub);
subdomain_eqps = NULL;
}
}

void SteadyNSSolver::BuildDomainOperators()
{
StokesSolver::BuildDomainOperators();
Expand Down Expand Up @@ -633,6 +620,12 @@ void SteadyNSSolver::InitROMHandler()
{
StokesSolver::InitROMHandler();

rom_handler->SetNonlinearMode(nonlinear_mode);
subdomain_tensors.SetSize(numSub);
subdomain_tensors = NULL;
subdomain_eqps.SetSize(numSub);
subdomain_eqps = NULL;

switch (rom_handler->GetNonlinearHandling())
{
case NonlinearHandling::TENSOR:
Expand Down
2 changes: 0 additions & 2 deletions src/stokes_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ void StokesSolver::InitVariables()
}

f_coeffs.SetSize(0);

if (use_rom) MultiBlockSolver::InitROMHandler();
}

void StokesSolver::DeterminePressureDirichlet()
Expand Down
5 changes: 0 additions & 5 deletions src/unsteady_ns_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ UnsteadyNSSolver::~UnsteadyNSSolver()
delete Hop;
}

void UnsteadyNSSolver::InitVariables()
{
StokesSolver::InitVariables();
}

void UnsteadyNSSolver::BuildDomainOperators()
{
SteadyNSSolver::BuildDomainOperators();
Expand Down

0 comments on commit 1544fde

Please sign in to comment.