From b5635bc0b8a7a87d482ca7a61ff49e7a2d734cf1 Mon Sep 17 00:00:00 2001 From: Ido Akkerman Date: Tue, 18 Nov 2025 14:34:07 +0100 Subject: [PATCH 01/15] Add override, and 1 delete per line --- lib/linalg/Vector.cpp | 3 ++- lib/linalg/svd/IncrementalSVD.h | 2 +- lib/linalg/svd/IncrementalSVDStandard.h | 4 ++-- lib/linalg/svd/StaticSVD.h | 2 +- lib/utils/CSVDatabase.h | 2 +- lib/utils/HDFDatabase.h | 18 +++++++++--------- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/linalg/Vector.cpp b/lib/linalg/Vector.cpp index 8f27a1d0e..1459e50e3 100644 --- a/lib/linalg/Vector.cpp +++ b/lib/linalg/Vector.cpp @@ -507,7 +507,8 @@ Vector::gather() MPI_COMM_WORLD) == MPI_SUCCESS); delete [] d_vec; - delete [] data_offsets, data_cnts; + delete [] data_offsets; + delete [] data_cnts; d_vec = d_new_vec; d_alloc_size = new_size; d_dim = new_size; diff --git a/lib/linalg/svd/IncrementalSVD.h b/lib/linalg/svd/IncrementalSVD.h index 5e4bcb2c6..b5a4f4903 100644 --- a/lib/linalg/svd/IncrementalSVD.h +++ b/lib/linalg/svd/IncrementalSVD.h @@ -62,7 +62,7 @@ class IncrementalSVD : public SVD bool takeSample( double* u_in, - bool add_without_increase = false); + bool add_without_increase = false)override; /** * @brief Returns the basis vectors for the current time interval as a diff --git a/lib/linalg/svd/IncrementalSVDStandard.h b/lib/linalg/svd/IncrementalSVDStandard.h index d38613358..f6722d575 100644 --- a/lib/linalg/svd/IncrementalSVDStandard.h +++ b/lib/linalg/svd/IncrementalSVDStandard.h @@ -97,7 +97,7 @@ class IncrementalSVDStandard : public IncrementalSVD addLinearlyDependentSample( const Matrix & A, const Matrix & W, - const Matrix & sigma); + const Matrix & sigma) override; /** * @brief Add a new, unique sample to the SVD. @@ -112,7 +112,7 @@ class IncrementalSVDStandard : public IncrementalSVD const Vector & j, const Matrix & A, const Matrix & W, - const Matrix & sigma); + const Matrix & sigma) override; }; } diff --git a/lib/linalg/svd/StaticSVD.h b/lib/linalg/svd/StaticSVD.h index ebdab51fb..5fec4982f 100644 --- a/lib/linalg/svd/StaticSVD.h +++ b/lib/linalg/svd/StaticSVD.h @@ -51,7 +51,7 @@ class StaticSVD : public SVD bool takeSample( double* u_in, - bool add_without_increase = false); + bool add_without_increase = false) override; /** * @brief Returns the basis vectors for the current time interval as a diff --git a/lib/utils/CSVDatabase.h b/lib/utils/CSVDatabase.h index c9132a15f..5da496070 100644 --- a/lib/utils/CSVDatabase.h +++ b/lib/utils/CSVDatabase.h @@ -77,7 +77,7 @@ class CSVDatabase : public Database * @return True if the file close was successful. */ bool - close(); + close() override; /** * @brief Writes an array of integers associated with the supplied filename. diff --git a/lib/utils/HDFDatabase.h b/lib/utils/HDFDatabase.h index 3faadcf60..853907e62 100644 --- a/lib/utils/HDFDatabase.h +++ b/lib/utils/HDFDatabase.h @@ -77,7 +77,7 @@ class HDFDatabase : public Database */ virtual bool - close(); + close() override; /** * @brief Writes an array of integers associated with the supplied key to @@ -101,7 +101,7 @@ class HDFDatabase : public Database const std::string& key, const int* const data, int nelements, - const bool distributed=false); + const bool distributed=false) override; /** * @brief Writes an array of doubles associated with the supplied key to @@ -125,7 +125,7 @@ class HDFDatabase : public Database const std::string& key, const double* const data, int nelements, - const bool distributed=false); + const bool distributed=false)override; /** * @brief Writes a vector of doubles associated with the supplied key to @@ -149,7 +149,7 @@ class HDFDatabase : public Database const std::string& key, const std::vector& data, int nelements, - const bool distributed=false); + const bool distributed=false)override; /** * @brief Reads an array of integers associated with the supplied key @@ -172,7 +172,7 @@ class HDFDatabase : public Database const std::string& key, int* data, int nelements, - const bool distributed=false); + const bool distributed=false)override; /** * @brief Count the number of elements in an array of doubles associated @@ -184,7 +184,7 @@ class HDFDatabase : public Database */ virtual int - getDoubleArraySize(const std::string& key); + getDoubleArraySize(const std::string& key)override; /** * @brief Reads an array of doubles associated with the supplied key @@ -207,7 +207,7 @@ class HDFDatabase : public Database const std::string& key, double* data, int nelements, - const bool distributed=false); + const bool distributed=false)override; /** * @brief Reads a sub-array of doubles associated with the supplied key @@ -232,7 +232,7 @@ class HDFDatabase : public Database double* data, int nelements, const std::vector& idx, - const bool distributed=false); + const bool distributed=false)override; /** * @brief Reads an array of doubles associated with the supplied key @@ -264,7 +264,7 @@ class HDFDatabase : public Database int offset, int block_size, int stride, - const bool distributed=false); + const bool distributed=false)override; protected: From d4658b18940a41f09e6fbd80888ef667aaf48247 Mon Sep 17 00:00:00 2001 From: Ido Akkerman Date: Tue, 18 Nov 2025 15:39:33 +0100 Subject: [PATCH 02/15] Add override --- lib/linalg/svd/IncrementalSVDBrand.h | 4 ++-- lib/linalg/svd/IncrementalSVDFastUpdate.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/linalg/svd/IncrementalSVDBrand.h b/lib/linalg/svd/IncrementalSVDBrand.h index 35cdf9f0d..c0ff2fd90 100644 --- a/lib/linalg/svd/IncrementalSVDBrand.h +++ b/lib/linalg/svd/IncrementalSVDBrand.h @@ -142,7 +142,7 @@ class IncrementalSVDBrand : public IncrementalSVD addLinearlyDependentSample( const Matrix & A, const Matrix & W, - const Matrix & sigma); + const Matrix & sigma) override; /** * @brief Add a new, unique sample to the SVD. @@ -157,7 +157,7 @@ class IncrementalSVDBrand : public IncrementalSVD const Vector & j, const Matrix & A, const Matrix & W, - const Matrix & sigma); + const Matrix & sigma) override; /** * @brief The matrix U'. U' is not distributed and the entire matrix diff --git a/lib/linalg/svd/IncrementalSVDFastUpdate.h b/lib/linalg/svd/IncrementalSVDFastUpdate.h index 87aac3955..9c9ffa163 100644 --- a/lib/linalg/svd/IncrementalSVDFastUpdate.h +++ b/lib/linalg/svd/IncrementalSVDFastUpdate.h @@ -98,7 +98,7 @@ class IncrementalSVDFastUpdate : public IncrementalSVD addLinearlyDependentSample( const Matrix & A, const Matrix & W, - const Matrix & sigma); + const Matrix & sigma)override; /** * @brief Add a new, unique sample to the SVD. @@ -113,7 +113,7 @@ class IncrementalSVDFastUpdate : public IncrementalSVD const Vector & j, const Matrix & A, const Matrix & W, - const Matrix & sigma); + const Matrix & sigma)override; /** * @brief The matrix U'. U' is not distributed and the entire matrix From 18f95adb573a558ecd74876c1917af95e9e380a1 Mon Sep 17 00:00:00 2001 From: Ido Akkerman Date: Tue, 18 Nov 2025 15:39:50 +0100 Subject: [PATCH 03/15] Correct delete --- lib/linalg/Matrix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/linalg/Matrix.cpp b/lib/linalg/Matrix.cpp index 559176bbc..6d431bdc8 100644 --- a/lib/linalg/Matrix.cpp +++ b/lib/linalg/Matrix.cpp @@ -816,7 +816,8 @@ Matrix::gather() MPI_COMM_WORLD) == MPI_SUCCESS); delete [] d_mat; - delete [] data_offsets, data_cnts; + delete [] data_offsets; + delete [] data_cnts; d_mat = d_new_mat; d_alloc_size = new_size; From 3151d9aa1345008e93057ea0f771006a65dd6781 Mon Sep 17 00:00:00 2001 From: Ido Akkerman Date: Tue, 18 Nov 2025 15:40:06 +0100 Subject: [PATCH 04/15] Make destructor virtual --- lib/algo/greedy/GreedySampler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/algo/greedy/GreedySampler.h b/lib/algo/greedy/GreedySampler.h index 4e1c7fceb..48d2d14f4 100644 --- a/lib/algo/greedy/GreedySampler.h +++ b/lib/algo/greedy/GreedySampler.h @@ -254,7 +254,7 @@ class GreedySampler /** * @brief Destructor. */ - ~GreedySampler(); + virtual ~GreedySampler(); /** * @brief Returns the next parameter point for which sampling is required. From 8e606d788df73c5d3bc37f17db450fdd47b7dac7 Mon Sep 17 00:00:00 2001 From: Ido Akkerman Date: Tue, 18 Nov 2025 15:40:55 +0100 Subject: [PATCH 05/15] Fix visit ambiguity --- examples/dmd/de_dg_advection_greedy.cpp | 12 +++---- examples/dmd/heat_conduction_dmdc.cpp | 2 +- .../dmd/parametric_dmdc_heat_conduction.cpp | 2 +- .../prom/de_parametric_maxwell_greedy.cpp | 6 ++-- .../prom/elliptic_eigenproblem_global_rom.cpp | 2 +- .../prom/nonlinear_elasticity_global_rom.cpp | 32 ++++++++++++++++--- examples/prom/poisson_global_rom.cpp | 18 +++++++---- 7 files changed, 52 insertions(+), 22 deletions(-) diff --git a/examples/dmd/de_dg_advection_greedy.cpp b/examples/dmd/de_dg_advection_greedy.cpp index ce545bede..8f1eeb9b6 100644 --- a/examples/dmd/de_dg_advection_greedy.cpp +++ b/examples/dmd/de_dg_advection_greedy.cpp @@ -478,7 +478,7 @@ double simulation() // Create data collection for solution output: either VisItDataCollection for // ascii data files, or SidreDataCollection for binary data files. DataCollection *dc = NULL; - if (visit) + if (::visit) { if (binary) { @@ -791,7 +791,7 @@ double simulation() sout << "solution\n" << pmesh << u_gf << flush; } - if (visit) + if (::visit) { dc->SetCycle(ti); dc->SetTime(t); @@ -946,14 +946,14 @@ double simulation() VisItDataCollection dmd_visit_dc("DMD_DG_Advection_Greedy_" + to_string(f_factor), &pmesh); dmd_visit_dc.RegisterField("temperature", &u_gf); - if (visit) + if (::visit) { dmd_visit_dc.SetCycle(0); dmd_visit_dc.SetTime(0.0); dmd_visit_dc.Save(); } - if (visit) + if (::visit) { for (int i = 1; i < ts.size(); i++) { @@ -1148,7 +1148,7 @@ int main(int argc, char *argv[]) args.AddOption(&visualization, "-vis", "--visualization", "-no-vis", "--no-visualization", "Enable or disable GLVis visualization."); - args.AddOption(&visit, "-visit", "--visit-datafiles", "-no-visit", + args.AddOption(&::visit, "-visit", "--visit-datafiles", "-no-visit", "--no-visit-datafiles", "Save data files for VisIt (visit.llnl.gov) visualization."); args.AddOption(¶view, "-paraview", "--paraview-datafiles", "-no-paraview", @@ -1271,7 +1271,7 @@ int main(int argc, char *argv[]) else if (build_database) { MFEM_VERIFY(rdim != -1, "rdim must be set."); - MFEM_VERIFY(!visit + MFEM_VERIFY(!::visit && !visualization, "visit and visualization must be turned off during the build_database phase.") std::ifstream infile(io_dir+"/dg_advection_greedy_parametric_data"); diff --git a/examples/dmd/heat_conduction_dmdc.cpp b/examples/dmd/heat_conduction_dmdc.cpp index 910b68215..c507e3ef0 100644 --- a/examples/dmd/heat_conduction_dmdc.cpp +++ b/examples/dmd/heat_conduction_dmdc.cpp @@ -210,7 +210,7 @@ int main(int argc, char *argv[]) // handle triangular, quadrilateral, tetrahedral and hexahedral meshes // with the same code. Mesh *mesh; - if (mesh_file == "") + if (strcmp(mesh_file, "") == 0 ) { mesh = new Mesh(Mesh::MakeCartesian2D(2, 2, Element::QUADRILATERAL)); } diff --git a/examples/dmd/parametric_dmdc_heat_conduction.cpp b/examples/dmd/parametric_dmdc_heat_conduction.cpp index b1692deb7..1b373e964 100644 --- a/examples/dmd/parametric_dmdc_heat_conduction.cpp +++ b/examples/dmd/parametric_dmdc_heat_conduction.cpp @@ -323,7 +323,7 @@ int main(int argc, char *argv[]) // handle triangular, quadrilateral, tetrahedral and hexahedral meshes // with the same code. Mesh *mesh; - if (mesh_file == "") + if (strcmp(mesh_file, "") == 0 ) { mesh = new Mesh(Mesh::MakeCartesian2D(2, 2, Element::QUADRILATERAL)); } diff --git a/examples/prom/de_parametric_maxwell_greedy.cpp b/examples/prom/de_parametric_maxwell_greedy.cpp index 86a283d88..fa2fc5ea4 100644 --- a/examples/prom/de_parametric_maxwell_greedy.cpp +++ b/examples/prom/de_parametric_maxwell_greedy.cpp @@ -388,7 +388,7 @@ double simulation() // 27. Save data in the VisIt format. DataCollection *dc = NULL; - if (visit) + if (::visit) { if (offline) dc = new VisItDataCollection("de_maxwell_local", pmesh); else if (fom) dc = new VisItDataCollection("de_maxwell_local_fom", pmesh); @@ -647,7 +647,7 @@ int main(int argc, char *argv[]) "--no-partial-assembly", "Enable Partial Assembly."); args.AddOption(&device_config, "-d", "--device", "Device configuration string, see Device::Configure()."); - args.AddOption(&visit, "-visit", "--visit-datafiles", "-no-visit", + args.AddOption(&::visit, "-visit", "--visit-datafiles", "-no-visit", "--no-visit-datafiles", "Save data files for VisIt (visit.llnl.gov) visualization."); args.AddOption(&visualization, "-vis", "--visualization", "-no-vis", @@ -738,7 +738,7 @@ int main(int argc, char *argv[]) MFEM_VERIFY(!offline && !online, "offline and online must be turned off during the build_database phase."); - MFEM_VERIFY(!visit + MFEM_VERIFY(!::visit && !visualization, "visit and visualization must be turned off during the build_database phase.") std::ifstream infile("de_parametric_maxwell_greedy_algorithm_data"); diff --git a/examples/prom/elliptic_eigenproblem_global_rom.cpp b/examples/prom/elliptic_eigenproblem_global_rom.cpp index 7619486f8..c4cdc3979 100644 --- a/examples/prom/elliptic_eigenproblem_global_rom.cpp +++ b/examples/prom/elliptic_eigenproblem_global_rom.cpp @@ -234,7 +234,7 @@ int main(int argc, char *argv[]) // handle triangular, quadrilateral, tetrahedral and hexahedral meshes // with the same code. Mesh *mesh; - if (mesh_file == "") + if (strcmp(mesh_file, "") == 0 ) { mesh = new Mesh(Mesh::MakeCartesian2D(2, 2, Element::QUADRILATERAL)); } diff --git a/examples/prom/nonlinear_elasticity_global_rom.cpp b/examples/prom/nonlinear_elasticity_global_rom.cpp index c1aa0553b..21aef2fd0 100644 --- a/examples/prom/nonlinear_elasticity_global_rom.cpp +++ b/examples/prom/nonlinear_elasticity_global_rom.cpp @@ -591,8 +591,19 @@ int main(int argc, char *argv[]) // discontinuous higher-order space. Since x and v are integrated in time // as a system, we group them together in block vector vx, on the unique // parallel degrees of freedom, with offsets given by array true_offset. - H1_FECollection fe_coll(order, dim); - ParFiniteElementSpace fespace(pmesh, &fe_coll, dim); + FiniteElementCollection *fe_coll; + NURBSExtension *NURBSext = NULL; + + if (pmesh->NURBSext) + { + fe_coll = new NURBSFECollection(order); + NURBSext = new NURBSExtension(pmesh->NURBSext, order); + } + else + { + fe_coll = new H1_FECollection(order, dim); + } + ParFiniteElementSpace fespace(pmesh, NURBSext, fe_coll, dim); HYPRE_BigInt glob_size = fespace.GlobalTrueVSize(); if (myid == 0) @@ -614,8 +625,19 @@ int main(int argc, char *argv[]) ParGridFunction x_ref(&fespace); pmesh->GetNodes(x_ref); - L2_FECollection w_fec(order + 1, dim); - ParFiniteElementSpace w_fespace(pmesh, &w_fec); + FiniteElementCollection *w_fec; + NURBSExtension *w_NURBSext = NULL; + if (pmesh->NURBSext) + { + w_fec = new NURBSFECollection(order + 1); + w_NURBSext = new NURBSExtension(pmesh->NURBSext, order+1); + } + else + { + w_fec = new L2_FECollection(order + 1, dim); + } + + ParFiniteElementSpace w_fespace(pmesh, w_NURBSext, w_fec); ParGridFunction w_gf(&w_fespace); // Basis params @@ -1393,6 +1415,8 @@ int main(int argc, char *argv[]) delete eqpSol_S; delete window_ids; delete load_eqpsol; + delete w_fec; + delete fe_coll; totalTimer.Stop(); if (myid == 0) diff --git a/examples/prom/poisson_global_rom.cpp b/examples/prom/poisson_global_rom.cpp index 11054e5ed..0ff2817bf 100644 --- a/examples/prom/poisson_global_rom.cpp +++ b/examples/prom/poisson_global_rom.cpp @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) MPI_Comm_rank(MPI_COMM_WORLD, &myid); // 2. Parse command-line options. - const char *mesh_file = "../data/star.mesh"; + const char *mesh_file = "../data/square-nurbs.mesh"; int order = 1; bool static_cond = false; bool pa = false; @@ -161,7 +161,7 @@ int main(int argc, char *argv[]) { int ref_levels = (int)floor(log(10000./mesh.GetNE())/log(2.)/dim); - for (int l = 0; l < ref_levels; l++) + for (int l = 0; l < ref_levels+2; l++) { mesh.UniformRefinement(); } @@ -172,20 +172,26 @@ int main(int argc, char *argv[]) // parallel mesh is defined, the serial mesh can be deleted. ParMesh pmesh(MPI_COMM_WORLD, mesh); mesh.Clear(); - { + /* { int par_ref_levels = 2; for (int l = 0; l < par_ref_levels; l++) { pmesh.UniformRefinement(); } - } + }*/ // 7. Define a parallel finite element space on the parallel mesh. Here we // use continuous Lagrange finite elements of the specified order. If // order < 1, we instead use an isoparametric/isogeometric space. FiniteElementCollection *fec; + NURBSExtension *NURBSext = NULL; bool delete_fec; - if (order > 0) + if (pmesh.NURBSext) + { + fec = new NURBSFECollection(order); + NURBSext = new NURBSExtension(pmesh.NURBSext, order); + } + else if (order > 0) { fec = new H1_FECollection(order, dim); delete_fec = true; @@ -204,7 +210,7 @@ int main(int argc, char *argv[]) fec = new H1_FECollection(order = 1, dim); delete_fec = true; } - ParFiniteElementSpace fespace(&pmesh, fec); + ParFiniteElementSpace fespace(&pmesh, NURBSext, fec); HYPRE_Int size = fespace.GlobalTrueVSize(); if (myid == 0) { From 4803160027af0b22939078d31251acac9ffbaa9e Mon Sep 17 00:00:00 2001 From: Ido Akkerman Date: Tue, 18 Nov 2025 15:45:14 +0100 Subject: [PATCH 06/15] Fix visit ambiguity --- .../dmd/de_parametric_heat_conduction_greedy.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/dmd/de_parametric_heat_conduction_greedy.cpp b/examples/dmd/de_parametric_heat_conduction_greedy.cpp index b0a3aff09..ca02bde8e 100644 --- a/examples/dmd/de_parametric_heat_conduction_greedy.cpp +++ b/examples/dmd/de_parametric_heat_conduction_greedy.cpp @@ -306,7 +306,7 @@ double simulation() to_string(radius) + "_" + to_string(alpha) + "_" + to_string(cx) + "_" + to_string(cy), pmesh); visit_dc.RegisterField("temperature", &u_gf); - if (!de && !online && visit) + if (!de && !online && ::visit) { visit_dc.SetCycle(0); visit_dc.SetTime(0.0); @@ -522,7 +522,7 @@ double simulation() sout << "solution\n" << *pmesh << u_gf << flush; } - if (!de && !online && visit) + if (!de && !online && ::visit) { visit_dc.SetCycle(ti); visit_dc.SetTime(t); @@ -732,14 +732,14 @@ double simulation() to_string(radius) + "_" + to_string(alpha) + "_" + to_string(cx) + "_" + to_string(cy), pmesh); dmd_visit_dc.RegisterField("temperature", &u_gf); - if (visit) + if (::visit) { dmd_visit_dc.SetCycle(0); dmd_visit_dc.SetTime(0.0); dmd_visit_dc.Save(); } - if (visit) + if (::visit) { for (int i = 1; i < ts.size(); i++) { @@ -1017,7 +1017,7 @@ int main(int argc, char *argv[]) args.AddOption(&visualization, "-vis", "--visualization", "-no-vis", "--no-visualization", "Enable or disable GLVis visualization."); - args.AddOption(&visit, "-visit", "--visit-datafiles", "-no-visit", + args.AddOption(&::visit, "-visit", "--visit-datafiles", "-no-visit", "--no-visit-datafiles", "Save data files for VisIt (visit.llnl.gov) visualization."); args.AddOption(&vis_steps, "-vs", "--visualization-steps", @@ -1054,7 +1054,7 @@ int main(int argc, char *argv[]) if (build_database) { MFEM_VERIFY(rdim != -1, "rdim must be set."); - MFEM_VERIFY(!visit + MFEM_VERIFY(!::visit && !visualization, "visit and visualization must be turned off during the build_database phase.") std::ifstream infile("de_parametric_heat_conduction_greedy_data"); From 4de3686ff7cbe3710449f147dda5e6e3d033de77 Mon Sep 17 00:00:00 2001 From: Ido Akkerman Date: Fri, 21 Nov 2025 09:33:53 +0100 Subject: [PATCH 07/15] Removing using namespace std from library --- lib/mfem/PointwiseSnapshot.hpp | 1 - lib/mfem/SampleMesh.cpp | 31 +++++++++++++++++++++---------- lib/mfem/SampleMesh.hpp | 5 ++++- lib/mfem/Utilities.hpp | 1 - 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/lib/mfem/PointwiseSnapshot.hpp b/lib/mfem/PointwiseSnapshot.hpp index 33e99f4e0..0da1852dc 100644 --- a/lib/mfem/PointwiseSnapshot.hpp +++ b/lib/mfem/PointwiseSnapshot.hpp @@ -14,7 +14,6 @@ #include "mfem.hpp" using namespace mfem; -using namespace std; #ifdef MFEM_USE_GSLIB namespace CAROM { diff --git a/lib/mfem/SampleMesh.cpp b/lib/mfem/SampleMesh.cpp index 944097b9a..1a9234e78 100644 --- a/lib/mfem/SampleMesh.cpp +++ b/lib/mfem/SampleMesh.cpp @@ -10,6 +10,14 @@ #include "SampleMesh.hpp" +using std::vector; +using std::set; +using std::map; +using std::make_pair; +using std::string; +using std::cout; +using std::endl; + namespace CAROM { #define FULL_DOF_STENCIL @@ -899,7 +907,7 @@ void ParaViewPrintAttributes(const string &fname, const Array *el_number=nullptr, const Array *vert_number=nullptr) { - ofstream out(fname + ".vtu"); + std::ofstream out(fname + ".vtu"); out << "\n"; @@ -1221,8 +1229,8 @@ void SampleMeshManager::ConstructSampleMesh() spaceTOS[i+1] = spaceTOS[i] + fespace[i]->GetTrueVSize(); } - SetSampleMaps(); - CreateSampleMesh(); + SetSampleMaps();std::cout<<1224 <GetNE() == elemLocalIndices.size(), ""); if (myid == 0) { sample_pmesh = new ParMesh(root_comm, *sample_mesh); delete sample_mesh; - + for (int i=0; iGetNURBSext()<FEColl(), + spfespace[i] = new ParFiniteElementSpace(sample_pmesh, + fespace[i]->GetNURBSext(), + fespace[i]->FEColl(), fespace[i]->GetVDim()); } - +std::cout<<1593 < spNtrue(nspaces); for (int i=0; iTrueVSize() : 0; @@ -1604,7 +1615,7 @@ void SampleMeshManager::CreateSampleMesh() Finish_s2sp_augmented(myid, nprocs, fespace, sample_dofs_block, sample_dofs_sub_to_sample_dofs, local_num_sample_dofs_sub, true, s2sp); #endif - +std::cout<<1607 < v; - ifstream file; + std::ifstream file; file.open(file_name); string line; while(getline(file, line)) { diff --git a/lib/mfem/SampleMesh.hpp b/lib/mfem/SampleMesh.hpp index 343c439b6..ec4d1b969 100644 --- a/lib/mfem/SampleMesh.hpp +++ b/lib/mfem/SampleMesh.hpp @@ -20,7 +20,10 @@ #include "linalg/Matrix.h" using namespace mfem; -using namespace std; +using std::vector; +using std::set; +using std::map; +using std::string; namespace CAROM { diff --git a/lib/mfem/Utilities.hpp b/lib/mfem/Utilities.hpp index 9e7b32b57..d55bad445 100644 --- a/lib/mfem/Utilities.hpp +++ b/lib/mfem/Utilities.hpp @@ -15,7 +15,6 @@ #include "linalg/Matrix.h" using namespace mfem; -using namespace std; namespace CAROM { From c2eeaba88e60a3cc6c3e4824707a79176b086504 Mon Sep 17 00:00:00 2001 From: Ido Akkerman Date: Fri, 21 Nov 2025 09:34:31 +0100 Subject: [PATCH 08/15] Fix example usage of std --- examples/dmd/de_dg_advection_greedy.cpp | 25 +++++++++++---- .../de_parametric_heat_conduction_greedy.cpp | 25 +++++++++++---- .../prom/de_parametric_maxwell_greedy.cpp | 21 +++++++++--- .../prom/nonlinear_elasticity_global_rom.cpp | 32 +++++++++---------- 4 files changed, 69 insertions(+), 34 deletions(-) diff --git a/examples/dmd/de_dg_advection_greedy.cpp b/examples/dmd/de_dg_advection_greedy.cpp index 8f1eeb9b6..96b8da1d3 100644 --- a/examples/dmd/de_dg_advection_greedy.cpp +++ b/examples/dmd/de_dg_advection_greedy.cpp @@ -72,7 +72,18 @@ #include "utils/CSVDatabase.h" -using namespace std; +using std::vector; +using std::cout; +using std::endl; +using std::flush; +using std::max; +using std::min; +using std::to_string; +using std::ifstream; +using std::ofstream; +using std::ostringstream; +using std::setfill; +using std::setw; using namespace mfem; // Choice for the problem setup. The fluid velocity, initial condition and @@ -478,7 +489,7 @@ double simulation() // Create data collection for solution output: either VisItDataCollection for // ascii data files, or SidreDataCollection for binary data files. DataCollection *dc = NULL; - if (::visit) + if (visit) { if (binary) { @@ -791,7 +802,7 @@ double simulation() sout << "solution\n" << pmesh << u_gf << flush; } - if (::visit) + if (visit) { dc->SetCycle(ti); dc->SetTime(t); @@ -946,14 +957,14 @@ double simulation() VisItDataCollection dmd_visit_dc("DMD_DG_Advection_Greedy_" + to_string(f_factor), &pmesh); dmd_visit_dc.RegisterField("temperature", &u_gf); - if (::visit) + if (visit) { dmd_visit_dc.SetCycle(0); dmd_visit_dc.SetTime(0.0); dmd_visit_dc.Save(); } - if (::visit) + if (visit) { for (int i = 1; i < ts.size(); i++) { @@ -1148,7 +1159,7 @@ int main(int argc, char *argv[]) args.AddOption(&visualization, "-vis", "--visualization", "-no-vis", "--no-visualization", "Enable or disable GLVis visualization."); - args.AddOption(&::visit, "-visit", "--visit-datafiles", "-no-visit", + args.AddOption(&visit, "-visit", "--visit-datafiles", "-no-visit", "--no-visit-datafiles", "Save data files for VisIt (visit.llnl.gov) visualization."); args.AddOption(¶view, "-paraview", "--paraview-datafiles", "-no-paraview", @@ -1271,7 +1282,7 @@ int main(int argc, char *argv[]) else if (build_database) { MFEM_VERIFY(rdim != -1, "rdim must be set."); - MFEM_VERIFY(!::visit + MFEM_VERIFY(!visit && !visualization, "visit and visualization must be turned off during the build_database phase.") std::ifstream infile(io_dir+"/dg_advection_greedy_parametric_data"); diff --git a/examples/dmd/de_parametric_heat_conduction_greedy.cpp b/examples/dmd/de_parametric_heat_conduction_greedy.cpp index ca02bde8e..d0435507e 100644 --- a/examples/dmd/de_parametric_heat_conduction_greedy.cpp +++ b/examples/dmd/de_parametric_heat_conduction_greedy.cpp @@ -70,7 +70,18 @@ #define mkdir(dir, mode) _mkdir(dir) #endif -using namespace std; +using std::vector; +using std::cout; +using std::endl; +using std::flush; +using std::max; +using std::min; +using std::to_string; +using std::ifstream; +using std::ofstream; +using std::ostringstream; +using std::setfill; +using std::setw; using namespace mfem; /** After spatial discretization, the conduction model can be written as: @@ -306,7 +317,7 @@ double simulation() to_string(radius) + "_" + to_string(alpha) + "_" + to_string(cx) + "_" + to_string(cy), pmesh); visit_dc.RegisterField("temperature", &u_gf); - if (!de && !online && ::visit) + if (!de && !online && visit) { visit_dc.SetCycle(0); visit_dc.SetTime(0.0); @@ -522,7 +533,7 @@ double simulation() sout << "solution\n" << *pmesh << u_gf << flush; } - if (!de && !online && ::visit) + if (!de && !online && visit) { visit_dc.SetCycle(ti); visit_dc.SetTime(t); @@ -732,14 +743,14 @@ double simulation() to_string(radius) + "_" + to_string(alpha) + "_" + to_string(cx) + "_" + to_string(cy), pmesh); dmd_visit_dc.RegisterField("temperature", &u_gf); - if (::visit) + if (visit) { dmd_visit_dc.SetCycle(0); dmd_visit_dc.SetTime(0.0); dmd_visit_dc.Save(); } - if (::visit) + if (visit) { for (int i = 1; i < ts.size(); i++) { @@ -1017,7 +1028,7 @@ int main(int argc, char *argv[]) args.AddOption(&visualization, "-vis", "--visualization", "-no-vis", "--no-visualization", "Enable or disable GLVis visualization."); - args.AddOption(&::visit, "-visit", "--visit-datafiles", "-no-visit", + args.AddOption(&visit, "-visit", "--visit-datafiles", "-no-visit", "--no-visit-datafiles", "Save data files for VisIt (visit.llnl.gov) visualization."); args.AddOption(&vis_steps, "-vs", "--visualization-steps", @@ -1054,7 +1065,7 @@ int main(int argc, char *argv[]) if (build_database) { MFEM_VERIFY(rdim != -1, "rdim must be set."); - MFEM_VERIFY(!::visit + MFEM_VERIFY(!visit && !visualization, "visit and visualization must be turned off during the build_database phase.") std::ifstream infile("de_parametric_heat_conduction_greedy_data"); diff --git a/examples/prom/de_parametric_maxwell_greedy.cpp b/examples/prom/de_parametric_maxwell_greedy.cpp index fa2fc5ea4..f71a18b9d 100644 --- a/examples/prom/de_parametric_maxwell_greedy.cpp +++ b/examples/prom/de_parametric_maxwell_greedy.cpp @@ -72,7 +72,20 @@ #define mkdir(dir, mode) _mkdir(dir) #endif -using namespace std; +using std::vector; +using std::set; +using std::map; +using std::make_pair; +using std::string; +using std::cout; +using std::endl; +using std::flush; +using std::max; +using std::min; +using std::to_string; +using std::ifstream; +using std::ofstream; +using std::ostringstream; using namespace mfem; // Exact solution, E, and r.h.s., f. See below for implementation. @@ -388,7 +401,7 @@ double simulation() // 27. Save data in the VisIt format. DataCollection *dc = NULL; - if (::visit) + if (visit) { if (offline) dc = new VisItDataCollection("de_maxwell_local", pmesh); else if (fom) dc = new VisItDataCollection("de_maxwell_local_fom", pmesh); @@ -647,7 +660,7 @@ int main(int argc, char *argv[]) "--no-partial-assembly", "Enable Partial Assembly."); args.AddOption(&device_config, "-d", "--device", "Device configuration string, see Device::Configure()."); - args.AddOption(&::visit, "-visit", "--visit-datafiles", "-no-visit", + args.AddOption(&visit, "-visit", "--visit-datafiles", "-no-visit", "--no-visit-datafiles", "Save data files for VisIt (visit.llnl.gov) visualization."); args.AddOption(&visualization, "-vis", "--visualization", "-no-vis", @@ -738,7 +751,7 @@ int main(int argc, char *argv[]) MFEM_VERIFY(!offline && !online, "offline and online must be turned off during the build_database phase."); - MFEM_VERIFY(!::visit + MFEM_VERIFY(!visit && !visualization, "visit and visualization must be turned off during the build_database phase.") std::ifstream infile("de_parametric_maxwell_greedy_algorithm_data"); diff --git a/examples/prom/nonlinear_elasticity_global_rom.cpp b/examples/prom/nonlinear_elasticity_global_rom.cpp index 21aef2fd0..7ae5c3ddc 100644 --- a/examples/prom/nonlinear_elasticity_global_rom.cpp +++ b/examples/prom/nonlinear_elasticity_global_rom.cpp @@ -910,7 +910,7 @@ int main(int argc, char *argv[]) } if (use_eqp) - { + {std::cout<<911<GetNPoints() * fespace.GetNE(), true); SetupEQP_snapshots(ir0, myid, &fespace, nsets, BV_librom.get(), @@ -965,10 +965,10 @@ int main(int argc, char *argv[]) num_sample_dofs_per_proc); smm->RegisterSampledVariable("H", 0, sample_dofs, num_sample_dofs_per_proc); - +std::cout<<968<ConstructSampleMesh(); } - +std::cout<<971<ConstructSampleMesh(); } -std::cout<<971< 0) + if (order > 0) { fec = new H1_FECollection(order, dim); delete_fec = true; @@ -210,7 +204,7 @@ int main(int argc, char *argv[]) fec = new H1_FECollection(order = 1, dim); delete_fec = true; } - ParFiniteElementSpace fespace(&pmesh, NURBSext, fec); + ParFiniteElementSpace fespace(&pmesh, fec); HYPRE_Int size = fespace.GlobalTrueVSize(); if (myid == 0) { From 34e820a5dc2aaa43a1b14248692a36eaf9e5f0a7 Mon Sep 17 00:00:00 2001 From: Ido Akkerman Date: Fri, 21 Nov 2025 09:45:02 +0100 Subject: [PATCH 10/15] Remove debug statements --- lib/mfem/SampleMesh.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/mfem/SampleMesh.cpp b/lib/mfem/SampleMesh.cpp index 1a9234e78..5a2be53f3 100644 --- a/lib/mfem/SampleMesh.cpp +++ b/lib/mfem/SampleMesh.cpp @@ -10,12 +10,7 @@ #include "SampleMesh.hpp" -using std::vector; -using std::set; -using std::map; using std::make_pair; -using std::string; -using std::cout; using std::endl; namespace CAROM { @@ -1229,8 +1224,8 @@ void SampleMeshManager::ConstructSampleMesh() spaceTOS[i+1] = spaceTOS[i] + fespace[i]->GetTrueVSize(); } - SetSampleMaps();std::cout<<1224 <GetNE() == elemLocalIndices.size(), ""); if (myid == 0) @@ -1593,7 +1588,7 @@ std::cout<<1580 <GetNURBSext()<FEColl(), fespace[i]->GetVDim()); } -std::cout<<1593 < spNtrue(nspaces); for (int i=0; iTrueVSize() : 0; @@ -1615,7 +1610,7 @@ std::cout<<1593 < Date: Fri, 21 Nov 2025 09:46:56 +0100 Subject: [PATCH 11/15] Rationalize Cmakefiles --- CMakeLists.txt | 127 +++----------------------------- examples/dmd/CMakeLists.txt | 31 ++++++++ examples/misc/CMakeLists.txt | 9 +++ examples/prom/CMakeLists.txt | 28 +++++++ lib/CMakeLists.txt | 10 ++- regression_tests/CMakeLists.txt | 25 +++++++ 6 files changed, 109 insertions(+), 121 deletions(-) create mode 100644 examples/dmd/CMakeLists.txt create mode 100644 examples/misc/CMakeLists.txt create mode 100644 examples/prom/CMakeLists.txt create mode 100644 regression_tests/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 71d0a2d71..af3b61190 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,133 +110,26 @@ set(CAROM_HAVE_LAPACK ${LAPACK_FOUND}) set(CAROM_HAVE_HDF5 ${HDF5_FOUND}) if (USE_MFEM) - find_library(MFEM mfem "${CMAKE_SOURCE_DIR}/dependencies/mfem" "${MFEM_DIR}/lib") - find_library(HYPRE HYPRE "${CMAKE_SOURCE_DIR}/dependencies/hypre/src/hypre/lib" "${HYPRE_DIR}/lib") - find_library(PARMETIS parmetis "${CMAKE_SOURCE_DIR}/dependencies/parmetis-4.0.3/build/lib/libparmetis" "${PARMETIS_DIR}/lib") - find_library(METIS metis "${CMAKE_SOURCE_DIR}/dependencies/parmetis-4.0.3/build/lib/libmetis" "${METIS_DIR}/lib") - find_path(MFEM_INCLUDES mfem.hpp "${CMAKE_SOURCE_DIR}/dependencies/mfem" "${MFEM_DIR}/include") - find_path(HYPRE_INCLUDES HYPRE.h "${CMAKE_SOURCE_DIR}/dependencies/hypre/src/hypre/include" "${HYPRE_DIR}/include") - find_path(PARMETIS_INCLUDES metis.h "${CMAKE_SOURCE_DIR}/dependencies/parmetis-4.0.3/metis/include" "${PARMETIS_DIR}/metis/include") + find_package(mfem REQUIRED NAMES MFEM HINTS "${MFEM_DIR}" + "${MFEM_DIR}/lib/cmake/mfem" NO_DEFAULT_PATH) + message(STATUS "Found mfem config in: ${mfem_DIR} (version ${MFEM_VERSION})") endif() -add_subdirectory(lib) +set(CAROM_LIBS ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES} MPI::MPI_C ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran) +set(CAROM_INCS ${CMAKE_CURRENT_SOURCE_DIR} ${MPI_C_INCLUDE_DIRS}) -# Use the C++11 standard as an entire feature instead of -# enumerating individual compiler features for simplicity -target_compile_features(ROM PRIVATE cxx_std_11) +add_subdirectory(lib) if (ENABLE_EXAMPLES) + add_subdirectory(examples/misc) if (USE_MFEM) - set(examples - poisson_global_rom - poisson_local_rom_greedy - dg_advection_global_rom - dg_advection_local_rom_matrix_interp - mixed_nonlinear_diffusion - nonlinear_elasticity_global_rom - linear_elasticity_global_rom - maxwell_global_rom - de_parametric_maxwell_greedy - maxwell_local_rom_greedy - grad_div_global_rom - elliptic_eigenproblem_global_rom - dg_advection - nonlinear_elasticity - heat_conduction - heat_conduction_dmdc - parametric_heat_conduction - de_parametric_heat_conduction_greedy - de_dg_advection_greedy - wave_equation - dg_euler - local_dw_csv - parametric_tw_csv - parametric_dw_csv - parametric_dmdc_heat_conduction) - set(example_directories - prom - prom - prom - prom - prom - prom - prom - prom - prom - prom - prom - prom - dmd - dmd - dmd - dmd - dmd - dmd - dmd - dmd - dmd - dmd - dmd - dmd - dmd) - - list(LENGTH examples len1) - math(EXPR len2 "${len1} - 1") - - foreach(val RANGE ${len2}) - list(GET examples ${val} name) - list(GET example_directories ${val} example_dir) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples/${example_dir}) - add_executable(${name} examples/${example_dir}/${name}.cpp) - - target_link_libraries(${name} - PRIVATE ROM ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} MPI::MPI_C ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran) - target_include_directories(${name} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - ${MPI_C_INCLUDE_DIRS}) - target_compile_features(${name} PRIVATE cxx_std_11) - endforeach() # IN LISTS examples + add_subdirectory(examples/prom) + add_subdirectory(examples/dmd) file(COPY examples/data DESTINATION ${CMAKE_BINARY_DIR}/examples) file(COPY examples/merlin DESTINATION ${CMAKE_BINARY_DIR}/examples) file(COPY examples/dmd/heat_conduction_csv.sh DESTINATION ${CMAKE_BINARY_DIR}/examples/dmd) file(COPY examples/dmd/heat_conduction_hdf.sh DESTINATION ${CMAKE_BINARY_DIR}/examples/dmd) - endif() - - set(misc_example_names - combine_samples) - - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples/misc) - - foreach(name IN LISTS misc_example_names) - add_executable(${name} examples/misc/${name}.cpp) - - target_link_libraries(${name} - PRIVATE ROM ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} MPI::MPI_C ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran) - target_include_directories(${name} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - ${MPI_C_INCLUDE_DIRS}) - target_compile_features(${name} PRIVATE cxx_std_11) - endforeach(name) # IN LISTS misc_exmaple_names - - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) - - if (USE_MFEM) - set(regression_test_names - basisComparator - checkError - computeSpeedup - solutionComparator - fileComparator) - - foreach(name IN LISTS regression_test_names) - add_executable(${name} regression_tests/${name}.cpp) - target_link_libraries(${name} - PRIVATE ROM ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} MPI::MPI_C ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran) - target_include_directories(${name} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - ${MPI_C_INCLUDE_DIRS}) - target_compile_features(${name} PRIVATE cxx_std_11) - endforeach(name) # IN LISTS regression_test_names + add_subdirectory(regression_tests) endif() endif(ENABLE_EXAMPLES) diff --git a/examples/dmd/CMakeLists.txt b/examples/dmd/CMakeLists.txt new file mode 100644 index 000000000..c45510d04 --- /dev/null +++ b/examples/dmd/CMakeLists.txt @@ -0,0 +1,31 @@ +############################################################################### +# +# Copyright (c) 2013-2024, Lawrence Livermore National Security, LLC +# and other libROM project developers. See the top-level COPYRIGHT +# file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) +# +############################################################################### + +set(examples + dg_advection + nonlinear_elasticity + heat_conduction + heat_conduction_dmdc + parametric_heat_conduction + de_parametric_heat_conduction_greedy + de_dg_advection_greedy + wave_equation + dg_euler + local_dw_csv + parametric_tw_csv + parametric_dw_csv + parametric_dmdc_heat_conduction) + +foreach(name IN LISTS examples) + add_executable(${name} ${name}.cpp) + target_link_libraries(${name} PRIVATE ROM ${CAROM_LIBS}) + target_include_directories(${name} PRIVATE ${CAROM_INCS}) + target_compile_features(${name} PRIVATE cxx_std_17) +endforeach() diff --git a/examples/misc/CMakeLists.txt b/examples/misc/CMakeLists.txt new file mode 100644 index 000000000..c93e056ca --- /dev/null +++ b/examples/misc/CMakeLists.txt @@ -0,0 +1,9 @@ +set(examples + combine_samples) + +foreach(name IN LISTS examples) + add_executable(${name} ${name}.cpp) + target_link_libraries(${name} PRIVATE ROM ${CAROM_LIBS}) + target_include_directories(${name} PRIVATE ${CAROM_INCS}) + target_compile_features(${name} PRIVATE cxx_std_17) +endforeach() diff --git a/examples/prom/CMakeLists.txt b/examples/prom/CMakeLists.txt new file mode 100644 index 000000000..063018cfa --- /dev/null +++ b/examples/prom/CMakeLists.txt @@ -0,0 +1,28 @@ +############################################################################### +# +# Copyright (c) 2013-2024, Lawrence Livermore National Security, LLC +# and other libROM project developers. See the top-level COPYRIGHT +# file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) +# +############################################################################### +set(examples + poisson_global_rom + poisson_local_rom_greedy + dg_advection_global_rom + dg_advection_local_rom_matrix_interp + mixed_nonlinear_diffusion + nonlinear_elasticity_global_rom + linear_elasticity_global_rom + maxwell_global_rom + de_parametric_maxwell_greedy + maxwell_local_rom_greedy + elliptic_eigenproblem_global_rom) + +foreach(name IN LISTS examples) + add_executable(${name} ${name}.cpp) + target_link_libraries(${name} PRIVATE ROM ${CAROM_LIBS}) + target_include_directories(${name} PRIVATE ${CAROM_INCS}) + target_compile_features(${name} PRIVATE cxx_std_17) +endforeach() diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 873fd3db2..d3dd8fb5f 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -97,9 +97,9 @@ if (BLAS_LIBRARIES MATCHES ".*mkl.*") find_package(MKL COMPONENTS BLACS ScaLAPACK) if (NOT MKL_ScaLAPACK_FOUND) find_package(ScaLAPACK REQUIRED) - target_link_libraries(ROM PUBLIC ${ScaLAPACK_LIBRARIES}) + target_link_libraries(ROM PUBLIC ${ScaLAPACK_LIBRARIES} ${MFEM_LIBRARIES}) else() - target_link_libraries(ROM PUBLIC ${MKL_ScaLAPACK_LIBRARY} ${MKL_BLACS_LIBRARY} ${MKL_LIBRARIES}) + target_link_libraries(ROM PUBLIC ${MKL_ScaLAPACK_LIBRARY} ${MKL_BLACS_LIBRARY} ${MKL_LIBRARIES} ${MFEM_LIBRARIES}) target_include_directories(ROM PUBLIC ${MKL_INCLUDE_DIRS}) endif() else() # BLAS or LAPACK isn't MKL @@ -112,7 +112,7 @@ else() # BLAS or LAPACK isn't MKL set(ENV{PATH} "${CMAKE_SOURCE_DIR}/dependencies/scalapack-2.2.0:$ENV{PATH}") find_package(ScaLAPACK REQUIRED) endif() - target_link_libraries(ROM PUBLIC ${ScaLAPACK_LIBRARIES}) + target_link_libraries(ROM PUBLIC ${ScaLAPACK_LIBRARIES} ${MFEM_LIBRARIES}) endif() # PUBLIC dependencies are transitive; these dependencies are used in @@ -131,7 +131,7 @@ endif() # 3.0. target_link_libraries(ROM PUBLIC ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} MPI::MPI_C ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran ${HDF5_LIBRARIES} - ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MFEM} ${HYPRE} ${PARMETIS} ${METIS} + ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MFEM} ${HYPRE} ${PARMETIS} ${METIS} ${MFEM_LIBRARIES} PRIVATE ${ZLIB_LIBRARIES} ZLIB::ZLIB) target_include_directories(ROM PUBLIC @@ -144,6 +144,8 @@ target_include_directories(ROM PUBLIC ${MFEM_C_INCLUDE_DIRS} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +target_compile_features(ROM PRIVATE cxx_std_17) + # Find headers from the source file list that need to be installed set(HEADERS "") foreach(file IN LISTS source_files) diff --git a/regression_tests/CMakeLists.txt b/regression_tests/CMakeLists.txt new file mode 100644 index 000000000..67824a55d --- /dev/null +++ b/regression_tests/CMakeLists.txt @@ -0,0 +1,25 @@ +############################################################################### +# +# Copyright (c) 2013-2024, Lawrence Livermore National Security, LLC +# and other libROM project developers. See the top-level COPYRIGHT +# file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) +# +############################################################################### + +set(regression_test_names + basisComparator + checkError + computeSpeedup + solutionComparator + fileComparator) + +foreach(name IN LISTS regression_test_names) + add_executable(${name} ${name}.cpp) + target_link_libraries(${name} PRIVATE ROM ${CAROM_LIBS}) + target_include_directories(${name} PRIVATE ${CAROM_INCS}) + target_compile_features(${name} PRIVATE cxx_std_17) +endforeach() + + From d01f5b10ff30c74eb3033642b5da8a1ce167ff41 Mon Sep 17 00:00:00 2001 From: Ido Akkerman Date: Fri, 21 Nov 2025 10:04:09 +0100 Subject: [PATCH 12/15] Revert some changes --- lib/mfem/SampleMesh.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/mfem/SampleMesh.cpp b/lib/mfem/SampleMesh.cpp index 5a2be53f3..35fc00052 100644 --- a/lib/mfem/SampleMesh.cpp +++ b/lib/mfem/SampleMesh.cpp @@ -10,8 +10,10 @@ #include "SampleMesh.hpp" -using std::make_pair; using std::endl; +using std::make_pair; +using std::ofstream; +using std::ifstream; namespace CAROM { @@ -902,7 +904,7 @@ void ParaViewPrintAttributes(const string &fname, const Array *el_number=nullptr, const Array *vert_number=nullptr) { - std::ofstream out(fname + ".vtu"); + ofstream out(fname + ".vtu"); out << "\n"; @@ -1320,7 +1322,7 @@ void SampleMeshManager::WriteVariableSampleMap(const string variable, string file_name) const { const int var = GetVariableIndex(variable); - std::ofstream file; + ofstream file; file.open(file_name); for (int i=0; iGetNURBSext(), - fespace[i]->FEColl(), + spfespace[i] = new ParFiniteElementSpace(sample_pmesh, fespace[i]->FEColl(), fespace[i]->GetVDim()); } @@ -1791,7 +1790,7 @@ void SampleDOFSelector::ReadMapFromFile(const string variable, string file_name) vmap[variable] = nvar; vector v; - std::ifstream file; + ifstream file; file.open(file_name); string line; while(getline(file, line)) { From 187203ff751ffd4936ef3aef38cbacfbb3ac9d35 Mon Sep 17 00:00:00 2001 From: Ido Akkerman Date: Fri, 21 Nov 2025 10:08:48 +0100 Subject: [PATCH 13/15] Add white space --- lib/linalg/svd/IncrementalSVD.h | 2 +- lib/linalg/svd/IncrementalSVDFastUpdate.h | 4 ++-- lib/utils/HDFDatabase.h | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/linalg/svd/IncrementalSVD.h b/lib/linalg/svd/IncrementalSVD.h index b5a4f4903..a79fd1bfa 100644 --- a/lib/linalg/svd/IncrementalSVD.h +++ b/lib/linalg/svd/IncrementalSVD.h @@ -62,7 +62,7 @@ class IncrementalSVD : public SVD bool takeSample( double* u_in, - bool add_without_increase = false)override; + bool add_without_increase = false) override; /** * @brief Returns the basis vectors for the current time interval as a diff --git a/lib/linalg/svd/IncrementalSVDFastUpdate.h b/lib/linalg/svd/IncrementalSVDFastUpdate.h index 9c9ffa163..973454a12 100644 --- a/lib/linalg/svd/IncrementalSVDFastUpdate.h +++ b/lib/linalg/svd/IncrementalSVDFastUpdate.h @@ -98,7 +98,7 @@ class IncrementalSVDFastUpdate : public IncrementalSVD addLinearlyDependentSample( const Matrix & A, const Matrix & W, - const Matrix & sigma)override; + const Matrix & sigma) override; /** * @brief Add a new, unique sample to the SVD. @@ -113,7 +113,7 @@ class IncrementalSVDFastUpdate : public IncrementalSVD const Vector & j, const Matrix & A, const Matrix & W, - const Matrix & sigma)override; + const Matrix & sigma) override; /** * @brief The matrix U'. U' is not distributed and the entire matrix diff --git a/lib/utils/HDFDatabase.h b/lib/utils/HDFDatabase.h index 853907e62..4c82377a5 100644 --- a/lib/utils/HDFDatabase.h +++ b/lib/utils/HDFDatabase.h @@ -125,7 +125,7 @@ class HDFDatabase : public Database const std::string& key, const double* const data, int nelements, - const bool distributed=false)override; + const bool distributed=false) override; /** * @brief Writes a vector of doubles associated with the supplied key to @@ -149,7 +149,7 @@ class HDFDatabase : public Database const std::string& key, const std::vector& data, int nelements, - const bool distributed=false)override; + const bool distributed=false) override; /** * @brief Reads an array of integers associated with the supplied key @@ -172,7 +172,7 @@ class HDFDatabase : public Database const std::string& key, int* data, int nelements, - const bool distributed=false)override; + const bool distributed=false) override; /** * @brief Count the number of elements in an array of doubles associated @@ -184,7 +184,7 @@ class HDFDatabase : public Database */ virtual int - getDoubleArraySize(const std::string& key)override; + getDoubleArraySize(const std::string& key) override; /** * @brief Reads an array of doubles associated with the supplied key @@ -207,7 +207,7 @@ class HDFDatabase : public Database const std::string& key, double* data, int nelements, - const bool distributed=false)override; + const bool distributed=false) override; /** * @brief Reads a sub-array of doubles associated with the supplied key @@ -232,7 +232,7 @@ class HDFDatabase : public Database double* data, int nelements, const std::vector& idx, - const bool distributed=false)override; + const bool distributed=false) override; /** * @brief Reads an array of doubles associated with the supplied key @@ -264,7 +264,7 @@ class HDFDatabase : public Database int offset, int block_size, int stride, - const bool distributed=false)override; + const bool distributed=false) override; protected: From 1224ebea34e025000a9303f17a1481cddefe04a2 Mon Sep 17 00:00:00 2001 From: Ido Akkerman Date: Fri, 21 Nov 2025 10:53:04 +0100 Subject: [PATCH 14/15] Allow both cmake and configure for MFEM builds --- CMakeLists.txt | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af3b61190..6dd2f8bdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,9 +110,28 @@ set(CAROM_HAVE_LAPACK ${LAPACK_FOUND}) set(CAROM_HAVE_HDF5 ${HDF5_FOUND}) if (USE_MFEM) - find_package(mfem REQUIRED NAMES MFEM HINTS "${MFEM_DIR}" - "${MFEM_DIR}/lib/cmake/mfem" NO_DEFAULT_PATH) - message(STATUS "Found mfem config in: ${mfem_DIR} (version ${MFEM_VERSION})") + # Try to find MFEM installed using cmake + find_package(mfem NAMES MFEM HINTS "${MFEM_DIR}" + "${MFEM_DIR}/lib/cmake/mfem" "${CMAKE_SOURCE_DIR}/dependencies/mfem/lib/cmake/mfem" NO_DEFAULT_PATH QUIET) + if (mfem_FOUND) + message(STATUS "Found mfem config in: ${mfem_DIR} (version ${MFEM_VERSION})") + else() + # Try to find MFEM installed using configure + find_library(MFEM mfem HINTS "${MFEM_DIR}/lib" "${CMAKE_SOURCE_DIR}/dependencies/mfem") + find_library(HYPRE HYPRE HINTS "${HYPRE_DIR}/lib" "${CMAKE_SOURCE_DIR}/dependencies/hypre/src/hypre/lib") + find_library(PARMETIS parmetis HINTS "${PARMETIS_DIR}/lib" "${CMAKE_SOURCE_DIR}/dependencies/parmetis-4.0.3/build/lib/libparmetis") + find_library(METIS metis HINTS "${METIS_DIR}/lib" "${CMAKE_SOURCE_DIR}/dependencies/parmetis-4.0.3/build/lib/libmetis") + find_path(MFEM_INCLUDES mfem.hpp HINTS "${MFEM_DIR}/include" "${CMAKE_SOURCE_DIR}/dependencies/mfem") + find_path(HYPRE_INCLUDES HYPRE.h HINTS "${HYPRE_DIR}/include" "${CMAKE_SOURCE_DIR}/dependencies/hypre/src/hypre/include") + find_path(PARMETIS_INCLUDES metis.h "${PARMETIS_DIR}/metis/include" "${CMAKE_SOURCE_DIR}/dependencies/parmetis-4.0.3/metis/include") + + if (${MFEM} STREQUAL "MFEM-NOTFOUND") + error( "MFEM not found" ) + else() + message(STATUS "MFEM library:" ${MFEM}) + message(STATUS "MFEM includes:" ${MFEM_INCLUDES}) + endif() + endif() endif() set(CAROM_LIBS ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES} MPI::MPI_C ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran) From ab377e271882262c168cfd61463623cf4c4b5395 Mon Sep 17 00:00:00 2001 From: Ido Akkerman Date: Fri, 21 Nov 2025 11:17:10 +0100 Subject: [PATCH 15/15] Add missing using statements --- lib/mfem/PointwiseSnapshot.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/mfem/PointwiseSnapshot.cpp b/lib/mfem/PointwiseSnapshot.cpp index 9d3ea9a4b..426de547b 100644 --- a/lib/mfem/PointwiseSnapshot.cpp +++ b/lib/mfem/PointwiseSnapshot.cpp @@ -1,6 +1,8 @@ #include "PointwiseSnapshot.hpp" #ifdef MFEM_USE_GSLIB +using std::cout; +using std::endl; namespace CAROM { PointwiseSnapshot::PointwiseSnapshot(const int sdim, const int *dims_)