Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
75ab3c0
advdiff: add option for steady-ns solver.
dreamer2368 Dec 19, 2025
502a8a2
error for unknown flow solver
dreamer2368 Dec 22, 2025
8b5aae2
changing function signature of SetParameterizedProblem.
dreamer2368 Dec 22, 2025
cb0db4d
resample if SetParameterizedProblem fails.
dreamer2368 Dec 22, 2025
bdbccbe
error message if setparameterizedproblem fails for non-random sampling.
dreamer2368 Dec 22, 2025
6d045e7
fix stokes solver.
dreamer2368 Dec 22, 2025
8397e4d
fix resampling
dreamer2368 Dec 27, 2025
95154aa
rom solver follows different options than fom solver.
dreamer2368 Dec 27, 2025
aaacd90
use different order for flow solver
dreamer2368 Jan 12, 2026
f194248
ComponentTopologyHandler subset constructor.
dreamer2368 Jan 15, 2026
1ed5556
MultiBlockSolver can take a-priori defined TopologyHandler.
dreamer2368 Jan 15, 2026
0ebb1eb
fix linelast BC setup to be consistent with other solver. option fix …
dreamer2368 Jan 15, 2026
a7568b9
sanity check on bdr type definition.
dreamer2368 Jan 16, 2026
3e63c57
subset constructor saves subset-to-original mesh mapping.
dreamer2368 Jan 16, 2026
a6a9c56
StokesSolver::SetSubsetComplementaryFlux for subset incompressibility.
dreamer2368 Jan 16, 2026
ff05bb8
base setup for SchwarzROM.
dreamer2368 Jan 16, 2026
99baea2
minor fix
dreamer2368 Jan 16, 2026
ed7ca86
schwarz loop.
dreamer2368 Jan 16, 2026
29f9462
MultiBlockSolver::PrintConfiguration
dreamer2368 Jan 17, 2026
a164146
PrintBoundaryType
dreamer2368 Jan 17, 2026
38aec96
SteadyNSSolver::SchwarzROM fixed. May need to try a few more things t…
dreamer2368 Jan 18, 2026
3fe0847
rom2fom error comparison and finalizing the loop.;
dreamer2368 Jan 19, 2026
55dd99d
output setup for SchwarzROM.
dreamer2368 Jan 19, 2026
2e45f46
minor fix on MultiBlockSolver::SetParameterizedProblem
dreamer2368 Jan 19, 2026
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ set(scaleupROMObj_SOURCES

include/steady_ns_solver.hpp
src/steady_ns_solver.cpp
src/steady_ns_solver_schwarz.cpp

include/advdiff_solver.hpp
src/advdiff_solver.cpp
Expand Down
1 change: 1 addition & 0 deletions bin/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ int main(int argc, char *argv[])
else if (mode == "aux_train_rom") AuxiliaryTrainROM(MPI_COMM_WORLD);
else if (mode == "train_eqp") TrainEQP(MPI_COMM_WORLD);
else if (mode == "single_run") SingleRun(MPI_COMM_WORLD, output_file);
else if (mode == "schwarz_rom") SingleSchwarzRun(MPI_COMM_WORLD, output_file);
else if (mode == "print_eqp") PrintEQPCoords(MPI_COMM_WORLD);
else
{
Expand Down
12 changes: 7 additions & 5 deletions include/advdiff_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define SCALEUPROM_ADVDIFF_SOLVER_HPP

#include "poisson_solver.hpp"
#include "stokes_solver.hpp"
#include "steady_ns_solver.hpp"

// By convention we only use mfem namespace as default, not CAROM.
using namespace mfem;
Expand All @@ -26,7 +26,9 @@ friend class ParameterizedProblem;
/*
flow solver to obtain the prescribed velocity field. both StokesSolver / SteadyNSSolver can be used.
*/
StokesSolver *stokes_solver = NULL;
std::string flow_solver_type = "";
int flow_solver_order = -1;
StokesSolver *flow_solver = NULL;
bool load_flow = false;
bool save_flow = false;
std::string flow_file = "";
Expand All @@ -39,7 +41,7 @@ friend class ParameterizedProblem;
Array<GridFunction *> global_flow_visual;

public:
AdvDiffSolver();
AdvDiffSolver(TopologyHandler *input_topol_handler=NULL);

virtual ~AdvDiffSolver();

Expand All @@ -52,15 +54,15 @@ friend class ParameterizedProblem;

void SetFlowAtSubdomain(std::function<void(const Vector &, double, Vector &)> F, const int m=-1);

void SetParameterizedProblem(ParameterizedProblem *problem) override;
bool SetParameterizedProblem(ParameterizedProblem *problem) override;

void SaveVisualization() override;

protected:
void SetMUMPSSolver() override;

private:
void GetFlowField(ParameterizedProblem *flow_problem);
bool GetFlowField(ParameterizedProblem *flow_problem);
};

#endif
17 changes: 17 additions & 0 deletions include/component_topology_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ class ComponentTopologyHandler : public TopologyHandler

std::unordered_map<int,int> vtx2to1; // vertex mapping from component 2 to component 1.
Array2D<int> be_pairs; // boundary element pairs between component 1 and 2.

PortData() {}

PortData(const PortData &input)
: Component1(input.Component1), Component2(input.Component2),
Attr1(input.Attr1), Attr2(input.Attr2), vtx2to1(input.vtx2to1),
be_pairs(input.be_pairs) {}
};

