void qoiRoutine( const QUESO::GslVector& paramValues, const QUESO::GslVector* paramDirection, const void* functionDataPtr, QUESO::GslVector& qoiValues, QUESO::DistArray<QUESO::GslVector*>* gradVectors, QUESO::DistArray<QUESO::GslMatrix*>* hessianMatrices, QUESO::DistArray<QUESO::GslVector*>* hessianEffects) { // Logic just to avoid warnings from INTEL compiler const QUESO::GslVector* aux1 = paramDirection; if (aux1) {}; QUESO::DistArray<QUESO::GslVector*>* aux2 = gradVectors; if (aux2) {}; aux2 = hessianEffects; QUESO::DistArray<QUESO::GslMatrix*>* aux3 = hessianMatrices; if (aux3) {}; // Just checking: the user, at the application level, expects // vector 'paramValues' to have size 2 and // vector 'qoiValues' to have size 1. UQ_FATAL_TEST_MACRO(paramValues.sizeGlobal() != 2, QUESO::UQ_UNAVAILABLE_RANK, "qoiRoutine()", "paramValues vector does not have size 2"); UQ_FATAL_TEST_MACRO(qoiValues.sizeGlobal() != 1, QUESO::UQ_UNAVAILABLE_RANK, "qoiRoutine()", "qoiValues vector does not have size 1"); // Actual code // // This code exemplifies multiple Monte Carlo solvers, each calling this qoi routine. // In this simple example, only node 0 in each sub-environment does the job even though // there might be more than one node per sub-environment. // In a more realistic situation, if the user is asking for multiple nodes per sub- // environment, then the model code in the qoi routine might really demand more than one // node. Here we use 'env.subRank()' only. A realistic application might want to use // either 'env.subComm()' or 'env.subComm().Comm()'. const QUESO::BaseEnvironment& env = paramValues.env(); if (env.subRank() == 0) { double coef1 = ((qoiRoutine_DataType *) functionDataPtr)->coef1; double coef2 = ((qoiRoutine_DataType *) functionDataPtr)->coef2; qoiValues[0] = (coef1*paramValues[0] + coef2*paramValues[1]); } else { qoiValues[0] = 0.; } return; }
void qoiRoutine( const QUESO::GslVector& paramValues, const QUESO::GslVector* paramDirection, const void* functionDataPtr, QUESO::GslVector& qoiValues, QUESO::DistArray<QUESO::GslVector*>* gradVectors, QUESO::DistArray<QUESO::GslMatrix*>* hessianMatrices, QUESO::DistArray<QUESO::GslVector*>* hessianEffects) { //logic to avoid warnings from intel compiler const QUESO::GslVector* aux1 = paramDirection; if (aux1) {}; QUESO::DistArray<QUESO::GslVector*>* aux2 = gradVectors; if (aux2) {}; aux2 = hessianEffects; QUESO::DistArray<QUESO::GslMatrix*>* aux3 = hessianMatrices; if (aux3) {}; //checking size of paramValues and qoiValues //both should be size 1 UQ_FATAL_TEST_MACRO(paramValues.sizeGlobal() != 1, QUESO::UQ_UNAVAILABLE_RANK, "qoiRoutine()", "paramValues vector does not have size 1"); UQ_FATAL_TEST_MACRO(qoiValues.sizeGlobal() != 1, QUESO::UQ_UNAVAILABLE_RANK, "qoiRoutine()", "qoiValues vector does not have size 1"); //compute qoi const QUESO::BaseEnvironment& env = paramValues.env(); if(env.subRank() == 0) { double coef1 = ((qoiRoutine_DataType *) functionDataPtr)->coef1; qoiValues[0] = coef1*paramValues[0]; } else { qoiValues[0] = 0.; } return; }