该项目是《Problem-independent machine learning (PIML)-based topology optimization—A universal approach》的python复现
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

28 lines
965 B

def BaseFunction(i, k, u, knot):
'''
Calculate base function using Cox-deBoor function.
:param i: index of base function
:param k: order (degree + 1)
:param u: parameter
:param knot: knot vector
:return: base function
'''
Nik_u = 0
if k == 1:
if u >= knot[i] and u < knot[i + 1]:
Nik_u = 1.0
else:
Nik_u = 0.0
else:
length1 = knot[i + k - 1] - knot[i]
length2 = knot[i + k] - knot[i + 1]
if not length1 and not length2:
Nik_u = 0
elif not length1:
Nik_u = (knot[i + k] - u) / length2 * BaseFunction(i + 1, k - 1, u, knot)
elif not length2:
Nik_u = (u - knot[i]) / length1 * BaseFunction(i, k - 1, u, knot)
else:
Nik_u = (u - knot[i]) / length1 * BaseFunction(i, k - 1, u, knot) + \
(knot[i + k] - u) / length2 * BaseFunction(i + 1, k - 1, u, knot)
return Nik_u