float GetCurrAcc(float V0, float V1, float dist, float a0, float a1) { float t10,t11,t0,t1; t10 = t_xx (V0, V1, a0, a1, dist, 1.0f); t11 = t_xx (V0, V1, a0, a1, dist, -1.0f); t1 = t_1 (t10, t11); t0 = t_0 (V0, V1, a0, a1, t1); return getA (t0, a1, a0); }
int main() { freopen("output.txt", "a", stdout); std::chrono::system_clock::time_point start = std::chrono::system_clock::now(); bad b; std::thread t_1(increase, &(b.a)); std::thread t_2(increase, &(b.b)); t_1.join(); t_2.join(); std::chrono::system_clock::time_point end = std::chrono::system_clock::now(); std::cout << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() << std::endl; return 0; }
void TvergaardHutchinsonModel<EvalT, Traits>::computeState( typename Traits::EvalData workset, DepFieldMap dep_fields, FieldMap eval_fields) { // extract dependent MDFields auto jump = *dep_fields["Vector Jump"]; auto basis = *dep_fields["Current Basis"]; // extract evaluated MDFields auto traction = *eval_fields["Cohesive_Traction"]; auto traction_normal = *eval_fields["Normal_Traction"]; auto traction_shear = *eval_fields["Shear_Traction"]; auto jump_normal = *eval_fields["Normal_Jump"]; auto jump_shear = *eval_fields["Shear_Jump"]; for (int cell(0); cell < workset.numCells; ++cell) { for (int pt(0); pt < num_pts_; ++pt) { // current basis vector minitensor::Vector<ScalarT> g_0( minitensor::Source::ARRAY, 3, basis, cell, pt, 0, 0); minitensor::Vector<ScalarT> g_1( minitensor::Source::ARRAY, 3, basis, cell, pt, 1, 0); minitensor::Vector<ScalarT> n( minitensor::Source::ARRAY, 3, basis, cell, pt, 2, 0); // construct orthogonal unit basis minitensor::Vector<ScalarT> t_0(0.0, 0.0, 0.0), t_1(0.0, 0.0, 0.0); t_0 = g_0 / norm(g_0); t_1 = cross(n, t_0); // construct transformation matrix Q (2nd order tensor) minitensor::Tensor<ScalarT> Q(3, minitensor::Filler::ZEROS); // manually fill Q = [t_0; t_1; n]; Q(0, 0) = t_0(0); Q(1, 0) = t_0(1); Q(2, 0) = t_0(2); Q(0, 1) = t_1(0); Q(1, 1) = t_1(1); Q(2, 1) = t_1(2); Q(0, 2) = n(0); Q(1, 2) = n(1); Q(2, 2) = n(2); // global and local jump minitensor::Vector<ScalarT> jump_global( minitensor::Source::ARRAY, 3, jump, cell, pt, 0); minitensor::Vector<ScalarT> jump_local(3); jump_local = minitensor::dot(minitensor::transpose(Q), jump_global); // define shear and normal components of jump // needed for interpenetration // Note: need to protect sqrt around zero when using Sacado ScalarT JumpNormal, JumpShear, IntermediateValue; JumpNormal = jump_local(2); IntermediateValue = jump_local(0) * jump_local(0) + jump_local(1) * jump_local(1); if (IntermediateValue > 0.0) JumpShear = sqrt(IntermediateValue); else JumpShear = 0.0; // matrix beta that controls relative effect of shear and normal opening minitensor::Tensor<ScalarT> beta(3, minitensor::Filler::ZEROS); beta(0, 0) = beta_0; beta(1, 1) = beta_1; beta(2, 2) = beta_2; // compute scalar effective jump ScalarT jump_eff; IntermediateValue = minitensor::dot(jump_local, minitensor::dot(beta, jump_local)); if (IntermediateValue > 0.0) jump_eff = sqrt(IntermediateValue); else jump_eff = 0.0; // traction-separation law from Tvergaard-Hutchinson 1992 ScalarT sigma_eff; // Sacado::ScalarValue<ScalarT>::eval if (jump_eff <= delta_1) sigma_eff = sigma_c * jump_eff / delta_1; else if (jump_eff > delta_1 && jump_eff <= delta_2) sigma_eff = sigma_c; else if (jump_eff > delta_2 && jump_eff <= delta_c) sigma_eff = sigma_c * (delta_c - jump_eff) / (delta_c - delta_2); else sigma_eff = 0.0; // construct traction vector minitensor::Vector<ScalarT> traction_local(3); traction_local.clear(); if (jump_eff != 0) traction_local = minitensor::dot(beta, jump_local) * sigma_eff / jump_eff; // norm of the local shear components of the traction ScalarT TractionShear; IntermediateValue = traction_local(0) * traction_local(0) + traction_local(1) * traction_local(1); if (IntermediateValue > 0.0) TractionShear = sqrt(IntermediateValue); else TractionShear = 0.0; // global traction vector minitensor::Vector<ScalarT> traction_global(3); traction_global = minitensor::dot(Q, traction_local); traction(cell, pt, 0) = traction_global(0); traction(cell, pt, 1) = traction_global(1); traction(cell, pt, 2) = traction_global(2); // update state variables traction_normal(cell, pt) = traction_local(2); traction_shear(cell, pt) = TractionShear; jump_normal(cell, pt) = JumpNormal; jump_shear(cell, pt) = JumpShear; } } }
void highOrderTools::computeStraightSidedPositions() { _clean(); // compute straigh sided positions that are actually X,Y,Z positions // that are NOT always on curves and surfaces // points classified on model vertices shall not move ! for(GModel::viter it = _gm->firstVertex(); it != _gm->lastVertex(); ++it){ if ((*it)->points.size()){ MPoint *p = (*it)->points[0]; MVertex *v = p->getVertex(0); _straightSidedLocation [v] = SVector3((*it)->x(),(*it)->y(),(*it)->z()); _targetLocation [v] = SVector3((*it)->x(),(*it)->y(),(*it)->z()); } } // printf("coucou2\n"); // compute stright sided positions of vertices that are classified on model edges for(GModel::eiter it = _gm->firstEdge(); it != _gm->lastEdge(); ++it){ for (unsigned int i=0;i<(*it)->lines.size();i++){ MLine *l = (*it)->lines[i]; int N = l->getNumVertices()-2; SVector3 p0((*it)->lines[i]->getVertex(0)->x(), (*it)->lines[i]->getVertex(0)->y(), (*it)->lines[i]->getVertex(0)->z()); SVector3 p1((*it)->lines[i]->getVertex(1)->x(), (*it)->lines[i]->getVertex(1)->y(), (*it)->lines[i]->getVertex(1)->z()); for (int j=1;j<=N;j++){ const double xi = (double)(j)/(N+1); // printf("xi = %g\n",xi); const SVector3 straightSidedPoint = p0 *(1.-xi) + p1*xi; MVertex *v = (*it)->lines[i]->getVertex(j+1); if (_straightSidedLocation.find(v) == _straightSidedLocation.end()){ _straightSidedLocation [v] = straightSidedPoint; _targetLocation[v] = SVector3(v->x(),v->y(),v->z()); } } } } // printf("coucou3\n"); // compute stright sided positions of vertices that are classified on model faces for(GModel::fiter it = _gm->firstFace(); it != _gm->lastFace(); ++it){ for (unsigned int i=0;i<(*it)->mesh_vertices.size();i++){ MVertex *v = (*it)->mesh_vertices[i]; _targetLocation[v] = SVector3(v->x(),v->y(),v->z()); } for (unsigned int i=0;i<(*it)->triangles.size();i++){ MTriangle *t = (*it)->triangles[i]; MFace face = t->getFace(0); const nodalBasis* fs = t->getFunctionSpace(); for (int j=0;j<t->getNumVertices();j++){ if (t->getVertex(j)->onWhat() == *it){ const double t1 = fs->points(j, 0); const double t2 = fs->points(j, 1); SPoint3 pc = face.interpolate(t1, t2); _straightSidedLocation [t->getVertex(j)] = SVector3(pc.x(),pc.y(),pc.z()); } } } for (unsigned int i=0;i<(*it)->quadrangles.size();i++){ // printf("coucou quad %d\n",i); MQuadrangle *q = (*it)->quadrangles[i]; MFace face = q->getFace(0); const nodalBasis* fs = q->getFunctionSpace(); for (int j=0;j<q->getNumVertices();j++){ if (q->getVertex(j)->onWhat() == *it){ const double t1 = fs->points(j, 0); const double t2 = fs->points(j, 1); SPoint3 pc = face.interpolate(t1, t2); _straightSidedLocation [q->getVertex(j)] = SVector3(pc.x(),pc.y(),pc.z()); } } } } for(GModel::riter it = _gm->firstRegion(); it != _gm->lastRegion(); ++it){ for (unsigned int i=0;i<(*it)->mesh_vertices.size();i++){ MVertex *v = (*it)->mesh_vertices[i]; _targetLocation[v] = SVector3(v->x(),v->y(),v->z()); } for (unsigned int i=0;i<(*it)->tetrahedra.size();i++){ _dim = 3; MTetrahedron *t = (*it)->tetrahedra[i]; MTetrahedron t_1 ((*it)->tetrahedra[i]->getVertex(0), (*it)->tetrahedra[i]->getVertex(1), (*it)->tetrahedra[i]->getVertex(2), (*it)->tetrahedra[i]->getVertex(3)); const nodalBasis* fs = t->getFunctionSpace(); for (int j=0;j<t->getNumVertices();j++){ if (t->getVertex(j)->onWhat() == *it){ double t1 = fs->points(j, 0); double t2 = fs->points(j, 1); double t3 = fs->points(j, 2); SPoint3 pc; t_1.pnt(t1, t2, t3,pc); _straightSidedLocation [t->getVertex(j)] = SVector3(pc.x(),pc.y(),pc.z()); } } } for (unsigned int i=0;i<(*it)->hexahedra.size();i++){ _dim = 3; MHexahedron *h = (*it)->hexahedra[i]; MHexahedron h_1 ((*it)->hexahedra[i]->getVertex(0), (*it)->hexahedra[i]->getVertex(1), (*it)->hexahedra[i]->getVertex(2), (*it)->hexahedra[i]->getVertex(3), (*it)->hexahedra[i]->getVertex(4), (*it)->hexahedra[i]->getVertex(5), (*it)->hexahedra[i]->getVertex(6), (*it)->hexahedra[i]->getVertex(7)); const nodalBasis* fs = h->getFunctionSpace(); for (int j=0;j<h->getNumVertices();j++){ if (h->getVertex(j)->onWhat() == *it){ double t1 = fs->points(j, 0); double t2 = fs->points(j, 1); double t3 = fs->points(j, 2); SPoint3 pc; h_1.pnt(t1, t2, t3,pc); _straightSidedLocation [h->getVertex(j)] = SVector3(pc.x(),pc.y(),pc.z()); } } } } Msg::Info("highOrderTools has been set up : %d nodes are considered", _straightSidedLocation.size()); }