// Copyright (c) 2010-2023, Lawrence Livermore National Security, LLC. Produced // at the Lawrence Livermore National Laboratory. All Rights reserved. See files // LICENSE and NOTICE for details. LLNL-CODE-806117. // // This file is part of the MFEM library. For more information and source code // availability visit https://mfem.org. // // MFEM is free software; you can redistribute it and/or modify it under the // terms of the BSD-3 license. We welcome feedback and contributions, see file // CONTRIBUTING.md for details. #include "mfem.hpp" #include "unit_tests.hpp" #include #include #include #include using namespace mfem; // Prefix string for a single element 2D mfem quad mesh std::string meshPrefixStr = "MFEM mesh v1.0" "\n\n" "dimension" "\n" "2" "\n\n" "elements" "\n" "1" "\n" "1 3 0 1 2 3" "\n\n" "boundary" "\n" "0" "\n\n"; // Nodal grid function for a C-shaped quadratic quadrilateral std::string CShapedNodesStr = "vertices" "\n" "4" "\n\n" "nodes" "\n" "FiniteElementSpace" "\n" "FiniteElementCollection: Quadratic" "\n" "VDim: 2" "\n" "Ordering: 1" "\n" "0 0" "\n" "0 2" "\n" "0 6" "\n" "0 8" "\n" "0 1" "\n" "-6 4" "\n" "0 7" "\n" "-8 4" "\n" "-7 4" "\n"; TEST_CASE("InverseElementTransformation", "[InverseElementTransformation]") { typedef InverseElementTransformation InvTransform; const double tol = 2e-14; SECTION("{ C-shaped Q2 Quad }") { // Create quadratic with single C-shaped quadrilateral std::stringstream meshStr; meshStr << meshPrefixStr << CShapedNodesStr; Mesh mesh( meshStr ); REQUIRE( mesh.GetNE() == 1 ); REQUIRE( mesh.GetNodes() != nullptr ); // Optionally, dump mesh to disk bool dumpMesh = false; if (dumpMesh) { std::string filename = "c_shaped_quadratic_mesh"; VisItDataCollection dataCol(filename, &mesh); dataCol.Save(); } const int times = 100; const int dim = 2; // Create a uniform grid of integration points over the element const int geom = mesh.GetElementBaseGeometry(0); RefinedGeometry* ref = GlobGeometryRefiner.Refine(Geometry::Type(geom), times); const IntegrationRule& intRule = ref->RefPts; // Create a transformation IsoparametricTransformation tr; mesh.GetElementTransformation(0, &tr); Vector v(dim); const int npts = intRule.GetNPoints(); int pts_found = 0; double max_err = 0.0; for (int i=0; i= min_found_pts ); REQUIRE( max_err <= tol ); } }