Merge branch 'misc-improvements' into 'development'
Misc improvements See merge request damask/DAMASK!159
This commit is contained in:
commit
f1afc159ec
|
@ -68,12 +68,12 @@ class Result:
|
|||
self.con_physics = []
|
||||
for c in self.constituents:
|
||||
self.con_physics += f['/'.join([self.increments[0],'constituent',c])].keys()
|
||||
self.con_physics = list(set(self.con_physics)) # make unique
|
||||
self.con_physics = list(set(self.con_physics)) # make unique
|
||||
|
||||
self.mat_physics = []
|
||||
for m in self.materialpoints:
|
||||
self.mat_physics += f['/'.join([self.increments[0],'materialpoint',m])].keys()
|
||||
self.mat_physics = list(set(self.mat_physics)) # make unique
|
||||
self.mat_physics = list(set(self.mat_physics)) # make unique
|
||||
|
||||
self.selection = {'increments': self.increments,
|
||||
'constituents': self.constituents,'materialpoints': self.materialpoints,
|
||||
|
@ -86,13 +86,19 @@ class Result:
|
|||
def __repr__(self):
|
||||
"""Show selected data."""
|
||||
all_selected_increments = self.selection['increments']
|
||||
|
||||
self.pick('increments',all_selected_increments[0:1])
|
||||
first = self.list_data()
|
||||
|
||||
self.pick('increments',all_selected_increments[-1:])
|
||||
last = self.list_data()
|
||||
last = '' if len(all_selected_increments) < 2 else self.list_data()
|
||||
|
||||
self.pick('increments',all_selected_increments)
|
||||
in_between = ''.join(['\n{}\n ...\n'.format(inc) for inc in all_selected_increments[1:-2]])
|
||||
return util.srepr(first+ in_between + last)
|
||||
|
||||
in_between = '' if len(all_selected_increments) < 3 else \
|
||||
''.join(['\n{}\n ...\n'.format(inc) for inc in all_selected_increments[1:-2]])
|
||||
|
||||
return util.srepr(first + in_between + last)
|
||||
|
||||
|
||||
def _manage_selection(self,action,what,datasets):
|
||||
|
@ -1009,7 +1015,7 @@ class Result:
|
|||
continue
|
||||
lock.acquire()
|
||||
with h5py.File(self.fname, 'a') as f:
|
||||
try:
|
||||
try: # ToDo: Replace if exists?
|
||||
dataset = f[result[0]].create_dataset(result[1]['label'],data=result[1]['data'])
|
||||
for l,v in result[1]['meta'].items():
|
||||
dataset.attrs[l]=v.encode()
|
||||
|
|
|
@ -41,8 +41,8 @@ def curl(size,field):
|
|||
e[0, 2, 1] = e[2, 1, 0] = e[1, 0, 2] = -1.0
|
||||
|
||||
field_fourier = _np.fft.rfftn(field,axes=(0,1,2))
|
||||
curl_ = (_np.einsum('slm,ijkl,ijkm ->ijks', e,k_s,field_fourier)*2.0j*_np.pi if n == 3 else # vector, 3 -> 3
|
||||
_np.einsum('slm,ijkl,ijknm->ijksn',e,k_s,field_fourier)*2.0j*_np.pi) # tensor, 3x3 -> 3x3
|
||||
curl_ = (_np.einsum('slm,ijkl,ijkm ->ijks', e,k_s,field_fourier)*2.0j*_np.pi if n == 3 else # vector, 3 -> 3
|
||||
_np.einsum('slm,ijkl,ijknm->ijksn',e,k_s,field_fourier)*2.0j*_np.pi) # tensor, 3x3 -> 3x3
|
||||
|
||||
return _np.fft.irfftn(curl_,axes=(0,1,2),s=field.shape[:3])
|
||||
|
||||
|
@ -61,8 +61,8 @@ def divergence(size,field):
|
|||
k_s = _ks(size,field.shape[:3],True)
|
||||
|
||||
field_fourier = _np.fft.rfftn(field,axes=(0,1,2))
|
||||
div_ = (_np.einsum('ijkl,ijkl ->ijk', k_s,field_fourier)*2.0j*_np.pi if n == 3 else # vector, 3 -> 1
|
||||
_np.einsum('ijkm,ijklm->ijkl',k_s,field_fourier)*2.0j*_np.pi) # tensor, 3x3 -> 3
|
||||
div_ = (_np.einsum('ijkl,ijkl ->ijk', k_s,field_fourier)*2.0j*_np.pi if n == 3 else # vector, 3 -> 1
|
||||
_np.einsum('ijkm,ijklm->ijkl',k_s,field_fourier)*2.0j*_np.pi) # tensor, 3x3 -> 3
|
||||
|
||||
return _np.fft.irfftn(div_,axes=(0,1,2),s=field.shape[:3])
|
||||
|
||||
|
@ -81,8 +81,8 @@ def gradient(size,field):
|
|||
k_s = _ks(size,field.shape[:3],True)
|
||||
|
||||
field_fourier = _np.fft.rfftn(field,axes=(0,1,2))
|
||||
grad_ = (_np.einsum('ijkl,ijkm->ijkm', field_fourier,k_s)*2.0j*_np.pi if n == 1 else # scalar, 1 -> 3
|
||||
_np.einsum('ijkl,ijkm->ijklm',field_fourier,k_s)*2.0j*_np.pi) # vector, 3 -> 3x3
|
||||
grad_ = (_np.einsum('ijkl,ijkm->ijkm', field_fourier,k_s)*2.0j*_np.pi if n == 1 else # scalar, 1 -> 3
|
||||
_np.einsum('ijkl,ijkm->ijklm',field_fourier,k_s)*2.0j*_np.pi) # vector, 3 -> 3x3
|
||||
|
||||
return _np.fft.irfftn(grad_,axes=(0,1,2),s=field.shape[:3])
|
||||
|
||||
|
@ -146,7 +146,7 @@ def cell_displacement_avg(size,F):
|
|||
|
||||
"""
|
||||
F_avg = _np.average(F,axis=(0,1,2))
|
||||
return _np.einsum('ml,ijkl->ijkm',F_avg-_np.eye(3),cell_coord0(F.shape[:3][::-1],size))
|
||||
return _np.einsum('ml,ijkl->ijkm',F_avg - _np.eye(3),cell_coord0(F.shape[:3][::-1],size))
|
||||
|
||||
|
||||
def cell_displacement(size,F):
|
||||
|
@ -217,7 +217,7 @@ def cell_coord0_gridSizeOrigin(coord0,ordered=True):
|
|||
raise ValueError('Regular grid spacing violated.')
|
||||
|
||||
if ordered and not _np.allclose(coord0.reshape(tuple(grid[::-1])+(3,)),cell_coord0(grid,size,origin)):
|
||||
raise ValueError('I_nput data is not a regular grid.')
|
||||
raise ValueError('Input data is not a regular grid.')
|
||||
|
||||
return (grid,size,origin)
|
||||
|
||||
|
@ -250,8 +250,8 @@ def node_coord0(grid,size,origin=_np.zeros(3)):
|
|||
|
||||
"""
|
||||
return _np.mgrid[origin[0]:size[0]+origin[0]:(grid[0]+1)*1j,
|
||||
origin[1]:size[1]+origin[1]:(grid[1]+1)*1j,
|
||||
origin[2]:size[2]+origin[2]:(grid[2]+1)*1j].T
|
||||
origin[1]:size[1]+origin[1]:(grid[1]+1)*1j,
|
||||
origin[2]:size[2]+origin[2]:(grid[2]+1)*1j].T
|
||||
|
||||
|
||||
def node_displacement_fluct(size,F):
|
||||
|
@ -282,7 +282,7 @@ def node_displacement_avg(size,F):
|
|||
|
||||
"""
|
||||
F_avg = _np.average(F,axis=(0,1,2))
|
||||
return _np.einsum('ml,ijkl->ijkm',F_avg-_np.eye(3),node_coord0(F.shape[:3][::-1],size))
|
||||
return _np.einsum('ml,ijkl->ijkm',F_avg - _np.eye(3),node_coord0(F.shape[:3][::-1],size))
|
||||
|
||||
|
||||
def node_displacement(size,F):
|
||||
|
@ -363,7 +363,7 @@ def node_coord0_gridSizeOrigin(coord0,ordered=False):
|
|||
raise ValueError('Regular grid spacing violated.')
|
||||
|
||||
if ordered and not _np.allclose(coord0.reshape(tuple((grid+1)[::-1])+(3,)),node_coord0(grid,size,origin)):
|
||||
raise ValueError('I_nput data is not a regular grid.')
|
||||
raise ValueError('Input data is not a regular grid.')
|
||||
|
||||
return (grid,size,origin)
|
||||
|
||||
|
|
|
@ -24,6 +24,10 @@ def reference_dir(reference_dir_base):
|
|||
|
||||
class TestResult:
|
||||
|
||||
def test_self_report(self,default):
|
||||
print(default)
|
||||
|
||||
|
||||
def test_time_increments(self,default):
|
||||
shape = default.read_dataset(default.get_dataset_location('F'),0).shape
|
||||
default.set_by_time(0.0,20.0)
|
||||
|
|
|
@ -184,8 +184,6 @@ subroutine materialpoint_stressAndItsTangent(updateJaco,dt)
|
|||
e, & !< element number
|
||||
mySource, &
|
||||
myNgrains
|
||||
real(pReal), dimension(3,3) :: &
|
||||
subF
|
||||
real(pReal), dimension(discretization_nIP,discretization_nElem) :: &
|
||||
subFrac, &
|
||||
subStep
|
||||
|
@ -376,16 +374,15 @@ subroutine materialpoint_stressAndItsTangent(updateJaco,dt)
|
|||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
! deformation partitioning
|
||||
! based on materialpoint_subF0,.._subF,crystallite_partionedF0, and homogenization_state,
|
||||
! results in crystallite_partionedF
|
||||
!$OMP PARALLEL DO PRIVATE(myNgrains,subF)
|
||||
!$OMP PARALLEL DO PRIVATE(myNgrains)
|
||||
elementLooping2: do e = FEsolving_execElem(1),FEsolving_execElem(2)
|
||||
myNgrains = homogenization_Ngrains(material_homogenizationAt(e))
|
||||
IpLooping2: do i = FEsolving_execIP(1),FEsolving_execIP(2)
|
||||
if(requested(i,e) .and. .not. doneAndHappy(1,i,e)) then ! requested but not yet done
|
||||
subF = materialpoint_F0(1:3,1:3,i,e) &
|
||||
+ (materialpoint_F(1:3,1:3,i,e)-materialpoint_F0(1:3,1:3,i,e))*(subStep(i,e)+subFrac(i,e))
|
||||
call partitionDeformation(subF,i,e) ! partition deformation onto constituents
|
||||
call partitionDeformation(materialpoint_F0(1:3,1:3,i,e) &
|
||||
+ (materialpoint_F(1:3,1:3,i,e)-materialpoint_F0(1:3,1:3,i,e))&
|
||||
*(subStep(i,e)+subFrac(i,e)), &
|
||||
i,e)
|
||||
crystallite_dt(1:myNgrains,i,e) = dt*subStep(i,e) ! propagate materialpoint dt to grains
|
||||
crystallite_requested(1:myNgrains,i,e) = .true. ! request calculation for constituents
|
||||
else
|
||||
|
@ -397,23 +394,22 @@ subroutine materialpoint_stressAndItsTangent(updateJaco,dt)
|
|||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
! crystallite integration
|
||||
! based on crystallite_partionedF0,.._partionedF
|
||||
! incrementing by crystallite_dt
|
||||
|
||||
converged = crystallite_stress() !ToDo: MD not sure if that is the best logic
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
! state update
|
||||
!$OMP PARALLEL DO PRIVATE(subF)
|
||||
!$OMP PARALLEL DO
|
||||
elementLooping3: do e = FEsolving_execElem(1),FEsolving_execElem(2)
|
||||
IpLooping3: do i = FEsolving_execIP(1),FEsolving_execIP(2)
|
||||
if (requested(i,e) .and. .not. doneAndHappy(1,i,e)) then
|
||||
if (.not. converged(i,e)) then
|
||||
doneAndHappy(1:2,i,e) = [.true.,.false.]
|
||||
else
|
||||
subF = materialpoint_F0(1:3,1:3,i,e) &
|
||||
+ (materialpoint_F(1:3,1:3,i,e)-materialpoint_F0(1:3,1:3,i,e))*(subStep(i,e)+subFrac(i,e))
|
||||
doneAndHappy(1:2,i,e) = updateState(dt*subStep(i,e),subF,i,e)
|
||||
doneAndHappy(1:2,i,e) = updateState(dt*subStep(i,e), &
|
||||
materialpoint_F0(1:3,1:3,i,e) &
|
||||
+ (materialpoint_F(1:3,1:3,i,e)-materialpoint_F0(1:3,1:3,i,e)) &
|
||||
*(subStep(i,e)+subFrac(i,e)), &
|
||||
i,e)
|
||||
converged(i,e) = all(doneAndHappy(1:2,i,e)) ! converged if done and happy
|
||||
endif
|
||||
endif
|
||||
|
|
|
@ -63,27 +63,27 @@ module quaternions
|
|||
module procedure assign_quat__
|
||||
module procedure assign_vec__
|
||||
end interface assignment (=)
|
||||
|
||||
|
||||
interface quaternion
|
||||
module procedure init__
|
||||
end interface quaternion
|
||||
|
||||
|
||||
interface abs
|
||||
procedure abs__
|
||||
end interface abs
|
||||
|
||||
|
||||
interface dot_product
|
||||
procedure dot_product__
|
||||
end interface dot_product
|
||||
|
||||
|
||||
interface conjg
|
||||
module procedure conjg__
|
||||
end interface conjg
|
||||
|
||||
|
||||
interface exp
|
||||
module procedure exp__
|
||||
end interface exp
|
||||
|
||||
|
||||
interface log
|
||||
module procedure log__
|
||||
end interface log
|
||||
|
@ -95,7 +95,7 @@ module quaternions
|
|||
interface aimag
|
||||
module procedure aimag__
|
||||
end interface aimag
|
||||
|
||||
|
||||
public :: &
|
||||
quaternions_init, &
|
||||
assignment(=), &
|
||||
|
@ -118,7 +118,7 @@ end subroutine quaternions_init
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> construct a quaternion from a 4-vector
|
||||
!> @brief construct a quaternion from a 4-vector
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) pure function init__(array)
|
||||
|
||||
|
@ -133,7 +133,7 @@ end function init__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> assign a quaternion
|
||||
!> @brief assign a quaternion
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
elemental pure subroutine assign_quat__(self,other)
|
||||
|
||||
|
@ -141,12 +141,12 @@ elemental pure subroutine assign_quat__(self,other)
|
|||
type(quaternion), intent(in) :: other
|
||||
|
||||
self = [other%w,other%x,other%y,other%z]
|
||||
|
||||
|
||||
end subroutine assign_quat__
|
||||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> assign a 4-vector
|
||||
!> @brief assign a 4-vector
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
pure subroutine assign_vec__(self,other)
|
||||
|
||||
|
@ -162,7 +162,7 @@ end subroutine assign_vec__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> add a quaternion
|
||||
!> @brief add a quaternion
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function add__(self,other)
|
||||
|
||||
|
@ -170,24 +170,24 @@ type(quaternion) elemental pure function add__(self,other)
|
|||
|
||||
add__ = [ self%w, self%x, self%y ,self%z] &
|
||||
+ [other%w, other%x, other%y,other%z]
|
||||
|
||||
|
||||
end function add__
|
||||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> return (unary positive operator)
|
||||
!> @brief return (unary positive operator)
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function pos__(self)
|
||||
|
||||
class(quaternion), intent(in) :: self
|
||||
|
||||
pos__ = self * (+1.0_pReal)
|
||||
|
||||
|
||||
end function pos__
|
||||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> subtract a quaternion
|
||||
!> @brief subtract a quaternion
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function sub__(self,other)
|
||||
|
||||
|
@ -195,24 +195,24 @@ type(quaternion) elemental pure function sub__(self,other)
|
|||
|
||||
sub__ = [ self%w, self%x, self%y ,self%z] &
|
||||
- [other%w, other%x, other%y,other%z]
|
||||
|
||||
|
||||
end function sub__
|
||||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> negate (unary negative operator)
|
||||
!> @brief negate (unary negative operator)
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function neg__(self)
|
||||
|
||||
class(quaternion), intent(in) :: self
|
||||
|
||||
neg__ = self * (-1.0_pReal)
|
||||
|
||||
|
||||
end function neg__
|
||||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> multiply with a quaternion
|
||||
!> @brief multiply with a quaternion
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function mul_quat__(self,other)
|
||||
|
||||
|
@ -227,7 +227,7 @@ end function mul_quat__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> multiply with a scalar
|
||||
!> @brief multiply with a scalar
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function mul_scal__(self,scal)
|
||||
|
||||
|
@ -235,12 +235,12 @@ type(quaternion) elemental pure function mul_scal__(self,scal)
|
|||
real(pReal), intent(in) :: scal
|
||||
|
||||
mul_scal__ = [self%w,self%x,self%y,self%z]*scal
|
||||
|
||||
|
||||
end function mul_scal__
|
||||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> divide by a quaternion
|
||||
!> @brief divide by a quaternion
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function div_quat__(self,other)
|
||||
|
||||
|
@ -252,7 +252,7 @@ end function div_quat__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> divide by a scalar
|
||||
!> @brief divide by a scalar
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function div_scal__(self,scal)
|
||||
|
||||
|
@ -265,7 +265,7 @@ end function div_scal__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> test equality
|
||||
!> @brief test equality
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
logical elemental pure function eq__(self,other)
|
||||
|
||||
|
@ -278,7 +278,7 @@ end function eq__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> test inequality
|
||||
!> @brief test inequality
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
logical elemental pure function neq__(self,other)
|
||||
|
||||
|
@ -290,7 +290,7 @@ end function neq__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> raise to the power of a quaternion
|
||||
!> @brief raise to the power of a quaternion
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function pow_quat__(self,expon)
|
||||
|
||||
|
@ -303,7 +303,7 @@ end function pow_quat__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> raise to the power of a scalar
|
||||
!> @brief raise to the power of a scalar
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function pow_scal__(self,expon)
|
||||
|
||||
|
@ -316,7 +316,7 @@ end function pow_scal__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> take exponential
|
||||
!> @brief take exponential
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function exp__(a)
|
||||
|
||||
|
@ -336,7 +336,7 @@ end function exp__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> take logarithm
|
||||
!> @brief take logarithm
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function log__(a)
|
||||
|
||||
|
@ -356,7 +356,7 @@ end function log__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> return norm
|
||||
!> @brief return norm
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
real(pReal) elemental pure function abs__(self)
|
||||
|
||||
|
@ -368,7 +368,7 @@ end function abs__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> calculate dot product
|
||||
!> @brief calculate dot product
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
real(pReal) elemental pure function dot_product__(a,b)
|
||||
|
||||
|
@ -380,7 +380,7 @@ end function dot_product__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> take conjugate complex
|
||||
!> @brief take conjugate complex
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function conjg__(self)
|
||||
|
||||
|
@ -392,7 +392,7 @@ end function conjg__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> homomorph
|
||||
!> @brief homomorph
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function homomorphed(self)
|
||||
|
||||
|
@ -404,7 +404,7 @@ end function homomorphed
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> return as plain array
|
||||
!> @brief return as plain array
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
pure function asArray(self)
|
||||
|
||||
|
@ -417,7 +417,7 @@ end function asArray
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> real part (scalar)
|
||||
!> @brief real part (scalar)
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
pure function real__(self)
|
||||
|
||||
|
@ -430,7 +430,7 @@ end function real__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> imaginary part (3-vector)
|
||||
!> @brief imaginary part (3-vector)
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
pure function aimag__(self)
|
||||
|
||||
|
@ -443,7 +443,7 @@ end function aimag__
|
|||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> inverse
|
||||
!> @brief inverse
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
type(quaternion) elemental pure function inverse(self)
|
||||
|
||||
|
|
Loading…
Reference in New Issue