bool PLCrackPrescribedDir :: propagateInterface(Domain &iDomain, EnrichmentFront &iEnrFront, TipPropagation &oTipProp) { if ( !iEnrFront.propagationIsAllowed() ) { return false; } const TipInfo &tipInfo = iEnrFront.giveTipInfo(); SpatialLocalizer *localizer = iDomain.giveSpatialLocalizer(); // It is meaningless to propagate a tip that is not inside any element if ( tipInfo.mGlobalCoord.giveSize() == 0 ) { return false; } Element *el = localizer->giveElementContainingPoint(tipInfo.mGlobalCoord); if ( el == NULL ) { return false; } double angleRad = mAngle * M_PI / 180.0; FloatArray dir = { cos(angleRad), sin(angleRad) }; oTipProp.mTipIndex = tipInfo.mTipIndex; oTipProp.mPropagationDir = dir; oTipProp.mPropagationLength = mIncrementLength; return true; }
bool PLnodeRadius :: propagateInterface(Domain &iDomain, EnrichmentFront &iEnrFront, TipPropagation &oTipProp) { if ( !iEnrFront.propagationIsAllowed() ) { printf("EnrichmentFront.propagationIsAllowed is false \n"); return false; } const TipInfo &tipInfo = iEnrFront.giveTipInfo(); // includes the dofman numbers which represent the boundary of the EI. //tipInfo.mTipDofManNumbers.printYourself(); // No listbased tip (or EI) present, so nothing to propagate. if ( tipInfo.mTipDofManNumbers.giveSize() == 0 ) { printf("No dofmans in tip; nothing to propagate. \n"); return false; } // Localise nodes within certain radius from tip nodes oTipProp.mPropagationDofManNumbers.clear(); SpatialLocalizer *localizer = iDomain.giveSpatialLocalizer(); for ( int i = 1 ; i <= tipInfo.mTipDofManNumbers.giveSize() ; i++ ) { //DofManager *dofMan = iDomain.giveDofManager(tipInfo.mTipDofManNumbers.at(i)); //const FloatArray gCoords = dofMan->giveCoordinates(); Node *iNode = iDomain.giveNode(tipInfo.mTipDofManNumbers.at(i)); const FloatArray gCoords = iNode->giveNodeCoordinates(); std :: list< int > nodeList; localizer->giveAllNodesWithinBox(nodeList,gCoords,mRadius); for ( int jNode : nodeList ) { //printf("nodeList node %d \n",jNode); oTipProp.mPropagationDofManNumbers.insertSortedOnce(jNode); } } //oTipProp.mPropagationDofManNumbers.printYourself(" The following noded will be propagated to:"); return true; }
void GnuplotExportModule::outputXFEM(Crack &iCrack, TimeStep *tStep) { const std::vector<GaussPoint*> &czGaussPoints = iCrack.giveCohesiveZoneGaussPoints(); std::vector<double> arcLengthPositions, normalJumps, tangJumps, normalTractions; const BasicGeometry *bg = iCrack.giveGeometry(); for( GaussPoint *gp: czGaussPoints ) { StructuralInterfaceMaterialStatus *matStat = dynamic_cast<StructuralInterfaceMaterialStatus*> ( gp->giveMaterialStatus() ); if(matStat != NULL) { // Compute arc length position of the Gauss point const FloatArray &coord = (gp->giveGlobalCoordinates()); double tangDist = 0.0, arcPos = 0.0; bg->computeTangentialSignDist(tangDist, coord, arcPos); arcLengthPositions.push_back(arcPos); // Compute displacement jump in normal and tangential direction // Local numbering: (tang_z, tang, normal) const FloatArray &jumpLoc = matStat->giveJump(); double normalJump = jumpLoc.at(3); normalJumps.push_back(normalJump); tangJumps.push_back( jumpLoc.at(2) ); const FloatArray &trac = matStat->giveFirstPKTraction(); normalTractions.push_back(trac.at(3)); } } Domain *domain = emodel->giveDomain(1); XfemManager *xMan = domain->giveXfemManager(); if ( xMan != NULL ) { double time = 0.0; TimeStep *ts = emodel->giveCurrentStep(); if ( ts != NULL ) { time = ts->giveTargetTime(); } int eiIndex = iCrack.giveNumber(); std :: stringstream strNormalJump; strNormalJump << "NormalJumpGnuplotEI" << eiIndex << "Time" << time << ".dat"; std :: string nameNormalJump = strNormalJump.str(); XFEMDebugTools::WriteArrayToGnuplot(nameNormalJump, arcLengthPositions, normalJumps); std :: stringstream strTangJump; strTangJump << "TangJumpGnuplotEI" << eiIndex << "Time" << time << ".dat"; std :: string nameTangJump = strTangJump.str(); XFEMDebugTools::WriteArrayToGnuplot(nameTangJump, arcLengthPositions, tangJumps); std :: stringstream strNormalTrac; strNormalTrac << "NormalTracGnuplotEI" << eiIndex << "Time" << time << ".dat"; std :: string nameNormalTrac = strNormalTrac.str(); XFEMDebugTools::WriteArrayToGnuplot(nameNormalTrac, arcLengthPositions, normalTractions); std::vector<FloatArray> matForcesStart, matForcesEnd; std::vector<double> radii; // Material forces for(double matForceRadius : mMatForceRadii) { radii.push_back(matForceRadius); EnrichmentFront *efStart = iCrack.giveEnrichmentFrontStart(); const TipInfo &tipInfoStart = efStart->giveTipInfo(); FloatArray matForceStart; mpMatForceEvaluator->computeMaterialForce(matForceStart, *domain, tipInfoStart, tStep, matForceRadius); if(matForceStart.giveSize() > 0) { matForcesStart.push_back(matForceStart); } else { matForcesStart.push_back({0.0,0.0}); } EnrichmentFront *efEnd = iCrack.giveEnrichmentFrontEnd(); const TipInfo &tipInfoEnd = efEnd->giveTipInfo(); FloatArray matForceEnd; mpMatForceEvaluator->computeMaterialForce(matForceEnd, *domain, tipInfoEnd, tStep, matForceRadius); if(matForceEnd.giveSize() > 0) { matForcesEnd.push_back(matForceEnd); } else { matForcesEnd.push_back({0.0,0.0}); } } std::vector< std::vector<FloatArray> > matForcesStartArray, matForcesEndArray; matForcesStartArray.push_back(matForcesStart); matForcesEndArray.push_back(matForcesEnd); std :: stringstream strRadii; strRadii << "MatForceRadiiGnuplotTime" << time << "Crack" << iCrack.giveNumber() << ".dat"; XFEMDebugTools::WriteArrayToGnuplot(strRadii.str(), radii, radii); std :: stringstream strMatForcesStart; strMatForcesStart << "MatForcesStartGnuplotTime" << time << "Crack" << iCrack.giveNumber() << ".dat"; WritePointsToGnuplot(strMatForcesStart.str(), matForcesStartArray); std :: stringstream strMatForcesEnd; strMatForcesEnd << "MatForcesEndGnuplotTime" << time << "Crack" << iCrack.giveNumber() << ".dat"; WritePointsToGnuplot(strMatForcesEnd.str(), matForcesEndArray); double crackLength = iCrack.computeLength(); // printf("crackLength: %e\n", crackLength ); mCrackLengthHist[eiIndex].push_back(crackLength); std :: stringstream strCrackLength; strCrackLength << "CrackLengthGnuplotEI" << eiIndex << "Time" << time << ".dat"; XFEMDebugTools::WriteArrayToGnuplot(strCrackLength.str(), mTimeHist, mCrackLengthHist[eiIndex]); } }
bool PLMaterialForce :: propagateInterface(Domain &iDomain, EnrichmentFront &iEnrFront, TipPropagation &oTipProp) { // printf("Entering PLMaterialForce :: propagateInterface().\n"); if ( !iEnrFront.propagationIsAllowed() ) { return false; } // Fetch crack tip data const TipInfo &tipInfo = iEnrFront.giveTipInfo(); // Check if the tip is located in the domain SpatialLocalizer *localizer = iDomain.giveSpatialLocalizer(); FloatArray lCoords, closest; // printf("tipInfo.mGlobalCoord: \n"); tipInfo.mGlobalCoord.printYourself(); if( tipInfo.mGlobalCoord.giveSize() == 0 ) { return false; } localizer->giveElementClosestToPoint(lCoords, closest, tipInfo.mGlobalCoord); if(closest.distance(tipInfo.mGlobalCoord) > 1.0e-9) { // printf("Tip is outside all elements.\n"); return false; } FloatArray matForce; TimeStep *tStep = iDomain.giveEngngModel()->giveCurrentStep(); mpMaterialForceEvaluator->computeMaterialForce(matForce, iDomain, tipInfo, tStep, mRadius); // printf("matForce: "); matForce.printYourself(); if(matForce.giveSize() == 0) { return false; } double forceNorm = matForce.computeNorm(); // printf("forceNorm: %e mCrackPropThreshold: %e\n", forceNorm, mCrackPropThreshold); if(forceNorm < mCrackPropThreshold || forceNorm < 1.0e-20) { return false; } printf("forceNorm: %e mCrackPropThreshold: %e\n", forceNorm, mCrackPropThreshold); printf("Propagating crack in PLMaterialForce :: propagateInterface.\n"); // printf("Tip coord: "); tipInfo.mGlobalCoord.printYourself(); FloatArray dir(matForce); dir.times(1.0/forceNorm); // printf("dir: "); dir.printYourself(); const double cosAngTol = 1.0/sqrt(2.0); if(tipInfo.mTangDir.dotProduct(dir) < cosAngTol) { // Do not allow sharper turns than 45 degrees if( tipInfo.mNormalDir.dotProduct(dir) > 0.0 ) { dir = tipInfo.mTangDir; dir.add(tipInfo.mNormalDir); dir.normalize(); } else { // dir = tipInfo.mNormalDir; // dir.times(-1.0); dir = tipInfo.mTangDir; dir.add(-1.0,tipInfo.mNormalDir); dir.normalize(); } printf("//////////////////////////////////////////// Resticting crack propagation direction.\n"); // printf("tipInfo.mTangDir: "); tipInfo.mTangDir.printYourself(); // printf("dir: "); dir.printYourself(); } // Fill up struct oTipProp.mTipIndex = tipInfo.mTipIndex; oTipProp.mPropagationDir = dir; oTipProp.mPropagationLength = mIncrementLength; return true; }