Skip to content

Commit 9a88440

Browse files
committed
Merge branch 'housekeeping_2025-05-04' into 'development'
housekeeping 2025-05-04 See merge request damask/DAMASK!1066
2 parents 6bc9f43 + fc98f31 commit 9a88440

18 files changed

+348
-210
lines changed

CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ endif()
6363
add_definitions(-DCMAKE_SYSTEM_NAME="${CMAKE_SYSTEM_NAME}")
6464
add_definitions(-DCMAKE_SYSTEM_PROCESSOR="${CMAKE_SYSTEM_PROCESSOR}")
6565

66+
add_definitions(-DSTRLEN=256)
67+
add_definitions(-DPATHLEN=4096)
68+
6669
if(PETSC_VERSION VERSION_EQUAL 3.17.0)
6770
add_definitions("-DCHKERRQ=PetscCall")
6871
endif()
@@ -134,21 +137,18 @@ if(CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
134137
endif()
135138

136139

137-
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
138-
set(Fortran_COMPILER_VERSION_MIN 11.1)
139-
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM")
140-
set(Fortran_COMPILER_VERSION_MIN 19)
141-
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang")
142-
set(Fortran_COMPILER_VERSION_MIN 20)
140+
if((CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") OR
141+
(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") OR
142+
(CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang"))
143+
include("${PROJECT_SOURCE_DIR}/cmake/Compiler-${CMAKE_Fortran_COMPILER_ID}.cmake")
143144
else()
144145
message(FATAL_ERROR "Compiler '${CMAKE_Fortran_COMPILER_ID}' not supported")
145146
endif()
147+
146148
if(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS Fortran_COMPILER_VERSION_MIN)
147149
message(FATAL_ERROR "Version '${CMAKE_Fortran_COMPILER_VERSION}' of '${CMAKE_Fortran_COMPILER_ID}' is not supported")
148150
endif()
149151

150-
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
151-
include("Compiler-${CMAKE_Fortran_COMPILER_ID}")
152152

153153
file(STRINGS "$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib/petsc/conf/petscvariables" PETSC_EXTERNAL_LIB REGEX "PETSC_EXTERNAL_LIB_BASIC = .*$?")
154154
string(REPLACE "PETSC_EXTERNAL_LIB_BASIC = " "" PETSC_EXTERNAL_LIB "${PETSC_EXTERNAL_LIB}")

cmake/Compiler-GNU.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
###################################################################################################
22
# GNU Compiler
33
###################################################################################################
4+
set(Fortran_COMPILER_VERSION_MIN 11.1)
5+
46
if (OPENMP)
57
set (OPENMP_FLAGS "-fopenmp")
68
endif ()

cmake/Compiler-IntelLLVM.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
###################################################################################################
22
# IntelLLVM Compiler
33
###################################################################################################
4+
set(Fortran_COMPILER_VERSION_MIN 19)
5+
46
if (OPENMP)
57
set (OPENMP_FLAGS "-fiopenmp")
68
endif ()

cmake/Compiler-LLVMFlang.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
###################################################################################################
22
# LLVM Compiler
33
###################################################################################################
4+
set(Fortran_COMPILER_VERSION_MIN 20)
5+
46
if (OPENMP)
57
set (OPENMP_FLAGS "-fopenmp")
68
endif ()
79

810
set (STANDARD_CHECK "-std=f2018 -pedantic" )
9-
10-
#------------------------------------------------------------------------------------------------
11-
# Fine tuning compilation options
12-
set (COMPILE_FLAGS "${COMPILE_FLAGS} -cpp") # preprocessor, needed for CMake < 3.18

python/damask/_colormap.py

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __eq__(self,
7878
Returns
7979
-------
8080
eq : bool
81-
Wheter self equals other.
81+
Whether self equals other.
8282
"""
8383
if not isinstance(other, Colormap):
8484
return NotImplemented
@@ -504,27 +504,71 @@ def _interpolate_msh(frac: float,
504504
505505
This interpolation gives a perceptually uniform colormap.
506506
507+
Parameters
508+
----------
509+
frac : float
510+
Location at the colormap in a range [0,1].
511+
low : numpy.ndarray, shape (3)
512+
Color in Msh for the low end of the colormap.
513+
high : numpy.ndarray, shape (3)
514+
Color in Msh for the high end of the colormap.
515+
516+
Returns
517+
-------
518+
color : numpy.ndarray, shape (3)
519+
Color in Msh at frac between low and high.
520+
507521
References
508522
----------
509523
| https://www.kennethmoreland.com/color-maps/ColorMapsExpanded.pdf
510524
| https://www.kennethmoreland.com/color-maps/diverging_map.py
511525
"""
512-
def rad_diff(a,b):
513-
return abs(a[2]-b[2])
514-
515-
def adjust_hue(msh_sat, msh_unsat):
516-
"""If saturation of one of the two colors is much less than the other, hue of the less."""
517-
if msh_sat[0] >= msh_unsat[0]:
526+
def rad_diff(h_1,h_2):
527+
"""
528+
Compute angular difference between two hue orientations.
529+
530+
Parameters
531+
----------
532+
h_1 : float
533+
First hue orientation.
534+
h_2 : float
535+
Second hue orientation.
536+
537+
Returns
538+
-------
539+
d : float
540+
Angular difference between given hue orientations.
541+
"""
542+
d = abs(h_1-h_2)%(2*np.pi)
543+
return min(d,2*np.pi-d)
544+
545+
def adjust_hue(msh_sat, m_unsat):
546+
"""
547+
Provide adjusted hue when interpolating to an unsaturated color.
548+
549+
Parameters
550+
----------
551+
msh_sat : numpy.ndarray, shape(3)
552+
Saturated color in Msh space.
553+
m_unsat : float
554+
Magnitue (in Msh space) of unsaturated color.
555+
556+
Returns
557+
-------
558+
h_adjusted : float
559+
Adjusted hue.
560+
"""
561+
if msh_sat[0] >= m_unsat:
518562
return msh_sat[2]
519563

520-
hSpin = msh_sat[1]/np.sin(msh_sat[1])*np.sqrt(msh_unsat[0]**2.0-msh_sat[0]**2)/msh_sat[0]
564+
hSpin = msh_sat[1]/np.sin(msh_sat[1])*np.sqrt(m_unsat**2.0-msh_sat[0]**2)/msh_sat[0]
521565
if msh_sat[2] < - np.pi/3.0: hSpin *= -1.0
522566
return msh_sat[2] + hSpin
523567

524568
lo = np.array(low)
525569
hi = np.array(high)
526570

527-
if (lo[1] > 0.05 and hi[1] > 0.05 and rad_diff(lo,hi) > np.pi/3.0):
571+
if (lo[1] > 0.05 and hi[1] > 0.05 and rad_diff(lo[2],hi[2]) > np.pi/3.0):
528572
M_mid = max(lo[0],hi[0],88.0)
529573
if frac < 0.5:
530574
hi = np.array([M_mid,0.0,0.0])
@@ -533,9 +577,9 @@ def adjust_hue(msh_sat, msh_unsat):
533577
lo = np.array([M_mid,0.0,0.0])
534578
frac = 2.0*frac - 1.0
535579
if lo[1] < 0.05 < hi[1]:
536-
lo[2] = adjust_hue(hi,lo)
580+
lo[2] = adjust_hue(hi,lo[0])
537581
elif hi[1] < 0.05 < lo[1]:
538-
hi[2] = adjust_hue(lo,hi)
582+
hi[2] = adjust_hue(lo,hi[0])
539583

540584
return (1.0 - frac) * lo + frac * hi
541585

python/damask/_configmaterial.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,22 +258,20 @@ def is_complete(self) -> bool:
258258
Returns
259259
-------
260260
complete : bool
261-
Whether the material.yaml definition is complete.
261+
Whether the material configuration definition is complete.
262262
"""
263-
def LabeledList(label,items):
263+
def labeled_list(label,items):
264264
return f'{label.capitalize()}{"s" if len(items)>1 else ""} {util.srepr(items,",",quote=True)}'
265265

266266
ok = True
267267
msg = []
268268
all = set(['homogenization','phase','material'])
269-
miss = set([item for item in all if item not in self])
270-
empty = set([item for item in all-miss if self[item] is None])
271269

272-
if miss:
273-
msg.append(f'{LabeledList("top-level",miss)} missing')
270+
if miss := set([item for item in all if item not in self]):
271+
msg.append(f'{labeled_list("top-level",miss)} missing')
274272
ok = False
275-
if empty:
276-
msg.append(f'{LabeledList("top-level",empty)} empty')
273+
if empty := set([item for item in all-miss if self[item] is None]):
274+
msg.append(f'{labeled_list("top-level",empty)} empty')
277275

278276
if ok:
279277
ok &= len(self['material']) > 0
@@ -303,10 +301,10 @@ def LabeledList(label,items):
303301
'homogenization':homogenization}.items():
304302
me = set([] if v in empty else self[v])
305303
if _miss := other - me:
306-
msg.append(f'{LabeledList(v,_miss)} missing')
304+
msg.append(f'{labeled_list(v,_miss)} missing')
307305
ok = False
308306
if len(_empty := [item for item in me if self[v][item] is None]) > 0:
309-
msg.append(f'{LabeledList(v,_empty)} undefined')
307+
msg.append(f'{labeled_list(v,_empty)} undefined')
310308
ok = False
311309

312310
logger.info(util.srepr(msg))

0 commit comments

Comments
 (0)