From 475bf496c9bb694a54ccd85af4e5e64474fd915e Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 8 Sep 2023 13:26:45 +0200 Subject: [PATCH] changed: use ASM(mx)u(Cube|Square) in TestLRSplineField(s) similar to the tensor spline tests --- src/ASM/LR/Test/ASMuSquare.h | 2 +- src/ASM/LR/Test/TestLRSplineField.C | 35 ++++++++--------- src/ASM/LR/Test/TestLRSplineFields.C | 57 ++++++++++++---------------- 3 files changed, 42 insertions(+), 52 deletions(-) diff --git a/src/ASM/LR/Test/ASMuSquare.h b/src/ASM/LR/Test/ASMuSquare.h index 1b868c6d..e6a3bd01 100644 --- a/src/ASM/LR/Test/ASMuSquare.h +++ b/src/ASM/LR/Test/ASMuSquare.h @@ -34,7 +34,7 @@ public: "[0, 1] x 1 (2)\n" "# Elements:\n" "0 [2] : (0, 0) x (1, 1) {0, 1, 2, 3}\n"; - explicit ASMuSquare() + explicit ASMuSquare(unsigned char n_f = 2) : ASMu2D(2,n_f) { std::stringstream geo("200 1 0 0\n2 0\n2 2\n0 0 1 1\n2 2\n0 0 1 1\n0 0\n1 0\n0 1\n1 1\n"); this->read(geo); diff --git a/src/ASM/LR/Test/TestLRSplineField.C b/src/ASM/LR/Test/TestLRSplineField.C index 16e0509a..5f821b27 100644 --- a/src/ASM/LR/Test/TestLRSplineField.C +++ b/src/ASM/LR/Test/TestLRSplineField.C @@ -12,21 +12,21 @@ #include "Field.h" #include "FiniteElement.h" -#include "IFEM.h" -#include "SIM2D.h" -#include "SIM3D.h" +#include "ASMuCube.h" +#include "ASMuSquare.h" #include "gtest/gtest.h" +#include + TEST(TestLRSplineField, Value2D) { - IFEM::getOptions().discretization = ASM::LRSpline; - SIM2D sim(1); - sim.createDefaultModel(); + ASMuSquare patch(1); + EXPECT_TRUE(patch.generateFEMTopology()); std::vector sc = {0.0, 1.0, 1.0, 2.0}; // x + y - Field* fscalar = Field::create(sim.getPatch(1), sc); + std::unique_ptr fscalar(Field::create(&patch, sc)); static std::vector> tests_scalar = {{{0.5, 0.5, 1.0}}, {{1.0, 0.0, 1.0}}, {{0.0, 1.0, 1.0}}, @@ -42,12 +42,11 @@ TEST(TestLRSplineField, Value2D) TEST(TestLRSplineField, Grad2D) { - IFEM::getOptions().discretization = ASM::LRSpline; - SIM2D sim(1); - sim.createDefaultModel(); + ASMuSquare patch(1); + EXPECT_TRUE(patch.generateFEMTopology()); std::vector sc = {0.0, 1.0, 1.0, 2.0}; // x + y - Field* fscalar = Field::create(sim.getPatch(1), sc); + std::unique_ptr fscalar(Field::create(&patch, sc)); static std::vector> tests_scalar = {{{0.5, 0.5}}, {{1.0, 0.0}}, {{0.0, 1.0}}, @@ -66,12 +65,11 @@ TEST(TestLRSplineField, Grad2D) TEST(TestLRSplineField, Value3D) { - IFEM::getOptions().discretization = ASM::LRSpline; - SIM3D sim(1); - sim.createDefaultModel(); + ASMuCube patch(1); + EXPECT_TRUE(patch.generateFEMTopology()); std::vector sc = {0.0, 1.0, 1.0, 2.0, 1.0, 2.0, 2.0, 3.0}; // x + y + z - Field* fscalar = Field::create(sim.getPatch(1), sc); + std::unique_ptr fscalar(Field::create(&patch, sc)); static std::vector> tests_scalar = {{{0.5, 0.5, 0.5, 1.5}}, {{0.0, 0.0, 0.0, 0.0}}, {{1.0, 0.0, 0.0, 1.0}}, @@ -93,12 +91,11 @@ TEST(TestLRSplineField, Value3D) TEST(TestLRSplineField, Grad3D) { - IFEM::getOptions().discretization = ASM::LRSpline; - SIM3D sim(1); - sim.createDefaultModel(); + ASMuCube patch(1); + EXPECT_TRUE(patch.generateFEMTopology()); std::vector sc = {0.0, 1.0, 1.0, 2.0, 1.0, 2.0, 2.0, 3.0}; // x + y + z - Field* fscalar = Field::create(sim.getPatch(1), sc); + std::unique_ptr fscalar(Field::create(&patch, sc)); static std::vector> tests_scalar = {{{0.5, 0.5, 0.5}}, {{0.0, 0.0, 0.0}}, {{1.0, 0.0, 0.0}}, diff --git a/src/ASM/LR/Test/TestLRSplineFields.C b/src/ASM/LR/Test/TestLRSplineFields.C index e2b2ba19..59ee0a60 100644 --- a/src/ASM/LR/Test/TestLRSplineFields.C +++ b/src/ASM/LR/Test/TestLRSplineFields.C @@ -14,28 +14,27 @@ #include "Fields.h" #include "FiniteElement.h" #include "ASMmxBase.h" -#include "IFEM.h" -#include "SIM2D.h" -#include "SIM3D.h" +#include "ASMuCube.h" +#include "ASMuSquare.h" #include "gtest/gtest.h" #include +#include #include TEST(TestLRSplineFields, Value2D) { - IFEM::getOptions().discretization = ASM::LRSpline; - SIM2D sim(2); - ASSERT_TRUE(sim.createDefaultModel()); + ASMuSquare patch; + EXPECT_TRUE(patch.generateFEMTopology()); // {x+y+x*y, x-y+x*y} std::vector vc = {0.0, 0.0, 1.0, 1.0, 1.0, -1.0, 3.0, 1.0}; - Fields* fvector = Fields::create(sim.getPatch(1), vc); - Field* fscalar = Field::create(sim.getPatch(1), vc, 1, 2); + std::unique_ptr fvector(Fields::create(&patch, vc)); + std::unique_ptr fscalar(Field::create(&patch, vc, 1, 2)); static std::vector> tests_vector = {{{0.5, 0.5, 1.25, 0.25}}, {{1.0, 0.0, 1.0, 1.0}}, @@ -57,10 +56,8 @@ TEST(TestLRSplineFields, Value2D) TEST(TestLRSplineFields, Value2Dmx) { ASMmxBase::Type = ASMmxBase::DIV_COMPATIBLE; - IFEM::getOptions().discretization = ASM::LRSpline; - SIM2D sim({1,1,1}); - ASSERT_TRUE(sim.createDefaultModel()); - ASSERT_TRUE(sim.createFEMmodel()); + ASMmxuSquare patch({1,1,1}); + EXPECT_TRUE(patch.generateFEMTopology()); // {x+y+x*y, x-y+x*y} std::vector vc = {0.0, @@ -78,8 +75,8 @@ TEST(TestLRSplineFields, Value2Dmx) 1.0, // p 0.0, 1.0, 1.0, 2.0}; // x + y - Fields* fvector = Fields::create(sim.getPatch(1), vc, 12); - Field* fscalar = Field::create(sim.getPatch(1), vc, 3, 1); + std::unique_ptr fvector(Fields::create(&patch, vc, 12)); + std::unique_ptr fscalar(Field::create(&patch, vc, 3, 1)); static std::vector> tests_vector = {{{0.5, 0.5, 1.25, 0.25, 1.0}}, {{1.0, 0.0, 1.0, 1.0, 1.0}}, @@ -100,13 +97,12 @@ TEST(TestLRSplineFields, Value2Dmx) TEST(TestLRSplineFields, Grad2D) { - IFEM::getOptions().discretization = ASM::LRSpline; - SIM2D sim(2); - ASSERT_TRUE(sim.createDefaultModel()); + ASMuSquare patch; + EXPECT_TRUE(patch.generateFEMTopology()); // {x+y+x*y, x-y+x*y} std::vector vc = {0.0, 0.0, 1.0, 1.0, 1.0, -1.0, 3.0, 1.0}; - Fields* fvector = Fields::create(sim.getPatch(1), vc); + std::unique_ptr fvector(Fields::create(&patch, vc)); static std::vector> tests_vector = {{{0.5, 0.5, 1.5, 1.5, 1.5, -0.5}}, {{1.0, 0.0, 1.0, 2.0, 1.0, 0.0}}, @@ -128,9 +124,8 @@ TEST(TestLRSplineFields, Grad2D) TEST(TestLRSplineFields, Value3D) { - IFEM::getOptions().discretization = ASM::LRSpline; - SIM3D sim(3); - ASSERT_TRUE(sim.createDefaultModel()); + ASMuCube patch; + EXPECT_TRUE(patch.generateFEMTopology()); // {x+y+z, x+y-z, x-y+z} std::vector vc = {0.0, 0.0, 0.0, @@ -141,8 +136,8 @@ TEST(TestLRSplineFields, Value3D) 2.0, 0.0, 2.0, 2.0, 0.0, 0.0, 3.0, 1.0, 1.0}; - Fields* fvector = Fields::create(sim.getPatch(1), vc); - Field* fscalar = Field::create(sim.getPatch(1), vc, 1, 2); + std::unique_ptr fvector(Fields::create(&patch, vc)); + std::unique_ptr fscalar(Field::create(&patch, vc, 1, 2)); static std::vector> tests_scalar = {{{0.5, 0.5, 0.5, 1.5, 0.5, 0.5}}, {{0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}, @@ -170,9 +165,8 @@ TEST(TestLRSplineFields, Value3D) TEST(TestLRSplineFields, Grad3D) { - IFEM::getOptions().discretization = ASM::LRSpline; - SIM3D sim(3); - ASSERT_TRUE(sim.createDefaultModel()); + ASMuCube patch; + EXPECT_TRUE(patch.generateFEMTopology()); // {x+y+z+x*y*z, x+y-z+x*y*z, x-y+z+x*y*z} std::vector vc = {0.0, 0.0, 0.0, @@ -183,7 +177,7 @@ TEST(TestLRSplineFields, Grad3D) 2.0, 0.0, 2.0, 2.0, 0.0, 0.0, 4.0, 2.0, 2.0}; - Fields* fvector = Fields::create(sim.getPatch(1), vc); + std::unique_ptr fvector(Fields::create(&patch, vc)); static std::vector, std::array>> tests_vector = {{{{0.5, 0.5, 0.5}}, {{1.25, 1.25, 1.25, @@ -230,9 +224,8 @@ TEST(TestLRSplineFields, Grad3D) TEST(TestLRSplineFields, Value3Dmx) { ASMmxBase::Type = ASMmxBase::DIV_COMPATIBLE; - SIM3D sim({1,1,1,1}); - ASSERT_TRUE(sim.createDefaultModel()); - ASSERT_TRUE(sim.createFEMmodel()); + ASMmxuCube patch({1,1,1,1}); + ASSERT_TRUE(patch.generateFEMTopology()); // {x+y+z+x*y*z, x+y-z+x*y*z, x-y+z+x*y*z} std::vector vc = {0.0, 0.5, 1.0, @@ -255,8 +248,8 @@ TEST(TestLRSplineFields, Value3Dmx) 0.0, 2.0, // p 0.0, 1.0, 1.0, 2.0, 1.0, 2.0, 2.0, 3.0}; - Fields* fvector = Fields::create(sim.getPatch(1), vc, 123); - Field* fscalar = Field::create(sim.getPatch(1), vc, 4, 1); + std::unique_ptr fvector(Fields::create(&patch, vc, 123)); + std::unique_ptr fscalar(Field::create(&patch, vc, 4, 1)); static std::vector> tests_vector = {{{0.5, 0.5, 0.5, 1.625, 0.625, 0.625, 1.5}}, {{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}},