10 #include "gtest/gtest.h" 15 #include "libmesh/quadrature_gauss.h" 19 using namespace Moose;
22 template <
typename T,
typename Map>
27 const std::set<SubdomainID> & sub_ids,
28 const std::string &
name)
36 TEST(FaceCenteredMapFunctorTest, testArgs)
38 const char * argv[2] = {
"foo",
"\0"};
42 auto * factory = &app->getFactory();
43 std::string mesh_type =
"MeshGeneratorMesh";
45 std::shared_ptr<MeshGeneratorMesh>
mesh;
51 app->actionWarehouse().mesh() =
mesh;
54 std::unique_ptr<MeshBase> lm_mesh;
55 InputParameters params = factory->getValidParams(
"GeneratedMeshGenerator");
56 params.
set<
unsigned int>(
"nx") = 2;
57 params.
set<
unsigned int>(
"ny") = 2;
61 lm_mesh = mesh_gen->generate();
62 mesh->setMeshBase(std::move(lm_mesh));
65 mesh->prepare(
nullptr);
67 mesh->setCoordSystem({}, coord_type_enum);
68 mesh->buildFiniteVolumeInfo();
69 mesh->computeFiniteVolumeCoords();
70 const auto & all_fi =
mesh->allFaceInfo();
77 for (
auto & fi : all_fi)
79 const auto & face_center = fi.faceCentroid();
81 -
sin(face_center(0)) *
cos(face_center(1)),
cos(face_center(0)) *
sin(face_center(1)), 0);
85 for (
auto & fi : all_fi)
87 const auto & face_center = fi.faceCentroid();
93 EXPECT_NEAR(result(0), -
sin(face_center(0)) *
cos(face_center(1)), 1e-14);
94 EXPECT_NEAR(result(1),
cos(face_center(0)) *
sin(face_center(1)), 1e-14);
95 EXPECT_EQ(result(2), 0);
100 auto test_gradient = [&u](
const auto & arg)
107 catch (std::runtime_error & e)
109 EXPECT_TRUE(std::string(e.what()).find(
"not implemented") != std::string::npos);
115 auto test_evaluate = [&u](
const auto & arg)
122 catch (std::runtime_error & e)
124 EXPECT_TRUE(std::string(e.what()).find(
"not implemented") != std::string::npos);
133 const auto elem_arg =
ElemArg{all_fi[0].elemPtr(),
false};
134 const auto elem_qp_arg =
ElemQpArg({all_fi[0].elemPtr(), 0, &qrule,
Point(0)});
135 const auto elem_side_qp_arg =
ElemSideQpArg({all_fi[0].elemPtr(), 0, 0, &qrule,
Point(0)});
136 const auto elem_point_arg =
ElemPointArg({all_fi[0].elemPtr(),
Point(0),
false});
138 test_gradient(elem_arg);
139 test_gradient(face_arg);
141 test_evaluate(elem_qp_arg);
142 test_evaluate(elem_side_qp_arg);
143 test_evaluate(elem_point_arg);
147 unrestricted_error_test(*
mesh,
"not_restricted");
150 unrestricted_error_test(
151 FaceArg{&all_fi[2], LimiterType::CentralDifference,
true,
false,
nullptr,
nullptr},
155 catch (std::runtime_error & e)
157 EXPECT_TRUE(std::string(e.what()).find(
"not_restricted") != std::string::npos);
158 EXPECT_TRUE(std::string(e.what()).find(
"Make sure to fill") != std::string::npos);
162 restricted_error_test(*
mesh, {1},
"is_restricted");
165 restricted_error_test(
166 FaceArg{&all_fi[2], LimiterType::CentralDifference,
true,
false,
nullptr,
nullptr},
170 catch (std::runtime_error & e)
172 EXPECT_TRUE(std::string(e.what()).find(
"is_restricted") != std::string::npos);
173 EXPECT_TRUE(std::string(e.what()).find(
"0") != std::string::npos);
175 std::string(e.what()).find(
176 "that subdomain id is not one of the subdomain ids the functor is restricted to") !=
FictionalFaceCenteredMapFunctor(const MooseMesh &mesh, const std::set< SubdomainID > &sub_ids, const std::string &name)
std::shared_ptr< MooseApp > createMooseApp(const std::string &default_app_type, int argc, char *argv[])
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sin(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tan
A functor whose evaluation relies on querying a map where the keys are face info ids and the values c...
VectorValue< Real > RealVectorValue
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template cos(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(cos
GradientType gradient(const ElemArg &elem, const StateArg &state) const
TEST(FaceCenteredMapFunctorTest, testArgs)
bool hasBlocks(SubdomainID) const override