Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit c5c32d88 authored by Olga Stamati's avatar Olga Stamati
Browse files

safer calculation of node spacing from an ldic field

parent 0a5e1897
Pipeline #48397 passed with stages
in 23 minutes and 44 seconds
......@@ -54,20 +54,22 @@ dims = f["fieldDims"]
fieldCoords = f["fieldCoords"]
# Calculate node spacing for each direction
spaceX = fieldCoords[1,2] - fieldCoords[0,2]
spaceY = fieldCoords[dims[2],1] - fieldCoords[0,1]
#spaceX = fieldCoords[1,2] - fieldCoords[0,2]
#spaceY = fieldCoords[dims[2],1] - fieldCoords[0,1]
# 2020-08-31 OS: safer calculation of node spacing
nodeSpacing = numpy.array([numpy.unique(fieldCoords[:, i])[1] - numpy.unique(fieldCoords[:, i])[0] if len(numpy.unique(fieldCoords[:, i])) > 1 else numpy.unique(fieldCoords[:, i])[0] for i in range(3)])
# Catch 2D case
if dims[0] == 1:
twoD = True
spaceZ = 0
#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]
#spaceZ = fieldCoords[dims[2]*dims[1],0] - fieldCoords[0,0]
# Check if a mask of points (based on return status of the correlation) is asked
......@@ -104,11 +106,11 @@ else:
print("\nspam-regularStrain: Computing F=I+du/dx")
if not args.Q8:
Ffield = spam.deformation.FfieldRegularGeers(disp, nodeSpacing=[spaceZ, spaceY, spaceX],
Ffield = spam.deformation.FfieldRegularGeers(disp, nodeSpacing=nodeSpacing,
mask=args.MASK,
neighbourRadius=args.STRAIN_NEIGHBOUR_RADIUS)
else:
Ffield = spam.deformation.FfieldRegularQ8( disp, nodeSpacing=[spaceZ, spaceY, spaceX])
Ffield = spam.deformation.FfieldRegularQ8( disp, nodeSpacing=nodeSpacing)
# Now compute what's been asked for...
print("\nspam-regularStrain: Decomposing F into ", args.COMPONENTS)
......@@ -143,14 +145,13 @@ if args.TSV:
else:
outputPositions = fieldCoords.copy().reshape(dims[0], dims[1], dims[2], 3)[0:-1, 0:-1, 0:-1, :]
# Add a half-node spacing to the output field
outputPositions[:, :, :, 0] += spaceZ / 2.0
outputPositions[:, :, :, 1] += spaceY / 2.0
outputPositions[:, :, :, 2] += spaceX / 2.0
outputPositions[:, :, :, 0] += nodeSpacing[0] / 2.0
outputPositions[:, :, :, 1] += nodeSpacing[1] / 2.0
outputPositions[:, :, :, 2] += nodeSpacing[2] / 2.0
# Here we want to pass an Nx3 matrix of poitions:
spam.helpers.writeStrainTSV(fileNameBase+".tsv", outputPositions.reshape(-1,3), decomposedFfield, firstColumn="StrainPointNumber")
if args.TIFF:
for component in args.COMPONENTS:
if component == 'vol' or component == 'dev' or component == 'volss' or component == 'devss':
......@@ -168,8 +169,8 @@ if args.TIFF:
if args.VTK:
cellData = {}
if not twoD: aspectRatio = [spaceZ, spaceY, spaceX]
else: aspectRatio = [ 1, spaceY, spaceX]
if not twoD: aspectRatio = nodeSpacing
else: aspectRatio = [ 1, nodeSpacing[1], nodeSpacing[2]]
# For geers strains are at the measurement points
# Ad per the displacements coming out of spam-ldic this will plot nicely if 2xHWS = NS
......
......@@ -758,7 +758,7 @@ def correctPhiField(fileName=None, fieldCoords=None, fieldValues=None, fieldRS=N
elif saveFileName is None and fileName is None:
saveFileName = "spam"
TSVheader = "NodeNumber\tZpos\tYpos\tXpos\tF11\tF12\tF13\tZdisp\tF21\tF22\tF23\tYdisp\tF31\tF32\tF33\tXdisp\treturnStatus\tdeltaPhiNorm\titerations\tPSCC"
TSVheader = "NodeNumber\tZpos\tYpos\tXpos\tFzz\tFzy\tFzx\tZdisp\tFyz\tFyy\tFyx\tYdisp\tFxz\tFxy\tFxx\tXdisp\treturnStatus\tdeltaPhiNorm\titerations\tPSCC"
outMatrix = numpy.array([numpy.array(range(PhiField.shape[0])),
fieldCoords[:, 0], fieldCoords[:, 1], fieldCoords[:, 2],
PhiField[:, 0, 0], PhiField[:, 0, 1], PhiField[:, 0, 2], PhiField[:, 0, 3],
......
......@@ -710,7 +710,8 @@ def TSVtoVTK(fileName, fieldBinRatio=1.0, pixelSize=1.0, returnRS=False, outDir=
else:
dims = fi["fieldDims"]
coords = fi["fieldCoords"] * pixelSize
aspectRatio = numpy.array([numpy.unique(coords[:, 0])[1] - numpy.unique(coords[:, 0])[0], numpy.unique(coords[:, 1])[1] - numpy.unique(coords[:, 1])[0], numpy.unique(coords[:, 2])[1] - numpy.unique(coords[:, 2])[0]])
aspectRatio = numpy.array([numpy.unique(coords[:, i])[1] - numpy.unique(coords[:, i])[0] if len(numpy.unique(coords[:, i])) > 1 else numpy.unique(coords[:, i])[0] for i in range(3)])
origin = coords[0] - aspectRatio/2.0
if not returnRS:
cellData = {"displacements": (PhiField[:, :-1, 3] * pixelSize).reshape((dims[0], dims[1], dims[2], 3))}
......@@ -719,4 +720,4 @@ def TSVtoVTK(fileName, fieldBinRatio=1.0, pixelSize=1.0, returnRS=False, outDir=
cellData = {"displacements": (PhiField[:, :-1, 3] * pixelSize).reshape((dims[0], dims[1], dims[2], 3)),
"returnStatus": fi["returnStatus"].reshape(dims[0], dims[1], dims[2])}
spam.helpers.writeStructuredVTK(aspectRatio=aspectRatio, cellData=cellData, fileName="{}/{}.vtk".format(outDir, prefix))
spam.helpers.writeStructuredVTK(aspectRatio=aspectRatio, origin = origin, cellData=cellData, fileName="{}/{}.vtk".format(outDir, prefix))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment