added ASCIItable tests to CI pipelining
This commit is contained in:
parent
1adffb0deb
commit
742d58cfce
|
@ -156,6 +156,13 @@ Post_AverageDown:
|
||||||
- master
|
- master
|
||||||
- release
|
- release
|
||||||
|
|
||||||
|
Post_ASCIItable:
|
||||||
|
stage: postprocessing
|
||||||
|
script: ASCIItable/test.py
|
||||||
|
except:
|
||||||
|
- master
|
||||||
|
- release
|
||||||
|
|
||||||
Post_General:
|
Post_General:
|
||||||
stage: postprocessing
|
stage: postprocessing
|
||||||
script: PostProcessing/test.py
|
script: PostProcessing/test.py
|
||||||
|
|
2
PRIVATE
2
PRIVATE
|
@ -1 +1 @@
|
||||||
Subproject commit c6db7cee2d9349e2d463f5ef6284446007fc7915
|
Subproject commit 3d12562fbfb3a57dbb3777ac045a12376b3400e8
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python3
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys
|
import os,sys
|
||||||
|
@ -21,7 +21,7 @@ Add data of selected column(s) from (first) row of linked ASCIItable that shares
|
||||||
parser.add_option('--link',
|
parser.add_option('--link',
|
||||||
dest = 'link', nargs = 2,
|
dest = 'link', nargs = 2,
|
||||||
type = 'string', metavar = 'string string',
|
type = 'string', metavar = 'string string',
|
||||||
help = 'column labels containing linked values')
|
help = 'column labels of table and linked table containing linking values')
|
||||||
parser.add_option('-l','--label',
|
parser.add_option('-l','--label',
|
||||||
dest = 'label',
|
dest = 'label',
|
||||||
action = 'extend', metavar = '<string LIST>',
|
action = 'extend', metavar = '<string LIST>',
|
||||||
|
@ -105,7 +105,7 @@ for name in filenames:
|
||||||
outputAlive = True
|
outputAlive = True
|
||||||
while outputAlive and table.data_read(): # read next data line of ASCII table
|
while outputAlive and table.data_read(): # read next data line of ASCII table
|
||||||
try:
|
try:
|
||||||
table.data_append(data[np.argwhere(np.all((map(float,table.data[myLink:myLink+myLinkDim]) - index)==0,axis=1))[0]]) # add data of first matching line
|
table.data_append(data[np.argwhere(np.all((list(map(float,table.data[myLink:myLink+myLinkDim])) - index)==0,axis=1))[0]]) # add data of first matching line
|
||||||
except IndexError:
|
except IndexError:
|
||||||
table.data_append(np.nan*np.ones_like(data[0])) # or add NaNs
|
table.data_append(np.nan*np.ones_like(data[0])) # or add NaNs
|
||||||
outputAlive = table.data_write() # output processed line
|
outputAlive = table.data_write() # output processed line
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python3
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys
|
import os,sys
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python3
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,math
|
import os,sys,math
|
||||||
|
@ -49,7 +49,7 @@ parser.set_defaults(d = 1,
|
||||||
|
|
||||||
(options, filenames) = parser.parse_args()
|
(options, filenames) = parser.parse_args()
|
||||||
|
|
||||||
options.immutable = map(int,options.immutable)
|
options.immutable = list(map(int,options.immutable))
|
||||||
|
|
||||||
getInterfaceEnergy = lambda A,B: np.float32((A*B != 0)*(A != B)*1.0) # 1.0 if A & B are distinct & nonzero, 0.0 otherwise
|
getInterfaceEnergy = lambda A,B: np.float32((A*B != 0)*(A != B)*1.0) # 1.0 if A & B are distinct & nonzero, 0.0 otherwise
|
||||||
struc = ndimage.generate_binary_structure(3,1) # 3D von Neumann neighborhood
|
struc = ndimage.generate_binary_structure(3,1) # 3D von Neumann neighborhood
|
||||||
|
@ -70,9 +70,9 @@ for name in filenames:
|
||||||
table.head_read()
|
table.head_read()
|
||||||
info,extra_header = table.head_getGeom()
|
info,extra_header = table.head_getGeom()
|
||||||
|
|
||||||
damask.util.croak(['grid a b c: {}'.format(' x '.join(map(str,info['grid']))),
|
damask.util.croak(['grid a b c: {}'.format(' x '.join(list(map(str,info['grid'])))),
|
||||||
'size x y z: {}'.format(' x '.join(map(str,info['size']))),
|
'size x y z: {}'.format(' x '.join(list(map(str,info['size'])))),
|
||||||
'origin x y z: {}'.format(' : '.join(map(str,info['origin']))),
|
'origin x y z: {}'.format(' : '.join(list(map(str,info['origin'])))),
|
||||||
'homogenization: {}'.format(info['homogenization']),
|
'homogenization: {}'.format(info['homogenization']),
|
||||||
'microstructures: {}'.format(info['microstructures']),
|
'microstructures: {}'.format(info['microstructures']),
|
||||||
])
|
])
|
||||||
|
@ -102,9 +102,9 @@ for name in filenames:
|
||||||
gauss = np.exp(-(X*X + Y*Y + Z*Z)/(2.0*options.d*options.d),dtype=np.float32) \
|
gauss = np.exp(-(X*X + Y*Y + Z*Z)/(2.0*options.d*options.d),dtype=np.float32) \
|
||||||
/np.power(2.0*np.pi*options.d*options.d,(3.0 - np.count_nonzero(info['grid'] == 1))/2.,dtype=np.float32)
|
/np.power(2.0*np.pi*options.d*options.d,(3.0 - np.count_nonzero(info['grid'] == 1))/2.,dtype=np.float32)
|
||||||
|
|
||||||
gauss[:,:,:grid[2]/2:-1] = gauss[:,:,1:(grid[2]+1)/2] # trying to cope with uneven (odd) grid size
|
gauss[:,:,:grid[2]//2:-1] = gauss[:,:,1:(grid[2]+1)//2] # trying to cope with uneven (odd) grid size
|
||||||
gauss[:,:grid[1]/2:-1,:] = gauss[:,1:(grid[1]+1)/2,:]
|
gauss[:,:grid[1]//2:-1,:] = gauss[:,1:(grid[1]+1)//2,:]
|
||||||
gauss[:grid[0]/2:-1,:,:] = gauss[1:(grid[0]+1)/2,:,:]
|
gauss[:grid[0]//2:-1,:,:] = gauss[1:(grid[0]+1)//2,:,:]
|
||||||
gauss = np.fft.rfftn(gauss).astype(np.complex64)
|
gauss = np.fft.rfftn(gauss).astype(np.complex64)
|
||||||
|
|
||||||
for smoothIter in range(options.N):
|
for smoothIter in range(options.N):
|
||||||
|
@ -119,9 +119,9 @@ for name in filenames:
|
||||||
microstructure,i,axis=0), j,axis=1), k,axis=2)))
|
microstructure,i,axis=0), j,axis=1), k,axis=2)))
|
||||||
|
|
||||||
# periodically extend interfacial energy array by half a grid size in positive and negative directions
|
# periodically extend interfacial energy array by half a grid size in positive and negative directions
|
||||||
periodic_interfaceEnergy = np.tile(interfaceEnergy,(3,3,3))[grid[0]/2:-grid[0]/2,
|
periodic_interfaceEnergy = np.tile(interfaceEnergy,(3,3,3))[grid[0]//2:-grid[0]//2,
|
||||||
grid[1]/2:-grid[1]/2,
|
grid[1]//2:-grid[1]//2,
|
||||||
grid[2]/2:-grid[2]/2]
|
grid[2]//2:-grid[2]//2]
|
||||||
|
|
||||||
# transform bulk volume (i.e. where interfacial energy remained zero), store index of closest boundary voxel
|
# transform bulk volume (i.e. where interfacial energy remained zero), store index of closest boundary voxel
|
||||||
index = ndimage.morphology.distance_transform_edt(periodic_interfaceEnergy == 0.,
|
index = ndimage.morphology.distance_transform_edt(periodic_interfaceEnergy == 0.,
|
||||||
|
@ -148,15 +148,15 @@ for name in filenames:
|
||||||
ndimage.morphology.binary_dilation(interfaceEnergy > 0.,
|
ndimage.morphology.binary_dilation(interfaceEnergy > 0.,
|
||||||
structure = struc,
|
structure = struc,
|
||||||
iterations = int(round(options.d*2.))-1),# fat boundary
|
iterations = int(round(options.d*2.))-1),# fat boundary
|
||||||
periodic_bulkEnergy[grid[0]/2:-grid[0]/2, # retain filled energy on fat boundary...
|
periodic_bulkEnergy[grid[0]//2:-grid[0]//2, # retain filled energy on fat boundary...
|
||||||
grid[1]/2:-grid[1]/2,
|
grid[1]//2:-grid[1]//2,
|
||||||
grid[2]/2:-grid[2]/2], # ...and zero everywhere else
|
grid[2]//2:-grid[2]//2], # ...and zero everywhere else
|
||||||
0.)).astype(np.complex64) *
|
0.)).astype(np.complex64) *
|
||||||
gauss).astype(np.float32)
|
gauss).astype(np.float32)
|
||||||
|
|
||||||
periodic_diffusedEnergy = np.tile(diffusedEnergy,(3,3,3))[grid[0]/2:-grid[0]/2,
|
periodic_diffusedEnergy = np.tile(diffusedEnergy,(3,3,3))[grid[0]//2:-grid[0]//2,
|
||||||
grid[1]/2:-grid[1]/2,
|
grid[1]//2:-grid[1]//2,
|
||||||
grid[2]/2:-grid[2]/2] # periodically extend the smoothed bulk energy
|
grid[2]//2:-grid[2]//2] # periodically extend the smoothed bulk energy
|
||||||
|
|
||||||
|
|
||||||
# transform voxels close to interface region
|
# transform voxels close to interface region
|
||||||
|
@ -164,15 +164,15 @@ for name in filenames:
|
||||||
return_distances = False,
|
return_distances = False,
|
||||||
return_indices = True) # want index of closest bulk grain
|
return_indices = True) # want index of closest bulk grain
|
||||||
|
|
||||||
periodic_microstructure = np.tile(microstructure,(3,3,3))[grid[0]/2:-grid[0]/2,
|
periodic_microstructure = np.tile(microstructure,(3,3,3))[grid[0]//2:-grid[0]//2,
|
||||||
grid[1]/2:-grid[1]/2,
|
grid[1]//2:-grid[1]//2,
|
||||||
grid[2]/2:-grid[2]/2] # periodically extend the microstructure
|
grid[2]//2:-grid[2]//2] # periodically extend the microstructure
|
||||||
|
|
||||||
microstructure = periodic_microstructure[index[0],
|
microstructure = periodic_microstructure[index[0],
|
||||||
index[1],
|
index[1],
|
||||||
index[2]].reshape(2*grid)[grid[0]/2:-grid[0]/2,
|
index[2]].reshape(2*grid)[grid[0]//2:-grid[0]//2,
|
||||||
grid[1]/2:-grid[1]/2,
|
grid[1]//2:-grid[1]//2,
|
||||||
grid[2]/2:-grid[2]/2] # extent grains into interface region
|
grid[2]//2:-grid[2]//2] # extent grains into interface region
|
||||||
|
|
||||||
# replace immutable microstructures with closest mutable ones
|
# replace immutable microstructures with closest mutable ones
|
||||||
index = ndimage.morphology.distance_transform_edt(np.in1d(microstructure,options.immutable).reshape(grid),
|
index = ndimage.morphology.distance_transform_edt(np.in1d(microstructure,options.immutable).reshape(grid),
|
||||||
|
@ -236,3 +236,4 @@ for name in filenames:
|
||||||
# --- output finalization --------------------------------------------------------------------------
|
# --- output finalization --------------------------------------------------------------------------
|
||||||
|
|
||||||
table.close()
|
table.close()
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python3
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import threading,time,os,sys,random
|
import threading,time,os,sys,random
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from cStringIO import StringIO
|
from io import StringIO
|
||||||
|
import binascii
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||||
|
@ -96,7 +97,7 @@ class myThread (threading.Thread):
|
||||||
perturbedGeomVFile = StringIO()
|
perturbedGeomVFile = StringIO()
|
||||||
perturbedSeedsVFile.reset()
|
perturbedSeedsVFile.reset()
|
||||||
perturbedGeomVFile.write(damask.util.execute('geom_fromVoronoiTessellation '+
|
perturbedGeomVFile.write(damask.util.execute('geom_fromVoronoiTessellation '+
|
||||||
' -g '+' '.join(map(str, options.grid)),streamIn=perturbedSeedsVFile)[0])
|
' -g '+' '.join(list(map(str, options.grid))),streamIn=perturbedSeedsVFile)[0])
|
||||||
perturbedGeomVFile.reset()
|
perturbedGeomVFile.reset()
|
||||||
|
|
||||||
#--- evaluate current seeds file ----------------------------------------------------------------------
|
#--- evaluate current seeds file ----------------------------------------------------------------------
|
||||||
|
@ -214,7 +215,7 @@ options = parser.parse_args()[0]
|
||||||
damask.util.report(scriptName,options.seedFile)
|
damask.util.report(scriptName,options.seedFile)
|
||||||
|
|
||||||
if options.randomSeed is None:
|
if options.randomSeed is None:
|
||||||
options.randomSeed = int(os.urandom(4).encode('hex'), 16)
|
options.randomSeed = int(binascii.hexlify(os.urandom(4)),16)
|
||||||
damask.util.croak(options.randomSeed)
|
damask.util.croak(options.randomSeed)
|
||||||
delta = (options.scale/options.grid[0],options.scale/options.grid[1],options.scale/options.grid[2])
|
delta = (options.scale/options.grid[0],options.scale/options.grid[1],options.scale/options.grid[2])
|
||||||
baseFile=os.path.splitext(os.path.basename(options.seedFile))[0]
|
baseFile=os.path.splitext(os.path.basename(options.seedFile))[0]
|
||||||
|
@ -240,17 +241,17 @@ if os.path.isfile(os.path.splitext(options.seedFile)[0]+'.seeds'):
|
||||||
for line in initialSeedFile: bestSeedsVFile.write(line)
|
for line in initialSeedFile: bestSeedsVFile.write(line)
|
||||||
else:
|
else:
|
||||||
bestSeedsVFile.write(damask.util.execute('seeds_fromRandom'+\
|
bestSeedsVFile.write(damask.util.execute('seeds_fromRandom'+\
|
||||||
' -g '+' '.join(map(str, options.grid))+\
|
' -g '+' '.join(list(map(str, options.grid)))+\
|
||||||
' -r {:d}'.format(options.randomSeed)+\
|
' -r {:d}'.format(options.randomSeed)+\
|
||||||
' -N '+str(nMicrostructures))[0])
|
' -N '+str(nMicrostructures))[0])
|
||||||
bestSeedsUpdate = time.time()
|
bestSeedsUpdate = time.time()
|
||||||
|
|
||||||
# ----------- tessellate initial seed file to get and evaluate geom file
|
# ----------- tessellate initial seed file to get and evaluate geom file
|
||||||
bestSeedsVFile.reset()
|
bestSeedsVFile.seek(0)
|
||||||
initialGeomVFile = StringIO()
|
initialGeomVFile = StringIO()
|
||||||
initialGeomVFile.write(damask.util.execute('geom_fromVoronoiTessellation '+
|
initialGeomVFile.write(damask.util.execute('geom_fromVoronoiTessellation '+
|
||||||
' -g '+' '.join(map(str, options.grid)),bestSeedsVFile)[0])
|
' -g '+' '.join(list(map(str, options.grid))),bestSeedsVFile)[0])
|
||||||
initialGeomVFile.reset()
|
initialGeomVFile.seek(0)
|
||||||
initialGeomTable = damask.ASCIItable(initialGeomVFile,None,labeled=False,readonly=True)
|
initialGeomTable = damask.ASCIItable(initialGeomVFile,None,labeled=False,readonly=True)
|
||||||
initialGeomTable.head_read()
|
initialGeomTable.head_read()
|
||||||
info,devNull = initialGeomTable.head_getGeom()
|
info,devNull = initialGeomTable.head_getGeom()
|
||||||
|
|
Loading…
Reference in New Issue