From 9edbce7bea5780aeb907e1a90a0d7d4392aa4661 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Mon, 9 Nov 2026 13:57:33 -0500 Subject: [PATCH] refactor(examples): deleted demo library examples directory --- examples/meson.build | 35 --------------- examples/parallel_hypre.cpp | 88 ------------------------------------- examples/serial_poisson.cpp | 81 ---------------------------------- 3 files changed, 204 deletions(-) delete mode 100644 examples/meson.build delete mode 100644 examples/parallel_hypre.cpp delete mode 100644 examples/serial_poisson.cpp diff --git a/examples/meson.build b/examples/meson.build deleted file mode 100644 index e30a8a32..00000000 --- a/examples/meson.build +++ /dev/null @@ -1,35 +0,0 @@ -example_deps = [mfem_dep, template_include_dep] -example_build_rpath = mfem_runtime_prefix == '' ? '' : mfem_runtime_prefix / 'lib' -example_install_rpath = '' -if mfem_runtime_prefix != '' and not is_windows and not is_wasm - example_install_rpath = host_machine.system() == 'darwin' ? '@loader_path/../lib' : '$ORIGIN/../lib' -endif - -serial_example = [] -parallel_example = [] - -if get_option('build_examples') - serial_example = executable( - 'mfem-serial-poisson', - 'serial_poisson.cpp', - dependencies: example_deps, - override_options: ['cpp_std=' + mfem_consumer_cpp_std], - build_rpath: example_build_rpath, - install_rpath: example_install_rpath, - install: true, - install_tag: 'examples', - ) - - if mfem_has_mpi - parallel_example = executable( - 'mfem-parallel-hypre', - 'parallel_hypre.cpp', - dependencies: example_deps, - override_options: ['cpp_std=' + mfem_consumer_cpp_std], - build_rpath: example_build_rpath, - install_rpath: example_install_rpath, - install: true, - install_tag: 'examples', - ) - endif -endif diff --git a/examples/parallel_hypre.cpp b/examples/parallel_hypre.cpp deleted file mode 100644 index bd34297b..00000000 --- a/examples/parallel_hypre.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include - -#include -#include - -#if !MESON_MFEM_HAS_MPI || !MESON_MFEM_HAS_HYPRE -#error "This example requires the MPI/Hypre capability" -#endif - -int main(int argc, char **argv) -{ - mfem::Mpi::Init(argc, argv); - mfem::Hypre::Init(); - const int rank = mfem::Mpi::WorldRank(); - const int ranks = mfem::Mpi::WorldSize(); - const char *device_name = argc > 1 ? argv[1] : "cpu"; - mfem::Device device(device_name); - - mfem::Mesh serial_mesh = mfem::Mesh::MakeCartesian2D( - 8, 8, mfem::Element::QUADRILATERAL, true, 1.0, 1.0); - mfem::Array partitioning(serial_mesh.GetNE()); - for (int element = 0; element < serial_mesh.GetNE(); ++element) - { - partitioning[element] = static_cast(element) * ranks / - serial_mesh.GetNE(); - } - mfem::ParMesh mesh(MPI_COMM_WORLD, serial_mesh, partitioning.GetData()); - serial_mesh.Clear(); - - mfem::H1_FECollection elements(2, mesh.Dimension()); - mfem::ParFiniteElementSpace space(&mesh, &elements); - mfem::Array essential_boundary(mesh.bdr_attributes.Max()); - essential_boundary = 1; - mfem::Array essential_dofs; - space.GetEssentialTrueDofs(essential_boundary, essential_dofs); - - mfem::ConstantCoefficient one(1.0); - mfem::ParLinearForm rhs(&space); - rhs.AddDomainIntegrator(new mfem::DomainLFIntegrator(one)); - rhs.Assemble(); - - mfem::ParGridFunction solution(&space); - solution = 0.0; - mfem::ParBilinearForm diffusion(&space); - diffusion.AddDomainIntegrator(new mfem::DiffusionIntegrator(one)); - diffusion.Assemble(); - - mfem::OperatorPtr matrix; - mfem::Vector linear_rhs; - mfem::Vector linear_solution; - diffusion.FormLinearSystem( - essential_dofs, solution, rhs, matrix, linear_solution, linear_rhs); - - mfem::HypreBoomerAMG boomer_amg; - boomer_amg.SetPrintLevel(0); - mfem::CGSolver solver(MPI_COMM_WORLD); - solver.SetPreconditioner(boomer_amg); - solver.SetOperator(*matrix); - solver.SetRelTol(1e-10); - solver.SetAbsTol(0.0); - solver.SetMaxIter(300); - solver.SetPrintLevel(0); - solver.Mult(linear_rhs, linear_solution); - diffusion.RecoverFEMSolution(linear_solution, rhs, solution); - -#if MESON_MFEM_HAS_GSLIB - mfem::FindPointsGSLIB find_points(MPI_COMM_WORLD); -#endif -#if MESON_MFEM_HAS_SUNDIALS - mfem::CVODESolver cvode(MPI_COMM_WORLD, CV_BDF); -#endif - - const double local_norm = solution.Norml2(); - double global_norm = 0.0; - MPI_Allreduce(&local_norm, &global_norm, 1, MPI_DOUBLE, MPI_SUM, - MPI_COMM_WORLD); - if (rank == 0) - { - std::cout << "MFEM parallel Poisson: ranks=" << ranks - << " global_dofs=" << space.GlobalTrueVSize() - << " norm_sum=" << global_norm - << " device=" << device_name << '\n'; - } - return solver.GetConverged() && std::isfinite(global_norm) && global_norm > 0.0 - ? 0 - : 2; -} diff --git a/examples/serial_poisson.cpp b/examples/serial_poisson.cpp deleted file mode 100644 index 6f926413..00000000 --- a/examples/serial_poisson.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include -#include - -#include -#include - -int main(int argc, char **argv) -{ - const char *device_name = argc > 1 ? argv[1] : -#if MESON_MFEM_HAS_CEED && !defined(__EMSCRIPTEN__) - "ceed-cpu"; -#else - "cpu"; -#endif - mfem::Device device(device_name); - - mfem::Mesh mesh = mfem::Mesh::MakeCartesian2D( - 6, 6, mfem::Element::QUADRILATERAL, true, 1.0, 1.0); - const int dimension = mesh.Dimension(); - mfem::H1_FECollection elements(2, dimension); - mfem::FiniteElementSpace space(&mesh, &elements); - - mfem::Array essential_boundary(mesh.bdr_attributes.Max()); - essential_boundary = 1; - mfem::Array essential_dofs; - space.GetEssentialTrueDofs(essential_boundary, essential_dofs); - - mfem::ConstantCoefficient one(1.0); - mfem::LinearForm rhs(&space); - rhs.AddDomainIntegrator(new mfem::DomainLFIntegrator(one)); - rhs.Assemble(); - - mfem::GridFunction solution(&space); - solution = 0.0; - - mfem::BilinearForm diffusion(&space); - diffusion.AddDomainIntegrator(new mfem::DiffusionIntegrator(one)); - if (mfem::Device::Allows(mfem::Backend::CEED_MASK)) - { - diffusion.SetAssemblyLevel(mfem::AssemblyLevel::PARTIAL); - } - diffusion.Assemble(); - - mfem::OperatorPtr matrix; - mfem::Vector linear_rhs; - mfem::Vector linear_solution; - diffusion.FormLinearSystem( - essential_dofs, solution, rhs, matrix, linear_solution, linear_rhs); - - mfem::CGSolver solver; - solver.SetOperator(*matrix); - solver.SetRelTol(1e-12); - solver.SetAbsTol(0.0); - solver.SetMaxIter(200); - solver.SetPrintLevel(0); - solver.Mult(linear_rhs, linear_solution); - diffusion.RecoverFEMSolution(linear_solution, rhs, solution); - -#if MESON_MFEM_HAS_FMS - mfem::FMSDataCollection fms_collection("meson-mfem-smoke", &mesh); - fms_collection.SetProtocol("ascii"); -#endif - -#if MESON_MFEM_HAS_ALGOIM - mfem::FunctionCoefficient level_set( - [](const mfem::Vector &point) { return point[0] + point[1] - 0.2; }); - mfem::AlgoimIntegrationRules algoim_rules(2, level_set, 2); - mfem::IntegrationRule cut_rule; - algoim_rules.GetVolumeIntegrationRule( - *mesh.GetElementTransformation(0), cut_rule); - if (cut_rule.GetNPoints() == 0) - { - return 3; - } -#endif - - const double norm = solution.Norml2(); - std::cout << "MFEM serial Poisson: dofs=" << space.GetTrueVSize() - << " l2=" << norm << " device=" << device_name << '\n'; - return solver.GetConverged() && std::isfinite(norm) && norm > 0.0 ? 0 : 2; -}