16
16
with contextlib .redirect_stdout (_strio ):
17
17
help (_fem )
18
18
_strio .seek (0 )
19
- setattr (__module , "__doc__" , f"{ getattr (__module , "__doc__" )} \n \n { _strio .read ()} " )
19
+ setattr (__module , "__doc__" , f"{
20
+ getattr (__module , "__doc__" )} \n \n { _strio .read ()} " )
21
+
20
22
21
23
def divergence (mesh , quadrature_order : int = 1 , GNe : np .ndarray = None ):
22
24
"""Construct an FEM divergence operator such that composing div(grad(u))
@@ -68,8 +70,9 @@ def hyper_elastic_potential(
68
70
energy = _fem .HyperElasticEnergy .StableNeoHookean ,
69
71
precompute_sparsity : bool = True ,
70
72
quadrature_order : int = 1 ,
71
- detJe : np .ndarray = None ,
72
- GNe : np .ndarray = None ):
73
+ eg : np .ndarray = None ,
74
+ wg : np .ndarray = None ,
75
+ GNeg : np .ndarray = None ):
73
76
"""Construct an FEM hyper elastic potential
74
77
75
78
Args:
@@ -79,23 +82,27 @@ def hyper_elastic_potential(
79
82
energy (pbat.fem.HyperElasticEnergy, optional): Constitutive model. Defaults to pbat.fem.HyperElasticEnergy.StableNeoHookean.
80
83
precompute_sparsity (bool, optional): Precompute an acceleration data structure for fast hessian construction. Defaults to True.
81
84
quadrature_order (int, optional): Polynomial order to use for potential (and its derivatives) evaluation. Defaults to 1.
82
- detJe (np.ndarray, optional): Jacobian determinants at quadrature points. Defaults to None.
83
- GNe (np.ndarray, optional): Shape function gradients at quadrature points. Defaults to None.
85
+ eg (np.ndarray, optional): Elements corresponding to each quadrature weight in wg.
86
+ wg (np.ndarray, optional): Quadrature weights at quadrature points. Defaults to None.
87
+ GNeg (np.ndarray, optional): Shape function gradients at quadrature points. Defaults to None.
84
88
85
89
Returns:
86
90
(pbat.fem.HyperElasticPotential, np.ndarray, np.ndarray):
87
91
"""
88
- if detJe is None :
89
- detJe = _fem .jacobian_determinants (
92
+ if eg is None or wg is None or GNeg is None :
93
+ wg = _fem .inner_product_weights (
90
94
mesh , quadrature_order = quadrature_order )
91
- if GNe is None :
92
- GNe = _fem .shape_function_gradients (
95
+ eg = np .linspace (0 , mesh .E .shape [1 ]- 1 ,
96
+ num = mesh .E .shape [1 ], dtype = np .int64 )
97
+ eg = np .repeat (eg , wg .shape [0 ])
98
+ wg = wg .flatten (order = "F" )
99
+ GNeg = _fem .shape_function_gradients (
93
100
mesh , quadrature_order = quadrature_order )
94
101
hep = _fem .HyperElasticPotential (
95
- mesh , detJe , GNe , Y , nu , energy = energy , quadrature_order = quadrature_order )
102
+ mesh , eg , wg , GNeg , Y , nu , energy = energy )
96
103
if precompute_sparsity :
97
104
hep .precompute_hessian_sparsity ()
98
- return hep , detJe , GNe
105
+ return hep , eg , wg , GNeg
99
106
100
107
101
108
def laplacian (
0 commit comments