Skip to content

Commit 891654b

Browse files
committed
Merge branch 'housekeeping_2025-10-22' into 'development'
housekeeping 2025-10-22 See merge request damask/DAMASK!1150
2 parents 7ceb006 + a4c219a commit 891654b

File tree

7 files changed

+131
-81
lines changed

7 files changed

+131
-81
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ variables:
1212
GIT_SUBMODULE_STRATEGY: normal
1313
# Shortcut names
1414
MARC_VERSION: '2025.1'
15-
PETSC_GCC_LATEST: '2025.09.30'
16-
PETSC_ONEAPI_LATEST: '2025.09.30'
15+
PETSC_GCC_LATEST: '2025.11.13'
16+
PETSC_ONEAPI_LATEST: '2025.11.13'
1717
PYTHON_LATEST: '2025.06.05'
1818

1919
####################################################################################################

PRIVATE

python/damask/_vtk.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,20 @@ def from_image_data(cells: IntSequence,
232232
-------
233233
new : damask.VTK
234234
VTK-based geometry without nodal or cell data.
235+
236+
Examples
237+
--------
238+
Create image data with larger spacing along z-direction:
239+
240+
>>> import damask
241+
>>> cells = (16,8,4)
242+
>>> size = (1.0,0.5,.4)
243+
>>> print(v := damask.VTK.from_image_data(cells=cells,size=size))
244+
vtkImageData
245+
<BLANKLINE>
246+
# cells: 512
247+
<BLANKLINE>
248+
# points: 765
235249
"""
236250
vtk_data = vtkImageData()
237251
vtk_data.SetDimensions(*(np.array(cells)+1))
@@ -267,6 +281,21 @@ def from_unstructured_grid(nodes: np.ndarray,
267281
-------
268282
new : damask.VTK
269283
VTK-based geometry without nodal or cell data.
284+
285+
Examples
286+
--------
287+
Create a first-order tetrahedron:
288+
289+
>>> import damask
290+
>>> import numpy as np
291+
>>> nodes = np.array([[0,0,0],[1,0,0],[1,1,0],[0,0,1]])
292+
>>> connectivity = np.array([[0,1,2,3]])
293+
>>> print(v := damask.VTK.from_unstructured_grid(nodes,connectivity,'TETRAHEDRON'))
294+
vtkUnstructuredGrid
295+
<BLANKLINE>
296+
# cells: 1
297+
<BLANKLINE>
298+
# points: 4
270299
"""
271300
vtk_nodes = vtkPoints()
272301
vtk_nodes.SetData(numpy_to_vtk(np.ascontiguousarray(nodes)))
@@ -529,6 +558,24 @@ def set(self,
529558
Notes
530559
-----
531560
If the number of cells equals the number of points, the data is added to both.
561+
562+
563+
Examples
564+
--------
565+
Add a constant tensor field called 'F' to image data:
566+
567+
>>> import numpy as np
568+
>>> import damask
569+
>>> cells = (16,8,16)
570+
>>> size = (1.0,0.5,1.0)
571+
>>> v = damask.VTK.from_image_data(cells=cells,size=size)
572+
>>> print(v := v.set(label='F',data=np.broadcast_to(np.eye(3),(np.prod(cells),3,3))))
573+
vtkImageData
574+
<BLANKLINE>
575+
# cells: 2048
576+
- F
577+
<BLANKLINE>
578+
# points: 2601
532579
"""
533580

534581
def _add_array(vtk_data,

src/IO.f90

Lines changed: 57 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ subroutine IO_error_new(error_ID, &
372372
info_1,info_2,info_3,info_4,info_5,info_6,info_7,info_8,info_9, &
373373
emph)
374374

375-
376375
integer(pI16), intent(in) :: error_ID ! should go back to default integer after completed migration.
377376
class(*), optional, intent(in) :: info_1,info_2,info_3,info_4,info_5,info_6,info_7,info_8,info_9
378377
integer, dimension(:), optional, intent(in) :: emph !< which info(s) to emphasize
@@ -595,7 +594,6 @@ subroutine IO_warning_new(warning_ID, &
595594
info_1,info_2,info_3,info_4,info_5,info_6,info_7,info_8,info_9, &
596595
emph)
597596

598-
599597
integer(pI16), intent(in) :: warning_ID ! should go back to default integer after completed migration.
600598
class(*), optional, intent(in) :: info_1,info_2,info_3,info_4,info_5,info_6,info_7,info_8,info_9
601599
integer, dimension(:), optional, intent(in) :: emph !< which info(s) to emphasize
@@ -969,15 +967,15 @@ subroutine panel(paneltype,ID,msg, &
969967

970968
end select
971969

972-
info_extra = as_str(info_1,is_emph(1)) &
973-
// as_str(info_2,is_emph(2)) &
974-
// as_str(info_3,is_emph(3)) &
975-
// as_str(info_4,is_emph(4)) &
976-
// as_str(info_5,is_emph(5)) &
977-
// as_str(info_6,is_emph(6)) &
978-
// as_str(info_7,is_emph(7)) &
979-
// as_str(info_8,is_emph(8)) &
980-
// as_str(info_9,is_emph(9))
970+
info_extra = as_str(info_1,is_emph(1,emph)) &
971+
// as_str(info_2,is_emph(2,emph)) &
972+
// as_str(info_3,is_emph(3,emph)) &
973+
// as_str(info_4,is_emph(4,emph)) &
974+
// as_str(info_5,is_emph(5,emph)) &
975+
// as_str(info_6,is_emph(6,emph)) &
976+
// as_str(info_7,is_emph(7,emph)) &
977+
// as_str(info_8,is_emph(8,emph)) &
978+
// as_str(info_9,is_emph(9,emph))
981979

982980

983981
!$OMP CRITICAL (write2out)
@@ -1006,55 +1004,61 @@ subroutine panel(paneltype,ID,msg, &
10061004
flush(IO_STDERR)
10071005
!$OMP END CRITICAL (write2out)
10081006

1009-
contains
1007+
end subroutine panel
10101008

1011-
!-----------------------------------------------------------------------------------------------
1012-
!> @brief Convert to string with white space prefix and optional emphasis.
1013-
!-----------------------------------------------------------------------------------------------
1014-
function as_str(info,emph)
1015-
1016-
character(len=:), allocatable :: as_str
1017-
class(*), optional, intent(in) :: info
1018-
logical, intent(in) :: emph
1019-
1020-
1021-
if (present(info)) then
1022-
select type(info)
1023-
type is (character(*))
1024-
as_str = info
1025-
type is (integer)
1026-
as_str = IO_intAsStr(info)
1027-
type is (real(pREAL))
1028-
as_str = IO_realAsStr(info)
1029-
class default
1030-
error stop 'cannot convert info argument to string'
1031-
end select
1032-
1033-
if (emph) then
1034-
if (IO_isaTTY(IO_STDERR)) then
1035-
as_str = IO_EMPH//as_str//IO_FORMATRESET
1036-
else
1037-
as_str = IO_QUOTES(2:2)//as_str//IO_QUOTES(2:2)
1038-
end if
1039-
end if
1040-
as_str = ' '//as_str
1041-
else
1042-
as_str = ''
1043-
end if
10441009

1045-
end function as_str
1010+
!-----------------------------------------------------------------------------------------------
1011+
!> @brief Convert to string with white space prefix and optional emphasis.
1012+
!-----------------------------------------------------------------------------------------------
1013+
function as_str(info,emph)
1014+
1015+
character(len=:), allocatable :: as_str
1016+
class(*), optional, intent(in) :: info
1017+
logical, intent(in) :: emph
1018+
10461019

1047-
pure logical function is_emph(i)
1048-
integer, intent(in) :: i
1020+
if (present(info)) then
1021+
select type(info)
1022+
type is (character(*))
1023+
as_str = info
1024+
type is (integer)
1025+
as_str = IO_intAsStr(info)
1026+
type is (real(pREAL))
1027+
as_str = IO_realAsStr(info)
1028+
class default
1029+
error stop 'cannot convert info argument to string'
1030+
end select
10491031

1050-
if (present(emph)) then
1051-
is_emph = any(emph == i)
1032+
if (emph) then
1033+
if (IO_isaTTY(IO_STDERR)) then
1034+
as_str = IO_EMPH//as_str//IO_FORMATRESET
10521035
else
1053-
is_emph = .false.
1036+
as_str = IO_QUOTES(2:2)//as_str//IO_QUOTES(2:2)
10541037
end if
1055-
end function is_emph
1038+
end if
1039+
as_str = ' '//as_str
1040+
else
1041+
as_str = ''
1042+
end if
10561043

1057-
end subroutine panel
1044+
end function as_str
1045+
1046+
!-----------------------------------------------------------------------------------------------
1047+
!> @brief Convert to string with white space prefix and optional emphasis.
1048+
!-----------------------------------------------------------------------------------------------
1049+
pure logical function is_emph(idx,emph)
1050+
1051+
integer, intent(in) :: idx
1052+
integer, dimension(:), optional, intent(in) :: emph !< which info(s) to emphasize
1053+
1054+
1055+
if (present(emph)) then
1056+
is_emph = any(emph == idx)
1057+
else
1058+
is_emph = .false.
1059+
end if
1060+
1061+
end function is_emph
10581062

10591063

10601064
end module IO

src/mesh/discretization_mesh.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ subroutine discretization_mesh_init()
303303
reshape(x_p,[3,int(mesh_maxNips*mesh_nElems)]), &
304304
x_n)
305305

306-
#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>24)
306+
#if (PETSC_VERSION_MINOR>24 || (PETSC_VERSION_MINOR==24 && PETSC_VERSION_SUBMINOR>=1))
307307
call writeGeometry(reshape(x_p,[3,int(mesh_maxNips*mesh_nElems)]),x_n,T_e)
308308
#else
309309
call writeGeometry(reshape(x_p,[3,int(mesh_maxNips*mesh_nElems)]),x_n)
@@ -561,7 +561,7 @@ subroutine build_nodes_and_connectivity(x_n, p_s)
561561
#if (PETSC_VERSION_MINOR>24 || (PETSC_VERSION_MINOR==24 && PETSC_VERSION_SUBMINOR>=1))
562562
PetscCall(DMPlexGetHeightStratum(coordDM, 0_pPETSCINT, cellStart, cellEnd, ierr))
563563
PetscCall(DMPlexGetCellType(coordDM, cellStart, cell_type, ierr))
564-
node_map = PETSc_to_VTK_node_order(cell_type, p_s)
564+
node_map = PETSc_to_VTK_node_order(cell_type, int(p_s))
565565

566566
allocate(T_e(nCellNodes, cellEnd - cellStart), source = -1_pPETSCINT)
567567
do cell = cellStart, cellEnd - 1_pPETSCINT

src/phase.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ module phase
6262
DAMAGE_ISOBRITTLE, &
6363
DAMAGE_ANISOBRITTLE, &
6464
THERMAL_SOURCE_DISSIPATION, &
65-
THERMAL_SOURCE_EXTERNALHEAT
65+
THERMAL_SOURCE_EXTERNALHEAT, &
66+
CHEMICAL_QUADENERGY
6667
end enum
6768

6869

src/phase_chemical.f90

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@
77
real(pREAL) :: V_m = 0.0_pREAL !< molar volume
88
end type tChemicalParameters
99

10-
enum, bind(c); enumerator :: &
11-
CHEMICAL_UNDEFINED_ID ,&
12-
CHEMICAL_QUADENERGY_ID
13-
end enum
14-
15-
integer(kind(CHEMICAL_UNDEFINED_ID)), dimension(:), allocatable :: &
10+
integer(kind(UNDEFINED)), dimension(:), allocatable :: &
1611
chemical_energy
1712

1813
type :: tDataContainer ! ?? not very telling name. Better: "fieldQuantities" ??
@@ -85,8 +80,7 @@ module subroutine chemical_init(phases)
8580
print'(/,a)', ' <<<+- phase:chemical init -+>>>'
8681

8782
allocate(current(size(phases)))
88-
!allocate(chemicalState(size(phases)))
89-
allocate(chemical_energy(size(phases)),source=CHEMICAL_UNDEFINED_ID)
83+
allocate(chemical_energy(size(phases)),source=UNDEFINED)
9084
allocate(param(size(phases)))
9185

9286
phases => config_material%get_dict('phase')
@@ -97,11 +91,11 @@ module subroutine chemical_init(phases)
9791
end do
9892

9993
!initialize chemical energy model
100-
where(quadEnergy_init()) chemical_energy = CHEMICAL_QUADENERGY_ID
94+
where(quadEnergy_init()) chemical_energy = CHEMICAL_QUADENERGY
10195

10296
do ph = 1,size(phases)
10397
Nmembers = count(material_ID_phase == ph)
104-
if (chemical_energy(ph) == CHEMICAL_UNDEFINED_ID) then
98+
if (chemical_energy(ph) == UNDEFINED) then
10599
allocate(current(ph)%C(1,Nmembers),source=0.0_pREAL)
106100
allocate(current(ph)%dot_C(1,Nmembers),source=0.0_pREAL)
107101
allocate(current(ph)%C0(1,Nmembers),source=0.0_pREAL)
@@ -116,6 +110,7 @@ end subroutine chemical_init
116110
!< @brief Calculates composition for constituent.
117111
!----------------------------------------------------------------------------------------------
118112
module function phase_calculate_composition(mu,co,ce) result(conc)
113+
119114
real(pREAL), intent(in), dimension(:) :: mu
120115
integer, intent(in) :: co, ce
121116
real(pREAL), dimension(:), allocatable :: conc
@@ -124,49 +119,51 @@ module function phase_calculate_composition(mu,co,ce) result(conc)
124119
integer :: &
125120
ph, en
126121

122+
127123
ph = material_ID_phase(co,ce)
128124
en = material_entry_phase(co,ce)
129125

130126
mu_chemical = mu
131127
chemicalEnergyType: select case (chemical_energy(ph))
132128

133-
case (CHEMICAL_QUADENERGY_ID)
134-
conc = quadEnergy_composition(mu_chemical,ph,en)
135-
case default
136-
conc = [0.0_pREAL]
129+
case (CHEMICAL_QUADENERGY)
130+
conc = quadEnergy_composition(mu_chemical,ph,en)
137131

138132
end select chemicalEnergyType
139133

140134
end function phase_calculate_composition
141135

142136

143137
!----------------------------------------------------------------------------------------------
144-
!< @brief Retrieves composition for constituent
138+
!< @brief Retrieves composition for constituent.
145139
!----------------------------------------------------------------------------------------------
146140
module function phase_get_mobility(co,ce) result(mobility)
141+
147142
integer, intent(in) :: co, ce
148143
real(pREAL), dimension(:,:),allocatable :: mobility
149144

150145
integer :: &
151146
ph, en
152147

148+
153149
ph = material_ID_phase(co,ce)
154150
en = material_entry_phase(co,ce)
155151

156152
chemicalEnergyType: select case (chemical_energy(ph))
157153

158-
case (CHEMICAL_QUADENERGY_ID)
159-
mobility = quadEnergy_mobility(ph,en)
154+
case (CHEMICAL_QUADENERGY)
155+
mobility = quadEnergy_mobility(ph,en)
160156

161157
end select chemicalEnergyType
162158

163159
end function phase_get_mobility
164160

165161

166162
!----------------------------------------------------------------------------------------------
167-
!< @brief Retrieves composition tangent for constituent
163+
!< @brief Retrieves composition tangent for constituent.
168164
!----------------------------------------------------------------------------------------------
169165
module function phase_compositionTangent(mu,co,ce) result(comp_tangent)
166+
170167
real(pREAL), dimension(:), intent(in) :: mu
171168
integer, intent(in) :: co, ce
172169
real(pREAL), dimension(:,:),allocatable :: comp_tangent
@@ -175,14 +172,15 @@ module function phase_compositionTangent(mu,co,ce) result(comp_tangent)
175172
integer :: &
176173
ph, en
177174

175+
178176
ph = material_ID_phase(co,ce)
179177
en = material_entry_phase(co,ce)
180178

181179
mu_chemical = mu
182180
chemicalEnergyType: select case (chemical_energy(ph))
183181

184-
case (CHEMICAL_QUADENERGY_ID)
185-
comp_tangent = quadEnergy_compositionTangent(mu_chemical,ph,en)
182+
case (CHEMICAL_QUADENERGY)
183+
comp_tangent = quadEnergy_compositionTangent(mu_chemical,ph,en)
186184

187185
end select chemicalEnergyType
188186

@@ -212,12 +210,12 @@ module subroutine chemical_result(group,ph)
212210
integer, intent(in) :: ph
213211

214212

215-
if (chemical_energy(ph) /= CHEMICAL_UNDEFINED_ID) &
213+
if (chemical_energy(ph) /= UNDEFINED) &
216214
call result_closeGroup(result_addGroup(group//'chemical'))
217215

218216
chemicalEnergyType: select case (chemical_energy(ph))
219217

220-
case (CHEMICAL_QUADENERGY_ID)
218+
case (CHEMICAL_QUADENERGY)
221219
call quadEnergy_results(ph,current(ph)%C,group//'chemical/')
222220

223221
end select chemicalEnergyType

0 commit comments

Comments
 (0)