From 7b8bf4111c896f3898a1b8d973d31d8baf8f9160 Mon Sep 17 00:00:00 2001 From: Daniel Schwen Date: Thu, 16 Jan 2020 08:47:21 -0700 Subject: [PATCH] Test datatype sizes (#401) --- unit/Makefile | 4 ++-- unit/src/GSLTest.C | 17 ++++++++-------- unit/src/TensorSizeCheck.C | 41 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 unit/src/TensorSizeCheck.C diff --git a/unit/Makefile b/unit/Makefile index fabd9b30..4608f17a 100644 --- a/unit/Makefile +++ b/unit/Makefile @@ -24,8 +24,8 @@ include $(MOOSE_DIR)/modules/modules.mk ############################################################################### # Extra stuff for GTEST -ADDITIONAL_INCLUDES := -I$(FRAMEWORK_DIR)/contrib/gtest -ADDITIONAL_LIBS := $(FRAMEWORK_DIR)/contrib/gtest/libgtest.la +ADDITIONAL_INCLUDES += -I$(FRAMEWORK_DIR)/contrib/gtest +ADDITIONAL_LIBS += $(FRAMEWORK_DIR)/contrib/gtest/libgtest.la # dep apps APPLICATION_DIR := $(CURRENT_DIR)/.. diff --git a/unit/src/GSLTest.C b/unit/src/GSLTest.C index 9e64ba66..e8e45f68 100644 --- a/unit/src/GSLTest.C +++ b/unit/src/GSLTest.C @@ -11,26 +11,26 @@ /* */ /* See COPYRIGHT for full restrictions */ /****************************************************************/ +#ifdef GSL_ENABLED #include #include -//GSL includes +// GSL includes #include // function to integrate double function(double x, void * params) { - double alpha = *(double *) params; - double f = std::log(alpha*x) / std::sqrt(x); + double alpha = *(double *)params; + double f = std::log(alpha * x) / std::sqrt(x); return f; } TEST(GSLTest, integrationTest) { - gsl_integration_workspace * w - = gsl_integration_workspace_alloc (1000); + gsl_integration_workspace * w = gsl_integration_workspace_alloc(1000); double result, error; double alpha = 1.0; @@ -39,12 +39,13 @@ TEST(GSLTest, integrationTest) F.function = &function; F.params = α - gsl_integration_qags (&F, 0, 1, 0, 1e-7, 1000, - w, &result, &error); + gsl_integration_qags(&F, 0, 1, 0, 1e-7, 1000, w, &result, &error); EXPECT_NEAR(result, -4.000000000000085265, 1e-18) << "Integration result is wrong"; EXPECT_NEAR(error, 0.000000000000135447, 1e-18) << "Integration error is wrong"; EXPECT_EQ(w->size, 8); - gsl_integration_workspace_free (w); + gsl_integration_workspace_free(w); } + +#endif diff --git a/unit/src/TensorSizeCheck.C b/unit/src/TensorSizeCheck.C new file mode 100644 index 00000000..4181d61c --- /dev/null +++ b/unit/src/TensorSizeCheck.C @@ -0,0 +1,41 @@ +/****************************************************************/ +/* DO NOT MODIFY THIS HEADER */ +/* MOOSE - Multiphysics Object Oriented Simulation Environment */ +/* */ +/* (c) 2010 Battelle Energy Alliance, LLC */ +/* ALL RIGHTS RESERVED */ +/* */ +/* Prepared by Battelle Energy Alliance, LLC */ +/* Under Contract No. DE-AC07-05ID14517 */ +/* With the U. S. Department of Energy */ +/* */ +/* See COPYRIGHT for full restrictions */ +/****************************************************************/ + +#include +#include + +#include "libmesh/vector_value.h" + +#include "MooseTypes.h" +#include "RankTwoTensor.h" +#include "RankThreeTensor.h" +#include "RankFourTensor.h" + +TEST(TensorSizeCheck, vector) { EXPECT_EQ(sizeof(RealVectorValue), LIBMESH_DIM * sizeof(Real)); } + +TEST(TensorSizeCheck, rankTwo) +{ + EXPECT_EQ(sizeof(RankTwoTensor), LIBMESH_DIM * LIBMESH_DIM * sizeof(Real)); +} + +TEST(TensorSizeCheck, rankThree) +{ + EXPECT_EQ(sizeof(RankThreeTensor), LIBMESH_DIM * LIBMESH_DIM * LIBMESH_DIM * sizeof(Real)); +} + +TEST(TensorSizeCheck, rankFour) +{ + EXPECT_EQ(sizeof(RankFourTensor), + LIBMESH_DIM * LIBMESH_DIM * LIBMESH_DIM * LIBMESH_DIM * sizeof(Real)); +}