morphogen 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- morphogen/__init__.py +60 -0
- morphogen/__main__.py +7 -0
- morphogen/_platform.py +55 -0
- morphogen/_public.py +153 -0
- morphogen/_utils.py +80 -0
- morphogen/_version.py +1 -0
- morphogen/analysis/__init__.py +174 -0
- morphogen/analysis/anisotropy.py +135 -0
- morphogen/analysis/basic.py +38 -0
- morphogen/analysis/cells.py +54 -0
- morphogen/analysis/connectivity.py +156 -0
- morphogen/analysis/correlation.py +195 -0
- morphogen/analysis/covariance.py +80 -0
- morphogen/analysis/fractal.py +54 -0
- morphogen/analysis/measures.py +188 -0
- morphogen/analysis/morphology.py +265 -0
- morphogen/analysis/particles.py +160 -0
- morphogen/analysis/percolation.py +2034 -0
- morphogen/analysis/power_laws.py +143 -0
- morphogen/analysis/random_sets.py +351 -0
- morphogen/analysis/stereology.py +289 -0
- morphogen/analysis/surface.py +107 -0
- morphogen/analysis/topology.py +92 -0
- morphogen/automata/__init__.py +74 -0
- morphogen/automata/engine.py +211 -0
- morphogen/automata/growth.py +686 -0
- morphogen/automata/lattice.py +143 -0
- morphogen/automata/reaction.py +255 -0
- morphogen/automata/rules.py +353 -0
- morphogen/automata/tilings.py +1715 -0
- morphogen/cli.py +3526 -0
- morphogen/config.py +2167 -0
- morphogen/contact/__init__.py +113 -0
- morphogen/contact/experiments.py +368 -0
- morphogen/contact/hertz.py +104 -0
- morphogen/contact/kernels.py +827 -0
- morphogen/contact/periodic.py +278 -0
- morphogen/contact/problem.py +578 -0
- morphogen/contact/surfaces.py +310 -0
- morphogen/coupling/__init__.py +43 -0
- morphogen/coupling/ageing.py +143 -0
- morphogen/coupling/diffusion.py +226 -0
- morphogen/coupling/fenicsx.py +484 -0
- morphogen/coupling/oxidation.py +447 -0
- morphogen/coupling/plates.py +247 -0
- morphogen/design/__init__.py +51 -0
- morphogen/design/csp.py +616 -0
- morphogen/design/frames.py +277 -0
- morphogen/design/search.py +287 -0
- morphogen/design/tiles.py +336 -0
- morphogen/distributions.py +312 -0
- morphogen/domain.py +203 -0
- morphogen/dynamics/__init__.py +179 -0
- morphogen/dynamics/model.py +638 -0
- morphogen/dynamics/openradioss.py +643 -0
- morphogen/dynamics/results.py +515 -0
- morphogen/fracture/__init__.py +170 -0
- morphogen/fracture/bulk.py +349 -0
- morphogen/fracture/cohesive.py +1614 -0
- morphogen/fracture/ductile.py +557 -0
- morphogen/fracture/lefm.py +1168 -0
- morphogen/fracture/mixed.py +1178 -0
- morphogen/fracture/periodic.py +733 -0
- morphogen/fracture/phasefield.py +714 -0
- morphogen/fracture/phasefield_finite.py +368 -0
- morphogen/fracture/surface.py +572 -0
- morphogen/fracture/toughness.py +566 -0
- morphogen/gpu.py +108 -0
- morphogen/gui/__init__.py +8 -0
- morphogen/gui/api.py +1927 -0
- morphogen/gui/desktop.py +387 -0
- morphogen/gui/icon.png +0 -0
- morphogen/gui/index.html +1909 -0
- morphogen/gui/server.py +229 -0
- morphogen/gui/tools/__init__.py +629 -0
- morphogen/gui/tools/compare.py +149 -0
- morphogen/gui/tools/contact.py +391 -0
- morphogen/gui/tools/couplings.py +1085 -0
- morphogen/gui/tools/crackfront.py +245 -0
- morphogen/gui/tools/design.py +224 -0
- morphogen/gui/tools/dynamics.py +824 -0
- morphogen/gui/tools/fracture.py +2586 -0
- morphogen/gui/tools/interop.py +1654 -0
- morphogen/gui/tools/learning.py +595 -0
- morphogen/gui/tools/mechanics.py +3881 -0
- morphogen/gui/tools/nonlocal_damage.py +1321 -0
- morphogen/gui/tools/phasefield.py +215 -0
- morphogen/gui/tools/physics.py +597 -0
- morphogen/gui/tools/stability.py +1756 -0
- morphogen/gui/tools/statistics.py +1408 -0
- morphogen/gui/viewer.js +1100 -0
- morphogen/homogenization/__init__.py +210 -0
- morphogen/homogenization/acoustics.py +566 -0
- morphogen/homogenization/amg.py +1005 -0
- morphogen/homogenization/apparent.py +1046 -0
- morphogen/homogenization/behaviours.cu +2285 -0
- morphogen/homogenization/behaviours.py +944 -0
- morphogen/homogenization/beremin.py +263 -0
- morphogen/homogenization/bifurcation.py +1085 -0
- morphogen/homogenization/bloch.py +507 -0
- morphogen/homogenization/bounds.py +226 -0
- morphogen/homogenization/core.py +458 -0
- morphogen/homogenization/coupled.py +1135 -0
- morphogen/homogenization/crystal.py +2967 -0
- morphogen/homogenization/dilatation.py +454 -0
- morphogen/homogenization/elements.py +157 -0
- morphogen/homogenization/fatigue.py +768 -0
- morphogen/homogenization/fe.py +1739 -0
- morphogen/homogenization/fenicsx.py +307 -0
- morphogen/homogenization/fft.py +499 -0
- morphogen/homogenization/fft_nonlinear.py +391 -0
- morphogen/homogenization/finite.py +613 -0
- morphogen/homogenization/flow.py +361 -0
- morphogen/homogenization/frames.py +1125 -0
- morphogen/homogenization/gpu.py +1241 -0
- morphogen/homogenization/harmonic.py +427 -0
- morphogen/homogenization/identification.py +579 -0
- morphogen/homogenization/kernels.py +760 -0
- morphogen/homogenization/laws.py +2061 -0
- morphogen/homogenization/materials.py +1080 -0
- morphogen/homogenization/mfront.py +589 -0
- morphogen/homogenization/networks.py +880 -0
- morphogen/homogenization/nonlinear.py +2612 -0
- morphogen/homogenization/ntfa.py +577 -0
- morphogen/homogenization/paths.py +476 -0
- morphogen/homogenization/photonic.py +467 -0
- morphogen/homogenization/poroelastic.py +212 -0
- morphogen/homogenization/porous.py +1120 -0
- morphogen/homogenization/postprocess.py +290 -0
- morphogen/homogenization/solvers.py +1140 -0
- morphogen/homogenization/tensors.py +240 -0
- morphogen/homogenization/voxel_fe.py +457 -0
- morphogen/homogenization/xfem.py +1016 -0
- morphogen/homogenization/zmat.py +1258 -0
- morphogen/iga/__init__.py +48 -0
- morphogen/iga/analysis.py +508 -0
- morphogen/iga/basis.py +214 -0
- morphogen/iga/geometry.py +501 -0
- morphogen/iga/homogenization.py +219 -0
- morphogen/iga/optimization.py +700 -0
- morphogen/iga/shapes.py +331 -0
- morphogen/image.py +128 -0
- morphogen/io/__init__.py +246 -0
- morphogen/io/amitex.py +741 -0
- morphogen/io/ebsd.py +881 -0
- morphogen/io/export.py +196 -0
- morphogen/io/geometry.py +158 -0
- morphogen/io/medit.py +147 -0
- morphogen/io/meshes.py +844 -0
- morphogen/io/metaimage.py +97 -0
- morphogen/io/mfront.py +1104 -0
- morphogen/io/native.py +57 -0
- morphogen/io/radioss.py +764 -0
- morphogen/io/solvers.py +371 -0
- morphogen/io/tables.py +278 -0
- morphogen/io/tiff.py +66 -0
- morphogen/io/vtk.py +701 -0
- morphogen/io/xdmf.py +200 -0
- morphogen/kernels/__init__.py +5 -0
- morphogen/kernels/annealing.py +192 -0
- morphogen/kernels/cells.py +69 -0
- morphogen/kernels/collective.py +87 -0
- morphogen/kernels/force_biased.py +595 -0
- morphogen/kernels/implicit.py +145 -0
- morphogen/kernels/leaves.py +132 -0
- morphogen/kernels/packing.py +304 -0
- morphogen/kernels/raster.py +279 -0
- morphogen/kernels/rsa.py +371 -0
- morphogen/kernels/union.py +135 -0
- morphogen/kernels/watershed.py +190 -0
- morphogen/laser/__init__.py +234 -0
- morphogen/laser/architectures.py +375 -0
- morphogen/laser/bending.py +216 -0
- morphogen/laser/cells.py +1694 -0
- morphogen/laser/design.py +940 -0
- morphogen/laser/figures.py +227 -0
- morphogen/laser/heat.py +804 -0
- morphogen/laser/materials.py +691 -0
- morphogen/laser/mechanics.py +1670 -0
- morphogen/laser/metallurgy.py +615 -0
- morphogen/laser/patterns.py +828 -0
- morphogen/laser/periodic.py +392 -0
- morphogen/laser/process.py +362 -0
- morphogen/laser/run.py +534 -0
- morphogen/laser/solid.py +216 -0
- morphogen/laser/specimen.py +200 -0
- morphogen/laser/structures.py +708 -0
- morphogen/learning/__init__.py +81 -0
- morphogen/learning/behaviour.py +398 -0
- morphogen/learning/data.py +328 -0
- morphogen/learning/learned.cpp +668 -0
- morphogen/learning/logarithmic.py +202 -0
- morphogen/learning/mfront.py +409 -0
- morphogen/learning/networks.py +767 -0
- morphogen/learning/run.py +212 -0
- morphogen/learning/standard.py +814 -0
- morphogen/learning/training.py +235 -0
- morphogen/mesh/__init__.py +29 -0
- morphogen/mesh/conforming.py +1423 -0
- morphogen/mesh/curved.py +600 -0
- morphogen/mesh/exact.py +1717 -0
- morphogen/mesh/octree.py +350 -0
- morphogen/mesh/polycrystal.py +1041 -0
- morphogen/mesh/polyhedra.py +677 -0
- morphogen/mesh/regularize.py +570 -0
- morphogen/mesh/surface.py +97 -0
- morphogen/mesh/tetra.py +512 -0
- morphogen/mesh/voxel.py +124 -0
- morphogen/micromorphic/__init__.py +31 -0
- morphogen/micromorphic/damage.py +359 -0
- morphogen/micromorphic/ductile.py +534 -0
- morphogen/micromorphic/finite.py +220 -0
- morphogen/micromorphic/microfoam.py +787 -0
- morphogen/micromorphic/space.py +341 -0
- morphogen/models/__init__.py +195 -0
- morphogen/models/affine.py +384 -0
- morphogen/models/automata.py +592 -0
- morphogen/models/base.py +500 -0
- morphogen/models/boolean.py +310 -0
- morphogen/models/bouligand.py +331 -0
- morphogen/models/branching.py +241 -0
- morphogen/models/combination.py +430 -0
- morphogen/models/deadleaves.py +766 -0
- morphogen/models/design.py +289 -0
- morphogen/models/ebsd.py +206 -0
- morphogen/models/fibers.py +1476 -0
- morphogen/models/foam.py +594 -0
- morphogen/models/gaussian.py +314 -0
- morphogen/models/growth.py +459 -0
- morphogen/models/hardcore.py +317 -0
- morphogen/models/hierarchical.py +269 -0
- morphogen/models/honeycomb.py +749 -0
- morphogen/models/implicit.py +177 -0
- morphogen/models/laminate.py +470 -0
- morphogen/models/lattice.py +351 -0
- morphogen/models/lattice_field.py +345 -0
- morphogen/models/levelset_foam.py +563 -0
- morphogen/models/nacre.py +411 -0
- morphogen/models/nested.py +924 -0
- morphogen/models/osteons.py +374 -0
- morphogen/models/pieces.py +167 -0
- morphogen/models/planar.py +126 -0
- morphogen/models/reconstruction.py +203 -0
- morphogen/models/scale_rich.py +1409 -0
- morphogen/models/scale_rich_3d.py +1616 -0
- morphogen/models/tessellation.py +735 -0
- morphogen/models/tiling_field.py +302 -0
- morphogen/models/tpms.py +197 -0
- morphogen/models/transparent.py +406 -0
- morphogen/models/union.py +141 -0
- morphogen/optimization/__init__.py +43 -0
- morphogen/optimization/cell.py +295 -0
- morphogen/optimization/filters.py +115 -0
- morphogen/optimization/mma.py +226 -0
- morphogen/optimization/run.py +219 -0
- morphogen/optimization/topology.py +632 -0
- morphogen/orientations.py +568 -0
- morphogen/parallel.py +599 -0
- morphogen/pipeline.py +978 -0
- morphogen/primitives.py +188 -0
- morphogen/results.py +564 -0
- morphogen/rve/__init__.py +73 -0
- morphogen/rve/report.py +627 -0
- morphogen/rve/scaling.py +363 -0
- morphogen/rve/study.py +1054 -0
- morphogen/rve/windows.py +345 -0
- morphogen/seeding.py +51 -0
- morphogen/settings.py +118 -0
- morphogen/stopping.py +48 -0
- morphogen/symmetry.py +384 -0
- morphogen/templates/activator_inhibitor.yaml +22 -0
- morphogen/templates/aggregation.yaml +23 -0
- morphogen/templates/boolean_cylinders.yaml +20 -0
- morphogen/templates/boolean_spheres.yaml +22 -0
- morphogen/templates/bouligand.yaml +28 -0
- morphogen/templates/cellular_automaton.yaml +25 -0
- morphogen/templates/coated_spheres.yaml +26 -0
- morphogen/templates/contact_fibers.yaml +27 -0
- morphogen/templates/cox_nanocomposite.yaml +22 -0
- morphogen/templates/cross_linked_fibers.yaml +26 -0
- morphogen/templates/curved_arcs.yaml +28 -0
- morphogen/templates/curved_fibers.yaml +24 -0
- morphogen/templates/dead_leaves.yaml +22 -0
- morphogen/templates/delaunay_network.yaml +22 -0
- morphogen/templates/dense_packing.yaml +22 -0
- morphogen/templates/diffusion.yaml +33 -0
- morphogen/templates/ebsd.yaml +34 -0
- morphogen/templates/ebsd_map.ctf +3087 -0
- morphogen/templates/fracture_composite.yaml +42 -0
- morphogen/templates/fracture_rubber.yaml +47 -0
- morphogen/templates/gaussian_excursion.yaml +17 -0
- morphogen/templates/graded_lattice.yaml +24 -0
- morphogen/templates/hardcore_fibers.yaml +22 -0
- morphogen/templates/hardcore_spheres.yaml +22 -0
- morphogen/templates/hierarchical_lattice.yaml +22 -0
- morphogen/templates/homogenization_acoustic_foam.yaml +36 -0
- morphogen/templates/homogenization_beremin.yaml +50 -0
- morphogen/templates/homogenization_cleavage.yaml +51 -0
- morphogen/templates/homogenization_cleavage_band.yaml +55 -0
- morphogen/templates/homogenization_contact.yaml +43 -0
- morphogen/templates/homogenization_crack_closure.yaml +49 -0
- morphogen/templates/homogenization_crystal_plasticity.yaml +50 -0
- morphogen/templates/homogenization_crystal_plasticity_fft.yaml +52 -0
- morphogen/templates/homogenization_crystallization.yaml +30 -0
- morphogen/templates/homogenization_debonding.yaml +43 -0
- morphogen/templates/homogenization_detwinning.yaml +58 -0
- morphogen/templates/homogenization_ductile_damage.yaml +47 -0
- morphogen/templates/homogenization_fatigue.yaml +40 -0
- morphogen/templates/homogenization_grain_fracture.yaml +56 -0
- morphogen/templates/homogenization_gyroid.yaml +30 -0
- morphogen/templates/homogenization_intergranular.yaml +43 -0
- morphogen/templates/homogenization_interphase.yaml +42 -0
- morphogen/templates/homogenization_mixed_loading.yaml +33 -0
- morphogen/templates/homogenization_ntfa.yaml +56 -0
- morphogen/templates/homogenization_piezoelectric.yaml +27 -0
- morphogen/templates/homogenization_polycrystal.yaml +30 -0
- morphogen/templates/homogenization_polycrystal_inclusions.yaml +30 -0
- morphogen/templates/homogenization_poroelastic.yaml +26 -0
- morphogen/templates/homogenization_rubber.yaml +40 -0
- morphogen/templates/homogenization_slip_cleavage.yaml +50 -0
- morphogen/templates/homogenization_spheres.yaml +31 -0
- morphogen/templates/homogenization_transport.yaml +29 -0
- morphogen/templates/homogenization_twinning.yaml +54 -0
- morphogen/templates/homogenization_viscoelastic.yaml +34 -0
- morphogen/templates/homogenization_viscoplastic.yaml +42 -0
- morphogen/templates/homogenization_voronoi.yaml +26 -0
- morphogen/templates/homogenization_xfem.yaml +23 -0
- morphogen/templates/hyperuniform_cells.yaml +24 -0
- morphogen/templates/laguerre.yaml +18 -0
- morphogen/templates/laser_bending.yaml +35 -0
- morphogen/templates/laser_cells.yaml +38 -0
- morphogen/templates/laser_corrugated.yaml +36 -0
- morphogen/templates/level_set_foam.yaml +29 -0
- morphogen/templates/menger_sponge.yaml +17 -0
- morphogen/templates/nacre.yaml +25 -0
- morphogen/templates/nucleation_growth.yaml +25 -0
- morphogen/templates/optimize_auxetic.yaml +29 -0
- morphogen/templates/optimize_auxetic_3d.yaml +27 -0
- morphogen/templates/optimize_bulk.yaml +23 -0
- morphogen/templates/optimize_conductivity.yaml +20 -0
- morphogen/templates/osteons.yaml +28 -0
- morphogen/templates/penetrable_spheres.yaml +21 -0
- morphogen/templates/poisson_fibers.yaml +21 -0
- morphogen/templates/random_laminate.yaml +26 -0
- morphogen/templates/random_lattice.yaml +27 -0
- morphogen/templates/random_walk_fibers.yaml +26 -0
- morphogen/templates/reaction_diffusion.yaml +22 -0
- morphogen/templates/reconstruction.yaml +22 -0
- morphogen/templates/rve_cellular_automaton.yaml +23 -0
- morphogen/templates/rve_crystal_plasticity_fft.yaml +51 -0
- morphogen/templates/rve_multiphysics.yaml +43 -0
- morphogen/templates/rve_poisson_fibers.yaml +22 -0
- morphogen/templates/rve_poisson_fibers_fe.yaml +33 -0
- morphogen/templates/rve_voronoi_windows.yaml +20 -0
- morphogen/templates/scale_rich_network.yaml +29 -0
- morphogen/templates/scale_rich_plates.yaml +30 -0
- morphogen/templates/sequential_dead_leaves.yaml +25 -0
- morphogen/templates/strut_lattice.yaml +21 -0
- morphogen/templates/tile_assembly.yaml +28 -0
- morphogen/templates/tpms.yaml +19 -0
- morphogen/templates/trabecular_bone.yaml +29 -0
- morphogen/templates/transparent_dead_leaves.yaml +23 -0
- morphogen/templates/vascular_tree.yaml +23 -0
- morphogen/templates/voronoi.yaml +20 -0
- morphogen/templates/wood.yaml +34 -0
- morphogen/templates/workflow.yaml +56 -0
- morphogen/texture.py +665 -0
- morphogen/theory.py +162 -0
- morphogen/viz/__init__.py +12 -0
- morphogen/viz/export.py +244 -0
- morphogen/viz/figures.py +707 -0
- morphogen/viz/png.py +148 -0
- morphogen/viz/sections.py +696 -0
- morphogen/viz/surfaces.py +1352 -0
- morphogen/viz/video.py +904 -0
- morphogen/viz/workflow.py +488 -0
- morphogen-1.0.0.dist-info/METADATA +2316 -0
- morphogen-1.0.0.dist-info/RECORD +381 -0
- morphogen-1.0.0.dist-info/WHEEL +4 -0
- morphogen-1.0.0.dist-info/entry_points.txt +5 -0
- morphogen-1.0.0.dist-info/licenses/LICENSE +674 -0
|
@@ -0,0 +1,827 @@
|
|
|
1
|
+
"""Kernels of the contact of surfaces (Numba): the functions of the faces, the point of a
|
|
2
|
+
face nearest a point, the forces of a slave point on a master face or on a rigid
|
|
3
|
+
obstacle, with Coulomb's friction, and their tangents.
|
|
4
|
+
|
|
5
|
+
A *slave point* is an integration point of a face of the slave surface, of weight ``w``
|
|
6
|
+
(its share of the reference area of the face). Its state (:data:`STATE` values) is kept
|
|
7
|
+
from the end of a step to the next: the multiplier of the augmented Lagrangian, the point
|
|
8
|
+
of the master surface that faced it (a face and its coordinates; for an obstacle, its
|
|
9
|
+
position relative to the obstacle), the tangential traction, the energy that friction
|
|
10
|
+
dissipated per unit area, its gap and its pressure.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import math
|
|
16
|
+
|
|
17
|
+
import numpy as np
|
|
18
|
+
from numba import njit, prange
|
|
19
|
+
|
|
20
|
+
#: The parameters of a contact: the penalty of the normal gap, the stiffness of the
|
|
21
|
+
#: stick, the coefficient of friction, the deepest penetration looked for, the gap below
|
|
22
|
+
#: which two surfaces touch, the size of the faces, and the distance within which a face
|
|
23
|
+
#: of a surface that lies behind a point of it, at rest, is across a wall from the point;
|
|
24
|
+
#: how far beyond the rim of the master a point still faces it (:data:`RIM`), and whether
|
|
25
|
+
#: the weight of a point is the share of its face that the other surface sees
|
|
26
|
+
#: (:func:`_share`: the points at the nodes)
|
|
27
|
+
P_STIFF, P_STICK, P_MU, P_DEPTH, P_TOUCH, P_SIZE, P_BEHIND, P_RIM, P_SHARE = range(9)
|
|
28
|
+
#: How far beyond the rim of the master surface (in the coordinates of its faces) a slave
|
|
29
|
+
#: point still faces it, on the face continued: nothing for the points inside the faces
|
|
30
|
+
#: of the slave; a twentieth of a face for those at its nodes, which may lie on the rim
|
|
31
|
+
#: of the master (two bodies of the same section) and would otherwise face it or not
|
|
32
|
+
#: with the rounding of each iteration
|
|
33
|
+
RIM, RIM_NODES = 1e-12, 0.05
|
|
34
|
+
#: How far outside a master face (in its coordinates) a slave point stays on it
|
|
35
|
+
SLACK = 0.05
|
|
36
|
+
#: Two faces face each other when the cosine of the angle of their outward normals is
|
|
37
|
+
#: below this (more than 104 degrees apart): faces at right angles along an edge of a body,
|
|
38
|
+
#: a little distorted, do not
|
|
39
|
+
FACING = -0.25
|
|
40
|
+
#: The same for a surface against itself: the walls of a notch that closes touch at its
|
|
41
|
+
#: bottom while their normals are still far from opposite (the two walls of the corner of
|
|
42
|
+
#: a hexagonal cell: 60 degrees apart at rest), and what tells them from the two sides of
|
|
43
|
+
#: an edge of the body is where they lay at rest (:func:`_across`)
|
|
44
|
+
FACING_OWN = 0.6
|
|
45
|
+
#: The state of a slave point (the last: the share of its weight that presses)
|
|
46
|
+
S_LAMBDA, S_FACE, S_XI, S_ETA, S_TX, S_TY, S_TZ, S_WORK, S_GAP, S_PRESSURE, S_SHARE = range(11)
|
|
47
|
+
STATE = 11
|
|
48
|
+
#: The kinds of rigid obstacles
|
|
49
|
+
PLANE, SPHERE, CYLINDER, CONE = 0, 1, 2, 3
|
|
50
|
+
|
|
51
|
+
#: The points of the faces of three nodes (exact to degree 2) and of six (to degree 4):
|
|
52
|
+
#: ξ, η and weights that add up to 1
|
|
53
|
+
POINTS3 = np.array([[1 / 6, 1 / 6, 1 / 3], [2 / 3, 1 / 6, 1 / 3], [1 / 6, 2 / 3, 1 / 3]])
|
|
54
|
+
#: The points at the nodes of the faces, for surfaces whose corners and edges touch
|
|
55
|
+
#: first: the vertices of a face of three nodes (exact to degree 1); the vertices, the
|
|
56
|
+
#: middles of the edges and the centroid of a face of six (exact to degree 3)
|
|
57
|
+
NODES3 = np.array([[0.0, 0.0, 1 / 3], [1.0, 0.0, 1 / 3], [0.0, 1.0, 1 / 3]])
|
|
58
|
+
NODES6 = np.array(
|
|
59
|
+
[
|
|
60
|
+
[0.0, 0.0, 1 / 20],
|
|
61
|
+
[1.0, 0.0, 1 / 20],
|
|
62
|
+
[0.0, 1.0, 1 / 20],
|
|
63
|
+
[0.5, 0.0, 2 / 15],
|
|
64
|
+
[0.5, 0.5, 2 / 15],
|
|
65
|
+
[0.0, 0.5, 2 / 15],
|
|
66
|
+
[1 / 3, 1 / 3, 9 / 20],
|
|
67
|
+
]
|
|
68
|
+
)
|
|
69
|
+
#: The rules of the contact points of a surface
|
|
70
|
+
RULES = ("gauss", "nodes")
|
|
71
|
+
_GA, _GB = 0.445948490915965, 0.091576213509771
|
|
72
|
+
POINTS6 = np.array(
|
|
73
|
+
[
|
|
74
|
+
[_GA, _GA, 0.223381589678011],
|
|
75
|
+
[1.0 - 2.0 * _GA, _GA, 0.223381589678011],
|
|
76
|
+
[_GA, 1.0 - 2.0 * _GA, 0.223381589678011],
|
|
77
|
+
[_GB, _GB, 0.109951743655322],
|
|
78
|
+
[1.0 - 2.0 * _GB, _GB, 0.109951743655322],
|
|
79
|
+
[_GB, 1.0 - 2.0 * _GB, 0.109951743655322],
|
|
80
|
+
]
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@njit(cache=True)
|
|
85
|
+
def shapes(n, xi, eta, shape, dxi, deta):
|
|
86
|
+
"""The functions of the nodes of a face of ``n`` nodes (3, or 6: the corners, then the
|
|
87
|
+
middles of the edges 0-1, 1-2 and 2-0) at a point, and their derivatives."""
|
|
88
|
+
zeta = 1.0 - xi - eta
|
|
89
|
+
if n == 3:
|
|
90
|
+
shape[0], shape[1], shape[2] = zeta, xi, eta
|
|
91
|
+
dxi[0], dxi[1], dxi[2] = -1.0, 1.0, 0.0
|
|
92
|
+
deta[0], deta[1], deta[2] = -1.0, 0.0, 1.0
|
|
93
|
+
return
|
|
94
|
+
shape[0] = zeta * (2.0 * zeta - 1.0)
|
|
95
|
+
shape[1] = xi * (2.0 * xi - 1.0)
|
|
96
|
+
shape[2] = eta * (2.0 * eta - 1.0)
|
|
97
|
+
shape[3] = 4.0 * zeta * xi
|
|
98
|
+
shape[4] = 4.0 * xi * eta
|
|
99
|
+
shape[5] = 4.0 * eta * zeta
|
|
100
|
+
dxi[0] = 1.0 - 4.0 * zeta
|
|
101
|
+
dxi[1] = 4.0 * xi - 1.0
|
|
102
|
+
dxi[2] = 0.0
|
|
103
|
+
dxi[3] = 4.0 * (zeta - xi)
|
|
104
|
+
dxi[4] = 4.0 * eta
|
|
105
|
+
dxi[5] = -4.0 * eta
|
|
106
|
+
deta[0] = 1.0 - 4.0 * zeta
|
|
107
|
+
deta[1] = 0.0
|
|
108
|
+
deta[2] = 4.0 * eta - 1.0
|
|
109
|
+
deta[3] = -4.0 * xi
|
|
110
|
+
deta[4] = 4.0 * xi
|
|
111
|
+
deta[5] = 4.0 * (zeta - eta)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@njit(cache=True)
|
|
115
|
+
def _closest_flat(a, b, c, p):
|
|
116
|
+
"""The coordinates (ξ, η) of the point of the triangle ``a b c`` nearest ``p``
|
|
117
|
+
(Ericson 2005, §5.1.5: the regions of its corners, of its edges and of its face)."""
|
|
118
|
+
ab = b - a
|
|
119
|
+
ac = c - a
|
|
120
|
+
ap = p - a
|
|
121
|
+
d1 = ab[0] * ap[0] + ab[1] * ap[1] + ab[2] * ap[2]
|
|
122
|
+
d2 = ac[0] * ap[0] + ac[1] * ap[1] + ac[2] * ap[2]
|
|
123
|
+
if d1 <= 0.0 and d2 <= 0.0:
|
|
124
|
+
return 0.0, 0.0
|
|
125
|
+
bp = p - b
|
|
126
|
+
d3 = ab[0] * bp[0] + ab[1] * bp[1] + ab[2] * bp[2]
|
|
127
|
+
d4 = ac[0] * bp[0] + ac[1] * bp[1] + ac[2] * bp[2]
|
|
128
|
+
if d3 >= 0.0 and d4 <= d3:
|
|
129
|
+
return 1.0, 0.0
|
|
130
|
+
vc = d1 * d4 - d3 * d2
|
|
131
|
+
if vc <= 0.0 and d1 >= 0.0 and d3 <= 0.0:
|
|
132
|
+
return d1 / (d1 - d3), 0.0
|
|
133
|
+
cp = p - c
|
|
134
|
+
d5 = ab[0] * cp[0] + ab[1] * cp[1] + ab[2] * cp[2]
|
|
135
|
+
d6 = ac[0] * cp[0] + ac[1] * cp[1] + ac[2] * cp[2]
|
|
136
|
+
if d6 >= 0.0 and d5 <= d6:
|
|
137
|
+
return 0.0, 1.0
|
|
138
|
+
vb = d5 * d2 - d1 * d6
|
|
139
|
+
if vb <= 0.0 and d2 >= 0.0 and d6 <= 0.0:
|
|
140
|
+
return 0.0, d2 / (d2 - d6)
|
|
141
|
+
va = d3 * d6 - d5 * d4
|
|
142
|
+
if va <= 0.0 and (d4 - d3) >= 0.0 and (d5 - d6) >= 0.0:
|
|
143
|
+
w = (d4 - d3) / ((d4 - d3) + (d5 - d6))
|
|
144
|
+
return 1.0 - w, w
|
|
145
|
+
denom = 1.0 / (va + vb + vc)
|
|
146
|
+
return vb * denom, vc * denom
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@njit(cache=True)
|
|
150
|
+
def _at(n, x, xi, eta, point, a, b):
|
|
151
|
+
"""The point of a face at (ξ, η) and its two tangents."""
|
|
152
|
+
shape = np.empty(n)
|
|
153
|
+
dxi = np.empty(n)
|
|
154
|
+
deta = np.empty(n)
|
|
155
|
+
shapes(n, xi, eta, shape, dxi, deta)
|
|
156
|
+
for c in range(3):
|
|
157
|
+
point[c] = 0.0
|
|
158
|
+
a[c] = 0.0
|
|
159
|
+
b[c] = 0.0
|
|
160
|
+
for i in range(n):
|
|
161
|
+
point[c] += shape[i] * x[i, c]
|
|
162
|
+
a[c] += dxi[i] * x[i, c]
|
|
163
|
+
b[c] += deta[i] * x[i, c]
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
@njit(cache=True)
|
|
167
|
+
def _edge_point(x, edge, t, point, tangent, curvature):
|
|
168
|
+
"""The point of an edge of a face of six nodes at ``t`` (edge 0: from the corner 0 to
|
|
169
|
+
1, 1: from 1 to 2, 2: from 2 to 0), its derivative and its second derivative."""
|
|
170
|
+
i, j, k = edge, (edge + 1) % 3, 3 + edge # its ends and its middle
|
|
171
|
+
n0 = (1.0 - t) * (1.0 - 2.0 * t)
|
|
172
|
+
n1 = t * (2.0 * t - 1.0)
|
|
173
|
+
n2 = 4.0 * t * (1.0 - t)
|
|
174
|
+
for c in range(3):
|
|
175
|
+
point[c] = n0 * x[i, c] + n1 * x[j, c] + n2 * x[k, c]
|
|
176
|
+
tangent[c] = (
|
|
177
|
+
(4.0 * t - 3.0) * x[i, c] + (4.0 * t - 1.0) * x[j, c] + (4.0 - 8.0 * t) * x[k, c]
|
|
178
|
+
)
|
|
179
|
+
curvature[c] = 4.0 * x[i, c] + 4.0 * x[j, c] - 8.0 * x[k, c]
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
@njit(cache=True)
|
|
183
|
+
def closest(n, x, p, slack, rim, over=RIM):
|
|
184
|
+
"""The coordinates (ξ, η) of the point of a face of ``n`` nodes (``x``: their
|
|
185
|
+
positions) nearest ``p``, the square of their distance, and how it lies: 1, the foot
|
|
186
|
+
of the perpendicular from ``p`` (the gap is then along the normal of the face); 0, a
|
|
187
|
+
point of an edge that the face shares with another of its surface (a point over a
|
|
188
|
+
ridge); -1, a point of the rim of the surface (``rim``: which of the edges 0-1, 1-2
|
|
189
|
+
and 2-0 of the face no other face shares): ``p`` is beyond the surface. A face of six
|
|
190
|
+
nodes may be curved: Newton's method on its surface from the nearest point of the
|
|
191
|
+
triangle of its corners, then, where it leaves the face, on its three edges.
|
|
192
|
+
``slack``: how far outside the face (in its coordinates), across the edges that it
|
|
193
|
+
shares, the foot of the perpendicular is still taken, on the face continued: a point
|
|
194
|
+
that hovers over an edge then stays on one face; ``over``: likewise across the edges
|
|
195
|
+
of the rim (:data:`RIM`)."""
|
|
196
|
+
# how far out each edge lets the foot of the perpendicular be
|
|
197
|
+
out0 = over if rim[0] else slack # the edge 0-1: η = 0
|
|
198
|
+
out1 = over if rim[1] else slack # the edge 1-2: ξ + η = 1
|
|
199
|
+
out2 = over if rim[2] else slack # the edge 2-0: ξ = 0
|
|
200
|
+
point = np.empty(3)
|
|
201
|
+
a = np.empty(3)
|
|
202
|
+
b = np.empty(3)
|
|
203
|
+
if n == 3:
|
|
204
|
+
# the foot of the perpendicular on the plane of the triangle
|
|
205
|
+
for c in range(3):
|
|
206
|
+
a[c] = x[1, c] - x[0, c]
|
|
207
|
+
b[c] = x[2, c] - x[0, c]
|
|
208
|
+
point[c] = p[c] - x[0, c]
|
|
209
|
+
d00 = a[0] * a[0] + a[1] * a[1] + a[2] * a[2]
|
|
210
|
+
d01 = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
|
|
211
|
+
d11 = b[0] * b[0] + b[1] * b[1] + b[2] * b[2]
|
|
212
|
+
d20 = point[0] * a[0] + point[1] * a[1] + point[2] * a[2]
|
|
213
|
+
d21 = point[0] * b[0] + point[1] * b[1] + point[2] * b[2]
|
|
214
|
+
det = d00 * d11 - d01 * d01
|
|
215
|
+
xi = (d11 * d20 - d01 * d21) / det
|
|
216
|
+
eta = (d00 * d21 - d01 * d20) / det
|
|
217
|
+
free = xi >= -out2 and eta >= -out0 and xi + eta <= 1.0 + out1
|
|
218
|
+
if not free:
|
|
219
|
+
xi, eta = _closest_flat(x[0], x[1], x[2], p)
|
|
220
|
+
_at(3, x, xi, eta, point, a, b)
|
|
221
|
+
d2 = (point[0] - p[0]) ** 2 + (point[1] - p[1]) ** 2 + (point[2] - p[2]) ** 2
|
|
222
|
+
return xi, eta, d2, 1 if free else _on_rim(xi, eta, rim)
|
|
223
|
+
xi, eta = _closest_flat(x[0], x[1], x[2], p)
|
|
224
|
+
# the second derivatives of the position: constant on a face of six nodes
|
|
225
|
+
xx = np.empty(3)
|
|
226
|
+
yy = np.empty(3)
|
|
227
|
+
xy = np.empty(3)
|
|
228
|
+
for c in range(3):
|
|
229
|
+
xx[c] = 4.0 * (x[0, c] + x[1, c]) - 8.0 * x[3, c]
|
|
230
|
+
yy[c] = 4.0 * (x[0, c] + x[2, c]) - 8.0 * x[5, c]
|
|
231
|
+
xy[c] = 4.0 * (x[0, c] - x[3, c] + x[4, c] - x[5, c])
|
|
232
|
+
u, v = xi, eta
|
|
233
|
+
free = False
|
|
234
|
+
for _ in range(20):
|
|
235
|
+
_at(6, x, u, v, point, a, b)
|
|
236
|
+
r0, r1, r2 = point[0] - p[0], point[1] - p[1], point[2] - p[2]
|
|
237
|
+
g1 = r0 * a[0] + r1 * a[1] + r2 * a[2]
|
|
238
|
+
g2 = r0 * b[0] + r1 * b[1] + r2 * b[2]
|
|
239
|
+
aa = a[0] * a[0] + a[1] * a[1] + a[2] * a[2]
|
|
240
|
+
bb = b[0] * b[0] + b[1] * b[1] + b[2] * b[2]
|
|
241
|
+
ab = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
|
|
242
|
+
h11 = aa + r0 * xx[0] + r1 * xx[1] + r2 * xx[2]
|
|
243
|
+
h22 = bb + r0 * yy[0] + r1 * yy[1] + r2 * yy[2]
|
|
244
|
+
h12 = ab + r0 * xy[0] + r1 * xy[1] + r2 * xy[2]
|
|
245
|
+
det = h11 * h22 - h12 * h12
|
|
246
|
+
if det <= 1e-12 * aa * bb or h11 <= 0.0: # not convex there: Gauss-Newton
|
|
247
|
+
h11, h22, h12 = aa, bb, ab
|
|
248
|
+
det = h11 * h22 - h12 * h12
|
|
249
|
+
du = -(h22 * g1 - h12 * g2) / det
|
|
250
|
+
dv = -(h11 * g2 - h12 * g1) / det
|
|
251
|
+
u += du
|
|
252
|
+
v += dv
|
|
253
|
+
if u < -0.5 or v < -0.5 or u + v > 1.5:
|
|
254
|
+
break # far outside the face: its edges
|
|
255
|
+
if abs(du) + abs(dv) < 1e-13:
|
|
256
|
+
free = u >= -out2 - 1e-12 and v >= -out0 - 1e-12 and u + v <= 1.0 + out1 + 1e-12
|
|
257
|
+
break
|
|
258
|
+
if free:
|
|
259
|
+
_at(6, x, u, v, point, a, b)
|
|
260
|
+
d2 = (point[0] - p[0]) ** 2 + (point[1] - p[1]) ** 2 + (point[2] - p[2]) ** 2
|
|
261
|
+
return u, v, d2, 1
|
|
262
|
+
best = math.inf
|
|
263
|
+
for edge in range(3):
|
|
264
|
+
if edge == 0:
|
|
265
|
+
t = xi
|
|
266
|
+
elif edge == 1:
|
|
267
|
+
t = eta
|
|
268
|
+
else:
|
|
269
|
+
t = 1.0 - eta
|
|
270
|
+
t = min(max(t, 0.0), 1.0)
|
|
271
|
+
for _ in range(20):
|
|
272
|
+
_edge_point(x, edge, t, point, a, b)
|
|
273
|
+
r0, r1, r2 = point[0] - p[0], point[1] - p[1], point[2] - p[2]
|
|
274
|
+
g = r0 * a[0] + r1 * a[1] + r2 * a[2]
|
|
275
|
+
h = a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + r0 * b[0] + r1 * b[1] + r2 * b[2]
|
|
276
|
+
if h <= 0.0:
|
|
277
|
+
h = a[0] * a[0] + a[1] * a[1] + a[2] * a[2]
|
|
278
|
+
new = min(max(t - g / h, 0.0), 1.0)
|
|
279
|
+
if abs(new - t) < 1e-13:
|
|
280
|
+
t = new
|
|
281
|
+
break
|
|
282
|
+
t = new
|
|
283
|
+
_edge_point(x, edge, t, point, a, b)
|
|
284
|
+
d2 = (point[0] - p[0]) ** 2 + (point[1] - p[1]) ** 2 + (point[2] - p[2]) ** 2
|
|
285
|
+
if d2 < best:
|
|
286
|
+
best = d2
|
|
287
|
+
if edge == 0:
|
|
288
|
+
xi, eta = t, 0.0
|
|
289
|
+
elif edge == 1:
|
|
290
|
+
xi, eta = 1.0 - t, t
|
|
291
|
+
else:
|
|
292
|
+
xi, eta = 0.0, 1.0 - t
|
|
293
|
+
return xi, eta, best, _on_rim(xi, eta, rim)
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
@njit(cache=True)
|
|
297
|
+
def _on_rim(xi, eta, rim):
|
|
298
|
+
"""-1 if a point of the boundary of a face lies on an edge of the rim of its surface,
|
|
299
|
+
0 otherwise."""
|
|
300
|
+
if rim[0] and eta <= 1e-12:
|
|
301
|
+
return -1
|
|
302
|
+
if rim[1] and xi + eta >= 1.0 - 1e-12:
|
|
303
|
+
return -1
|
|
304
|
+
if rim[2] and xi <= 1e-12:
|
|
305
|
+
return -1
|
|
306
|
+
return 0
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
@njit(cache=True)
|
|
310
|
+
def _normal(a, b, n):
|
|
311
|
+
"""The unit normal ``a × b`` of two tangents; returns the norm of the product."""
|
|
312
|
+
n[0] = a[1] * b[2] - a[2] * b[1]
|
|
313
|
+
n[1] = a[2] * b[0] - a[0] * b[2]
|
|
314
|
+
n[2] = a[0] * b[1] - a[1] * b[0]
|
|
315
|
+
norm = math.sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2])
|
|
316
|
+
n[0] /= norm
|
|
317
|
+
n[1] /= norm
|
|
318
|
+
n[2] /= norm
|
|
319
|
+
return norm
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
@njit(cache=True)
|
|
323
|
+
def _share(ns, xs, xi, eta, normal) -> float:
|
|
324
|
+
"""The share of the face of a slave point that the other surface sees: the cosine of
|
|
325
|
+
the angle of the inward normal of the face, at the point, and the ``normal`` of the
|
|
326
|
+
other surface there (1 for two surfaces that lie on each other, 0 for a face seen
|
|
327
|
+
edge-on or from behind). The points at the nodes of the faces carry it: a node of an
|
|
328
|
+
edge of a body belongs to the faces of both sides of the edge, and only what each
|
|
329
|
+
shows to the other surface presses on it (the side of a block that stands on a plane
|
|
330
|
+
carries nothing)."""
|
|
331
|
+
p = np.empty(3)
|
|
332
|
+
a = np.empty(3)
|
|
333
|
+
b = np.empty(3)
|
|
334
|
+
own = np.empty(3)
|
|
335
|
+
_at(ns, xs, xi, eta, p, a, b)
|
|
336
|
+
_normal(a, b, own)
|
|
337
|
+
return max(0.0, -(own[0] * normal[0] + own[1] * normal[1] + own[2] * normal[2]))
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
@njit(cache=True)
|
|
341
|
+
def _friction(par, pressure, slip, normal, old, predict, traction):
|
|
342
|
+
"""The tangential traction of a slave point that moved by ``slip`` along the master
|
|
343
|
+
since the end of the last step (a radial return on the traction of then, turned into
|
|
344
|
+
the tangent plane of now); returns the energy dissipated per unit area."""
|
|
345
|
+
mu, stick = par[P_MU], par[P_STICK]
|
|
346
|
+
traction[0] = traction[1] = traction[2] = 0.0
|
|
347
|
+
if mu <= 0.0:
|
|
348
|
+
return 0.0
|
|
349
|
+
# the traction of the last step in the tangent plane, its norm kept
|
|
350
|
+
t0, t1, t2 = old[S_TX], old[S_TY], old[S_TZ]
|
|
351
|
+
before = math.sqrt(t0 * t0 + t1 * t1 + t2 * t2)
|
|
352
|
+
along = t0 * normal[0] + t1 * normal[1] + t2 * normal[2]
|
|
353
|
+
t0 -= along * normal[0]
|
|
354
|
+
t1 -= along * normal[1]
|
|
355
|
+
t2 -= along * normal[2]
|
|
356
|
+
now = math.sqrt(t0 * t0 + t1 * t1 + t2 * t2)
|
|
357
|
+
if now > 0.0:
|
|
358
|
+
t0 *= before / now
|
|
359
|
+
t1 *= before / now
|
|
360
|
+
t2 *= before / now
|
|
361
|
+
along = slip[0] * normal[0] + slip[1] * normal[1] + slip[2] * normal[2]
|
|
362
|
+
t0 += stick * (slip[0] - along * normal[0])
|
|
363
|
+
t1 += stick * (slip[1] - along * normal[1])
|
|
364
|
+
t2 += stick * (slip[2] - along * normal[2])
|
|
365
|
+
norm = math.sqrt(t0 * t0 + t1 * t1 + t2 * t2)
|
|
366
|
+
limit = mu * max(pressure, 0.0)
|
|
367
|
+
if norm <= limit or predict:
|
|
368
|
+
traction[0], traction[1], traction[2] = t0, t1, t2
|
|
369
|
+
return 0.0
|
|
370
|
+
scale = limit / norm
|
|
371
|
+
traction[0], traction[1], traction[2] = scale * t0, scale * t1, scale * t2
|
|
372
|
+
# the slip of the return: (trial - traction) / stick, along the traction
|
|
373
|
+
return limit * (norm - limit) / stick
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
@njit(cache=True)
|
|
377
|
+
def _touched(par, old) -> bool:
|
|
378
|
+
"""Whether a point pressed or touched the master at the end of the last step."""
|
|
379
|
+
return old[S_PRESSURE] > 0.0 or old[S_GAP] <= par[P_TOUCH]
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
@njit(cache=True)
|
|
383
|
+
def pair_point(ns, nm, xs, xm, xs_old, xm_old, rim, xi, eta, weight, par, old, anchored, anchor,
|
|
384
|
+
predict, f, new): # fmt: skip
|
|
385
|
+
"""The forces (``f``: the nodes of the slave face, then those of the master face) of a
|
|
386
|
+
slave point at (``xi``, ``eta``) of its face against a master face, and its state
|
|
387
|
+
``new``. ``anchored``: the point of the master that faced it at the end of the last
|
|
388
|
+
step lies on this face (at the coordinates of ``old``); otherwise ``anchor`` is its
|
|
389
|
+
position now; a point that no point of the master faced then rubs by the move of
|
|
390
|
+
the two points that touch now since then (``xs_old``, ``xm_old``: the nodes of the two
|
|
391
|
+
faces at the end of the last step). ``rim``: the edges of the master face on the rim
|
|
392
|
+
of its surface.
|
|
393
|
+
``predict``: a point that touched stays closed and sticks. Returns whether the point
|
|
394
|
+
presses."""
|
|
395
|
+
shape = np.empty(ns)
|
|
396
|
+
dxi = np.empty(ns)
|
|
397
|
+
deta = np.empty(ns)
|
|
398
|
+
shapes(ns, xi, eta, shape, dxi, deta)
|
|
399
|
+
p = np.zeros(3)
|
|
400
|
+
for i in range(ns):
|
|
401
|
+
for c in range(3):
|
|
402
|
+
p[c] += shape[i] * xs[i, c]
|
|
403
|
+
u, v, _, _ = closest(nm, xm, p, SLACK, rim, par[P_RIM])
|
|
404
|
+
there = np.empty(3)
|
|
405
|
+
a = np.empty(3)
|
|
406
|
+
b = np.empty(3)
|
|
407
|
+
_at(nm, xm, u, v, there, a, b)
|
|
408
|
+
normal = np.empty(3)
|
|
409
|
+
_normal(a, b, normal)
|
|
410
|
+
gap = (
|
|
411
|
+
(p[0] - there[0]) * normal[0]
|
|
412
|
+
+ (p[1] - there[1]) * normal[1]
|
|
413
|
+
+ (p[2] - there[2]) * normal[2]
|
|
414
|
+
)
|
|
415
|
+
touched = _touched(par, old)
|
|
416
|
+
closed = predict and touched
|
|
417
|
+
pressure = old[S_LAMBDA] - par[P_STIFF] * gap
|
|
418
|
+
for k in range(STATE):
|
|
419
|
+
new[k] = old[k]
|
|
420
|
+
new[S_XI], new[S_ETA], new[S_GAP] = u, v, gap
|
|
421
|
+
new[S_TX] = new[S_TY] = new[S_TZ] = 0.0
|
|
422
|
+
new[S_PRESSURE] = 0.0
|
|
423
|
+
new[S_SHARE] = 1.0
|
|
424
|
+
for k in range(3 * (ns + nm)):
|
|
425
|
+
f[k] = 0.0
|
|
426
|
+
if pressure <= 0.0 and not closed:
|
|
427
|
+
return False
|
|
428
|
+
if par[P_SHARE] > 0.0: # a point at a node: what its face shows to the master
|
|
429
|
+
new[S_SHARE] = _share(ns, xs, xi, eta, normal)
|
|
430
|
+
weight = weight * new[S_SHARE]
|
|
431
|
+
new[S_PRESSURE] = max(pressure, 0.0)
|
|
432
|
+
traction = np.zeros(3)
|
|
433
|
+
shape_m = np.empty(nm)
|
|
434
|
+
shapes(nm, u, v, shape_m, np.empty(nm), np.empty(nm))
|
|
435
|
+
if par[P_MU] > 0.0:
|
|
436
|
+
slip = np.empty(3)
|
|
437
|
+
if not touched: # it comes into contact: the move of the two points over the step
|
|
438
|
+
for c in range(3):
|
|
439
|
+
slip[c] = p[c] - there[c]
|
|
440
|
+
for i in range(ns):
|
|
441
|
+
slip[c] -= shape[i] * xs_old[i, c]
|
|
442
|
+
for i in range(nm):
|
|
443
|
+
slip[c] += shape_m[i] * xm_old[i, c]
|
|
444
|
+
elif anchored:
|
|
445
|
+
_at(nm, xm, old[S_XI], old[S_ETA], slip, a, b)
|
|
446
|
+
for c in range(3):
|
|
447
|
+
slip[c] = there[c] - slip[c]
|
|
448
|
+
else:
|
|
449
|
+
for c in range(3):
|
|
450
|
+
slip[c] = there[c] - anchor[c]
|
|
451
|
+
rubbed = _friction(par, pressure, slip, normal, old, closed, traction)
|
|
452
|
+
new[S_WORK] = old[S_WORK] + new[S_SHARE] * rubbed
|
|
453
|
+
new[S_TX], new[S_TY], new[S_TZ] = traction[0], traction[1], traction[2]
|
|
454
|
+
for c in range(3):
|
|
455
|
+
force = weight * (pressure * normal[c] - traction[c]) # on the slave point
|
|
456
|
+
for i in range(ns):
|
|
457
|
+
f[3 * i + c] = -shape[i] * force
|
|
458
|
+
for i in range(nm):
|
|
459
|
+
f[3 * (ns + i) + c] = shape_m[i] * force
|
|
460
|
+
return True
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
@njit(cache=True)
|
|
464
|
+
def _slave_normal(ns, xs, xi, eta, p, normal):
|
|
465
|
+
"""A slave point and the outward normal of its face there."""
|
|
466
|
+
a = np.empty(3)
|
|
467
|
+
b = np.empty(3)
|
|
468
|
+
_at(ns, xs, xi, eta, p, a, b)
|
|
469
|
+
_normal(a, b, normal)
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
@njit(cache=True)
|
|
473
|
+
def _across(nm, xm, p, rim, par) -> bool:
|
|
474
|
+
"""Whether a face of a surface is across a wall of solid from a point of the same
|
|
475
|
+
surface: at rest (``xm``: the nodes of the face, ``p``: the point, both in the
|
|
476
|
+
reference positions), the point lies behind the face, within the distance
|
|
477
|
+
:data:`P_BEHIND` of it. The two sides of a thin ligament, back to back, look like two
|
|
478
|
+
surfaces that went through each other by its thickness; surfaces that do come to
|
|
479
|
+
touch were in front of each other at rest."""
|
|
480
|
+
u, v, d2, _ = closest(nm, xm, p, 0.0, rim)
|
|
481
|
+
if d2 > par[P_BEHIND] * par[P_BEHIND]:
|
|
482
|
+
return False
|
|
483
|
+
there = np.empty(3)
|
|
484
|
+
a = np.empty(3)
|
|
485
|
+
b = np.empty(3)
|
|
486
|
+
normal = np.empty(3)
|
|
487
|
+
_at(nm, xm, u, v, there, a, b)
|
|
488
|
+
_normal(a, b, normal)
|
|
489
|
+
gap = ((p[0] - there[0]) * normal[0] + (p[1] - there[1]) * normal[1]
|
|
490
|
+
+ (p[2] - there[2]) * normal[2]) # fmt: skip
|
|
491
|
+
return gap < -par[P_TOUCH]
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
@njit(parallel=True, cache=True)
|
|
495
|
+
def pair_forces(x, x_old, x_ref, ident, slave, master, rims, face, xi, eta, weight, candidates,
|
|
496
|
+
last, par, old, new, own, tangent, predict, fe, ke, nodes, active): # fmt: skip
|
|
497
|
+
"""The forces and tangents of the slave points of a pair of surfaces in the positions
|
|
498
|
+
``x`` of the nodes (``x_old``: at the end of the last step; ``x_ref``: at rest;
|
|
499
|
+
``ident``: the node that each is, itself or, for the image of a node of a periodic
|
|
500
|
+
cell, the one that it is the same as across a face of the cell). For
|
|
501
|
+
each point, the master face among its ``candidates`` whose nearest point is the
|
|
502
|
+
closest, among those that face it (opposite normals) within the deepest penetration
|
|
503
|
+
looked for, and not beyond the rim of the master surface
|
|
504
|
+
(``rims``: the edges of each master face that no other shares); ``own``: the two
|
|
505
|
+
surfaces are one (the faces that share a node with that of the point are left out,
|
|
506
|
+
and those that it has gone through but that lay behind it at rest, across a wall of
|
|
507
|
+
solid: :func:`_across`).
|
|
508
|
+
``last``: the face of each point at the
|
|
509
|
+
last evaluation (-1: none), which it keeps while the foot of its perpendicular stays on
|
|
510
|
+
it or within :data:`SLACK` of it: a point that hovers over an edge between two faces,
|
|
511
|
+
where the tangent of the forces breaks, would otherwise go from one to the other at
|
|
512
|
+
each iteration. ``fe`` (points x dofs), ``ke`` (points x
|
|
513
|
+
dofs x dofs, by central differences of the forces), ``nodes`` (the nodes of the dofs)
|
|
514
|
+
and ``active`` (whether the point presses)."""
|
|
515
|
+
ns, nm = slave.shape[1], master.shape[1]
|
|
516
|
+
nd = 3 * (ns + nm)
|
|
517
|
+
for q in prange(face.shape[0]):
|
|
518
|
+
xs = np.empty((ns, 3))
|
|
519
|
+
for i in range(ns):
|
|
520
|
+
xs[i] = x[slave[face[q], i]]
|
|
521
|
+
p = np.empty(3)
|
|
522
|
+
normal_s = np.empty(3)
|
|
523
|
+
_slave_normal(ns, xs, xi[q], eta[q], p, normal_s)
|
|
524
|
+
xm = np.empty((nm, 3))
|
|
525
|
+
there = np.empty(3)
|
|
526
|
+
a = np.empty(3)
|
|
527
|
+
b = np.empty(3)
|
|
528
|
+
normal = np.empty(3)
|
|
529
|
+
p_ref = np.empty(3) # the point at rest, for the faces that it has gone through
|
|
530
|
+
if own:
|
|
531
|
+
for i in range(ns):
|
|
532
|
+
xs[i] = x_ref[slave[face[q], i]]
|
|
533
|
+
_slave_normal(ns, xs, xi[q], eta[q], p_ref, normal)
|
|
534
|
+
for i in range(ns):
|
|
535
|
+
xs[i] = x[slave[face[q], i]]
|
|
536
|
+
best, best_d2, best_gap = -1, math.inf, math.inf
|
|
537
|
+
before = int(old[q, S_FACE])
|
|
538
|
+
apart = FACING_OWN if own else FACING
|
|
539
|
+
if last[q] >= 0: # the face of the last evaluation, while the point is over it
|
|
540
|
+
m = last[q]
|
|
541
|
+
for i in range(nm):
|
|
542
|
+
xm[i] = x[master[m, i]]
|
|
543
|
+
u, v, d2, how = closest(nm, xm, p, SLACK, rims[m], par[P_RIM])
|
|
544
|
+
if how == 1:
|
|
545
|
+
_at(nm, xm, u, v, there, a, b)
|
|
546
|
+
_normal(a, b, normal)
|
|
547
|
+
gap = ((p[0] - there[0]) * normal[0] + (p[1] - there[1]) * normal[1]
|
|
548
|
+
+ (p[2] - there[2]) * normal[2]) # fmt: skip
|
|
549
|
+
facing = (normal[0] * normal_s[0] + normal[1] * normal_s[1]
|
|
550
|
+
+ normal[2] * normal_s[2]) < apart # fmt: skip
|
|
551
|
+
if facing and gap >= -par[P_DEPTH]:
|
|
552
|
+
through = False
|
|
553
|
+
if own and gap < 0.0:
|
|
554
|
+
for i in range(nm):
|
|
555
|
+
xm[i] = x_ref[master[m, i]]
|
|
556
|
+
through = _across(nm, xm, p_ref, rims[m], par)
|
|
557
|
+
if not through:
|
|
558
|
+
best, best_d2, best_gap = m, d2, gap
|
|
559
|
+
kept = best >= 0
|
|
560
|
+
for k in range(candidates.shape[1]):
|
|
561
|
+
m = candidates[q, k]
|
|
562
|
+
if m < 0 or kept:
|
|
563
|
+
continue
|
|
564
|
+
if own:
|
|
565
|
+
shared = False
|
|
566
|
+
for i in range(3):
|
|
567
|
+
for j in range(3):
|
|
568
|
+
if ident[slave[face[q], i]] == ident[master[m, j]]:
|
|
569
|
+
shared = True
|
|
570
|
+
if shared:
|
|
571
|
+
continue
|
|
572
|
+
for i in range(nm):
|
|
573
|
+
xm[i] = x[master[m, i]]
|
|
574
|
+
u, v, d2, how = closest(nm, xm, p, 0.0, rims[m], par[P_RIM])
|
|
575
|
+
if how < 0:
|
|
576
|
+
continue # beyond the rim of the surface
|
|
577
|
+
if how == 0:
|
|
578
|
+
# on an edge that two faces share: over a ridge of the surface (the point
|
|
579
|
+
# is then within 60 degrees of the normal of the face), or beside the
|
|
580
|
+
# face, a little further than the corner where the rim meets that edge
|
|
581
|
+
_at(nm, xm, u, v, there, a, b)
|
|
582
|
+
_normal(a, b, normal)
|
|
583
|
+
along = ((p[0] - there[0]) * normal[0] + (p[1] - there[1]) * normal[1]
|
|
584
|
+
+ (p[2] - there[2]) * normal[2]) # fmt: skip
|
|
585
|
+
beside = d2 - along * along
|
|
586
|
+
if beside > (0.02 * par[P_SIZE]) ** 2 and along * along < 0.25 * d2:
|
|
587
|
+
continue
|
|
588
|
+
# a point on an edge is as near two faces: it stays on that of the last step,
|
|
589
|
+
# or goes to the first of them, whatever the rounding and the order of the search
|
|
590
|
+
margin = 1e-9 * best_d2 + 1e-300
|
|
591
|
+
if d2 > best_d2 + margin:
|
|
592
|
+
continue
|
|
593
|
+
if d2 >= best_d2 - margin and (best == before or (m != before and m > best)):
|
|
594
|
+
continue
|
|
595
|
+
_at(nm, xm, u, v, there, a, b)
|
|
596
|
+
_normal(a, b, normal)
|
|
597
|
+
if (normal[0] * normal_s[0] + normal[1] * normal_s[1]
|
|
598
|
+
+ normal[2] * normal_s[2]) >= apart: # fmt: skip
|
|
599
|
+
continue # a face that does not face the point: the other side of a wall
|
|
600
|
+
gap = ((p[0] - there[0]) * normal[0] + (p[1] - there[1]) * normal[1]
|
|
601
|
+
+ (p[2] - there[2]) * normal[2]) # fmt: skip
|
|
602
|
+
if gap < -par[P_DEPTH]:
|
|
603
|
+
continue
|
|
604
|
+
if own and gap < 0.0:
|
|
605
|
+
for i in range(nm):
|
|
606
|
+
xm[i] = x_ref[master[m, i]]
|
|
607
|
+
if _across(nm, xm, p_ref, rims[m], par):
|
|
608
|
+
continue # the other side of a ligament, not a face gone through
|
|
609
|
+
best, best_d2, best_gap = m, d2, gap
|
|
610
|
+
active[q] = False
|
|
611
|
+
for k in range(STATE):
|
|
612
|
+
new[q, k] = old[q, k]
|
|
613
|
+
new[q, S_FACE] = best
|
|
614
|
+
new[q, S_GAP] = best_gap
|
|
615
|
+
new[q, S_PRESSURE] = 0.0
|
|
616
|
+
new[q, S_TX] = new[q, S_TY] = new[q, S_TZ] = 0.0
|
|
617
|
+
if best < 0:
|
|
618
|
+
continue
|
|
619
|
+
xs_old = np.empty((ns, 3))
|
|
620
|
+
xm_old = np.empty((nm, 3))
|
|
621
|
+
for i in range(ns):
|
|
622
|
+
xs_old[i] = x_old[slave[face[q], i]]
|
|
623
|
+
for i in range(nm):
|
|
624
|
+
xm[i] = x[master[best, i]]
|
|
625
|
+
xm_old[i] = x_old[master[best, i]]
|
|
626
|
+
anchored = before == best
|
|
627
|
+
anchor = np.zeros(3)
|
|
628
|
+
if not anchored and before >= 0: # the point that faced it, on another face
|
|
629
|
+
xo = np.empty((nm, 3))
|
|
630
|
+
for i in range(nm):
|
|
631
|
+
xo[i] = x[master[before, i]]
|
|
632
|
+
_at(nm, xo, old[q, S_XI], old[q, S_ETA], anchor, a, b)
|
|
633
|
+
state = old[q].copy()
|
|
634
|
+
if before < 0: # no point faced it: nothing to rub against yet
|
|
635
|
+
state[S_GAP] = math.inf
|
|
636
|
+
state[S_PRESSURE] = 0.0
|
|
637
|
+
f = np.empty(nd)
|
|
638
|
+
fresh = np.empty(STATE)
|
|
639
|
+
pressed = pair_point(ns, nm, xs, xm, xs_old, xm_old, rims[best], xi[q], eta[q], weight[q],
|
|
640
|
+
par, state, anchored, anchor, False, f, fresh) # fmt: skip
|
|
641
|
+
fresh[S_FACE] = best
|
|
642
|
+
new[q] = fresh
|
|
643
|
+
closed = predict and _touched(par, state)
|
|
644
|
+
if not (pressed or closed):
|
|
645
|
+
continue
|
|
646
|
+
active[q] = True
|
|
647
|
+
fe[q] = f
|
|
648
|
+
for i in range(ns):
|
|
649
|
+
nodes[q, i] = slave[face[q], i]
|
|
650
|
+
for i in range(nm):
|
|
651
|
+
nodes[q, ns + i] = master[best, i]
|
|
652
|
+
if not tangent:
|
|
653
|
+
continue
|
|
654
|
+
size = math.sqrt(best_d2) + math.sqrt(
|
|
655
|
+
(xm[1, 0] - xm[0, 0]) ** 2 + (xm[1, 1] - xm[0, 1]) ** 2 + (xm[1, 2] - xm[0, 2]) ** 2
|
|
656
|
+
)
|
|
657
|
+
step = 1e-7 * size
|
|
658
|
+
fp = np.empty(nd)
|
|
659
|
+
fm = np.empty(nd)
|
|
660
|
+
dummy = np.empty(STATE)
|
|
661
|
+
for j in range(nd):
|
|
662
|
+
node, c = j // 3, j % 3
|
|
663
|
+
target = xs if node < ns else xm
|
|
664
|
+
row = node if node < ns else node - ns
|
|
665
|
+
keep = target[row, c]
|
|
666
|
+
target[row, c] = keep + step
|
|
667
|
+
pair_point(ns, nm, xs, xm, xs_old, xm_old, rims[best], xi[q], eta[q], weight[q],
|
|
668
|
+
par, state, anchored, anchor, closed, fp, dummy) # fmt: skip
|
|
669
|
+
target[row, c] = keep - step
|
|
670
|
+
pair_point(ns, nm, xs, xm, xs_old, xm_old, rims[best], xi[q], eta[q], weight[q],
|
|
671
|
+
par, state, anchored, anchor, closed, fm, dummy) # fmt: skip
|
|
672
|
+
target[row, c] = keep
|
|
673
|
+
for i in range(nd):
|
|
674
|
+
ke[q, i, j] = (fp[i] - fm[i]) / (2.0 * step)
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
@njit(cache=True)
|
|
678
|
+
def obstacle_distance(kind, geometry, p, normal):
|
|
679
|
+
"""The signed distance of the point ``p`` to a rigid obstacle (positive outside it)
|
|
680
|
+
and its outward normal there. ``geometry``: a point (0-2), a unit axis (3-5), a size
|
|
681
|
+
(6: the radius of a sphere or of a cylinder, the half-angle of a cone) and a sign (7:
|
|
682
|
+
-1 for the inside of a sphere or of a cylinder that holds the body). A plane: its
|
|
683
|
+
point and its outward normal; a sphere: its centre; a cylinder: a point of its axis;
|
|
684
|
+
a cone: its apex and its axis, from the apex into the cone."""
|
|
685
|
+
d0, d1, d2 = p[0] - geometry[0], p[1] - geometry[1], p[2] - geometry[2]
|
|
686
|
+
a0, a1, a2 = geometry[3], geometry[4], geometry[5]
|
|
687
|
+
if kind == PLANE:
|
|
688
|
+
normal[0], normal[1], normal[2] = a0, a1, a2
|
|
689
|
+
return d0 * a0 + d1 * a1 + d2 * a2
|
|
690
|
+
sign = geometry[7]
|
|
691
|
+
if kind == SPHERE:
|
|
692
|
+
r = math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)
|
|
693
|
+
if r > 0.0:
|
|
694
|
+
normal[0], normal[1], normal[2] = sign * d0 / r, sign * d1 / r, sign * d2 / r
|
|
695
|
+
else:
|
|
696
|
+
normal[0], normal[1], normal[2] = sign * a0, sign * a1, sign * a2
|
|
697
|
+
return sign * (r - geometry[6])
|
|
698
|
+
along = d0 * a0 + d1 * a1 + d2 * a2
|
|
699
|
+
r0, r1, r2 = d0 - along * a0, d1 - along * a1, d2 - along * a2
|
|
700
|
+
r = math.sqrt(r0 * r0 + r1 * r1 + r2 * r2)
|
|
701
|
+
if kind == CYLINDER:
|
|
702
|
+
if r > 0.0:
|
|
703
|
+
normal[0], normal[1], normal[2] = sign * r0 / r, sign * r1 / r, sign * r2 / r
|
|
704
|
+
else:
|
|
705
|
+
normal[0], normal[1], normal[2] = 0.0, 0.0, 0.0
|
|
706
|
+
return sign * (r - geometry[6])
|
|
707
|
+
# a cone: its side where the nearest point is on it, its apex otherwise
|
|
708
|
+
cos, sin = math.cos(geometry[6]), math.sin(geometry[6])
|
|
709
|
+
if along * cos + r * sin <= 0.0: # behind the apex
|
|
710
|
+
full = math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)
|
|
711
|
+
if full > 0.0:
|
|
712
|
+
normal[0], normal[1], normal[2] = d0 / full, d1 / full, d2 / full
|
|
713
|
+
else:
|
|
714
|
+
normal[0], normal[1], normal[2] = -a0, -a1, -a2
|
|
715
|
+
return full
|
|
716
|
+
if r > 0.0:
|
|
717
|
+
e0, e1, e2 = r0 / r, r1 / r, r2 / r
|
|
718
|
+
else: # on the axis, inside: any radial direction
|
|
719
|
+
e0, e1, e2 = _any_normal(a0, a1, a2)
|
|
720
|
+
normal[0] = cos * e0 - sin * a0
|
|
721
|
+
normal[1] = cos * e1 - sin * a1
|
|
722
|
+
normal[2] = cos * e2 - sin * a2
|
|
723
|
+
return r * cos - along * sin
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
@njit(cache=True)
|
|
727
|
+
def _any_normal(a0, a1, a2):
|
|
728
|
+
"""A unit vector normal to the unit vector ``a``."""
|
|
729
|
+
if abs(a0) < 0.9:
|
|
730
|
+
b0, b1, b2 = 1.0, 0.0, 0.0
|
|
731
|
+
else:
|
|
732
|
+
b0, b1, b2 = 0.0, 1.0, 0.0
|
|
733
|
+
along = b0 * a0 + b1 * a1 + b2 * a2
|
|
734
|
+
b0, b1, b2 = b0 - along * a0, b1 - along * a1, b2 - along * a2
|
|
735
|
+
norm = math.sqrt(b0 * b0 + b1 * b1 + b2 * b2)
|
|
736
|
+
return b0 / norm, b1 / norm, b2 / norm
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
@njit(cache=True)
|
|
740
|
+
def obstacle_point(ns, xs, xi, eta, weight, kind, geometry, par, old, predict, f, new):
|
|
741
|
+
"""The forces (the nodes of its face) of a slave point against a rigid obstacle and
|
|
742
|
+
its state ``new``; its state keeps, in place of a point of a master face, its position
|
|
743
|
+
relative to the obstacle at the end of the last step. Returns whether it presses."""
|
|
744
|
+
shape = np.empty(ns)
|
|
745
|
+
shapes(ns, xi, eta, shape, np.empty(ns), np.empty(ns))
|
|
746
|
+
p = np.zeros(3)
|
|
747
|
+
for i in range(ns):
|
|
748
|
+
for c in range(3):
|
|
749
|
+
p[c] += shape[i] * xs[i, c]
|
|
750
|
+
normal = np.empty(3)
|
|
751
|
+
gap = obstacle_distance(kind, geometry, p, normal)
|
|
752
|
+
touched = _touched(par, old)
|
|
753
|
+
closed = predict and touched
|
|
754
|
+
pressure = old[S_LAMBDA] - par[P_STIFF] * gap
|
|
755
|
+
for k in range(STATE):
|
|
756
|
+
new[k] = old[k]
|
|
757
|
+
new[S_GAP] = gap
|
|
758
|
+
new[S_TX] = new[S_TY] = new[S_TZ] = 0.0
|
|
759
|
+
new[S_PRESSURE] = 0.0
|
|
760
|
+
# where it is, relative to the obstacle
|
|
761
|
+
new[S_FACE], new[S_XI], new[S_ETA] = p[0] - geometry[0], p[1] - geometry[1], p[2] - geometry[2]
|
|
762
|
+
new[S_SHARE] = 1.0
|
|
763
|
+
for k in range(3 * ns):
|
|
764
|
+
f[k] = 0.0
|
|
765
|
+
if pressure <= 0.0 and not closed:
|
|
766
|
+
return False
|
|
767
|
+
if par[P_SHARE] > 0.0: # a point at a node: what its face shows to the obstacle
|
|
768
|
+
new[S_SHARE] = _share(ns, xs, xi, eta, normal)
|
|
769
|
+
weight = weight * new[S_SHARE]
|
|
770
|
+
new[S_PRESSURE] = max(pressure, 0.0)
|
|
771
|
+
traction = np.zeros(3)
|
|
772
|
+
if par[P_MU] > 0.0:
|
|
773
|
+
slip = np.empty(3)
|
|
774
|
+
slip[0] = new[S_FACE] - old[S_FACE]
|
|
775
|
+
slip[1] = new[S_XI] - old[S_XI]
|
|
776
|
+
slip[2] = new[S_ETA] - old[S_ETA]
|
|
777
|
+
rubbed = _friction(par, pressure, slip, normal, old, closed, traction)
|
|
778
|
+
new[S_WORK] = old[S_WORK] + new[S_SHARE] * rubbed
|
|
779
|
+
new[S_TX], new[S_TY], new[S_TZ] = traction[0], traction[1], traction[2]
|
|
780
|
+
for c in range(3):
|
|
781
|
+
force = weight * (pressure * normal[c] - traction[c]) # on the slave point
|
|
782
|
+
for i in range(ns):
|
|
783
|
+
f[3 * i + c] = -shape[i] * force
|
|
784
|
+
return True
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
@njit(parallel=True, cache=True)
|
|
788
|
+
def obstacle_forces(x, slave, face, xi, eta, weight, kind, geometry, par, old, new, tangent,
|
|
789
|
+
predict, fe, ke, active): # fmt: skip
|
|
790
|
+
"""The forces and tangents (central differences) of the slave points of a surface
|
|
791
|
+
against a rigid obstacle in the positions ``x`` of the nodes."""
|
|
792
|
+
ns = slave.shape[1]
|
|
793
|
+
nd = 3 * ns
|
|
794
|
+
for q in prange(face.shape[0]):
|
|
795
|
+
xs = np.empty((ns, 3))
|
|
796
|
+
for i in range(ns):
|
|
797
|
+
xs[i] = x[slave[face[q], i]]
|
|
798
|
+
f = np.empty(nd)
|
|
799
|
+
fresh = np.empty(STATE)
|
|
800
|
+
pressed = obstacle_point(ns, xs, xi[q], eta[q], weight[q], kind, geometry, par, old[q],
|
|
801
|
+
False, f, fresh) # fmt: skip
|
|
802
|
+
new[q] = fresh
|
|
803
|
+
closed = predict and _touched(par, old[q])
|
|
804
|
+
active[q] = pressed or closed
|
|
805
|
+
if not active[q]:
|
|
806
|
+
continue
|
|
807
|
+
fe[q] = f
|
|
808
|
+
if not tangent:
|
|
809
|
+
continue
|
|
810
|
+
step = 1e-7 * math.sqrt(
|
|
811
|
+
(xs[1, 0] - xs[0, 0]) ** 2 + (xs[1, 1] - xs[0, 1]) ** 2 + (xs[1, 2] - xs[0, 2]) ** 2
|
|
812
|
+
)
|
|
813
|
+
fp = np.empty(nd)
|
|
814
|
+
fm = np.empty(nd)
|
|
815
|
+
dummy = np.empty(STATE)
|
|
816
|
+
for j in range(nd):
|
|
817
|
+
node, c = j // 3, j % 3
|
|
818
|
+
keep = xs[node, c]
|
|
819
|
+
xs[node, c] = keep + step
|
|
820
|
+
obstacle_point(ns, xs, xi[q], eta[q], weight[q], kind, geometry, par, old[q],
|
|
821
|
+
closed, fp, dummy) # fmt: skip
|
|
822
|
+
xs[node, c] = keep - step
|
|
823
|
+
obstacle_point(ns, xs, xi[q], eta[q], weight[q], kind, geometry, par, old[q],
|
|
824
|
+
closed, fm, dummy) # fmt: skip
|
|
825
|
+
xs[node, c] = keep
|
|
826
|
+
for i in range(nd):
|
|
827
|
+
ke[q, i, j] = (fp[i] - fm[i]) / (2.0 * step)
|