void FillerBase::setTcal2(const String& tcaltime, const Vector<Float>& tcal) { uInt id = 0 ; Table tab = table_->tcal().table() ; Table result = //tab( nelements(tab.col("TCAL")) == uInt (tcal.size()) && // all(tab.col("TCAL")== tcal) && // tab.col("TIME") == tcaltime, 1 ) ; tab( nelements(tab.col("TCAL")) == uInt (tcal.size()) && all(tab.col("TCAL")== tcal), 1 ) ; if ( result.nrow() > 0 ) { ROTableColumn tmpCol( result, "ID" ) ; tmpCol.getScalar( 0, id ) ; } else { uInt rno = tab.nrow(); tab.addRow(); TableColumn idCol( tab, "ID" ) ; TableColumn tctimeCol( tab, "TIME" ) ; ArrayColumn<Float> tcalCol( tab, "TCAL" ) ; // get last assigned _id and increment if ( rno > 0 ) { idCol.getScalar(rno-1, id); id++; } tctimeCol.putScalar(rno, tcaltime); tcalCol.put(rno, tcal); idCol.putScalar(rno, id); } RecordFieldPtr<uInt> mcalidCol(row_.record(), "TCAL_ID"); *mcalidCol = id; }
//------------------------------------------------------------------------------ void PD_OSP::applySurfaceCorrection(double mu, double nu, int dim, double strain) { arma::vec3 strainFactor; arma::mat gd = arma::zeros(m_particles.nParticles(), dim); // Dilation correction arma::mat gb = arma::zeros(m_particles.nParticles(), dim); // Bond correction //-------------------------------------------------------------------------- // Apllying correction to the dilation term //-------------------------------------------------------------------------- // Stretching all particle in the x, y and z-direction strainFactor(0) = strain; strainFactor(1) = 0; strainFactor(2) = 0; for(int a=0; a<dim; a++) { if(a == 1) strainFactor.swap_rows(0,1); else if(a == 2) strainFactor.swap_rows(1,2); #ifdef USE_OPENMP # pragma omp parallel for #endif // Applying uniaxial stretch for(int i=0; i<m_particles.nParticles(); i++) { pair<int, int> idCol(i, i); int col_i = idCol.second; for(int d=0; d<dim; d++) { m_r(d, col_i) = (1 + strainFactor(d))*m_r(d, col_i); } } double dilation_term = strain; #ifdef USE_OPENMP # pragma omp parallel for #endif // Calculating the elastic energy density for(int i=0; i<m_particles.nParticles(); i++) { pair<int, int> idCol(i, i); int col_i = idCol.second; double theta_i = calculateDilationTerm(idCol); double factor = dilation_term/theta_i; gd(col_i, a) = factor; } #ifdef USE_OPENMP # pragma omp parallel for #endif // Resetting the positions for(int i=0; i<m_particles.nParticles(); i++) { pair<int, int> idCol(i, i); int col_i = idCol.second; for(int d=0; d<dim; d++) { m_r(d, col_i) = m_r(d, col_i)/(1 + strainFactor(d)); } } } //-------------------------------------------------------------------------- // Applying correction to the bond term //-------------------------------------------------------------------------- // Performing a simple shear of all particle in the x, y and z-direction arma::ivec3 axis; strainFactor(0) = 0.5*strain; strainFactor(1) = 0.*strain; strainFactor(2) = 0; axis(0) = 1; axis(1) = 0; axis(2) = 0; for(int a=0; a<dim; a++) { if(a == 1) { strainFactor.swap_rows(1,2); strainFactor.swap_rows(0,1); axis(0) = 0; axis(1) = 2; axis(2) = 1; } else if(a == 2) { strainFactor.swap_rows(2,0); strainFactor.swap_rows(1,2); axis(0) = 2; axis(1) = 0; axis(2) = 0; } //#ifdef USE_OPENMP //# pragma omp parallel for //#endif // Applying uniaxial stretch for(int i=0; i<m_particles.nParticles(); i++) { pair<int, int> idCol(i, i); int col_i = idCol.second; for(int d=0; d<dim; d++) { double shear = strainFactor(d)*m_r(axis(d), col_i); m_r(d, col_i) = m_r(d, col_i) + shear; // m_r(d, col_i) = m_r(d, col_i) + strainFactor(d)*m_r(axis(d), col_i); // m_r(d, col_i) = (1 + strainFactor(d))*m_r(d, col_i); } } double dilation_term = 0.5*mu*strain*strain; //#ifdef USE_OPENMP //# pragma omp parallel for //#endif // Calculating the elastic energy density for(int i=0; i<m_particles.nParticles(); i++) { pair<int, int> idCol(i, i); int col_i = idCol.second; double bond_i = calculateBondPotential(idCol); double factor = dilation_term/bond_i; gb(col_i, a) = factor; } //#ifdef USE_OPENMP //# pragma omp parallel for //#endif // Resetting the positions for(int i=0; i<m_particles.nParticles(); i++) { pair<int, int> idCol(i, i); int col_i = idCol.second; for(int d=0; d<dim; d++) { m_r(d, col_i) = m_r(d, col_i) - strainFactor(d)*m_r(axis(d), col_i); // m_r(d, col_i) = m_r(d, col_i)/(1 + strainFactor(d)); } } } //-------------------------------------------------------------------------- // Calculating the scaling //-------------------------------------------------------------------------- //#ifdef USE_OPENMP //# pragma omp parallel for //#endif for(int i=0; i<m_particles.nParticles(); i++) { pair<int, int> idCol(i, i); int pId = idCol.first; int col_i = idCol.second; vector<pair<int, vector<double>>> & PDconnections = m_particles.pdConnections(pId); for(auto &con:PDconnections) { int id_j = con.first; int col_j = m_pIds[id_j]; double dr0Len = con.second[m_indexDr0]; arma::vec3 n = (m_r.col(col_i) - m_r.col(col_j))/dr0Len; arma::vec3 gd_mean; arma::vec3 gb_mean; double Gd = 0; double Gb = 0; for(int d=0; d<dim; d++) { gd_mean(d) = 0.5*(gd(col_i, d) + gd(col_j, d)); gb_mean(d) = 0.5*(gb(col_i, d) + gb(col_j, d)); Gd += pow(n(d)/gd_mean(d), 2); Gb += pow(n(d)/gb_mean(d), 2); } Gd = pow(Gd, -0.5); Gb = pow(Gb, -0.5); con.second[m_indexForceScalingDilation] *= Gd; con.second[m_indexForceScalingBond] *= Gb; } } }