protected:
Expand Down Expand Up @@ -133,6 +140,16 @@ class ComponentTopologyHandler : public TopologyHandler
public:
ComponentTopologyHandler();

// Get a subset of the mesh array as a new ComponentTopologyHandler.
// Assumes meshes are arranged in an N x N square array.
// Extracts an M x M subset starting at (i0, j0).
// Internal ports within the subset are included.
// External ports connecting to meshes outside the subset are excluded.
// Boundary attributes of subset meshes facing outside are set as global boundary.
// Stores subset mesh to original mesh mapping.
ComponentTopologyHandler(ComponentTopologyHandler* global, const int i0, const int j0,
const int N, const int M, Array<int> &subset_to_orig);

virtual ~ComponentTopologyHandler();

// access
Expand Down
7 changes: 5 additions & 2 deletions include/linelast_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ class LinElastSolver : public MultiBlockSolver
double lambda = 1.0;
double mu = 1.0;

Vector zero;

// Initial positions
VectorCoefficient *init_x = NULL;

public:
LinElastSolver();
LinElastSolver(TopologyHandler *input_topol_handler=NULL);

virtual ~LinElastSolver();

Expand Down Expand Up @@ -86,6 +88,7 @@ class LinElastSolver : public MultiBlockSolver
virtual void SetupBCVariables() override;
virtual void SetupIC(std::function<void(const Vector &, double, Vector &)> F);
virtual void AddBCFunction(std::function<void(const Vector &, double, Vector &)> F, const int battr = -1);
virtual void AddBCFunction(const Vector &F, const int battr = -1);
virtual void AddRHSFunction(std::function<void(const Vector &, double, Vector &)> F);
virtual bool BCExistsOnBdr(const int &global_battr_idx);
virtual void SetupBCOperators();
Expand All @@ -101,7 +104,7 @@ class LinElastSolver : public MultiBlockSolver

void SanityCheckOnCoeffs();

virtual void SetParameterizedProblem(ParameterizedProblem *problem);
virtual bool SetParameterizedProblem(ParameterizedProblem *problem);
};

#endif
3 changes: 3 additions & 0 deletions include/main_workflow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ void FindSnapshotFilesForBasis(const BasisTag &basis_tag, const std::string &def
// return relative error if comparing solution.
double SingleRun(MPI_Comm comm, const std::string output_file = "");

// return relative error if comparing solution.
double SingleSchwarzRun(MPI_Comm comm, const std::string output_file = "");

// Auxiliary function to print out EQP point coordinates
void PrintEQPCoords(MPI_Comm comm);

Expand Down
15 changes: 13 additions & 2 deletions include/multiblock_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ friend class ParameterizedProblem;
ROMLinearElement *rom_elems = NULL;

public:
MultiBlockSolver();
MultiBlockSolver(TopologyHandler *input_topol_handler=NULL);

virtual ~MultiBlockSolver();

Expand Down Expand Up @@ -254,14 +254,25 @@ friend class ParameterizedProblem;
virtual void SaveBasisVisualization()
{ rom_handler->SaveBasisVisualization(fes, var_names); }

virtual void SetParameterizedProblem(ParameterizedProblem *problem);
virtual bool SetParameterizedProblem(ParameterizedProblem *problem);

void ComputeSubdomainErrorAndNorm(GridFunction *fom_sol, GridFunction *rom_sol, double &error, double &norm);
void ComputeRelativeError(Array<GridFunction *> fom_sols, Array<GridFunction *> rom_sols, Vector &error);
void CompareSolution(BlockVector &test_U, Vector &error);

virtual void SaveEQPCoords(const std::string &filename) {}

bool IsBdrTypeDefined()
{
for (int k = 0; k < bdr_type.Size(); k++)
if (bdr_type[k] == BoundaryType::NUM_BDR_TYPE)
return false;

return true;
}

void PrintConfiguration() const;

protected:
virtual void AssembleROMMat(BlockMatrix &romMat);
};
Expand Down
2 changes: 2 additions & 0 deletions include/parameterized_problem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ enum class BoundaryType
NUM_BDR_TYPE
};

