GslVector::GslVector(const BaseEnvironment& env, const Map& map, double value) : Vector(env,map), m_vec (gsl_vector_calloc(map.NumGlobalElements())) { //std::cout << "Entering GslVector::constructor(2)" << std::endl; UQ_FATAL_TEST_MACRO((m_vec == NULL), m_env.worldRank(), "GslVector::constructor(2)", "null vector generated"); UQ_FATAL_TEST_MACRO(m_vec->size != (unsigned int) map.NumMyElements(), m_env.worldRank(), "GslVector::constructor(2)", "incompatible local vec size"); UQ_FATAL_TEST_MACRO(m_vec->size != (unsigned int) map.NumGlobalElements(), m_env.worldRank(), "GslVector::constructor(2)", "incompatible global vec size"); this->cwSet(value); UQ_FATAL_TEST_MACRO(m_vec->size != (unsigned int) m_map.NumMyElements(), m_env.worldRank(), "GslVector::constructor(2)", "incompatible own vec size"); //std::cout << "Leaving GslVector::constructor(2)" << std::endl; }
// QUESO MpiComm MPI Constructor ------------------ MpiComm::MpiComm(const BaseEnvironment& env, RawType_MPI_Comm inputRawComm) : m_env (env), #ifdef QUESO_HAS_TRILINOS m_epetraMpiComm( new Epetra_MpiComm(inputRawComm) ), #endif m_rawComm (inputRawComm), m_worldRank (-1), m_myPid (-1), m_numProc (-1) { int mpiRC = MPI_Comm_rank(inputRawComm,&m_worldRank); UQ_FATAL_TEST_MACRO(mpiRC != MPI_SUCCESS, UQ_UNAVAILABLE_RANK, "MpiComm::constructor()", "failed MPI_Comm_rank() on full rank"); mpiRC = MPI_Comm_rank(inputRawComm,&m_myPid); UQ_FATAL_TEST_MACRO(mpiRC != MPI_SUCCESS, m_worldRank, "MpiComm::constructor()", "failed MPI_Comm_rank() on inputRawComm"); mpiRC = MPI_Comm_size(inputRawComm,&m_numProc); UQ_FATAL_TEST_MACRO(mpiRC != MPI_SUCCESS, m_worldRank, "MpiComm::constructor()", "failed MPI_Comm_size() on inputRawComm"); }
GslVector::GslVector(const GslVector& v) // mox : Vector(v.env(),v.map()), m_vec (gsl_vector_calloc(v.sizeLocal())) { //std::cout << "Entering GslVector::constructor(5)" << std::endl; // prudenci 2010-06-17 mox UQ_FATAL_TEST_MACRO((m_vec == NULL), m_env.worldRank(), "GslVector::constructor(5), copy", "null vector generated"); UQ_FATAL_TEST_MACRO(m_vec->size != (unsigned int) v.map().NumMyElements(), m_env.worldRank(), "GslVector::constructor(5)", "incompatible local vec size"); UQ_FATAL_TEST_MACRO(m_vec->size != (unsigned int) v.map().NumGlobalElements(), m_env.worldRank(), "GslVector::constructor(5)", "incompatible global vec size"); this->copy(v); UQ_FATAL_TEST_MACRO(m_vec->size != (unsigned int) m_map.NumMyElements(), m_env.worldRank(), "GslVector::constructor(5)", "incompatible own vec size"); //std::cout << "Leaving GslVector::constructor(5)" << std::endl; }
double uqLagrangeBasis1D1DFunctionClass::deriv(double domainValue) const { double value = 0.; if ((domainValue < m_minDomainValue) || (domainValue > m_maxDomainValue)) { std::cerr << "In uqLagrangeBasis1D1DFunctionClass::deriv()" << ": requested x (" << domainValue << ") is out of the interval (" << m_minDomainValue << ", " << m_maxDomainValue << ")" << std::endl; } UQ_FATAL_TEST_MACRO(((domainValue < m_minDomainValue) || (domainValue > m_maxDomainValue)), UQ_UNAVAILABLE_RANK, "uqLagrangeBasis1D1DFunctionClass::deriv()", "x out of range"); UQ_FATAL_TEST_MACRO(true, UQ_UNAVAILABLE_RANK, "uqLagrangeBasis1D1DFunctionClass::deriv()", "not implemented yet"); return value; }
GslVector::GslVector(const BaseEnvironment& env, double d1, double d2, const Map& map) : Vector(env,map), m_vec (gsl_vector_calloc(map.NumGlobalElements())) { //std::cout << "Entering GslVector::constructor(3)" << std::endl; UQ_FATAL_TEST_MACRO((m_vec == NULL), m_env.worldRank(), "GslVector::constructor(3), linspace", "null vector generated"); UQ_FATAL_TEST_MACRO(m_vec->size != (unsigned int) map.NumMyElements(), m_env.worldRank(), "GslVector::constructor(3)", "incompatible local vec size"); UQ_FATAL_TEST_MACRO(m_vec->size != (unsigned int) map.NumGlobalElements(), m_env.worldRank(), "GslVector::constructor(3)", "incompatible global vec size"); for (unsigned int i = 0; i < m_vec->size; ++i) { double alpha = (double) i / ((double) m_vec->size - 1.); (*this)[i] = (1.-alpha)*d1 + alpha*d2; } UQ_FATAL_TEST_MACRO(m_vec->size != (unsigned int) m_map.NumMyElements(), m_env.worldRank(), "GslVector::constructor(3)", "incompatible own vec size"); //std::cout << "Leaving GslVector::constructor(3)" << std::endl; }
GslVector::GslVector(const GslVector& v, double start, double end) : Vector(v.env(),v.map()), m_vec (gsl_vector_calloc(v.sizeLocal())) { //std::cout << "Entering GslVector::constructor(4)" << std::endl; UQ_FATAL_TEST_MACRO((m_vec == NULL), m_env.worldRank(), "GslVector::constructor(4), linspace", "null vector generated"); UQ_FATAL_TEST_MACRO(m_vec->size != (unsigned int) v.map().NumMyElements(), m_env.worldRank(), "GslVector::constructor(4)", "incompatible local vec size"); UQ_FATAL_TEST_MACRO(m_vec->size != (unsigned int) v.map().NumGlobalElements(), m_env.worldRank(), "GslVector::constructor(4)", "incompatible global vec size"); for (unsigned int i = 0; i < m_vec->size; ++i) { double alpha = (double) i / ((double) m_vec->size - 1.); (*this)[i] = (1. - alpha) * start + alpha * end; } UQ_FATAL_TEST_MACRO(m_vec->size != (unsigned int) m_map.NumMyElements(), m_env.worldRank(), "GslVector::constructor(4)", "incompatible own vec size"); //std::cout << "Leaving GslVector::constructor(4)" << std::endl; }
void GslVector::matlabDiff( unsigned int firstPositionToStoreDiff, double valueForRemainderPosition, GslVector& outputVec) const { unsigned int size = this->sizeLocal(); UQ_FATAL_TEST_MACRO(firstPositionToStoreDiff > 1, m_env.worldRank(), "GslVector::matlabDiff()", "invalid firstPositionToStoreDiff"); UQ_FATAL_TEST_MACRO(size != outputVec.sizeLocal(), m_env.worldRank(), "GslVector::matlabDiff()", "invalid size of outputVecs"); for (unsigned int i = 0; i < (size-1); ++i) { outputVec[firstPositionToStoreDiff+i] = (*this)[i+1]-(*this)[i]; } if (firstPositionToStoreDiff == 0) { outputVec[size-1] = valueForRemainderPosition; } else { outputVec[0] = valueForRemainderPosition; } return; }
double uqSampled1D1DFunctionClass::value(double domainValue) const { if ((domainValue < m_minDomainValue) || (domainValue > m_maxDomainValue)) { std::cerr << "In uqSampled1D1DFunctionClass::value()" << ": requested x (" << domainValue << ") is out of the interval (" << m_minDomainValue << ", " << m_maxDomainValue << ")" << std::endl; } UQ_FATAL_TEST_MACRO(((domainValue < m_minDomainValue) || (domainValue > m_maxDomainValue)), UQ_UNAVAILABLE_RANK, "uqSampled1D1DFunctionClass::value()", "x out of range"); double returnValue = 0.; unsigned int tmpSize = m_domainValues.size(); //std::cout << "In uqSampled1D1DFunctionClass::value()" // << ": domainValue = " << domainValue // << ", tmpSize = " << tmpSize // << ", m_domainValues[0] = " << m_domainValues[0] // << ", m_domainValues[max] = " << m_domainValues[tmpSize-1] // << std::endl; UQ_FATAL_TEST_MACRO(tmpSize == 0, UQ_UNAVAILABLE_RANK, "uqSampled1D1DFunctionClass::value()", "m_domainValues.size() = 0"); UQ_FATAL_TEST_MACRO(domainValue < m_domainValues[0], UQ_UNAVAILABLE_RANK, "uqSampled1D1DFunctionClass::value()", "domainValue < m_domainValues[0]"); UQ_FATAL_TEST_MACRO(m_domainValues[tmpSize-1] < domainValue, UQ_UNAVAILABLE_RANK, "uqSampled1D1DFunctionClass::value()", "m_domainValues[max] < domainValue"); unsigned int i = 0; for (i = 0; i < tmpSize; ++i) { if (domainValue <= m_domainValues[i]) break; } if (domainValue == m_domainValues[i]) { //if (domainValueWasMatchedExactly) *domainValueWasMatchedExactly = true; returnValue = m_imageValues[i]; } else { //if (domainValueWasMatchedExactly) *domainValueWasMatchedExactly = false; double ratio = (domainValue - m_domainValues[i-1])/(m_domainValues[i]-m_domainValues[i-1]); returnValue = m_imageValues[i-1] + ratio * (m_imageValues[i]-m_imageValues[i-1]); } return returnValue; }
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; }
double LogNormalJointPdf<V,M>::actualValue( const V& domainVector, const V* domainDirection, V* gradVector, M* hessianMatrix, V* hessianEffect) const { if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 55)) { *m_env.subDisplayFile() << "Entering LogNormalJointPdf<V,M>::actualValue()" << ", meanVector = " << *m_lawExpVector << ": domainVector = " << domainVector << ", domainVector.sizeLocal() = " << domainVector.sizeLocal() << ", this->m_domainSet.vectorSpace().dimLocal() = " << this->m_domainSet.vectorSpace().dimLocal() << std::endl; } UQ_FATAL_TEST_MACRO(domainVector.sizeLocal() != this->m_domainSet.vectorSpace().dimLocal(), m_env.worldRank(), "LogNormalJointPdf<V,M>::actualValue()", "invalid input"); UQ_FATAL_TEST_MACRO((gradVector || hessianMatrix || hessianEffect), m_env.worldRank(), "LogNormalJointPdf<V,M>::actualValue()", "incomplete code for gradVector, hessianMatrix and hessianEffect calculations"); double returnValue = 0.; V zeroVector(domainVector); zeroVector.cwSet(0.); if (domainVector.atLeastOneComponentSmallerOrEqualThan(zeroVector)) { returnValue = 0.; } else if (this->m_domainSet.contains(domainVector) == false) { // prudenci 2011-Oct-04 returnValue = 0.; } else { returnValue = std::exp(this->lnValue(domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect)); } //returnValue *= exp(m_logOfNormalizationFactor); // No need, because 'lnValue()' is called right above // [PDF-10] if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 55)) { *m_env.subDisplayFile() << "Leaving LogNormalJointPdf<V,M>::actualValue()" << ", meanVector = " << *m_lawExpVector << ": domainVector = " << domainVector << ", returnValue = " << returnValue << std::endl; } return returnValue; }
const D_V& ExperimentStorage<S_V,S_M,D_V,D_M>::dataVec_transformed(unsigned int experimentId) const { UQ_FATAL_TEST_MACRO(experimentId >= m_dataVecs_transformed.size(), m_env.worldRank(), "ExperimentStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>::dataVec_transformed()", "experimentId is too large"); UQ_FATAL_TEST_MACRO(m_dataVecs_transformed[experimentId] == NULL, m_env.worldRank(), "ExperimentStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>::dataVec_transformed()", "vector is NULL"); return *(m_dataVecs_transformed[experimentId]); }
const V& BaseTKGroup<V,M>::preComputingPosition(unsigned int stageId) const { UQ_FATAL_TEST_MACRO(m_preComputingPositions.size() <= stageId, m_env.worldRank(), "BaseTKGroup<V,M>::preComputingPosition()", "m_preComputingPositions.size() <= stageId"); UQ_FATAL_TEST_MACRO(m_preComputingPositions[stageId] == NULL, m_env.worldRank(), "BaseTKGroup<V,M>::preComputingPosition()", "m_preComputingPositions[stageId] == NULL"); return *m_preComputingPositions[stageId]; }
const S_V& ExperimentStorage<S_V,S_M,D_V,D_M>::scenarioVec_standard(unsigned int experimentId) const { UQ_FATAL_TEST_MACRO(experimentId >= m_scenarioVecs_standard.size(), m_env.worldRank(), "ExperimentStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>::scenarioVec_standard()", "experimentId is too large"); UQ_FATAL_TEST_MACRO(m_scenarioVecs_standard[experimentId] == NULL, m_env.worldRank(), "ExperimentStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>::scenarioVec_standard()", "vector is NULL"); return *(m_scenarioVecs_standard[experimentId]); }
//------------------------------------------------------ /// The actual (user-defined) qoi routine //------------------------------------------------------ void qoiRoutine( const uqGslVectorClass& paramValues, const uqGslVectorClass* paramDirection, const void* functionDataPtr, uqGslVectorClass& qoiValues, uqDistArrayClass<uqGslVectorClass*>* gradVectors, uqDistArrayClass<uqGslMatrixClass*>* hessianMatrices, uqDistArrayClass<uqGslVectorClass*>* hessianEffects) { const uqBaseEnvironmentClass& env = paramValues.env(); if (paramDirection && gradVectors && hessianEffects && hessianMatrices) { // Logic just to avoid warnings from INTEL compiler } // The user, at the application level, should have set // the vector 'paramValues' to have size 1 and // the vector 'qoiValues' to have size 1. UQ_FATAL_TEST_MACRO(paramValues.sizeGlobal() != 1, env.fullRank(), "qoiRoutine()", "paramValues vector does not have size 1"); UQ_FATAL_TEST_MACRO(qoiValues.sizeGlobal() != 1, env.fullRank(), "qoiRoutine()", "qoiValues vector does not have size 1"); // Compute qoi(s) double g = paramValues[0]; // Sample of the RV 'gravity acceleration' double distanceTraveled = 0.; if (env.subRank() == 0) { double velocity = ((qoiRoutine_DataClass *) functionDataPtr)->m_initialVelocity; double heights = ((qoiRoutine_DataClass *) functionDataPtr)->m_initialHeight; double alpha = ((qoiRoutine_DataClass *) functionDataPtr)->m_angle; double aux = velocity * sin(alpha); distanceTraveled = (velocity * cos(alpha) / g) * ( aux + sqrt(pow(aux,2) + 2.*g*heights) ); } qoiValues[0] = distanceTraveled; return; }
//***************************************************** // PiecewiseLinear 1D->1D class //***************************************************** uqPiecewiseLinear1D1DFunctionClass::uqPiecewiseLinear1D1DFunctionClass( double minDomainValue, double maxDomainValue, const std::vector<double>& referenceDomainValues, double referenceImageValue0, const std::vector<double>& rateValues) : uqBase1D1DFunctionClass(minDomainValue,maxDomainValue), m_numRefValues (referenceDomainValues.size()), m_referenceDomainValues(referenceDomainValues), m_rateValues (rateValues) { UQ_FATAL_TEST_MACRO(m_numRefValues == 0, UQ_UNAVAILABLE_RANK, "uqPiecewiseLinear1D1DFunctionClass::constructor()", "num ref values = 0"); UQ_FATAL_TEST_MACRO(m_numRefValues != rateValues.size(), UQ_UNAVAILABLE_RANK, "uqPiecewiseLinear1D1DFunctionClass::constructor()", "num rate values is inconsistent"); for (unsigned int i = 1; i < m_numRefValues; ++i) { // Yes, from '1' UQ_FATAL_TEST_MACRO(m_referenceDomainValues[i] <= m_referenceDomainValues[i-1], UQ_UNAVAILABLE_RANK, "uqPiecewiseLinear1D1DFunctionClass::constructor()", "reference domain values are inconsistent"); } m_referenceImageValues.clear(); m_referenceImageValues.resize(m_numRefValues,0.); m_referenceImageValues[0] = referenceImageValue0; for (unsigned int i = 1; i < m_numRefValues; ++i) { // Yes, from '1' m_referenceImageValues[i] = m_referenceImageValues[i-1] + m_rateValues[i-1]*(m_referenceDomainValues[i] - m_referenceDomainValues[i-1]); } if (false) { // For debug only std::cout << "In uqPiecewiseLinear1D1DFunctionClass::constructor():" << std::endl; for (unsigned int i = 0; i < m_numRefValues; ++i) { std::cout << "i = " << i << ", m_referenceDomainValues[i] = " << m_referenceDomainValues[i] << ", m_referenceImageValues[i] = " << m_referenceImageValues[i] << ", m_rateValues[i] = " << m_rateValues[i] << std::endl; } } }
int main(int argc, char* argv[]) { //*********************************************************************** // Initialize MPI //*********************************************************************** MPI_Init(&argc,&argv); //*********************************************************************** // Initialize QUESO environment //*********************************************************************** UQ_FATAL_TEST_MACRO((argc < 2), UQ_UNAVAILABLE_RANK, "main()", "run as <executable> 'inputFileName'"); uqFullEnvironmentClass* env = new uqFullEnvironmentClass(MPI_COMM_WORLD,argv[1],"",NULL); //*********************************************************************** // Run program //*********************************************************************** solveSip(*env); //*********************************************************************** // Finalize QUESO environment //*********************************************************************** delete env; //*********************************************************************** // Finalize MPI //*********************************************************************** MPI_Finalize(); return 0; }
//***************************************************** // WignerInverseChebyshev1st 1D quadrature class //***************************************************** uqWignerInverseChebyshev1st1DQuadratureClass::uqWignerInverseChebyshev1st1DQuadratureClass( double minDomainValue, double maxDomainValue, unsigned int order) : uqBase1DQuadratureClass(minDomainValue,maxDomainValue,order) { m_positions.resize(m_order+1,0.); // Yes, '+1' m_weights.resize (m_order+1,0.); // Yes, '+1' // http://en.wikipedia.org/wiki/Chebyshev-Gauss_quadrature switch (m_order) { default: UQ_FATAL_TEST_MACRO(true, UQ_UNAVAILABLE_RANK, "uqWignerInverseChebyshev1st1DQuadratureClass::constructor()", "order not supported"); break; } // Scale positions from the interval [-1, 1] to the interval [min,max] for (unsigned int j = 0; j < m_positions.size(); ++j) { m_positions[j] = .5*(m_maxDomainValue - m_minDomainValue)*m_positions[j] + .5*(m_maxDomainValue + m_minDomainValue); m_weights[j] *= .5*(m_maxDomainValue - m_minDomainValue); } }
int main(int argc, char* argv[]) { // Initialize environment MPI_Init(&argc,&argv); UQ_FATAL_TEST_MACRO(argc != 3, QUESO::UQ_UNAVAILABLE_RANK, "main()", "after executable argv[0], input file must be specified in command line as argv[1], then numModes (1 or 2) must be specified as argv[2]"); QUESO::FullEnvironment* env = new QUESO::FullEnvironment(MPI_COMM_WORLD,argv[1],"",NULL); // Compute unsigned int numModes = (unsigned int) atoi(argv[2]); compute(*env,numModes); // Finalize environment delete env; MPI_Finalize(); std::cout << std::endl << "FIM!" << std::endl << std::endl; return 0; }
double InverseGammaJointPdf<V,M>::lnValue( const V& domainVector, const V* domainDirection, V* gradVector, M* hessianMatrix, V* hessianEffect) const { UQ_FATAL_TEST_MACRO((domainDirection || gradVector || hessianMatrix || hessianEffect), m_env.worldRank(), "InverseGammaJointPdf<V,M>::lnValue()", "incomplete code for gradVector, hessianMatrix and hessianEffect calculations"); double result = 0.; for (unsigned int i = 0; i < domainVector.sizeLocal(); ++i) { result -= (m_alpha[i]+1.)*log(domainVector[i]); result -= m_beta[i]/domainVector[i]; if (m_normalizationStyle == 0) { // Code needs to be done yet } } result += m_logOfNormalizationFactor; // [PDF-07] return result; }
void SimulationModelOptions::scanOptionsValues() { UQ_FATAL_TEST_MACRO(m_optionsDesc == NULL, m_env.worldRank(), "SimulationModelOptions::scanOptionsValues()", "m_optionsDesc variable is NULL"); defineMyOptions (*m_optionsDesc); m_env.scanInputFileForMyOptions(*m_optionsDesc); //std::cout << "scan 000\n" // << std::endl; getMyOptionValues (*m_optionsDesc); //std::cout << "scan 001\n" // << std::endl; if (m_env.subDisplayFile() != NULL) { *m_env.subDisplayFile() << "In SimulationModelOptions::scanOptionsValues()" << ": after reading values of options with prefix '" << m_prefix << "', state of object is:" << "\n" << *this << std::endl; } return; }
// I/O methods ------------------------------------- void uqMonteCarloSGOptionsClass::scanOptionsValues() { UQ_FATAL_TEST_MACRO(m_optionsDesc == NULL, m_env.worldRank(), "uqMonteCarloSGOptionsClass::scanOptionsValues()", "m_optionsDesc variable is NULL"); defineMyOptions (*m_optionsDesc); m_env.scanInputFileForMyOptions(*m_optionsDesc); getMyOptionValues (*m_optionsDesc); if (m_env.subDisplayFile() != NULL) { *m_env.subDisplayFile() << "In uqMonteCarloSGOptionsClass::scanOptionsValues()" << ": after reading values of options with prefix '" << m_prefix << "', state of object is:" << "\n" << *this << std::endl; } // dakota #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS if (m_ov.m_pseqComputeStats) m_pseqStatisticalOptionsObj = new uqSequenceStatisticalOptionsClass(m_env,m_prefix + "pseq_"); if (m_ov.m_qseqComputeStats) m_qseqStatisticalOptionsObj = new uqSequenceStatisticalOptionsClass(m_env,m_prefix + "qseq_"); #endif return; }
unsigned int GslVector::sizeLocal() const { // mox //std::cout << "Entering GslVector::sizeLocal()" // << ": &m_map = " << &m_map // << std::endl; //std::cout << ", m_map.NumMyElements() = " << m_map.NumMyElements() // << std::endl; //std::cout << ", m_vec = " << m_vec // << std::endl; //std::cout << ", m_vec->size = " << m_vec->size // << std::endl; UQ_FATAL_TEST_MACRO(m_vec->size != (unsigned int) m_map.NumMyElements(), m_env.worldRank(), "GslVector::sizeLocal()", "incompatible vec size"); //std::cout << "Leaving GslVector::sizeLocal()" // << ": m_vec = " << m_vec // << ", m_vec->size = " << m_vec->size // << ", &m_map = " << &m_map // << ", m_map.NumMyElements() = " << m_map.NumMyElements() // << std::endl; return m_vec->size; }
SimulationModelOptions::SimulationModelOptions( const BaseEnvironment& env, const char* prefix) : m_ov (), m_prefix ((std::string)(prefix) + "sm_"), m_env (env), m_optionsDesc (new po::options_description("Simulation model options")), m_option_help (m_prefix + "help" ), m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ), m_option_dataOutputAllowAll (m_prefix + "dataOutputAllowAll" ), m_option_dataOutputAllowedSet (m_prefix + "dataOutputAllowedSet" ), m_option_p_eta (m_prefix + "p_eta" ), m_option_zeroRelativeSingularValue(m_prefix + "zeroRelativeSingularValue"), m_option_cdfThresholdForPEta (m_prefix + "cdfThresholdForPEta" ), m_option_a_w (m_prefix + "a_w" ), m_option_b_w (m_prefix + "b_w" ), m_option_a_rho_w (m_prefix + "a_rho_w" ), m_option_b_rho_w (m_prefix + "b_rho_w" ), m_option_a_eta (m_prefix + "a_eta" ), m_option_b_eta (m_prefix + "b_eta" ), m_option_a_s (m_prefix + "a_s" ), m_option_b_s (m_prefix + "b_s" ) { UQ_FATAL_TEST_MACRO(m_env.optionsInputFileName() == "", m_env.worldRank(), "SimulationModelOptions::constructor(1)", "this constructor is incompatible with the abscense of an options input file"); }
void LogNormalVectorRealizer<V,M>::realization(V& nextValues) const { V iidGaussianVector(m_unifiedImageSet.vectorSpace().zeroVector()); bool outOfSupport = true; do { iidGaussianVector.cwSetGaussian(0.0, 1.0); if (m_lowerCholLawCovMatrix) { nextValues = (*m_unifiedLawExpVector) + (*m_lowerCholLawCovMatrix)*iidGaussianVector; } else if (m_matU && m_vecSsqrt && m_matVt) { nextValues = (*m_unifiedLawExpVector) + (*m_matU)*( (*m_vecSsqrt) * ((*m_matVt)*iidGaussianVector) ); } else { UQ_FATAL_TEST_MACRO(true, m_env.worldRank(), "LogNormalVectorRealizer<V,M>::realization()", "inconsistent internal state"); } for (unsigned int i = 0; i < nextValues.sizeLocal(); ++i) { nextValues[i] = std::exp(nextValues[i]); } outOfSupport = !(this->m_unifiedImageSet.contains(nextValues)); } while (outOfSupport); // prudenci 2011-Oct-04 return; }
int main(int argc, char* argv[]) { //************************************************ // Initialize environments //************************************************ MPI_Init(&argc,&argv); UQ_FATAL_TEST_MACRO(argc != 2, QUESO::UQ_UNAVAILABLE_RANK, "main()", "input file must be specified in command line as argv[1], just after executable argv[0]"); QUESO::FullEnvironment* env = new QUESO::FullEnvironment(MPI_COMM_WORLD,argv[1],"",NULL); //std::cout << "proc " << env->fullRank() << ", HERE main 000" << std::endl; //env->fullComm().Barrier(); //std::cout << "proc " << env->fullRank() << ", HERE main 001" << std::endl; //************************************************ // Call application //************************************************ uqAppl<QUESO::GslVector, // type for parameter vectors QUESO::GslMatrix // type for parameter matrices >(*env); //************************************************ // Finalize environments //************************************************ delete env; MPI_Finalize(); return 0; }
int main(int argc, char* argv[]) { //************************************************ // Initialize environment //************************************************ #ifdef QUESO_HAS_MPI MPI_Init(&argc,&argv); UQ_FATAL_TEST_MACRO(argc != 2, QUESO::UQ_UNAVAILABLE_RANK, "main()", "input file must be specified in command line as argv[1], just after executable argv[0]"); QUESO::FullEnvironment* env = new QUESO::FullEnvironment(MPI_COMM_WORLD,argv[1],"",NULL); #else QUESO::FullEnvironment* env = new QUESO::FullEnvironment(argv[1],"",NULL); #endif //************************************************ // Run application //************************************************ uqAppl(*env); //************************************************ // Finalize environment //************************************************ delete env; #ifdef QUESO_HAS_MPI MPI_Finalize(); #endif return 0; }
int main(int argc, char* argv[]) { //************************************************ // Initialize environment //************************************************ MPI_Init(&argc,&argv); UQ_FATAL_TEST_MACRO(argc != 2, QUESO::UQ_UNAVAILABLE_RANK, "main()", "input file must be specified in command line as argv[1], just after executable argv[0]"); QUESO::FullEnvironment* env = new QUESO::FullEnvironment(MPI_COMM_WORLD,argv[1],"",NULL); //************************************************ // Run application //************************************************ uqAppl<QUESO::GslVector, // type for parameter vectors QUESO::GslMatrix, // type for parameter matrices QUESO::GslVector, // type for qoi vectors QUESO::GslMatrix // type for qoi matrices >(*env); //************************************************ // Finalize environment //************************************************ delete env; MPI_Finalize(); return 0; }
// Default constructor ------------------------------ EnvironmentOptions::EnvironmentOptions( const BaseEnvironment& env, const char* prefix) : m_ov (), m_env (env), m_prefix ((std::string)(prefix) + "env_"), m_optionsDesc (new po::options_description("Environment options")), m_option_help (m_prefix + "help" ), m_option_numSubEnvironments (m_prefix + "numSubEnvironments" ), m_option_subDisplayFileName (m_prefix + "subDisplayFileName" ), m_option_subDisplayAllowAll (m_prefix + "subDisplayAllowAll" ), m_option_subDisplayAllowInter0(m_prefix + "subDisplayAllowInter0"), m_option_subDisplayAllowedSet (m_prefix + "subDisplayAllowedSet" ), m_option_displayVerbosity (m_prefix + "displayVerbosity" ), m_option_syncVerbosity (m_prefix + "syncVerbosity" ), m_option_checkingLevel (m_prefix + "checkingLevel" ), m_option_rngType (m_prefix + "rngType" ), m_option_seed (m_prefix + "seed" ), m_option_platformName (m_prefix + "platformName" ), m_option_identifyingString (m_prefix + "identifyingString" ) { UQ_FATAL_TEST_MACRO(m_env.optionsInputFileName() == "", m_env.worldRank(), "EnvironmentOptions::constructor(1)", "this constructor is incompatible with the abscense of an options input file"); }
bool MiscCheckForSameValueInAllNodes(T& inputValue, // Yes, 'not' const double acceptableTreshold, const MpiComm& comm, const char* whereString) { // Filter out those nodes that should not participate if (comm.MyPID() < 0) return true; double localValue = (double) inputValue; double sumValue = 0.; comm.Allreduce((void *) &localValue, (void *) &sumValue, (int) 1, RawValue_MPI_DOUBLE, RawValue_MPI_SUM, whereString, "failed MPI on 'sumValue' inside MiscCheckForSameValueInAllNodes()"); double totalNumNodes = (double) comm.NumProc(); double testValue = fabs(1. - localValue/(sumValue/totalNumNodes)); unsigned int boolSum = 0; #if 1 unsigned int boolResult = 0; if (testValue > acceptableTreshold) boolResult = 1; comm.Allreduce((void *) &boolResult, (void *) &boolSum, (int) 1, RawValue_MPI_UNSIGNED, RawValue_MPI_SUM, whereString, "failed MPI on 'boolSum' inside MiscCheckForSameValueInAllNodes()"); if (boolSum > 0) { comm.Barrier(); for (int i = 0; i < comm.NumProc(); ++i) { if (i == comm.MyPID()) { std::cerr << "WARNING, " << whereString << ", inside MiscCheckForSameValueInAllNodes()" << ", rank (in this communicator) = " << i << ": boolSum = " << boolSum << ", localValue = " << localValue << ", sumValue = " << sumValue << ", totalNumNodes = " << totalNumNodes << ", avgValue = " << (sumValue/totalNumNodes) << ", relativeTest = " << testValue << std::endl; } comm.Barrier(); } comm.Barrier(); comm.Bcast((void *) &localValue, (int) 1, RawValue_MPI_DOUBLE, 0, whereString, "failed MPI on 'boolSum' inside MiscCheckForSameValueInAllNodes()"); inputValue = localValue; // IMPORTANT } #else UQ_FATAL_TEST_MACRO(testValue > acceptableTreshold, UQ_UNAVAILABLE_RANK, whereString, "not all nodes have the same value inside MiscCheckForSameValueInAllNodes()"); #endif return (boolSum == 0); }
const std::vector<double>& ArrayOfOneDTables<V,M>::oneDTable(unsigned int rowId) const { UQ_FATAL_TEST_MACRO(rowId >= (unsigned int) m_oneDTables.MyLength(), m_env.worldRank(), "ArrayOfOneDTables<T>::oneDTable()", "rowId is out of range"); ArrayOfOneDTables<V,M>* tmp = const_cast<ArrayOfOneDTables<V,M>*>(this); UQ_FATAL_TEST_MACRO(tmp->m_oneDTables(rowId,0) == NULL, m_env.worldRank(), "ArrayOfOneDTables<T>::oneDTable()", "requested row is still NULL"); return *(tmp->m_oneDTables(rowId,0)); }