MCPcopy Create free account
hub / github.com/Apress/python-for-matlab-development / deform

Method deform

pythran/fem/FE_model.py:199–227  ·  view source on GitHub ↗

dV is a linear list or array of deformations to apply to the nodal coordinates. Even indices are the x component, odd are y. scale = None means autoscale so that deformations are 30% of the model's max dimension.

(self, dV,                                    # {{{
               scale=None)

Source from the content-addressed store, hash-verified

197 print(S)
198 # }}}
199 def deform(self, dV, # {{{
200 scale=None):
201 """
202 dV is a linear list or array of deformations to
203 apply to the nodal coordinates.
204 Even indices are the x component, odd are y.
205
206 scale = None means autoscale so that deformations
207 are 30% of the model's max dimension.
208 """
209 if scale is None:
210 model_len = np.sqrt((self.xmax - self.xmin)**2 +
211 (self.ymax - self.ymin)**2)
212 S = 0.1 * model_len / np.max(np.abs(dV))
213 else:
214 S = scale
215
216 #print(f'max dV {np.max(np.abs(dV))}, model_len {model_len} S {S}')
217 for dX, dY, N in zip(dV[0::2],
218 dV[1::2],
219 self.node):
220 N.x += S*dX
221 N.y += S*dY
222
223 # update the bounding box to the deformed shape
224 self.xmin = min([_.x for _ in self.node])
225 self.xmax = max([_.x for _ in self.node])
226 self.ymin = min([_.y for _ in self.node])
227 self.ymax = max([_.y for _ in self.node])
228 # }}}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected