Skip to content

Commit

Permalink
Merge pull request idaholab#416 from dschwen/fft_prelim_tests_401
Browse files Browse the repository at this point in the history
Test datatype sizes to guide FFT design
  • Loading branch information
snschune authored Jan 16, 2020
2 parents 12f6695 + 7b8bf41 commit 7563af3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 10 deletions.
4 changes: 2 additions & 2 deletions unit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)/..
Expand Down
17 changes: 9 additions & 8 deletions unit/src/GSLTest.C
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/
#ifdef GSL_ENABLED

#include <cmath>
#include <gtest/gtest.h>

//GSL includes
// GSL includes
#include <gsl/gsl_integration.h>

// 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;
Expand All @@ -39,12 +39,13 @@ TEST(GSLTest, integrationTest)
F.function = &function;
F.params = &alpha;

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
41 changes: 41 additions & 0 deletions unit/src/TensorSizeCheck.C
Original file line number Diff line number Diff line change
@@ -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 <cmath>
#include <gtest/gtest.h>

#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));
}

0 comments on commit 7563af3

Please sign in to comment.