From 917ee335db6f9beb7104c64c4cfc02cfe44fd812 Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Tue, 10 Dec 2024 22:45:11 +0000 Subject: [PATCH] Update unit tests with MFEMScalarBoundaryIntegratedBC and MFEMVectorDomainLFKernel --- unit/src/MFEMIntegratedBCTest.C | 27 +++++++++++++++++++++++++++ unit/src/MFEMKernelTest.C | 25 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/unit/src/MFEMIntegratedBCTest.C b/unit/src/MFEMIntegratedBCTest.C index ae0dedd9..88d1ef28 100644 --- a/unit/src/MFEMIntegratedBCTest.C +++ b/unit/src/MFEMIntegratedBCTest.C @@ -1,4 +1,5 @@ #include "MFEMObjectUnitTest.h" +#include "MFEMScalarBoundaryIntegratedBC.h" #include "MFEMVectorBoundaryIntegratedBC.h" #include "MFEMVectorNormalIntegratedBC.h" #include "MFEMConvectiveHeatFluxBC.h" @@ -41,6 +42,32 @@ TEST_F(MFEMIntegratedBCTest, MFEMVectorNormalIntegratedBC) delete blf_integrator; } +/** + * Test MFEMScalarBoundaryIntegratedBC creates the expected mfem::BoundaryIntegrator successfully. + */ +TEST_F(MFEMIntegratedBCTest, MFEMScalarBoundaryIntegratedBC) +{ + // Build required BC inputs + InputParameters coef_params = _factory.getValidParams("MFEMGenericConstantMaterial"); + coef_params.set>("prop_names") = {"coef1"}; + coef_params.set>("prop_values") = {3.0}; + _mfem_problem->addMaterial("MFEMGenericConstantMaterial", "material1", coef_params); + + // Construct boundary condition + InputParameters bc_params = _factory.getValidParams("MFEMScalarBoundaryIntegratedBC"); + bc_params.set("variable") = "test_variable_name"; + bc_params.set("coefficient") = "coef1"; + bc_params.set>("boundary") = {"1"}; + MFEMScalarBoundaryIntegratedBC & integrated_bc = + addObject("MFEMScalarBoundaryIntegratedBC", "bc1", bc_params); + + // Test MFEMScalarBoundaryIntegratedBC returns an integrator of the expected type + auto lf_integrator = + dynamic_cast(integrated_bc.createLinearFormIntegrator()); + ASSERT_NE(lf_integrator, nullptr); + delete lf_integrator; +} + /** * Test MFEMConvectiveHeatFluxBC creates the expected mfem::BoundaryIntegrators successfully. */ diff --git a/unit/src/MFEMKernelTest.C b/unit/src/MFEMKernelTest.C index a6b253fc..4c4e253a 100644 --- a/unit/src/MFEMKernelTest.C +++ b/unit/src/MFEMKernelTest.C @@ -4,6 +4,7 @@ #include "MFEMDivDivKernel.h" #include "MFEMLinearElasticityKernel.h" #include "MFEMMixedVectorGradientKernel.h" +#include "MFEMVectorDomainLFKernel.h" #include "MFEMVectorFEDomainLFKernel.h" #include "MFEMVectorFEMassKernel.h" #include "MFEMVectorFEWeakDivergenceKernel.h" @@ -134,6 +135,30 @@ TEST_F(MFEMKernelTest, MFEMMixedVectorGradientKernel) delete integrator; } +/** + * Test MFEMVectorDomainLFKernel creates an mfem::VectorDomainLFIntegrator successfully. + */ +TEST_F(MFEMKernelTest, MFEMVectorDomainLFKernel) +{ + mfem::Vector expected1({2.0, 1.0, 0.0}); + InputParameters coef_params = _factory.getValidParams("MFEMGenericConstantVectorMaterial"); + coef_params.set>("prop_names") = {"coef1"}; + coef_params.set>("prop_values") = {expected1[0], expected1[1], expected1[2]}; + _mfem_problem->addMaterial("MFEMGenericConstantVectorMaterial", "material1", coef_params); + + // Construct kernel + InputParameters kernel_params = _factory.getValidParams("MFEMVectorDomainLFKernel"); + kernel_params.set("variable") = "test_variable_name"; + kernel_params.set("vector_coefficient") = "coef1"; + MFEMVectorDomainLFKernel & kernel = + addObject("MFEMVectorDomainLFKernel", "kernel1", kernel_params); + + // Test MFEMKernel returns an integrator of the expected type + auto integrator = dynamic_cast(kernel.createIntegrator()); + ASSERT_NE(integrator, nullptr); + delete integrator; +} + /** * Test MFEMVectorFEDomainLFKernel creates an mfem::VectorFEDomainLFIntegrator successfully. */