From 9cf613cbca696a368dadb22ff5050a86aa515ce7 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 25 Aug 2023 13:24:19 +0200 Subject: [PATCH] changed: move ASMuSquare and ASMuCube to separate header for reuse like in the structured ASMs tests --- src/ASM/LR/Test/ASMuCube.h | 76 ++++++++++++++++++++++++++++++++++++ src/ASM/LR/Test/ASMuSquare.h | 57 +++++++++++++++++++++++++++ src/ASM/LR/Test/TestASMu2D.C | 14 +------ src/ASM/LR/Test/TestASMu3D.C | 19 +-------- 4 files changed, 135 insertions(+), 31 deletions(-) create mode 100644 src/ASM/LR/Test/ASMuCube.h create mode 100644 src/ASM/LR/Test/ASMuSquare.h diff --git a/src/ASM/LR/Test/ASMuCube.h b/src/ASM/LR/Test/ASMuCube.h new file mode 100644 index 00000000..4091abed --- /dev/null +++ b/src/ASM/LR/Test/ASMuCube.h @@ -0,0 +1,76 @@ +//============================================================================== +//! +//! \file ASMuCube.h +//! +//! \date Oct 2 2019 +//! +//! \author Knut Morten Okstad / SINTEF +//! +//! \brief Default tri-unit cube LR patch for unit-testing. +//! +//============================================================================== + +#ifndef _ASM_UCUBE_H +#define _ASM_UCUBE_H + +#include "ASMu3Dmx.h" +#include + +class ASMuCube : public ASMu3D +{ +public: + // formatting matches write routine, do not change + static constexpr const char* cube = + "# LRSPLINE VOLUME\n" + "#\tp1\tp2\tp3\tNbasis\tNline\tNel\tdim\trat\n" + "\t2\t2\t2\t8\t6\t1\t3\t0\n" + "# Basis functions:\n" + "0: [0 0 1 ] x [0 0 1 ] x [0 0 1 ] 0 0 0 (1)\n" + "1: [0 1 1 ] x [0 0 1 ] x [0 0 1 ] 1 0 0 (1)\n" + "2: [0 0 1 ] x [0 1 1 ] x [0 0 1 ] 0 1 0 (1)\n" + "3: [0 1 1 ] x [0 1 1 ] x [0 0 1 ] 1 1 0 (1)\n" + "4: [0 0 1 ] x [0 0 1 ] x [0 1 1 ] 0 0 1 (1)\n" + "5: [0 1 1 ] x [0 0 1 ] x [0 1 1 ] 1 0 1 (1)\n" + "6: [0 0 1 ] x [0 1 1 ] x [0 1 1 ] 0 1 1 (1)\n" + "7: [0 1 1 ] x [0 1 1 ] x [0 1 1 ] 1 1 1 (1)\n" + "# Mesh rectangles:\n" + "[0, 0] x [0, 1] x [0, 1] (2)\n" + "[1, 1] x [0, 1] x [0, 1] (2)\n" + "[0, 1] x [0, 0] x [0, 1] (2)\n" + "[0, 1] x [1, 1] x [0, 1] (2)\n" + "[0, 1] x [0, 1] x [0, 0] (2)\n" + "[0, 1] x [0, 1] x [1, 1] (2)\n" + "# Elements:\n" + "0 [3] : (0, 0, 0) x (1, 1, 1) {0, 1, 2, 3, 4, 5, 6, 7}\n"; + + explicit ASMuCube(unsigned char n_f = 3) : ASMu3D(n_f) + { + std::stringstream geo("700 1 0 0\n3 0\n" + "2 2\n0 0 1 1\n" + "2 2\n0 0 1 1\n" + "2 2\n0 0 1 1\n" + "0 0 0\n1 0 0\n0 1 0\n1 1 0\n" + "0 0 1\n1 0 1\n0 1 1\n1 1 1\n"); + this->read(geo); + } + virtual ~ASMuCube() {} +}; + + +class ASMmxuCube : public ASMu3Dmx +{ +public: + explicit ASMmxuCube(const CharVec& n_f) : ASMu3Dmx(n_f) + { + std::stringstream geo("700 1 0 0\n3 0\n" + "2 2\n0 0 1 1\n" + "2 2\n0 0 1 1\n" + "2 2\n0 0 1 1\n" + "0 0 0\n1 0 0\n0 1 0\n1 1 0\n" + "0 0 1\n1 0 1\n0 1 1\n1 1 1\n"); + this->read(geo); + } + virtual ~ASMmxuCube() {} +}; + +#endif diff --git a/src/ASM/LR/Test/ASMuSquare.h b/src/ASM/LR/Test/ASMuSquare.h new file mode 100644 index 00000000..1b868c6d --- /dev/null +++ b/src/ASM/LR/Test/ASMuSquare.h @@ -0,0 +1,57 @@ +//============================================================================== +//! +//! \file ASMuSquare.h +//! +//! \date Oct 2 2019 +//! +//! \author Knut Morten Okstad / SINTEF +//! +//! \brief Default bi-unit square LR patch for unit-testing. +//! +//============================================================================== + +#ifndef ASM_USQUARE_H +#define ASM_USQUARE_H + +#include "ASMu2Dmx.h" +#include + +class ASMuSquare : public ASMu2D +{ +public: + static constexpr const char* square = + "# LRSPLINE SURFACE\n" + "#\tp1\tp2\tNbasis\tNline\tNel\tdim\trat\n" + "\t2\t2\t4\t4\t1\t2\t0\n" + "# Basis functions:\n" + "0: [0 0 1 ] x [0 0 1 ] 0 0 (1)\n" + "1: [0 1 1 ] x [0 0 1 ] 1 0 (1)\n" + "2: [0 0 1 ] x [0 1 1 ] 0 1 (1)\n" + "3: [0 1 1 ] x [0 1 1 ] 1 1 (1)\n" + "# Mesh lines:\n0 x [0, 1] (2)\n" + "1 x [0, 1] (2)\n" + "[0, 1] x 0 (2)\n" + "[0, 1] x 1 (2)\n" + "# Elements:\n" + "0 [2] : (0, 0) x (1, 1) {0, 1, 2, 3}\n"; + explicit ASMuSquare() + { + 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); + } + virtual ~ASMuSquare() {} +}; + + +class ASMmxuSquare : public ASMu2Dmx +{ +public: + explicit ASMmxuSquare(const CharVec& n_f) : ASMu2Dmx(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); + } + virtual ~ASMmxuSquare() {} +}; + +#endif diff --git a/src/ASM/LR/Test/TestASMu2D.C b/src/ASM/LR/Test/TestASMu2D.C index cca51dc1..fa184cff 100644 --- a/src/ASM/LR/Test/TestASMu2D.C +++ b/src/ASM/LR/Test/TestASMu2D.C @@ -10,7 +10,7 @@ //! //============================================================================== -#include "ASMu2D.h" +#include "ASMuSquare.h" #include "ASMs2D.h" #include "GaussQuadrature.h" #include "SIM2D.h" @@ -262,18 +262,6 @@ TEST(TestASMu2D, Connect) } -class ASMuSquare : public ASMu2D -{ -public: - ASMuSquare() - { - 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"); - EXPECT_TRUE(this->read(geo)); - } - virtual ~ASMuSquare() {} -}; - - TEST(TestASMu2D, ElementConnectivities) { ASMuSquare pch1; diff --git a/src/ASM/LR/Test/TestASMu3D.C b/src/ASM/LR/Test/TestASMu3D.C index adcd69ac..3aa1ff95 100644 --- a/src/ASM/LR/Test/TestASMu3D.C +++ b/src/ASM/LR/Test/TestASMu3D.C @@ -10,7 +10,7 @@ //! //============================================================================== -#include "ASMu3D.h" +#include "ASMuCube.h" #include "SIM3D.h" #include "GaussQuadrature.h" #include "LRSpline/LRSplineVolume.h" @@ -90,23 +90,6 @@ INSTANTIATE_TEST_CASE_P(TestASMu3D, testing::ValuesIn(tests)); -class ASMuCube : public ASMu3D -{ -public: - ASMuCube() - { - std::stringstream geo("700 1 0 0\n3 0\n" - "2 2\n0 0 1 1\n" - "2 2\n0 0 1 1\n" - "2 2\n0 0 1 1\n" - "0 0 0\n1 0 0\n0 1 0\n1 1 0\n" - "0 0 1\n1 0 1\n0 1 1\n1 1 1\n"); - EXPECT_TRUE(this->read(geo)); - } - virtual ~ASMuCube() {} -}; - - TEST(TestASMu3D, TransferGaussPtVars) { ASMuCube pch;