Commit 22a731dc authored by LEFEBVREJP email's avatar LEFEBVREJP email
Browse files

Merge branch 'tasmanian' into 'master'

Tasmanian

See merge request !71
parents 05ee7be8 0ceb0bb7
Pipeline #57749 passed with stages
in 14 minutes and 19 seconds
......@@ -23,7 +23,7 @@ mac_gcc_testing:
- python TriBITS/tribits/ci_support/clone_extra_repos.py
- mkdir build
- cd build
- cmake -DDEBUG_OUTPUT=1 -DBUILDNAME=$(uname -s)-GCC-4.8.5-Debug-${CI_BUILD_REF_NAME} -DCMAKE_BUILD_TYPE=DEBUG -Dradix_ENABLE_TESTS=ON -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -DTPL_ENABLE_VTK=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF ..
- cmake -DTasmanian_DIR=/opt/tasmanian/6.0 -DDEBUG_OUTPUT=1 -DBUILDNAME=$(uname -s)-GCC-4.8.5-Debug-${CI_BUILD_REF_NAME} -DCMAKE_BUILD_TYPE=DEBUG -Dradix_ENABLE_TESTS=ON -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -DTPL_ENABLE_VTK=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF ..
- ctest -D ExperimentalStart -D ExperimentalBuild -D ExperimentalTest -DExperimentalMemCheck -D ExperimentalSubmit
mac_llvm_testing:
......@@ -41,7 +41,7 @@ mac_llvm_testing:
- cd build
- which cmake
- export radix_ENABLE_Fortran=OFF
- cmake -DDEBUG_OUTPUT=1 -DBUILDNAME=$(uname -s)-LLVM-Debug-${CI_BUILD_REF_NAME} -DCMAKE_BUILD_TYPE=DEBUG -Dradix_ENABLE_TESTS=ON -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -DTPL_ENABLE_VTK=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF ..
- cmake -DTasmanian_DIR=/opt/tasmanian/6.0 -DDEBUG_OUTPUT=1 -DBUILDNAME=$(uname -s)-LLVM-Debug-${CI_BUILD_REF_NAME} -DCMAKE_BUILD_TYPE=DEBUG -Dradix_ENABLE_TESTS=ON -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -DTPL_ENABLE_VTK=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF ..
- ctest -D ExperimentalStart -D ExperimentalBuild -D ExperimentalTest -DExperimentalMemCheck -D ExperimentalSubmit
......@@ -60,7 +60,7 @@ linux_gcc_testing:
- module load cmake qt/5.9.0 vtk/8.1.0
- which cmake
- module load valgrind
- cmake -DBUILDNAME=$(uname -s)-GCC-4.8.5-Release-${CI_BUILD_REF_NAME} -DCMAKE_BUILD_TYPE=Release -Dradix_ENABLE_TESTS=ON -DENABLE_PYTHON_WRAPPERS=ON -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -DTPL_ENABLE_VTK=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF ..
- cmake -DTasmanian_DIR=/opt/vendors/tasmanian/6.0 -DBUILDNAME=$(uname -s)-GCC-4.8.5-Release-${CI_BUILD_REF_NAME} -DCMAKE_BUILD_TYPE=Release -Dradix_ENABLE_TESTS=ON -DENABLE_PYTHON_WRAPPERS=ON -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -DTPL_ENABLE_VTK=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF ..
- ctest -D ExperimentalStart -D ExperimentalBuild -D ExperimentalTest -D ExperimentalSubmit
linux_analysis:
......@@ -79,7 +79,7 @@ linux_analysis:
- module load cmake
- which cmake
- module load valgrind
- cmake -DDEBUG_OUTPUT=1 -D COVERAGE_EXTRA_FLAGS="-s ${CI_PROJECT_DIR}/googletest -d" -D MEMCHECK_COMMAND=$(which valgrind) -DBUILDNAME=$(uname -s)-GCC-4.8.5-Debug-${CI_BUILD_REF_NAME} -DCMAKE_BUILD_TYPE=DEBUG -Dradix_ENABLE_COVERAGE_TESTING=ON -Dradix_ENABLE_TESTS=ON -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF ..
- cmake -DTasmanian_DIR=/opt/vendors/tasmanian/6.0/ -DDEBUG_OUTPUT=1 -D COVERAGE_EXTRA_FLAGS="-s ${CI_PROJECT_DIR}/googletest -d" -D MEMCHECK_COMMAND=$(which valgrind) -DBUILDNAME=$(uname -s)-GCC-4.8.5-Debug-${CI_BUILD_REF_NAME} -DCMAKE_BUILD_TYPE=DEBUG -Dradix_ENABLE_COVERAGE_TESTING=ON -Dradix_ENABLE_TESTS=ON -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF ..
- ctest -D ExperimentalStart -D ExperimentalBuild -D ExperimentalTest -D ExperimentalMemCheck -D ExperimentalCoverage -D ExperimentalSubmit
allow_failure: true
......@@ -114,7 +114,7 @@ windows_mingw_testing:
- git clone https://github.com/lefebvre/googletest googletest
- mkdir build
- cd build
- cmake -DDEBUG_OUTPUT=1 -DTPL_LAPACK_LIBRARIES=c:/vendors/mingw-w64/lapack/3.5.0/lib/liblapack.a\\\;c:/vendors/mingw-w64/lapack/3.5.0/lib/libblas.a\\\;-lgfortran -DBUILDNAME=Windows-MinGW-GCC-4.8.5-Debug-%CI_BUILD_REF_NAME% -DCMAKE_BUILD_TYPE=DEBUG -Dradix_ENABLE_COVERAGE_TESTING=ON -Dradix_ENABLE_TESTS=ON -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF -G "MinGW Makefiles" ..
- cmake -DTasmanian_DIR=c:/vendors/mingw-w64/tasmanian/6.0/ -DDEBUG_OUTPUT=1 -DTPL_LAPACK_LIBRARIES=c:/vendors/mingw-w64/lapack/3.5.0/lib/liblapack.a\\\;c:/vendors/mingw-w64/lapack/3.5.0/lib/libblas.a\\\;-lgfortran -DBUILDNAME=Windows-MinGW-GCC-4.8.5-Debug-%CI_BUILD_REF_NAME% -DCMAKE_BUILD_TYPE=DEBUG -Dradix_ENABLE_COVERAGE_TESTING=ON -Dradix_ENABLE_TESTS=ON -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF -G "MinGW Makefiles" ..
- ctest -D ExperimentalStart -D ExperimentalBuild -D ExperimentalTest -D ExperimentalSubmit
windows_msvc_testing:
......@@ -133,7 +133,7 @@ windows_msvc_testing:
- cd build
- SET VTK_DIR=c:\vendors\cl\vtk\8.1.0\
- SET radix_ENABLE_Fortran=OFF
- cmake -DBUILD_SHARED_LIBS=ON -DBUILDNAME=Windows-CL-18-Release-%CI_BUILD_REF_NAME% -DCMAKE_BUILD_TYPE=RELEASE -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -DTPL_ENABLE_VTK=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF -Dradix_ENABLE_radixglls=OFF -G "NMake Makefiles" ..
- cmake -DTasmanian_DIR=c:/vendors/cl/tasmanian/6.0/ -DBUILD_SHARED_LIBS=ON -DBUILDNAME=Windows-CL-18-Release-%CI_BUILD_REF_NAME% -DCMAKE_BUILD_TYPE=RELEASE -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -DTPL_ENABLE_VTK=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF -Dradix_ENABLE_radixglls=OFF -G "NMake Makefiles" ..
- ctest -D ExperimentalStart -D ExperimentalBuild -D ExperimentalTest -D ExperimentalSubmit
windows_intel_shared_testing:
......@@ -152,5 +152,5 @@ windows_intel_shared_testing:
- mkdir build
- cd build
- SET VTK_DIR=c:\vendors\cl\vtk\8.1.0\
- cmake -DBUILD_SHARED_LIBS=ON -DTPL_LAPACK_LIBRARIES=c:/vendors/intel/lapack/3.5.0/lib/lapack.lib\\\;c:/vendors/intel/lapack/3.5.0/lib/blas.lib -DBUILDNAME=Windows-Intel-15-Release-%CI_BUILD_REF_NAME% -DCMAKE_C_COMPILER=icl -DCMAKE_CXX_COMPILER=icl -DCMAKE_BUILD_TYPE=RELEASE -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -DTPL_ENABLE_VTK=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF -G "NMake Makefiles" ..
- cmake -DTasmanian_DIR=c:/vendors/cl/tasmanian/6.0/ -DBUILD_SHARED_LIBS=ON -DTPL_LAPACK_LIBRARIES=c:/vendors/intel/lapack/3.5.0/lib/lapack.lib\\\;c:/vendors/intel/lapack/3.5.0/lib/blas.lib -DBUILDNAME=Windows-Intel-15-Release-%CI_BUILD_REF_NAME% -DCMAKE_C_COMPILER=icl -DCMAKE_CXX_COMPILER=icl -DCMAKE_BUILD_TYPE=RELEASE -Dradix_ENABLE_SECONDARY_TESTED_CODE=ON -Dradix_ENABLE_TESTS=ON -DTPL_ENABLE_VTK=ON -Dradix_ENABLE_radixplot=OFF -Dradix_ENABLE_radixwidgets=OFF -G "NMake Makefiles" ..
- ctest -D ExperimentalStart -D ExperimentalBuild -D ExperimentalTest -D ExperimentalSubmit
......@@ -55,6 +55,7 @@
SET(radix_TPLS_FINDMODS_CLASSIFICATIONS
LAPACK "${${PROJECT_NAME}_TRIBITS_DIR}/common_tpls/" PT
Tasmanian "cmake/TPLs/" ST
Qt5Core "cmake/TPLs/" ST
Qt5Gui "cmake/TPLs/" ST
Qt5Widgets "cmake/TPLs/" ST
......
TRIBITS_PACKAGE_DEFINE_DEPENDENCIES(
SUBPACKAGES_DIRS_CLASSIFICATIONS_OPTREQS
bug radixbug SS OPTIONAL
core radixcore SS OPTIONAL
dl radixdl SS OPTIONAL
pattern radixpattern SS OPTIONAL
algorithm radixalgorithm SS OPTIONAL
para radixpara SS OPTIONAL
command radixcommand SS OPTIONAL
math radixmath SS OPTIONAL
geo radixgeo SS OPTIONAL
glls radixglls SS OPTIONAL
io radixio SS OPTIONAL
geometry radixgeometry SS OPTIONAL
plot radixplot SS OPTIONAL
widgets radixwidgets SS OPTIONAL
ams radixams SS OPTIONAL
bug radixbug SS OPTIONAL
core radixcore SS OPTIONAL
dl radixdl SS OPTIONAL
pattern radixpattern SS OPTIONAL
algorithm radixalgorithm SS OPTIONAL
para radixpara SS OPTIONAL
command radixcommand SS OPTIONAL
math radixmath SS OPTIONAL
geo radixgeo SS OPTIONAL
glls radixglls SS OPTIONAL
io radixio SS OPTIONAL
geometry radixgeometry SS OPTIONAL
plot radixplot SS OPTIONAL
sparsegrids radixsparsegrids SS OPTIONAL
widgets radixwidgets SS OPTIONAL
ams radixams SS OPTIONAL
)
ASSERT_DEFINED(Tasmanian_DIR)
GET_FILENAME_COMPONENT(PACKAGE_PREFIX_DIR "${Tasmanian_DIR}/" ABSOLUTE)
MESSAGE(STATUS "Tasmanian Package Prefix: '${PACKAGE_PREFIX_DIR}'")
SET(Tasmanian_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include" CACHE STRING "" FORCE)
SET(Tasmanian_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/lib" CACHE STRING "" FORCE)
TRIBITS_TPL_FIND_INCLUDE_DIRS_AND_LIBRARIES(
Tasmanian
REQUIRED_HEADERS TasmanianSparseGrid.hpp
REQUIRED_LIBS_NAMES tasmaniansparsegrid
)
......@@ -2,23 +2,23 @@ Pressure,Height,Temperature,Relative Humidity,Dew Point,Wind Direction,Wind Spee
pres,zhgt,temp,rh,tdew,wdir,wspd,msg
mb,m,C,per,C,deg,knot,NULL
f,f,f,f,f,f,f,s
875,-9999,10.0,24,-9.6,20,0,
850,1499,6.4,34,-8.4,0,0,
875,1259,10.0,24,-9.6,-9999,0,
850,1499,6.4,34,-8.4,-9999,0,
843,-9999,5.3,37,-8.2,-9999,-9999,
830,-9999,6.0,46,-4.7,-9999,-9999,
800,1994,3.9,54,-9999.0,8,8,
750,2510,0.3,68,-9999.0,8,14,
800,1994,3.9,54,-9999.0,180,8,
750,2510,0.3,68,-9999.0,180,14,
732,-9999,-1.0,74,-5.0,-9999,-9999,
700,3066,-2.3,65,-8.0,9,17,
700,3066,-2.3,65,-8.0,202.5,17,
666,-9999,-1.0,22,-20.1,-9999,-9999,
650,3666,-2.4,14,-9999.0,9,19,
600,4285,-6.5,15,-9999.0,10,21,
650,3666,-2.4,-9999,-9999.0,202.5,19,RH(14)
600,4285,-6.5,-9999,-9999.0,225,21,RH(15)
572,-9999,-9.0,-9999,-9999.0,-9999,-9999,
562,-9999,-8.3,-9999,-9999.0,-9999,-9999,
550,4970,-9.4,15,-9999.0,10,24,
500,5695,-15.0,16,-9999.0,9,35,
450,6500,-20.9,17,-9999.0,9,27,
400,7342,-27.2,19,-9999.0,-9999,-9999,
550,4970,-9.4,-9999,-9999.0,225,24,RH(15)
500,5695,-15.0,-9999,-9999.0,202.5,35,RH(16)
450,6500,-20.9,-9999,-9999.0,202.5,27,RH(17)
400,7342,-27.2,-9999,-9999.0,-9999,-9999,RH(19)
374,-9999,-31.0,29,-43.2,-9999,-9999,
350,8284,-34.5,47,-9999.0,-9999,-9999,
318,-9999,-40.0,71,-43.2,-9999,-9999,
......@@ -26,5 +26,5 @@ f,f,f,f,f,f,f,s
267,-9999,-51.0,-9999,-9999.0,-9999,-9999,
256,-9999,-51.2,-9999,-9999.0,-9999,-9999,
250,10546,-52.2,-9999,-9999.0,-9999,-9999,
210,-9999,-60.6,-9999,-9999.0,-9999,-9999,
210,11705,-60.6,-9999,-9999.0,-9999,-9999,
200,12029,-9999.0,-9999,-9999.0,-9999,-9999,Extrapolated Height
TRIBITS_SUBPACKAGE(sparsegrids)
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
SET(CXXSRC
sparsegrids.cc
sparsegridsinterface.cc
)
SET(CXXHDR
sparsegrids.hh
sparsegridsinterface.hh
)
SET(CXXLIB ${SUBPACKAGE_FULLNAME})
TRIBITS_ADD_LIBRARY(${CXXLIB} SOURCES ${CXXSRC} NOINSTALLHEADERS ${CXXHDR})
IF(${PROJECT_NAME}_ENABLE_Fortran AND NOT BUILD_SHARED_LIBS)
ADD_COMPILE_OPTIONS("-ffree-line-length-none")
SET(F90SRC
sparsegrids_I.f90
sparsegrids_M.f90
)
SET(F90LIB ${SUBPACKAGE_FULLNAME}_F90)
TRIBITS_ADD_LIBRARY(${F90LIB} SOURCES ${F90SRC})
TARGET_LINK_LIBRARIES(${F90LIB} ${CXXLIB})
ENDIF()
TRIBITS_ADD_TEST_DIRECTORIES(tests)
TRIBITS_SUBPACKAGE_POSTPROCESS()
TRIBITS_PACKAGE_DEFINE_DEPENDENCIES(
LIB_REQUIRED_PACKAGES radixcore radixbug
LIB_OPTIONAL_PACKAGES
TEST_REQUIRED_PACKAGES testframework
TEST_OPTIONAL_PACKAGES
LIB_REQUIRED_TPLS Tasmanian
LIB_OPTIONAL_TPLS
TEST_REQUIRED_TPLS
TEST_OPTIONAL_TPLS
)
#!/bin/bash
mv sparse_gridsInterface.h sparse_grids_interface.hh
mv sparse_gridsInterface.cpp sparse_grids_interface.cc
sed -i '' 's@sparse_gridsInterface.h@sparse_grids_interface.hh@' sparse_grids_interface.cc
sed -i '' 's@sparse_grids_M@radix_sparse_grids_M@g' sparse_grids_M.f90
\ No newline at end of file
#include "radixsparsegrids/sparsegrids.hh"
#include "radixbug/bug.hh"
namespace radix {
SparseGrids::SparseGrids()
: mInputDimension(0),
mOutputDimension(0)
{
radix_insist(false, "call the non-default constructor");
}
SparseGrids::SparseGrids(const int input_dimension,
const int output_dimension,
const int depth,
const std::string& type_depth,
const std::string& type_1d_rule)
: mInputDimension(input_dimension),
mOutputDimension(output_dimension),
mA(input_dimension),
mB(input_dimension),
mAbscissas(input_dimension),
mIsConstrained(input_dimension, false),
mGrid(),
mPoints(nullptr)
{
radix_require(mInputDimension > 0);
radix_require(mOutputDimension > 0);
radix_require(depth >= 0);
TasGrid::TypeOneDRule rule;
if (type_1d_rule == "gauss-legendre")
{
rule = TasGrid::rule_gausslegendre;
std::fill(mA.begin(), mA.end(), -1.0);
std::fill(mB.begin(), mB.end(), 1.0);
}
else if (type_1d_rule == "gauss-hermite")
{
rule = TasGrid::rule_gausshermite;
std::fill(mA.begin(), mA.end(), 0.0);
std::fill(mB.begin(), mB.end(), 1.0);
}
else
{
radix_insist(false, type_1d_rule+" is not supported");
}
TasGrid::TypeDepth type;
if (type_depth == "level") {type = TasGrid::type_level;}
else if (type_depth == "curved") {type = TasGrid::type_curved;}
else if (type_depth == "ipcurved") {type = TasGrid::type_ipcurved;}
else if (type_depth == "qpcurved") {type = TasGrid::type_qpcurved;}
else if (type_depth == "hyperbolic") {type = TasGrid::type_hyperbolic;}
else if (type_depth == "iphyperbolic") {type = TasGrid::type_iphyperbolic;}
else if (type_depth == "qphyperbolic") {type = TasGrid::type_qphyperbolic;}
else if (type_depth == "tensor") {type = TasGrid::type_tensor;}
else if (type_depth == "iptensor") {type = TasGrid::type_iptensor;}
else if (type_depth == "qptensor") {type = TasGrid::type_qptensor;}
else if (type_depth == "iptotal") {type = TasGrid::type_iptotal;}
else if (type_depth == "qptotal") {type = TasGrid::type_qptotal;}
else
{
radix_insist(false, type_depth+" is not supported");
}
mGrid.makeGlobalGrid(mInputDimension, mOutputDimension, depth, type, rule);
mOutputValues.resize(mGrid.getNumPoints()*mOutputDimension, 0.0);
}
SparseGrids::~SparseGrids()
{
if (mPoints != nullptr) {delete[] mPoints;}
}
void SparseGrids::generateQuadrature()
{
mGrid.setDomainTransform(mA.data(), mB.data());
mPoints = mGrid.getPoints();
}
int SparseGrids::getNumQuadPoints() const
{
return mGrid.getNumPoints();
}
void SparseGrids::setTransformAt(const int index, const double left,
const double right)
{
mA[index] = left;
mB[index] = right;
}
void SparseGrids::setConstrainedTransformAt(
const int num_inputs, const int* input_indices, const double left, const double right)
{
radix_require(num_inputs > 1 && num_inputs <= mInputDimension);
radix_require(input_indices != nullptr);
int j = input_indices[0]-1;
constraints c;
radix_require(j > -1 && j < mInputDimension);
radix_require(!mIsConstrained[j]);
mIsConstrained[j] = true;
mA[j] = left;
mB[j] = right;
c.base = j;
for (int i = 1; i < num_inputs; ++i)
{
radix_require(j < input_indices[i]-1);
j = input_indices[i]-1;
radix_require(j > -1 && j < mInputDimension);
radix_require(!mIsConstrained[j]);
mIsConstrained[j] = true;
mA[j] = 0.0;
mB[j] = 1.0;
c.others.push_back(j);
}
mConstraints.push_back(c);
}
void SparseGrids::getQuadAbscissasAt(const int index, double* abscissas) const {
radix_require(index >= 0 && index < mGrid.getNumPoints());
radix_require(mPoints != nullptr);
radix_require(abscissas != nullptr);
for (int i = 0, j = index*mInputDimension; i < mInputDimension; ++i, ++j)
{
abscissas[i] = mPoints[j];
}
for (int i = 0, ie = mConstraints.size(); i < ie; ++i)
{
const int j = mConstraints[i].base;
double a = abscissas[j];
double span = mB[j] - a;
for (const auto k : mConstraints[i].others)
{
double cdf = abscissas[k];
a += span*cdf;
abscissas[k] = a;
span = mB[j]-a;
}
}
}
void SparseGrids::setOrdinatesAt(const int index, double* ordinates) {
radix_require(index >= 0 && index < mGrid.getNumPoints());
radix_require(ordinates != nullptr);
for (int i = 0, j = index*mOutputDimension; i < mOutputDimension; ++i, ++j)
{
mOutputValues[j] = ordinates[i];
}
}
void SparseGrids::generateSurrogate() {
mGrid.loadNeededPoints(mOutputValues.data());
std::vector<double>().swap(mOutputValues);
}
void SparseGrids::evaluate(const double* abscissas, double* ordinates) const {
radix_require(abscissas != nullptr);
radix_require(ordinates != nullptr);
if (mConstraints.size() == 0)
{
mGrid.evaluateFast(abscissas, ordinates);
}
else
{
for (int i = 0; i < mInputDimension; ++i)
{
mAbscissas[i] = abscissas[i];
}
for (int i = 0, ie = mConstraints.size(); i < ie; ++i)
{
const int j = mConstraints[i].base;
double a = mAbscissas[j];
double span = mB[j] - a;
for (const auto k : mConstraints[i].others)
{
double cdf = (mAbscissas[k]-a)/span;
a = mAbscissas[k];
mAbscissas[k] = cdf;
span = mB[j]-a;
}
}
mGrid.evaluateFast(mAbscissas.data(), ordinates);
}
}
} // namespace radix
<generate name="sparse_grids">
<include_relative name="radixsparsegrids/sparsegrids.hh"/>
<type_define name="RadixSparseGrids" type="radix::SparseGrids"/>
<class name="RadixSparseGrids">
<constructor name="Construct">
<param name="input_dimension" type="int"/>
<param name="output_dimension" type="int"/>
<param name="depth" type="int"/>
<param name="type_depth" type="char*"/>
<param name="type_1d_rule" type="char*"/>
</constructor>
<method name="SetConstrainedTransformAt">
<param name="num_inputs" type="int"/>
<param name="input_indices" type="int*"/>
<param name="left" type="double"/>
<param name="right" type="double"/>
</method>
<method name="SetTransformAt">
<param name="index" type="int" offset="-1"/>
<param name="left" type="double"/>
<param name="right" type="double"/>
</method>
<method name="GenerateQuadrature">
</method>
<method name="GetNumQuadPoints" return_type="int">
</method>
<method name="GetQuadAbscissasAt">
<param name="index" type="int" offset="-1"/>
<param name="abscissas" type="double*"/>
</method>
<method name="SetOrdinatesAt">
<param name="index" type="int" offset="-1"/>
<param name="ordinates" type="double*"/>
</method>
<method name="GenerateSurrogate">
</method>
<method name="Evaluate">
<param name="abscissas" type="double*"/>
<param name="ordinates" type="double*"/>
</method>
</class>
</generate>
#ifndef RADIX_RADIXSPARSEGRIDS_SPARSE_GRIDS_HH_
#define RADIX_RADIXSPARSEGRIDS_SPARSE_GRIDS_HH_
#include <string>
#include <vector>
#ifndef M_PI
#define _USE_MATH_DEFINES
#endif
#include "TasmanianSparseGrid.hpp"
#include "radixcore/visibility.hh"
namespace radix {
class RADIX_PUBLIC SparseGrids
{
public:
using TasmanianSparseGrid = TasGrid::TasmanianSparseGrid;
SparseGrids();
SparseGrids(const int input_dimension,
const int output_dimension,
const int depth,
const std::string& type_depth,
const std::string& type_oned_rule);
~SparseGrids();
void setTransformAt(const int index, const double left, const double right);
void setConstrainedTransformAt(const int num_inputs, const int* input_indices,
const double left, const double right);
void generateQuadrature();
int getNumQuadPoints() const;
void getQuadAbscissasAt(const int index, double* abscissas) const;
void setOutputDimension(const int dim);
void setOrdinatesAt(const int index, double* ordinates);
void generateSurrogate();
void evaluate(const double* abscissas, double* ordinates) const;
private:
struct constraints {
int base;
std::vector<int> others;
};
const int mInputDimension;
const int mOutputDimension;
std::vector<double> mA;
std::vector<double> mB;
mutable std::vector<double> mAbscissas;
std::vector<bool> mIsConstrained;
std::vector<constraints> mConstraints;
TasGrid::TasmanianSparseGrid mGrid;
double* mPoints;
std::vector<double> mOutputValues;
};
} // namespace radix
#endif // RADIX_RADIXSPARSEGRIDS_SPARSE_GRIDS_HH_
!>
!! This file has been dynamically generated by Class Interface Xml (CIX)
!! DO NOT MODIFY THIS FILE -- CHANGES WILL BE OVERWRITTEN UPON REGENERATION
!! If changes need to occur, modify the appropriate CIX xml file
!! Date Generated: Thu Mar 08 11:20:37 EST 2018
!! If any issues are experiences with this generated file that cannot be fixed
!! with adjustment of the CIX xml file, please contact Robert A. Lefebvre, raq@ornl.gov
!!/
module sparse_grids_I
use, intrinsic :: ISO_C_BINDING
interface
type(C_PTR) function f_RadixSparseGrids_Construct( input_dimension,output_dimension,depth,type_depth,type_1d_rule )BIND(C,name="RadixSparseGrids_Construct")
!DEC$ ATTRIBUTES DLLEXPORT::f_RadixSparseGrids_Construct
use,intrinsic :: ISO_C_BINDING
implicit none
type(C_PTR) :: RadixSparseGrids_ptr;
integer(C_INT) :: input_dimension;
integer(C_INT) :: output_dimension;
integer(C_INT) :: depth;
character(C_CHAR) :: type_depth;
character(C_CHAR) :: type_1d_rule;
end function
subroutine f_RadixSparseGrids_SetConstrainedTransformAt(RadixSparseGrids_ptr, num_inputs,input_indices,left,right ) BIND(C,name="RadixSparseGrids_SetConstrainedTransformAt")
!DEC$ ATTRIBUTES DLLEXPORT::f_RadixSparseGrids_SetConstrainedTransformAt
use,intrinsic :: ISO_C_BINDING
implicit none
type(C_PTR), value :: RadixSparseGrids_ptr;
integer(C_INT) :: num_inputs;
integer(C_INT) :: input_indices;
real(C_DOUBLE) :: left;
real(C_DOUBLE) :: right;
end subroutine
subroutine f_RadixSparseGrids_SetTransformAt(RadixSparseGrids_ptr, index,left,right ) BIND(C,name="RadixSparseGrids_SetTransformAt")
!DEC$ ATTRIBUTES DLLEXPORT::f_RadixSparseGrids_SetTransformAt
use,intrinsic :: ISO_C_BINDING
implicit none
type(C_PTR), value :: RadixSparseGrids_ptr;
integer(C_INT) :: index;
real(C_DOUBLE) :: left;
real(C_DOUBLE) :: right;
end subroutine
subroutine f_RadixSparseGrids_GenerateQuadrature(RadixSparseGrids_ptr ) BIND(C,name="RadixSparseGrids_GenerateQuadrature")
!DEC$ ATTRIBUTES DLLEXPORT::f_RadixSparseGrids_GenerateQuadrature
use,intrinsic :: ISO_C_BINDING
implicit none
type(C_PTR), value :: RadixSparseGrids_ptr;
end subroutine
integer(C_INT) function f_RadixSparseGrids_GetNumQuadPoints(RadixSparseGrids_ptr ) BIND(C,name="RadixSparseGrids_GetNumQuadPoints")
!DEC$ ATTRIBUTES DLLEXPORT::f_RadixSparseGrids_GetNumQuadPoints
use,intrinsic :: ISO_C_BINDING
implicit none
type(C_PTR), value :: RadixSparseGrids_ptr;
end function
subroutine f_RadixSparseGrids_GetQuadAbscissasAt(RadixSparseGrids_ptr, index,abscissas ) BIND(C,name="RadixSparseGrids_GetQuadAbscissasAt")
!DEC$ ATTRIBUTES DLLEXPORT::f_RadixSparseGrids_GetQuadAbscissasAt
use,intrinsic :: ISO_C_BINDING
implicit none
type(C_PTR), value :: RadixSparseGrids_ptr;
integer(C_INT) :: index;
real(C_DOUBLE) :: abscissas;
end subroutine
subroutine f_RadixSparseGrids_SetOrdinatesAt(RadixSparseGrids_ptr, index,ordinates ) BIND(C,name="RadixSparseGrids_SetOrdinatesAt")
!DEC$ ATTRIBUTES DLLEXPORT::f_RadixSparseGrids_SetOrdinatesAt
use,intrinsic :: ISO_C_BINDING
implicit none
type(C_PTR), value :: RadixSparseGrids_ptr;
integer(C_INT) :: index;
real(C_DOUBLE) :: ordinates;
end subroutine
subroutine f_RadixSparseGrids_GenerateSurrogate(RadixSparseGrids_ptr ) BIND(C,name="RadixSparseGrids_GenerateSurrogate")
!DEC$ ATTRIBUTES DLLEXPORT::f_RadixSparseGrids_GetSurrogate
use,intrinsic :: ISO_C_BINDING
implicit none
type(C_PTR), value :: RadixSparseGrids_ptr;
end subroutine
subroutine f_RadixSparseGrids_Evaluate(RadixSparseGrids_ptr, abscissas,ordinates ) BIND(C,name="RadixSparseGrids_Evaluate")
!DEC$ ATTRIBUTES DLLEXPORT::f_RadixSparseGrids_Evaluate
use,intrinsic :: ISO_C_BINDING
implicit none
type(C_PTR), value :: RadixSparseGrids_ptr;
real(C_DOUBLE) :: abscissas;
real(C_DOUBLE) :: ordinates;
end subroutine
type(C_PTR) function f_RadixSparseGrids_initialize( )BIND(C,name="RadixSparseGrids_initialize")
!DEC$ ATTRIBUTES DLLEXPORT::f_RadixSparseGrids_initialize
use,intrinsic :: ISO_C_BINDING
implicit none
type(C_PTR) :: RadixSparseGrids_ptr;
end function
subroutine f_RadixSparseGrids_destroy(this) BIND(C,name="RadixSparseGrids_destroy")
!DEC$ ATTRIBUTES DLLEXPORT::f_RadixSparseGrids_destroy
use,intrinsic :: ISO_C_BINDING
implicit none
type(C_PTR), value :: this;
end subroutine
end interface
end module sparse_grids_I