Skip to content

Commit

Permalink
Update unit tests with MFEMScalarBoundaryIntegratedBC and MFEMVectorD…
Browse files Browse the repository at this point in the history
…omainLFKernel
  • Loading branch information
alexanderianblair committed Dec 10, 2024
1 parent e06ace7 commit 917ee33
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
27 changes: 27 additions & 0 deletions unit/src/MFEMIntegratedBCTest.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "MFEMObjectUnitTest.h"
#include "MFEMScalarBoundaryIntegratedBC.h"
#include "MFEMVectorBoundaryIntegratedBC.h"
#include "MFEMVectorNormalIntegratedBC.h"
#include "MFEMConvectiveHeatFluxBC.h"
Expand Down Expand Up @@ -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<std::vector<std::string>>("prop_names") = {"coef1"};
coef_params.set<std::vector<double>>("prop_values") = {3.0};
_mfem_problem->addMaterial("MFEMGenericConstantMaterial", "material1", coef_params);

// Construct boundary condition
InputParameters bc_params = _factory.getValidParams("MFEMScalarBoundaryIntegratedBC");
bc_params.set<std::string>("variable") = "test_variable_name";
bc_params.set<std::string>("coefficient") = "coef1";
bc_params.set<std::vector<BoundaryName>>("boundary") = {"1"};
MFEMScalarBoundaryIntegratedBC & integrated_bc =
addObject<MFEMScalarBoundaryIntegratedBC>("MFEMScalarBoundaryIntegratedBC", "bc1", bc_params);

// Test MFEMScalarBoundaryIntegratedBC returns an integrator of the expected type
auto lf_integrator =
dynamic_cast<mfem::BoundaryLFIntegrator *>(integrated_bc.createLinearFormIntegrator());
ASSERT_NE(lf_integrator, nullptr);
delete lf_integrator;
}

/**
* Test MFEMConvectiveHeatFluxBC creates the expected mfem::BoundaryIntegrators successfully.
*/
Expand Down
25 changes: 25 additions & 0 deletions unit/src/MFEMKernelTest.C
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<std::vector<std::string>>("prop_names") = {"coef1"};
coef_params.set<std::vector<Real>>("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<std::string>("variable") = "test_variable_name";
kernel_params.set<std::string>("vector_coefficient") = "coef1";
MFEMVectorDomainLFKernel & kernel =
addObject<MFEMVectorDomainLFKernel>("MFEMVectorDomainLFKernel", "kernel1", kernel_params);

// Test MFEMKernel returns an integrator of the expected type
auto integrator = dynamic_cast<mfem::VectorDomainLFIntegrator *>(kernel.createIntegrator());
ASSERT_NE(integrator, nullptr);
delete integrator;
}

/**
* Test MFEMVectorFEDomainLFKernel creates an mfem::VectorFEDomainLFIntegrator successfully.
*/
Expand Down

0 comments on commit 917ee33

Please sign in to comment.