From 2224aed261e2dfd89cbf97aaffddc3bbdcacef04 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 2 Sep 2020 18:51:56 -0400 Subject: [PATCH] Switch from arrays to vectors, update regression test tolerances --- samples/cxx/custom/custom.cpp | 14 ++++++++++---- test_problems/SConscript | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/samples/cxx/custom/custom.cpp b/samples/cxx/custom/custom.cpp index efe1a11b795..1e8589a7d09 100644 --- a/samples/cxx/custom/custom.cpp +++ b/samples/cxx/custom/custom.cpp @@ -33,6 +33,12 @@ class ReactorODEs : public FuncEval { // number of chemical species in the system. nSpecies = gas->nSpecies(); + // resize the vector_fp storage containers for species partial molar enthalpies + // and net production rates. internal values are updated and used by the solver + // per iteration. + hbar.resize(nSpecies); + wdot.resize(nSpecies); + // number of equations in the ODE system. a conservation equation for each // species, plus a single energy conservation equation for the system. nEqs = nSpecies + 1; @@ -67,10 +73,8 @@ class ReactorODEs : public FuncEval { /* ----------------------- GET REQ'D PROPERTIES ----------------------- */ double rho = gas->density(); double cp = gas->cp_mass(); - double hbar[nSpecies]; - gas->getPartialMolarEnthalpies(hbar); - double wdot[nSpecies]; - kinetics->getNetProductionRates(wdot); + gas->getPartialMolarEnthalpies(&hbar[0]); + kinetics->getNetProductionRates(&wdot[0]); /* -------------------------- ENERGY EQUATION ------------------------- */ // the rate of change of the system temperature is found using the energy @@ -117,6 +121,8 @@ class ReactorODEs : public FuncEval { // private member variables, to be used internally. shared_ptr gas; shared_ptr kinetics; + vector_fp hbar; + vector_fp wdot; double pressure; int nSpecies; int nEqs; diff --git a/test_problems/SConscript b/test_problems/SConscript index c543818d987..4a880753d5d 100644 --- a/test_problems/SConscript +++ b/test_problems/SConscript @@ -232,7 +232,8 @@ Test('cxx-combustor', 'cxx_samples', '#build/samples/cxx/combustor/combustor', N comparisons=[('combustor_cxx_blessed.csv', 'combustor_cxx.csv')], threshold=1e-10, tolerance=2e-4) Test('cxx-custom', 'cxx_samples', '#build/samples/cxx/custom/custom', None, - comparisons=[('custom_cxx_blessed.csv', 'custom_cxx.csv')]) + comparisons=[('custom_cxx_blessed.csv', 'custom_cxx.csv')], + threshold=1e-10, tolerance=2e-4) Test('cxx-flamespeed', 'cxx_samples', '#build/samples/cxx/flamespeed/flamespeed', 'cxx_flamespeed_blessed.txt', comparisons=[('flamespeed_blessed.csv', 'flamespeed.csv')],