bool LESModel::read() { //if (regIOobject::read()) // Bit of trickery : we are both IOdictionary ('RASProperties') and // an regIOobject from the turbulenceModel level. Problem is to distinguish // between the two - we only want to reread the IOdictionary. bool ok = IOdictionary::readData ( IOdictionary::readStream ( IOdictionary::type() ) ); IOdictionary::close(); if (ok) { if (const dictionary* dictPtr = subDictPtr(type() + "Coeffs")) { coeffDict_ <<= *dictPtr; } delta_().read(*this); kMin_.readIfPresent(*this); return true; } else { return false; } }
/*! Add to current trasformation matrix a \b delta traslation. */ void ImageViewer::panQt(const QPoint &delta) { if (delta == QPoint()) return; // stop panning when the image is at the edge of window QPoint delta_(delta.x(), delta.y()); TToonzImageP timg = (TToonzImageP)m_image; TRasterImageP rimg = (TRasterImageP)m_image; if (timg || rimg) { bool isXPlus = delta.x() > 0; bool isYPlus = delta.y() > 0; TDimension imgSize((timg) ? timg->getSize() : rimg->getRaster()->getSize()); int subSampling = (timg) ? timg->getSubsampling() : rimg->getSubsampling(); TPointD cornerPos = TPointD(imgSize.lx * ((isXPlus) ? -1 : 1), imgSize.ly * ((isYPlus) ? 1 : -1)) * (0.5 / (double)subSampling); cornerPos = m_viewAff * cornerPos; if ((cornerPos.x > 0) == isXPlus) delta_.setX(0); if ((cornerPos.y < 0) == isYPlus) delta_.setY(0); } setViewAff(TTranslation(delta_.x(), -delta_.y()) * m_viewAff); update(); }
// Generalization of the addition operation, // x_plus_delta = Plus(x, delta) // with the condition that Plus(x, 0) = x. bool HomogeneousPointLocalParameterization::plus(const double* x, const double* delta, double* x_plus_delta) { Eigen::Map<const Eigen::Vector3d> delta_(delta); Eigen::Map<const Eigen::Vector4d> x_(x); Eigen::Map<Eigen::Vector4d> x_plus_delta_(x_plus_delta); // Euclidean style x_plus_delta_ = x_ + Eigen::Vector4d(delta_[0], delta_[1], delta_[2], 0); return true; }
// Computes the minimal difference between a variable x and a perturbed variable x_plus_delta. bool HomogeneousPointLocalParameterization::minus(const double* x, const double* x_plus_delta, double* delta) { Eigen::Map<Eigen::Vector3d> delta_(delta); Eigen::Map<const Eigen::Vector4d> x_(x); Eigen::Map<const Eigen::Vector4d> x_plus_delta_(x_plus_delta); // Euclidean style OKVIS_ASSERT_TRUE_DBG(Exception,fabs((x_plus_delta_-x_)[3])<1e-12, "comparing homogeneous points with different scale "<<x_plus_delta_[3]<<" vs. "<<x_[3]); delta_ = (x_plus_delta_ - x_).head<3>(); return true; }
bool LESModel::read() { if (regIOobject::read()) { if (const dictionary* dictPtr = subDictPtr(type() + "Coeffs")) { coeffDict_ <<= *dictPtr; } delta_().read(*this); readIfPresent("k0", k0_); return true; } else { return false; } }
void LESModel::correct(const tmp<volTensorField>&) { turbulenceModel::correct(); delta_().correct(); }
DRG::DRG(OpenSMOKE::ThermodynamicsMap_CHEMKIN<double>* thermodynamicsMapXML, OpenSMOKE::KineticsMap_CHEMKIN<double>* kineticsMapXML) : thermodynamicsMapXML_(*thermodynamicsMapXML), kineticsMapXML_(*kineticsMapXML) { epsilon_ = 1.e-2; NS_ = thermodynamicsMapXML_.NumberOfSpecies(); NR_ = kineticsMapXML_.NumberOfReactions(); ChangeDimensions(NR_, &rNet_, true); r_.resize(NS_, NS_); important_species_.resize(NS_); important_reactions_.resize(NR_); number_important_species_ = NS_; number_unimportant_reactions_ = 0; // Build a full matrix of net stoichiometric coefficients nu = nuB - nuF Eigen::MatrixXd nu_(NR_, NS_); { // Be careful: eigen vectors and matrices are 0-index based // Be careful: if the kinetic scheme is large, this matrix, since it is full, can be very memory expensive // Example: 10^3 species, 10^4 reactions = size of the matrix 10^7 elements! // This is the reason why we store stoichiometric matrices in sparse format. // Of course te advantage of having a full matrix, is that you access the elements directly, without // using iterators and pointers, as reported above nu_.setZero(); // Loop over all the reactions (product side) for (int k = 0; k < kineticsMapXML_.stoichiometry().stoichiometric_matrix_products().outerSize(); ++k) { // Loop over all the non-zero stoichiometric coefficients (product side) of reaction k for (Eigen::SparseMatrix<double>::InnerIterator it(kineticsMapXML_.stoichiometry().stoichiometric_matrix_products(), k); it; ++it) { nu_(it.row(), it.col()) += it.value(); } } // Loop over all the reactions (product side) for (int k = 0; k < kineticsMapXML_.stoichiometry().stoichiometric_matrix_reactants().outerSize(); ++k) { // Loop over all the non-zero stoichiometric coefficients (product side) of reaction k for (Eigen::SparseMatrix<double>::InnerIterator it(kineticsMapXML_.stoichiometry().stoichiometric_matrix_reactants(), k); it; ++it) { nu_(it.row(), it.col()) -= it.value(); } } } // Build the delta matrix (dense matrix) used by the DRG method Eigen::MatrixXd delta_(NR_, NS_); { for (unsigned int i = 0; i < NR_; i++) { for (unsigned int j = 0; j < NS_; j++) delta_(i, j) = (nu_(i, j) == 0) ? 0 : 1; } } // Sparse Algebra { // Sparse net stoichiometric matrix { nu_sparse_.resize(NS_,NR_); typedef Eigen::Triplet<double> T; std::vector<T> tripletList; tripletList.reserve(NR_*4); for (unsigned int i = 0; i < NR_; i++) for (unsigned int j = 0; j < NS_; j++) { if ( nu_(i,j) != 0.) tripletList.push_back(T(j,i,nu_(i,j))); } nu_sparse_.setFromTriplets(tripletList.begin(), tripletList.end()); } // Sparse delta matrix, 1 means the species is involved in the reaction, (NR x NS) delta_sparse_.resize(NS_,NR_); { typedef Eigen::Triplet<double> T; std::vector<T> tripletList; tripletList.reserve(NR_*4); for (unsigned int i = 0; i < NR_; i++) for (unsigned int j = 0; j < NS_; j++) { if ( delta_(i,j) != 0.) tripletList.push_back(T(j,i,1.)); } delta_sparse_.setFromTriplets(tripletList.begin(), tripletList.end()); } // Nu times delta { nu_times_delta_.resize(NS_); for (unsigned int k = 0; k < NS_; k++) { nu_times_delta_[k].resize(NS_, NR_); typedef Eigen::Triplet<double> T; std::vector<T> tripletList; tripletList.reserve(NR_*4); for (unsigned int i = 0; i < NR_; i++) for (unsigned int j = 0; j < NS_; j++) { const double prod = nu_(i,k) * delta_(i,j); if ( prod != 0.) tripletList.push_back(T(j,i, prod)); } nu_times_delta_[k].setFromTriplets(tripletList.begin(), tripletList.end()); } } } }
void LESModel::correct(const tmp<volTensorField>&) { delta_().correct(); }
thrust::device_reference<float> Block::delta(int t, int n, int c, int h, int w) {return delta_(t,n,c,h,w); }
thrust::device_ptr<float> Block::delta(int t, int n, int c, int h) {return delta_(t,n,c,h); }
thrust::device_ptr<float> Block::delta(int t, int n) {return delta_(t,n); }
//Delta thrust interface Tensor& Block::delta(int t) {return delta_(t); }