const std::string PrintBoundaryType(const BoundaryType bdr_type);

class ParameterizedProblem
{
friend class SampleGenerator;
Expand Down
4 changes: 2 additions & 2 deletions include/poisson_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ friend class ParameterizedProblem;
double kappa = -1.0;

public:
PoissonSolver();
PoissonSolver(TopologyHandler *input_topol_handler=NULL);

virtual ~PoissonSolver();

Expand Down Expand Up @@ -98,7 +98,7 @@ friend class ParameterizedProblem;

void SanityCheckOnCoeffs();

virtual void SetParameterizedProblem(ParameterizedProblem *problem);
virtual bool SetParameterizedProblem(ParameterizedProblem *problem);

protected:
virtual void SetMUMPSSolver();
Expand Down
14 changes: 13 additions & 1 deletion include/steady_ns_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class SteadyNSTensorROM : public SteadyNSROM

virtual void Mult(const Vector &x, Vector &y) const;
virtual Operator &GetGradient(const Vector &x) const;

void SaveOperator(std::string filename);
};

class SteadyNSEQPROM : public SteadyNSROM
Expand Down Expand Up @@ -166,7 +168,7 @@ friend class SteadyNSOperator;
NewtonSolver *newton_solver = NULL;

public:
SteadyNSSolver();
SteadyNSSolver(TopologyHandler *input_topol_handler=NULL);

virtual ~SteadyNSSolver();

Expand Down Expand Up @@ -198,6 +200,12 @@ friend class SteadyNSOperator;

void SaveEQPCoords(const std::string &filename) override;

void SchwarzROM(const int M, const int N, ParameterizedProblem *problem,
double &solve_time, int &num_solve, Array<double> &error_hist,
const int maxIter, const double threshold=1e-15,
const int plateau_track=3, const double plateau_range=1e-1,
const bool use_restart=false);

private:
DenseTensor* GetReducedTensor(DenseMatrix *basis, FiniteElementSpace *fespace);

Expand All @@ -210,6 +218,10 @@ friend class SteadyNSOperator;
void SaveEQPElems(const std::string &filename);
void LoadEQPElems(const std::string &filename);
void AssembleROMEQPOper();

protected:
void SetupSubsetRHSBCOperators(const Array<int> *meshes, const Array<int> *battrs,
const Array<VectorGridFunctionCoefficient *> *bfuncs);
};

#endif
13 changes: 11 additions & 2 deletions include/stokes_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ friend class ParameterizedProblem;
double kappa = -1.0;

public:
StokesSolver();
StokesSolver(TopologyHandler *input_topol_handler=NULL);

virtual ~StokesSolver();

Expand Down Expand Up @@ -197,7 +197,7 @@ friend class ParameterizedProblem;

void SanityCheckOnCoeffs();

virtual void SetParameterizedProblem(ParameterizedProblem *problem) override;
virtual bool SetParameterizedProblem(ParameterizedProblem *problem) override;

// to ensure incompressibility for the problems with all velocity dirichlet bc.
void SetComplementaryFlux(const Array<bool> nz_dbcs);
Expand All @@ -216,6 +216,15 @@ friend class ParameterizedProblem;
double ComputeBEIntegral(const FiniteElement &el, ElementTransformation &Tr, Coefficient &Q);
void ComputeBEIntegral(const FiniteElement &el, ElementTransformation &Tr,
VectorCoefficient &Q, Vector &result);

protected:
// Assumes meshes are arranged in an N x N square array.
// Extracts an M x M subset starting at (i0, j0).
// to ensure incompressibility for the subset domain with all velocity dirichlet bc.
void SetSubsetComplementaryFlux(const int N, const int M, const int i0, const int j0,
const Array<int> &subset_bdr_attributes,
const Array<BoundaryType> &subset_bdrtype,
const ParameterizedProblem *problem);
};

#endif
4 changes: 2 additions & 2 deletions include/unsteady_ns_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ friend class SteadyNSOperator;
double times[10];

public:
UnsteadyNSSolver();
UnsteadyNSSolver(TopologyHandler *input_topol_handler=NULL);

virtual ~UnsteadyNSSolver();

Expand All @@ -93,7 +93,7 @@ friend class SteadyNSOperator;
using MultiBlockSolver::SaveVisualization;
void SaveVisualization(const int step, const double time) override;

void SetParameterizedProblem(ParameterizedProblem *problem) override;
bool SetParameterizedProblem(ParameterizedProblem *problem) override;

BlockVector* PrepareSnapshots(std::vector<BasisTag> &basis_tags) override;

Expand Down
Loading