Commit 65710e44 by Olga Stamati

### implement Geers transformation gradient in 2D (closes #191)

parent 894bf309
Pipeline #53366 passed with stages
in 24 minutes and 17 seconds
 ... ... @@ -64,9 +64,6 @@ if dims[0] == 1: twoD = True #spaceZ = 0 print("spam-regularStrain: detected 2D field") if not args.Q8: print("\tIMPORTANT: overriding the strain calculation mode to Q8") args.Q8 = True else: twoD = False #spaceZ = fieldCoords[dims[2]*dims[1],0] - fieldCoords[0,0] ... ... @@ -131,7 +128,6 @@ else: # Save strain fields print("\nspam-regularStrain: Saving strain fields...") if args.TSV: # Positions for Geers are the measurement points if not args.Q8: if twoD: ... ...
 ... ... @@ -177,19 +177,27 @@ def FfieldRegularGeers(displacementField, nodeSpacing, neighbourRadius=1.5, mask import scipy.spatial pbar = progressbar.ProgressBar() #Define dimensions ##Define dimensions dims = displacementField.shape[0:3] nNodes = dims[0]*dims[1]*dims[2] displacementFieldFlat = displacementField.reshape(nNodes, 3) # Check if a 2D field is passed twoD = False if dims[0] == 1: twoD = True #Deformation gradient tensor F = du/dx +I Ffield = numpy.zeros((dims[0], dims[1], dims[2], 3, 3)) FfieldFlat = numpy.zeros((nNodes, 3, 3)) #Define field coordinates for KD-tree distance calculation, warning, the top point is at zero fieldCoordsFlat = numpy.mgrid[nodeSpacing[0]:dims[0]*nodeSpacing[0]+nodeSpacing[0]:nodeSpacing[0], nodeSpacing[1]:dims[1]*nodeSpacing[1]+nodeSpacing[1]:nodeSpacing[1], nodeSpacing[2]:dims[2]*nodeSpacing[2]+nodeSpacing[2]:nodeSpacing[2]].reshape(3, nNodes).T if twoD: fieldCoordsFlat = numpy.mgrid[0:1:1, nodeSpacing[1]:dims[1]*nodeSpacing[1]+nodeSpacing[1]:nodeSpacing[1], nodeSpacing[2]:dims[2]*nodeSpacing[2]+nodeSpacing[2]:nodeSpacing[2]].reshape(3, nNodes).T else: fieldCoordsFlat = numpy.mgrid[nodeSpacing[0]:dims[0]*nodeSpacing[0]+nodeSpacing[0]:nodeSpacing[0], nodeSpacing[1]:dims[1]*nodeSpacing[1]+nodeSpacing[1]:nodeSpacing[1], nodeSpacing[2]:dims[2]*nodeSpacing[2]+nodeSpacing[2]:nodeSpacing[2]].reshape(3, nNodes).T #Get non-nan displacements if mask: ... ... @@ -214,8 +222,8 @@ def FfieldRegularGeers(displacementField, nodeSpacing, neighbourRadius=1.5, mask #This is for the linear model, equation 15 in Geers centralNodePosition = fieldCoordsFlatGood[goodPoint] centralNodeDisplacement = displacementFieldFlatGood[goodPoint] sX0X0 = numpy.zeros((3,3)) sX0Xt = numpy.zeros((3,3)) sX0X0 = numpy.zeros((3, 3)) sX0Xt = numpy.zeros((3, 3)) m0 = numpy.zeros((3)) mt = numpy.zeros((3)) ... ... @@ -266,13 +274,25 @@ def FfieldRegularGeers(displacementField, nodeSpacing, neighbourRadius=1.5, mask A = sX0X0 - numpy.dot(m0, m0) C = sX0Xt - numpy.dot(m0, mt) F = numpy.zeros((3, 3)) if twoD: A = A[1:, 1:] C = C[1:, 1:] try: F[1:, 1:] = numpy.dot(numpy.linalg.inv(A), C) F[0, 0] = 1.0 except numpy.linalg.linalg.LinAlgError: #print("spam.deformation.deformationField.FfieldRegularGeers(): LinAlgError: A", A) pass else: try: F = numpy.dot(numpy.linalg.inv(A), C) except numpy.linalg.linalg.LinAlgError: #print("spam.deformation.deformationField.FfieldRegularGeers(): LinAlgError: A", A) pass try: FfieldFlatGood[goodPoint] = numpy.dot(numpy.linalg.inv(A), C) except numpy.linalg.linalg.LinAlgError: pass #print("spam.deformation.deformationField.FfieldRegularGeers(): LinAlgError: A", A) FfieldFlatGood[goodPoint] = F FfieldFlat[goodPointsMask] = FfieldFlatGood return FfieldFlat.reshape(dims[0], dims[1], dims[2], 3, 3) ... ...