Skip to content

Commit

Permalink
Merge pull request #225 from dmcdougall/nick_examples_dir
Browse files Browse the repository at this point in the history
Adding examples directory
  • Loading branch information
pbauman authored Jul 7, 2016
2 parents 577aeaa + d6fd195 commit a231340
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 5 deletions.
8 changes: 4 additions & 4 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Paul T. Bauman ([email protected])
Paul T. Bauman ([email protected])
Benjamin S. Kirk ([email protected])
Todd A. Oliver ([email protected])
Sylvain Plessis ([email protected])
Roy H. Stogner ([email protected])
Todd A. Oliver ([email protected])
Sylvain Plessis ([email protected])
Roy H. Stogner ([email protected])
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include $(top_srcdir)/doxygen/aminclude.am
AUTOMAKE_OPTIONS = foreign
ACLOCAL_AMFLAGS = -I m4 -I m4/common

SUBDIRS = src test doxygen share
SUBDIRS = src test doxygen share examples
EXTRA_DIST = CHANGES LICENSE COPYING share

# Eliminate .svn directories in dist tarball
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ AC_CONFIG_FILES([
share/Makefile
src/Makefile
test/Makefile
examples/Makefile
])

dnl-----------------------------------------------
Expand Down
45 changes: 45 additions & 0 deletions examples/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
EXTRA_DIST =

examplesdir = $(top_srcdir)/examples

examples_PROGRAMS =
examples_PROGRAMS += antioch_init

AM_CPPFLAGS =
AM_CPPFLAGS += -I$(top_srcdir)/src/core/include
AM_CPPFLAGS += -I$(top_srcdir)/src/units/include
AM_CPPFLAGS += -I$(top_srcdir)/src/particles_flux/include
AM_CPPFLAGS += -I$(top_srcdir)/src/kinetics/include
AM_CPPFLAGS += -I$(top_srcdir)/src/parsing/include
AM_CPPFLAGS += -I$(top_srcdir)/src/thermo/include
AM_CPPFLAGS += -I$(top_srcdir)/src/viscosity/include
AM_CPPFLAGS += -I$(top_srcdir)/src/diffusion/include
AM_CPPFLAGS += -I$(top_srcdir)/src/thermal_conduction/include
AM_CPPFLAGS += -I$(top_srcdir)/src/transport/include
AM_CPPFLAGS += -I$(top_srcdir)/src/utilities/include
AM_CPPFLAGS += -I$(top_builddir)/src/utilities/include
AM_CPPFLAGS += -I$(top_srcdir)/examples/antioch_test
AM_CPPFLAGS += $(antioch_optional_test_INCLUDES)

AM_LDFLAGS = $(antioch_optional_test_LDFLAGS)

LIBS = $(antioch_optional_test_LIBS)

LDADD = $(top_builddir)/src/libantioch.la

pkginclude_HEADERS =

#
# CPP TESTS
#
antioch_init_SOURCES = antioch_init.C

#Define examples to actually be run
TESTS =
XFAIL_TESTS =
TESTS += antioch_init

CLEANFILES =
if CODE_COVERAGE_ENABLED
CLEANFILES += *.gcda *.gcno
endif
102 changes: 102 additions & 0 deletions examples/antioch_init.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//-----------------------------------------------------------------------bl-
//--------------------------------------------------------------------------
//
// Antioch - A Gas Dynamics Thermochemistry Library
//
// Copyright (C) 2014-2016 Paul T. Bauman, Benjamin S. Kirk,
// Sylvain Plessis, Roy H. Stonger
//
// Copyright (C) 2013 The PECOS Development Team
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the Version 2.1 GNU Lesser General
// Public License as published by the Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc. 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA
//
//-----------------------------------------------------------------------el-
//
// $Id$
//
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------

// C++
#include <iostream>
#include <cmath>

// Antioch
#include "antioch/blottner_viscosity.h"

template <typename Scalar>
int test_viscosity( const Scalar mu, const Scalar mu_exact, const Scalar tol )
{
using std::abs;

int return_flag = 0;

const double rel_error = abs( (mu - mu_exact)/mu_exact);

if( rel_error > tol )
{
std::cerr << "Error: Mismatch in viscosity" << std::endl
<< "mu(T) = " << mu << std::endl
<< "mu_exact = " << mu_exact << std::endl
<< "rel_error = " << rel_error << std::endl
<< "tol = " << tol << std::endl;
return_flag = 1;
}

return return_flag;
}

template <typename Scalar>
int tester()
{
const Scalar a = 3.14e-3;
const Scalar b = 2.71e-2;
const Scalar c = 42.0e-5;

Antioch::BlottnerViscosity<Scalar> mu(a,b,c);

std::cout << mu << std::endl;

const Scalar T = 1521.2;

// octave gives
const Scalar mu_exact = 0.144422234167703;

int return_flag = 0;

const Scalar tol = 1.0e-14;

return_flag = test_viscosity( mu(T), mu_exact, tol );

const Scalar a2 = 1e-3;
const Scalar b2 = 2e-2;
const Scalar c2 = 3e-5;

mu.reset_coeffs( a2, b2, c2 );

// octave gives
const Scalar mu_exact2 = 0.122172495548880;

return_flag = test_viscosity( mu(T), mu_exact2, tol );

return return_flag;
}

int main()
{
return (tester<double>() ||
tester<long double>() ||
tester<float>());
}

0 comments on commit a231340

Please sign in to comment.