//2D only cuMatrix<N> operator()(vector<size_t> startPoint,vector<size_t> endPoint){ if(startPoint.size() == nDim() == endPoint.size()==2){ cout << "Dimension error in ()"<< endl; return cuMatrix<N>(); } vector<size_t> newDimension; size_t size = 1; size_t end = nDim(); for(size_t i = 0; i < end; ++i){ if(startPoint[i]>endPoint[i]){ cout << "startPoint > endPoint"<<endl; return cuMatrix<N>(); } newDimension.push_back(endPoint[i]-startPoint[i]+1); size*=newDimension[i]; } N* tempData; cudaMalloc((void**)&tempData,sizeof(N)*size); for(int i = startPoint[0]; i <= endPoint[0];++i){ cudaMemcpy(&(tempData[newDimension[1]*i]),&(m_data[dim(1)*i+startPoint[1]]),sizeof(N)*(endPoint[1]-startPoint[1]+1),cudaMemcpyDeviceToDevice); } return cuMatrix(tempData,newDimension,memPermission::owner); }
/* * * getUnitsStandardConcentration() * * Returns the units of the standard and general concentrations * Note they have the same units, as their divisor is * defined to be equal to the activity of the kth species * in the solution, which is unitless. * * This routine is used in print out applications where the * units are needed. Usually, MKS units are assumed throughout * the program and in the XML input files. * * uA[0] = kmol units - default = 1 * uA[1] = m units - default = -nDim(), the number of spatial * dimensions in the Phase class. * uA[2] = kg units - default = 0; * uA[3] = Pa(pressure) units - default = 0; * uA[4] = Temperature units - default = 0; * uA[5] = time units - default = 0 * * For EOS types other than cIdealSolidSolnPhase1, the default * kmol/m3 holds for standard concentration units. For * cIdealSolidSolnPhase0 type, the standard concentrtion is * unitless. */ void IdealSolnGasVPSS::getUnitsStandardConc(double *uA, int, int sizeUA) const { int eos = eosType(); if (eos == cIdealSolnGasPhase0) { for (int i = 0; i < sizeUA; i++) { uA[i] = 0.0; } } else { for (int i = 0; i < sizeUA; i++) { if (i == 0) uA[0] = 1.0; if (i == 1) uA[1] = -nDim(); if (i == 2) uA[2] = 0.0; if (i == 3) uA[3] = 0.0; if (i == 4) uA[4] = 0.0; if (i == 5) uA[5] = 0.0; } } }
/* * Returns the units of the standard and general concentrations * Note they have the same units, as their divisor is * defined to be equal to the activity of the kth species * in the solution, which is unitless. * * This routine is used in print out applications where the * units are needed. Usually, MKS units are assumed throughout * the program and in the XML input files. * * On return uA contains the powers of the units (MKS assumed) * of the standard concentrations and generalized concentrations * for the kth species. * * uA[0] = kmol units - default = 1 * uA[1] = m units - default = -nDim(), the number of spatial * dimensions in the Phase class. * uA[2] = kg units - default = 0; * uA[3] = Pa(pressure) units - default = 0; * uA[4] = Temperature units - default = 0; * uA[5] = time units - default = 0 */ void MolalityVPSSTP::getUnitsStandardConc(double* uA, int k, int sizeUA) const { for (int i = 0; i < sizeUA; i++) { if (i == 0) { uA[0] = 1.0; } if (i == 1) { uA[1] = -int(nDim()); } if (i == 2) { uA[2] = 0.0; } if (i == 3) { uA[3] = 0.0; } if (i == 4) { uA[4] = 0.0; } if (i == 5) { uA[5] = 0.0; } } }