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,1178 @@
|
|
|
1
|
+
"""Mixed-mode cracks in 3D, in small and finite strains: the energy release rate along the
|
|
2
|
+
front by the G-θ method, its partition into the modes I, II and III by the interaction
|
|
3
|
+
integrals, the direction of kinking, and the propagation of kinked cracks on meshes
|
|
4
|
+
conforming to them, rebuilt by MMG at each step (as Z-cracks).
|
|
5
|
+
|
|
6
|
+
*Problem.* The crack (a planar :class:`~morphogen.fracture.lefm.Crack` or a
|
|
7
|
+
:class:`KinkedCrack`) is opened on a mesh conforming to it (its lips duplicated,
|
|
8
|
+
:func:`~morphogen.fracture.lefm.crack_faces`), the displacements prescribed on node sets;
|
|
9
|
+
the bulk is linear elastic in small strains or a compressible neo-Hookean solid in finite
|
|
10
|
+
strains (total Lagrangian), the lips free or in frictionless contact (a penalty against
|
|
11
|
+
their interpenetration, under shear and closure): :func:`solve_crack`.
|
|
12
|
+
|
|
13
|
+
*Energy release rate* (the G-θ method of Destuynder & Djaoua 1981, as in Code_Aster and
|
|
14
|
+
Z-set): for a virtual advance ``θ = q(r) w(s) d`` of the front (``d`` the direction of
|
|
15
|
+
propagation, ``q`` from 1 within ``r_in`` of the front to 0 beyond ``r_out``, ``w`` a weight
|
|
16
|
+
along the front), ``∫ G w ds = ∫ (Hᵀ P - W I) : ∇θ dV`` with the displacement gradient
|
|
17
|
+
``H``, the first Piola-Kirchhoff stress ``P`` and the energy density ``W`` of the reference
|
|
18
|
+
configuration (Eshelby's energy-momentum tensor): exact for hyperelastic solids in finite
|
|
19
|
+
strains, the J-integral in small strains. The weights are the piecewise linear functions
|
|
20
|
+
of stations along the front, giving ``G(s)`` (a small system with the mass matrix of the
|
|
21
|
+
front), or 1, giving its mean. ``θ`` stays tangent to the lips: its domain does not reach
|
|
22
|
+
the mouth of the crack, nor the last kink of a kinked one. The check: the energy of the
|
|
23
|
+
body at fixed prescribed displacements, ``G = -dU/dA`` (:func:`energy_release_rate`).
|
|
24
|
+
|
|
25
|
+
*Modes* (the interaction integral of Yau, Wang & Corten 1980, in 3D as Moran & Shih 1987):
|
|
26
|
+
with the same ``θ``, the cross term of the energy-momentum tensors of the body and of the
|
|
27
|
+
asymptotic field of a unit factor of each mode (plane strain for I and II, antiplane for
|
|
28
|
+
III, in the axes ``(d, n, t = d × n)`` of the front), ``M = ∫ (σ_ij u'_i,k + σ'_ij u_i,k -
|
|
29
|
+
σ' : ε δ_kj) θ_k,j dV``, gives ``K_I = E' M_I / 2``, ``K_II = E' M_II / 2`` and ``K_III =
|
|
30
|
+
μ M_III`` (``E' = E / (1 - ν²)``, the isotropic elasticity of the material at the front,
|
|
31
|
+
the Voigt-Reuss-Hill estimate of an anisotropic one such as a crystal):
|
|
32
|
+
more accurate than the jumps of the lips, whose fit by ``sqrt(r)`` on linear elements
|
|
33
|
+
biases the mixity. Along a curved front the auxiliary fields, those of a straight front in
|
|
34
|
+
the turning axes of the front, are neither compatible nor balanced: the divergence of the
|
|
35
|
+
cross tensor, ``∫ (σ_ij (u'_i,kj - ε'_ij,k) + σ'_ij,j u_i,k) θ_k dV``, is added (Gosz &
|
|
36
|
+
Moran 2002), which makes the factors independent of the domain (zero along a straight
|
|
37
|
+
front, where it is skipped). Behind the front the auxiliary fields of an element are those
|
|
38
|
+
of its side of the crack (the angle continued across the plane of the crack): an element
|
|
39
|
+
flat along the lips, whose centroid lies within a step of differences of the plane (or
|
|
40
|
+
across it, where the mesh moved the lips), would otherwise difference the two sides of the
|
|
41
|
+
auxiliary displacement. The energy release rate of the G-θ method is shared in the
|
|
42
|
+
proportions ``K_I² / E'``, ``K_II² / E'``, ``K_III² / 2μ`` (in small strains, it converges
|
|
43
|
+
with their sum). The mean rotation of the domain, which adds nothing to the integrals, is
|
|
44
|
+
removed from the displacement gradient (the auxiliary stress is not in discrete
|
|
45
|
+
equilibrium: without it, a rigid rotation would bias the factors). In finite strains,
|
|
46
|
+
where the modes do not separate, the integral takes the stress and the displacement
|
|
47
|
+
gradient turned back by the rotation of the polar decomposition of the mean deformation
|
|
48
|
+
gradient around the front: an estimate of the mixity of the remote field. Lips in contact
|
|
49
|
+
carry tractions, whose work in the auxiliary fields, ``∫ t · (∇u' θ) dS`` over the lips,
|
|
50
|
+
is subtracted (their work in the actual field, that of the penalty, is neglected in
|
|
51
|
+
``G``); frictionless, it only concerns the mode I, which lips closed at the front do not
|
|
52
|
+
have: ``K_I ≥ 0`` (the closure of the singular integral near the front being the least
|
|
53
|
+
accurate part).
|
|
54
|
+
|
|
55
|
+
*Kinking* (Erdogan & Sih 1963): the direction of the largest hoop stress, ``θ = 2 atan((K_I
|
|
56
|
+
- sqrt(K_I² + 8 K_II²)) / (4 K_II))`` from ``d`` towards ``n`` (-70.5° in pure mode II); the
|
|
57
|
+
tearing mode III, which twists the front, counts in ``G`` but does not turn the path here.
|
|
58
|
+
|
|
59
|
+
*Morphologies* (crack meshes whose phases are those of the materials and whose sides of the
|
|
60
|
+
crack are apart, :func:`~morphogen.fracture.lefm.crack_mesh` with ``morphology``): the
|
|
61
|
+
material at the front is that of the elements in which the points of the front lie; the
|
|
62
|
+
interaction integrals, their ``G`` and the driving force at the tip (``energy="tip"``) take
|
|
63
|
+
``θ`` zero beyond ``r_in`` at the nodes outside that material (its interfaces with the
|
|
64
|
+
others, the other materials, the walls of the pores), so that they are those of the
|
|
65
|
+
material at the front, the configurational forces of the inclusions and of the pores in the
|
|
66
|
+
domain left out (the inhomogeneity term of Simha, Fischer, Kolednik & Chen 2003); the far J
|
|
67
|
+
(``"work"``, ``"free"``) keeps them. A front grown into a pore goes through it
|
|
68
|
+
(:func:`through_voids`).
|
|
69
|
+
|
|
70
|
+
*Inelastic bulks* (``bulk="points"``, or automatically when a phase is inelastic: the
|
|
71
|
+
behaviours of morphoGen's points, :mod:`morphogen.fracture.bulk`: von Mises
|
|
72
|
+
elasto-viscoplasticity, crystal plasticity, MFront laws, in small and finite strains).
|
|
73
|
+
The energy-momentum tensor then takes either the work density ``w = ∫ P : dF`` (the J of
|
|
74
|
+
the deformation theory of plasticity, independent of the domain under monotonic
|
|
75
|
+
proportional loading, and the release of the work of the loads at fixed displacements,
|
|
76
|
+
``-dW/dA``, the J of Begley & Landes), or the free energy ``ψ``: its divergence is then
|
|
77
|
+
``-∂ψ/∂α · ∇α`` in the zone where the internal variables ``α`` vary, so that ``∫ (Hᵀ P - ψ
|
|
78
|
+
I) : ∇θ dV`` grows with the domain, and adding ``-∫ ∂ψ/∂α · ∇α · θ dV`` gives the driving force
|
|
79
|
+
at the tip (the configurational force of Simha, Fischer, Shan, Chen & Kolednik 2008),
|
|
80
|
+
smaller than the far J by the shielding of the plastic zone: ``energy="work"``, ``"free"``
|
|
81
|
+
or ``"tip"`` of :meth:`CrackSolution.release_rate` (the same for elastic bodies).
|
|
82
|
+
|
|
83
|
+
*Propagation* (:func:`propagate_kinked`): at each step the body is meshed again conforming
|
|
84
|
+
to the crack (MMG through the signed distance to its path), solved, its ``G`` and modes
|
|
85
|
+
computed, and its front advanced by an increment in the direction of kinking (by Paris'
|
|
86
|
+
law ``da/dN = C ΔK^m``, ``ΔK = sqrt(E' G)``, the cycles of the increment). With a toughness
|
|
87
|
+
of the phases and of their interfaces (:mod:`morphogen.fracture.toughness`), each advance is
|
|
88
|
+
the candidate of the largest ``G(θ) / Γ(θ)``, the kink of the bulk or a deflection along an
|
|
89
|
+
interface ahead (the first-order kinked factors of Cotterell & Rice), and each crack has the
|
|
90
|
+
critical load factor ``sqrt(Γ / G)`` of its advance.
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
from __future__ import annotations
|
|
94
|
+
|
|
95
|
+
import math
|
|
96
|
+
from dataclasses import dataclass, field
|
|
97
|
+
|
|
98
|
+
import numpy as np
|
|
99
|
+
|
|
100
|
+
from morphogen.fracture.cohesive import (
|
|
101
|
+
CohesiveProblem,
|
|
102
|
+
CohesiveResult,
|
|
103
|
+
Contact,
|
|
104
|
+
Interfaces,
|
|
105
|
+
_tet_gradients,
|
|
106
|
+
lip_tractions,
|
|
107
|
+
)
|
|
108
|
+
from morphogen.fracture.lefm import crack_faces, line_in_box
|
|
109
|
+
from morphogen.mesh.tetra import TetMesh
|
|
110
|
+
|
|
111
|
+
_COUNT = 400 # points of the front
|
|
112
|
+
#: The three points of a face of the lips (those of its interface element)
|
|
113
|
+
_LIP_POINTS = ((1 / 6, 1 / 6), (2 / 3, 1 / 6), (1 / 6, 2 / 3))
|
|
114
|
+
#: The points and weights of Gauss on [0, 1] of the graded rule of the lips
|
|
115
|
+
_LIP_GAUSS = (
|
|
116
|
+
0.5 * (np.polynomial.legendre.leggauss(5)[0] + 1.0),
|
|
117
|
+
0.5 * np.polynomial.legendre.leggauss(5)[1],
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
@dataclass(frozen=True)
|
|
122
|
+
class KinkedCrack:
|
|
123
|
+
"""A crack with a straight front along ``axis``, whose path in the planes normal to the
|
|
124
|
+
front is the polyline of ``points`` (from its mouth, on the boundary of the body, to its
|
|
125
|
+
front): an edge or through crack that kinks as it grows (:meth:`grown`); the normal of
|
|
126
|
+
each segment ``e`` is ``axis × e`` (towards the side ``+``)."""
|
|
127
|
+
|
|
128
|
+
points: tuple
|
|
129
|
+
axis: tuple = (0.0, 0.0, 1.0)
|
|
130
|
+
|
|
131
|
+
def __post_init__(self) -> None:
|
|
132
|
+
t = np.asarray(self.axis, dtype=float)
|
|
133
|
+
t = t / np.linalg.norm(t)
|
|
134
|
+
p = np.atleast_2d(np.asarray(self.points, dtype=float))
|
|
135
|
+
p = p - np.outer((p - p[0]) @ t, t) # in the plane of the first point
|
|
136
|
+
if len(p) < 2 or np.any(np.linalg.norm(np.diff(p, axis=0), axis=1) <= 0):
|
|
137
|
+
raise ValueError("KinkedCrack: at least two distinct points")
|
|
138
|
+
object.__setattr__(self, "axis", tuple(t))
|
|
139
|
+
object.__setattr__(self, "points", tuple(map(tuple, p)))
|
|
140
|
+
|
|
141
|
+
@classmethod
|
|
142
|
+
def of(cls, crack) -> KinkedCrack:
|
|
143
|
+
"""The kinked crack of a straight planar :class:`~morphogen.fracture.lefm.Crack`."""
|
|
144
|
+
p, d, n = (np.asarray(v, dtype=float) for v in (crack.point, crack.direction, crack.normal))
|
|
145
|
+
return cls((tuple(p), tuple(p + crack.size * d)), tuple(np.cross(d, n)))
|
|
146
|
+
|
|
147
|
+
def _segments(self):
|
|
148
|
+
p = np.asarray(self.points)
|
|
149
|
+
e = np.diff(p, axis=0)
|
|
150
|
+
lengths = np.linalg.norm(e, axis=1)
|
|
151
|
+
e = e / lengths[:, None]
|
|
152
|
+
return p, e, lengths, np.cross(np.asarray(self.axis), e)
|
|
153
|
+
|
|
154
|
+
def _plane(self, x) -> np.ndarray:
|
|
155
|
+
x = np.atleast_2d(np.asarray(x, dtype=float))
|
|
156
|
+
t = np.asarray(self.axis)
|
|
157
|
+
return x - np.outer((x - self.points[0]) @ t, t)
|
|
158
|
+
|
|
159
|
+
@property
|
|
160
|
+
def size(self) -> float:
|
|
161
|
+
"""The length of the path."""
|
|
162
|
+
return float(self._segments()[2].sum())
|
|
163
|
+
|
|
164
|
+
@property
|
|
165
|
+
def last(self) -> float:
|
|
166
|
+
"""The length of the last segment."""
|
|
167
|
+
return float(self._segments()[2][-1])
|
|
168
|
+
|
|
169
|
+
@property
|
|
170
|
+
def tip(self) -> np.ndarray:
|
|
171
|
+
return np.asarray(self.points[-1])
|
|
172
|
+
|
|
173
|
+
def phi(self, x) -> np.ndarray:
|
|
174
|
+
"""Signed distance to the path, its first and last segments extended. The points
|
|
175
|
+
nearest a kink take the side of the sum of the normals of its two segments (its
|
|
176
|
+
pseudo-normal; that of one segment turns the side of the points ahead of it beyond
|
|
177
|
+
a kink of 90° or more, such as a deflection along an interface)."""
|
|
178
|
+
y = self._plane(x)
|
|
179
|
+
p, e, lengths, normals = self._segments()
|
|
180
|
+
best = np.full(len(y), np.inf)
|
|
181
|
+
value = np.zeros(len(y))
|
|
182
|
+
last = len(e) - 1
|
|
183
|
+
for i in range(len(e)):
|
|
184
|
+
tau = (y - p[i]) @ e[i]
|
|
185
|
+
low = -np.inf if i == 0 else 0.0
|
|
186
|
+
high = np.inf if i == last else lengths[i]
|
|
187
|
+
v = y - p[i] - np.outer(np.clip(tau, low, high), e[i])
|
|
188
|
+
dist = np.linalg.norm(v, axis=1)
|
|
189
|
+
side = v @ normals[i]
|
|
190
|
+
if i > 0: # nearest the kink at its start
|
|
191
|
+
side = np.where(tau < low, v @ (normals[i - 1] + normals[i]), side)
|
|
192
|
+
if i < last: # nearest the kink at its end
|
|
193
|
+
side = np.where(tau > high, v @ (normals[i] + normals[i + 1]), side)
|
|
194
|
+
closer = dist < best
|
|
195
|
+
best[closer] = dist[closer]
|
|
196
|
+
value[closer] = np.where(side >= 0.0, dist, -dist)[closer]
|
|
197
|
+
return value
|
|
198
|
+
|
|
199
|
+
def psi(self, x) -> np.ndarray:
|
|
200
|
+
"""Distance beyond the front along the last segment (negative behind it)."""
|
|
201
|
+
_, e, _, _ = self._segments()
|
|
202
|
+
return (self._plane(x) - self.tip) @ e[-1]
|
|
203
|
+
|
|
204
|
+
def local(self, x):
|
|
205
|
+
"""The coordinates of points along the axes ``d`` and ``n`` of the front."""
|
|
206
|
+
_, e, _, normals = self._segments()
|
|
207
|
+
y = self._plane(x) - self.tip
|
|
208
|
+
return y @ e[-1], y @ normals[-1]
|
|
209
|
+
|
|
210
|
+
def frame(self, x):
|
|
211
|
+
"""As :meth:`~morphogen.fracture.lefm.Crack.frame`: the distance ``r`` to the front,
|
|
212
|
+
the axes ``n``, ``d``, ``t`` of the last segment and the coordinate ``s`` along the
|
|
213
|
+
front."""
|
|
214
|
+
x = np.atleast_2d(np.asarray(x, dtype=float))
|
|
215
|
+
_, e, _, normals = self._segments()
|
|
216
|
+
r = np.hypot(*self.local(x))
|
|
217
|
+
axes = (normals[-1], e[-1], np.asarray(self.axis))
|
|
218
|
+
n, d, t = (np.broadcast_to(a, x.shape).copy() for a in axes)
|
|
219
|
+
return r, n, d, t, (x - self.points[0]) @ np.asarray(self.axis)
|
|
220
|
+
|
|
221
|
+
def front(self, lower, upper, count: int = _COUNT):
|
|
222
|
+
"""Points of the front inside the box ``[lower, upper]`` and their lengths."""
|
|
223
|
+
return line_in_box(self.tip, np.asarray(self.axis), lower, upper, count)
|
|
224
|
+
|
|
225
|
+
def grown(self, da: float, angle: float = 0.0) -> KinkedCrack:
|
|
226
|
+
"""The crack advanced by ``da`` at ``angle`` (radians) from its last segment towards
|
|
227
|
+
its normal (a new segment, or the last one longer if ``angle`` is 0), or its last
|
|
228
|
+
segment shortened by ``-da`` (``da < 0``). The new front is rounded to 10⁻¹⁰: the
|
|
229
|
+
meshes of MMG change with the last digits of the crack, so that rounding makes a
|
|
230
|
+
growth reproducible whatever the load at which its angles were computed."""
|
|
231
|
+
_, e, lengths, normals = self._segments()
|
|
232
|
+
da = float(da)
|
|
233
|
+
if da < 0 and (angle or -da >= (1 - 1e-9) * lengths[-1]):
|
|
234
|
+
raise ValueError("KinkedCrack.grown: shortened within its last segment, straight")
|
|
235
|
+
if da <= 0 or not angle:
|
|
236
|
+
tip = np.round(self.tip + da * e[-1], 10)
|
|
237
|
+
return KinkedCrack((*self.points[:-1], tuple(tip)), self.axis)
|
|
238
|
+
step = math.cos(angle) * e[-1] + math.sin(angle) * normals[-1]
|
|
239
|
+
return KinkedCrack((*self.points, tuple(np.round(self.tip + da * step, 10))), self.axis)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def _reach(crack) -> float:
|
|
243
|
+
"""How far from the front the domain of ``θ`` may go, tangent to the lips."""
|
|
244
|
+
if hasattr(crack, "reach"):
|
|
245
|
+
return float(crack.reach)
|
|
246
|
+
return crack.last if isinstance(crack, KinkedCrack) else float(crack.size)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def _closed(crack) -> bool:
|
|
250
|
+
"""Whether the front of a crack is a closed curve (a penny, a surface crack inside
|
|
251
|
+
the body)."""
|
|
252
|
+
return bool(getattr(crack, "closed", getattr(crack, "kind", None) == "penny"))
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def _curved(crack) -> bool:
|
|
256
|
+
"""Whether the front of a crack turns (the auxiliary fields then turn with it)."""
|
|
257
|
+
return bool(getattr(crack, "curved", getattr(crack, "kind", None) == "penny"))
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def _hats(s, at, closed: bool) -> np.ndarray:
|
|
261
|
+
"""The piecewise linear functions of the stations ``at`` at the coordinates ``s``
|
|
262
|
+
(points x stations; angles of a closed front); ``at`` None: one function, 1."""
|
|
263
|
+
s = np.asarray(s, dtype=float)
|
|
264
|
+
if at is None:
|
|
265
|
+
return np.ones((len(s), 1))
|
|
266
|
+
if closed:
|
|
267
|
+
h = 2 * np.pi / len(at)
|
|
268
|
+
dist = np.abs((s[:, None] - at[None, :] + np.pi) % (2 * np.pi) - np.pi)
|
|
269
|
+
else:
|
|
270
|
+
h = at[1] - at[0]
|
|
271
|
+
dist = np.abs(s[:, None] - at[None, :])
|
|
272
|
+
return np.clip(1.0 - dist / h, 0.0, None)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def _local(crack, x):
|
|
276
|
+
"""The coordinates of points along the axes ``d`` and ``n`` of the front."""
|
|
277
|
+
if hasattr(crack, "local"):
|
|
278
|
+
return crack.local(x)
|
|
279
|
+
return crack.psi(x), crack.phi(x)
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def _auxiliary(x1, x2, mu: float, nu: float, reference=None) -> np.ndarray:
|
|
283
|
+
"""The displacements (points x modes x 3) of the asymptotic fields of unit factors
|
|
284
|
+
``K_I``, ``K_II``, ``K_III`` at the coordinates ``(x1, x2)`` along ``(d, n)`` (plane
|
|
285
|
+
strain; Williams); ``reference``: angles from which the angles of the points are
|
|
286
|
+
continued (across the plane of the crack behind the front: the side of each point)."""
|
|
287
|
+
r = np.hypot(x1, x2)
|
|
288
|
+
angle = np.arctan2(x2, x1)
|
|
289
|
+
if reference is not None:
|
|
290
|
+
angle = angle + 2 * np.pi * np.round((reference - angle) / (2 * np.pi))
|
|
291
|
+
half = 0.5 * angle
|
|
292
|
+
c = np.sqrt(r / (2 * np.pi)) / (2 * mu)
|
|
293
|
+
sin, cos = np.sin(half), np.cos(half)
|
|
294
|
+
kappa = 3 - 4 * nu
|
|
295
|
+
u = np.zeros((len(r), 3, 3))
|
|
296
|
+
u[:, 0, 0] = c * cos * (kappa - 1 + 2 * sin**2)
|
|
297
|
+
u[:, 0, 1] = c * sin * (kappa + 1 - 2 * cos**2)
|
|
298
|
+
u[:, 1, 0] = c * sin * (kappa + 1 + 2 * cos**2)
|
|
299
|
+
u[:, 1, 1] = -c * cos * (kappa - 1 - 2 * sin**2)
|
|
300
|
+
u[:, 2, 2] = 4 * c * sin
|
|
301
|
+
return u
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
def _auxiliary_gradients(x1, x2, mu: float, nu: float, reference=None) -> np.ndarray:
|
|
305
|
+
"""The gradients (points x modes x 3 x 3, in the axes of the front) of the auxiliary
|
|
306
|
+
displacements (central differences, on the branch of ``reference``, by default that of
|
|
307
|
+
the points)."""
|
|
308
|
+
step = 1e-5 * np.maximum(np.hypot(x1, x2), 1e-300)
|
|
309
|
+
reference = np.arctan2(x2, x1) if reference is None else reference
|
|
310
|
+
g = np.zeros((len(step), 3, 3, 3))
|
|
311
|
+
for j, (a, b) in enumerate(((1.0, 0.0), (0.0, 1.0))):
|
|
312
|
+
plus = _auxiliary(x1 + a * step, x2 + b * step, mu, nu, reference)
|
|
313
|
+
minus = _auxiliary(x1 - a * step, x2 - b * step, mu, nu, reference)
|
|
314
|
+
g[:, :, :, j] = (plus - minus) / (2 * step)[:, None, None]
|
|
315
|
+
return g
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def _auxiliary_fields(crack, x, mu: float, nu: float, reference=None):
|
|
319
|
+
"""The gradients of the auxiliary displacements and their stresses (points x modes x 3
|
|
320
|
+
x 3, global axes) at the points ``x``: the fields of a straight front in the axes of
|
|
321
|
+
the nearest point of the front (on the branches of ``reference``)."""
|
|
322
|
+
local = _auxiliary_gradients(*_local(crack, x), mu, nu, reference)
|
|
323
|
+
strain = 0.5 * (local + np.swapaxes(local, 2, 3))
|
|
324
|
+
lam = 2 * mu * nu / (1 - 2 * nu)
|
|
325
|
+
stress = 2 * mu * strain + lam * np.einsum("emii->em", strain)[:, :, None, None] * np.eye(3)
|
|
326
|
+
_, n, d, t, _ = crack.frame(x)
|
|
327
|
+
axes = np.stack([d, n, t], axis=2) # columns: the axes of the front
|
|
328
|
+
turn = "eai,emij,ebj->emab"
|
|
329
|
+
return np.einsum(turn, axes, local, axes), np.einsum(turn, axes, stress, axes)
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def _auxiliary_derivatives(crack, x, mu: float, nu: float, reference):
|
|
333
|
+
"""The derivatives along the global axes (last index) of the auxiliary gradients and
|
|
334
|
+
stresses (central differences, on the branches of ``reference``: a step across the
|
|
335
|
+
plane of the crack behind the front, from an element flat along the lips, would
|
|
336
|
+
difference the two sides): terms of the curvature of a curved front."""
|
|
337
|
+
step = 1e-3 * np.maximum(crack.frame(x)[0], 1e-300)
|
|
338
|
+
dg = np.empty((len(x), 3, 3, 3, 3))
|
|
339
|
+
ds = np.empty_like(dg)
|
|
340
|
+
for j in range(3):
|
|
341
|
+
shift = np.zeros(3)
|
|
342
|
+
shift[j] = 1.0
|
|
343
|
+
g_plus, s_plus = _auxiliary_fields(crack, x + step[:, None] * shift, mu, nu, reference)
|
|
344
|
+
g_minus, s_minus = _auxiliary_fields(crack, x - step[:, None] * shift, mu, nu, reference)
|
|
345
|
+
dg[..., j] = (g_plus - g_minus) / (2 * step)[:, None, None, None]
|
|
346
|
+
ds[..., j] = (s_plus - s_minus) / (2 * step)[:, None, None, None]
|
|
347
|
+
return dg, ds
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
def _auxiliary_along_lips(x1, side: float, mu: float, nu: float) -> np.ndarray:
|
|
351
|
+
"""The derivatives along ``d`` (points x modes x 3, in the axes of the front) of the
|
|
352
|
+
auxiliary displacements on the side ``+`` (``side`` 1) or ``-`` (-1) of the lips."""
|
|
353
|
+
step = 1e-5 * np.maximum(np.abs(x1), 1e-300)
|
|
354
|
+
on = np.full(len(step), 0.0 if side > 0 else -0.0) # the angle ±π behind the front
|
|
355
|
+
plus = _auxiliary(x1 + step, on, mu, nu)
|
|
356
|
+
minus = _auxiliary(x1 - step, on, mu, nu)
|
|
357
|
+
return (plus - minus) / (2 * step)[:, None, None]
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def element_sides(mesh: TetMesh, crack) -> np.ndarray:
|
|
361
|
+
"""The side of a crack of each element of a mesh (1 or -1): that of its phase on a mesh
|
|
362
|
+
of :func:`~morphogen.fracture.lefm.crack_mesh` (the median sign of ``φ`` over it), or of
|
|
363
|
+
its label ``mesh.side`` on a crack mesh of a morphology, otherwise the sign of ``φ`` at
|
|
364
|
+
its centroid."""
|
|
365
|
+
phi = crack.phi(mesh.nodes[mesh.elements[:, :4]].mean(axis=1))
|
|
366
|
+
labels = None
|
|
367
|
+
if mesh.side is not None:
|
|
368
|
+
labels = mesh.side
|
|
369
|
+
elif mesh.metadata.get("crack_sides") == "phase":
|
|
370
|
+
labels = mesh.phase
|
|
371
|
+
if labels is not None:
|
|
372
|
+
side = np.ones(mesh.n_elements)
|
|
373
|
+
for p in np.unique(labels):
|
|
374
|
+
sel = labels == p
|
|
375
|
+
side[sel] = 1.0 if np.median(phi[sel]) >= 0 else -1.0
|
|
376
|
+
return side
|
|
377
|
+
return np.where(phi >= 0, 1.0, -1.0)
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def _same_material(a, b) -> bool:
|
|
381
|
+
if a is b:
|
|
382
|
+
return True
|
|
383
|
+
try:
|
|
384
|
+
return bool(a == b)
|
|
385
|
+
except (TypeError, ValueError): # materials that do not compare
|
|
386
|
+
return False
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def material_groups(phase, materials: dict) -> np.ndarray:
|
|
390
|
+
"""The material of each element (of its ``phase``) as a label: the first phase of an
|
|
391
|
+
equal material (phases of the same material make one group)."""
|
|
392
|
+
phase = np.asarray(phase, dtype=np.int64)
|
|
393
|
+
out = phase.copy()
|
|
394
|
+
first: list[int] = []
|
|
395
|
+
for p in np.unique(phase).tolist():
|
|
396
|
+
rep = next((q for q in first if _same_material(materials.get(q), materials.get(p))), p)
|
|
397
|
+
if rep == p:
|
|
398
|
+
first.append(p)
|
|
399
|
+
out[phase == p] = rep
|
|
400
|
+
return out
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def material_nodes(mesh: TetMesh, materials: dict, phase: int, lips=None) -> np.ndarray:
|
|
404
|
+
"""The nodes (a mask) inside the material of the phase ``phase`` of a crack mesh of a
|
|
405
|
+
morphology: those whose elements all have it (the phases of the same material alike),
|
|
406
|
+
off the walls of the pores (the free faces off the faces of the box and off the
|
|
407
|
+
``lips``, an :class:`~morphogen.fracture.cohesive.Interfaces` of the opened crack)."""
|
|
408
|
+
from morphogen.fracture.lefm import boundary_faces
|
|
409
|
+
|
|
410
|
+
tets = mesh.elements[:, :4]
|
|
411
|
+
material = materials[int(phase)]
|
|
412
|
+
same = [int(p) for p in np.unique(mesh.phase)
|
|
413
|
+
if int(p) in materials and _same_material(materials[int(p)], material)] # fmt: skip
|
|
414
|
+
other = ~np.isin(mesh.phase, same)
|
|
415
|
+
inside = np.ones(mesh.n_nodes, dtype=bool)
|
|
416
|
+
inside[tets[other].ravel()] = False
|
|
417
|
+
free = boundary_faces(mesh)
|
|
418
|
+
x, tol = mesh.nodes[free], mesh.tolerance()
|
|
419
|
+
wall = np.ones(len(free), dtype=bool)
|
|
420
|
+
for axis in range(3):
|
|
421
|
+
for value in (mesh.lower[axis], mesh.upper[axis]):
|
|
422
|
+
wall &= ~np.all(np.abs(x[:, :, axis] - value) <= tol, axis=1)
|
|
423
|
+
if lips is not None and lips.n_elements:
|
|
424
|
+
keys = {tuple(k) for k in np.sort(np.vstack([lips.minus, lips.plus]), axis=1).tolist()}
|
|
425
|
+
wall &= ~np.array([tuple(k) in keys for k in np.sort(free, axis=1).tolist()], dtype=bool)
|
|
426
|
+
inside[free[wall].ravel()] = False
|
|
427
|
+
return inside
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
def _isotropic_moduli(material) -> tuple[float, float]:
|
|
431
|
+
"""Young's modulus and Poisson's ratio of an isotropic material, or the isotropic
|
|
432
|
+
estimate of an anisotropic one (a crystal): the means of the Voigt and Reuss averages
|
|
433
|
+
of its bulk and shear moduli (Hill)."""
|
|
434
|
+
if material.young is not None and material.poisson is not None:
|
|
435
|
+
return float(material.young), float(material.poisson)
|
|
436
|
+
from morphogen.homogenization.materials import reuss_average, voigt_average
|
|
437
|
+
|
|
438
|
+
d = material.matrix("elastic")
|
|
439
|
+
(kv, gv), (kr, gr) = voigt_average(d), reuss_average(d)
|
|
440
|
+
k, g = 0.5 * (kv + kr), 0.5 * (gv + gr)
|
|
441
|
+
return 9.0 * k * g / (3.0 * k + g), (3.0 * k - 2.0 * g) / (2.0 * (3.0 * k + g))
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
def _as_materials(materials, mesh: TetMesh) -> dict:
|
|
445
|
+
"""A dict of the materials of the phases (one material: all the phases)."""
|
|
446
|
+
if hasattr(materials, "young"):
|
|
447
|
+
return {int(p): materials for p in np.unique(mesh.phase)}
|
|
448
|
+
return dict(materials)
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
def _moduli(materials, phase):
|
|
452
|
+
"""Lamé constants of the elements (isotropic materials)."""
|
|
453
|
+
mu = np.zeros(len(phase))
|
|
454
|
+
lam = np.zeros(len(phase))
|
|
455
|
+
for p, m in materials.items():
|
|
456
|
+
if m.void or m.young is None:
|
|
457
|
+
continue
|
|
458
|
+
sel = phase == p
|
|
459
|
+
mu[sel] = m.young / (2 * (1 + m.poisson))
|
|
460
|
+
lam[sel] = m.young * m.poisson / ((1 + m.poisson) * (1 - 2 * m.poisson))
|
|
461
|
+
return mu, lam
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
# -- solution --------------------------------------------------------------------------------
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
@dataclass
|
|
468
|
+
class CrackSolution:
|
|
469
|
+
"""A solved cracked body: its opened ``mesh``, the lips ``faces`` (pairs of faces), the
|
|
470
|
+
``crack``, the ``materials`` of the phases, the kinematics, the final ``displacement``
|
|
471
|
+
(nodes x 3), the ``steps`` of the solver, the final nodal ``forces``, the stiffness of
|
|
472
|
+
the ``contact`` of the lips and the ``bulk`` of points with its final state (inelastic
|
|
473
|
+
bodies; :class:`~morphogen.fracture.bulk.PointBulk`)."""
|
|
474
|
+
|
|
475
|
+
mesh: TetMesh
|
|
476
|
+
faces: Interfaces
|
|
477
|
+
crack: object
|
|
478
|
+
materials: dict
|
|
479
|
+
finite: bool
|
|
480
|
+
displacement: np.ndarray
|
|
481
|
+
steps: CohesiveResult = field(repr=False)
|
|
482
|
+
forces: np.ndarray | None = field(default=None, repr=False)
|
|
483
|
+
contact: float | None = None
|
|
484
|
+
bulk: object | None = field(default=None, repr=False)
|
|
485
|
+
friction: float = 0.0
|
|
486
|
+
_cache: dict = field(default_factory=dict, init=False, repr=False)
|
|
487
|
+
|
|
488
|
+
def stresses(self, energy: str = "work"):
|
|
489
|
+
"""The displacement gradient ``H``, the first Piola-Kirchhoff stress ``P`` (Cauchy
|
|
490
|
+
in small strains) and the energy density ``W`` of each element, its volume and the
|
|
491
|
+
gradients of its shape functions: ``W`` the elastic energy of an elastic body; for
|
|
492
|
+
a bulk of points, their work density (``energy="work"``) or their free energy
|
|
493
|
+
(``"free"`` or ``"tip"``)."""
|
|
494
|
+
if energy not in ("work", "free", "tip"):
|
|
495
|
+
raise ValueError("energy: 'work', 'free' or 'tip'")
|
|
496
|
+
key = "free" if self.bulk is not None and energy != "work" else "work"
|
|
497
|
+
if key in self._cache:
|
|
498
|
+
return self._cache[key]
|
|
499
|
+
mesh = self.mesh
|
|
500
|
+
grads, volumes = _tet_gradients(mesh.nodes, mesh.elements)
|
|
501
|
+
h = np.einsum("eai,eaj->eij", self.displacement[mesh.elements], grads)
|
|
502
|
+
if self.bulk is not None:
|
|
503
|
+
p = self.bulk.stress_tensors()
|
|
504
|
+
w = self.bulk.work.copy() if key == "work" else self.bulk.free_energy()
|
|
505
|
+
elif self.finite:
|
|
506
|
+
mu, lam = _moduli(self.materials, mesh.phase)
|
|
507
|
+
f = np.eye(3) + h
|
|
508
|
+
finv_t = np.transpose(np.linalg.inv(f), (0, 2, 1))
|
|
509
|
+
lnj = np.log(np.maximum(np.linalg.det(f), 1e-300))
|
|
510
|
+
p = mu[:, None, None] * (f - finv_t) + (lam * lnj)[:, None, None] * finv_t
|
|
511
|
+
w = 0.5 * mu * (np.einsum("eij,eij->e", f, f) - 3.0) - mu * lnj + 0.5 * lam * lnj**2
|
|
512
|
+
else:
|
|
513
|
+
from morphogen.homogenization.materials import material_table
|
|
514
|
+
|
|
515
|
+
table = material_table(
|
|
516
|
+
mesh.phase,
|
|
517
|
+
self.materials,
|
|
518
|
+
"elastic",
|
|
519
|
+
grains=mesh.cell,
|
|
520
|
+
orientations=mesh.orientations,
|
|
521
|
+
) # crystals: their grains
|
|
522
|
+
d = table.matrices[np.maximum(table.mat, 0)] * (table.mat >= 0)[:, None, None]
|
|
523
|
+
eps = np.stack([h[:, 0, 0], h[:, 1, 1], h[:, 2, 2], h[:, 1, 2] + h[:, 2, 1],
|
|
524
|
+
h[:, 2, 0] + h[:, 0, 2], h[:, 0, 1] + h[:, 1, 0]], axis=1) # fmt: skip
|
|
525
|
+
sig = np.einsum("eij,ej->ei", d, eps) # Voigt (11, 22, 33, 23, 31, 12)
|
|
526
|
+
w = 0.5 * np.einsum("ei,ei->e", sig, eps)
|
|
527
|
+
p = np.empty_like(h)
|
|
528
|
+
for k, (a, b) in enumerate(((0, 0), (1, 1), (2, 2), (1, 2), (2, 0), (0, 1))):
|
|
529
|
+
p[:, a, b] = p[:, b, a] = sig[:, k]
|
|
530
|
+
self._cache[key] = (h, p, w, volumes, grads)
|
|
531
|
+
return self._cache[key]
|
|
532
|
+
|
|
533
|
+
def energy(self, kind: str = "work") -> float:
|
|
534
|
+
"""The elastic energy of an elastic body; for a bulk of points, the work of its
|
|
535
|
+
stresses (``kind="work"``: the stored and dissipated energies, the work of the
|
|
536
|
+
loads at fixed displacements) or its free energy (``"free"``)."""
|
|
537
|
+
_, _, w, volumes, _ = self.stresses(kind)
|
|
538
|
+
return float(volumes @ w)
|
|
539
|
+
|
|
540
|
+
def potential(self) -> float:
|
|
541
|
+
"""The potential energy: the elastic energy (the work of the bulk) less the work of
|
|
542
|
+
the forces (dead loads)."""
|
|
543
|
+
if self.forces is None:
|
|
544
|
+
return self.energy()
|
|
545
|
+
return self.energy() - float(self.forces @ self.displacement.ravel())
|
|
546
|
+
|
|
547
|
+
def area(self) -> float:
|
|
548
|
+
"""The area of the crack (its opened faces, in the reference configuration)."""
|
|
549
|
+
return float(self.faces.areas(self.mesh).sum())
|
|
550
|
+
|
|
551
|
+
def element_size(self) -> float:
|
|
552
|
+
"""The mean length of the edges of the elements; on a mesh refined around the
|
|
553
|
+
front (:func:`~morphogen.fracture.lefm.refine_front`), of the elements that reach
|
|
554
|
+
within half their size of it: the size that the domains of the integrals and the
|
|
555
|
+
stations along the front are counted in."""
|
|
556
|
+
if "element_size" not in self._cache:
|
|
557
|
+
x = self.mesh.nodes[self.mesh.elements[:, :4]]
|
|
558
|
+
edges = x[:, [1, 2, 3, 2, 3, 3]] - x[:, [0, 0, 0, 1, 1, 2]]
|
|
559
|
+
lengths = np.linalg.norm(edges, axis=2).mean(axis=1)
|
|
560
|
+
if self.mesh.metadata.get("front_size"):
|
|
561
|
+
r = self.crack.frame(self.mesh.nodes)[0][self.mesh.elements[:, :4]]
|
|
562
|
+
near = r.min(axis=1) < 0.5 * lengths
|
|
563
|
+
if np.any(near):
|
|
564
|
+
lengths = lengths[near]
|
|
565
|
+
self._cache["element_size"] = float(np.mean(lengths))
|
|
566
|
+
return self._cache["element_size"]
|
|
567
|
+
|
|
568
|
+
def _stations(self, stations):
|
|
569
|
+
"""The stations along the front (None: one, the whole front), whether it is closed,
|
|
570
|
+
and the coordinates and lengths of its points."""
|
|
571
|
+
lower, upper = self.mesh.nodes.min(axis=0), self.mesh.nodes.max(axis=0)
|
|
572
|
+
points, lengths = self.crack.front(lower, upper, _COUNT)
|
|
573
|
+
if not len(points):
|
|
574
|
+
raise ValueError("no front inside the body")
|
|
575
|
+
s = self.crack.frame(points)[4]
|
|
576
|
+
closed = _closed(self.crack)
|
|
577
|
+
if stations is None:
|
|
578
|
+
return None, closed, s, lengths
|
|
579
|
+
count = int(stations)
|
|
580
|
+
if count < 2:
|
|
581
|
+
raise ValueError("stations: at least two")
|
|
582
|
+
if closed:
|
|
583
|
+
if len(points) < _COUNT:
|
|
584
|
+
raise ValueError("stations: a closed front inside the body")
|
|
585
|
+
at = np.linspace(-np.pi, np.pi, count, endpoint=False)
|
|
586
|
+
spacing = float(lengths.sum()) / count
|
|
587
|
+
else:
|
|
588
|
+
half = 0.5 * float(lengths.max())
|
|
589
|
+
at = np.linspace(s.min() - half, s.max() + half, count)
|
|
590
|
+
spacing = at[1] - at[0]
|
|
591
|
+
if spacing < 2.0 * self.element_size():
|
|
592
|
+
raise ValueError("stations: at least two elements apart along the front")
|
|
593
|
+
return at, closed, s, lengths
|
|
594
|
+
|
|
595
|
+
def _radius(self, value, default: float) -> float:
|
|
596
|
+
return default * self.element_size() if value is None else float(value)
|
|
597
|
+
|
|
598
|
+
def front_phase(self) -> int:
|
|
599
|
+
"""The phase at the front (its material: that of the front): of the elements in which
|
|
600
|
+
most of the points of the front lie (or of the element nearest the front, if none of
|
|
601
|
+
them lies in the body)."""
|
|
602
|
+
if "front_phase" not in self._cache:
|
|
603
|
+
from morphogen.fracture.ductile import locate
|
|
604
|
+
|
|
605
|
+
mesh = self.mesh
|
|
606
|
+
points, _ = self.crack.front(mesh.nodes.min(axis=0), mesh.nodes.max(axis=0), 64)
|
|
607
|
+
if len(points):
|
|
608
|
+
element, _ = locate(points, mesh)
|
|
609
|
+
phases, counts = np.unique(mesh.phase[element], return_counts=True)
|
|
610
|
+
phase = int(phases[np.argmax(counts)])
|
|
611
|
+
else:
|
|
612
|
+
centroids = mesh.nodes[mesh.elements[:, :4]].mean(axis=1)
|
|
613
|
+
phase = int(mesh.phase[int(np.argmin(self.crack.frame(centroids)[0]))])
|
|
614
|
+
self._cache["front_phase"] = phase
|
|
615
|
+
return self._cache["front_phase"]
|
|
616
|
+
|
|
617
|
+
def _theta(self, r_in, r_out, stations, restrict: bool = False):
|
|
618
|
+
"""The virtual advances ``θ`` of the stations at the nodes (stations x nodes x 3),
|
|
619
|
+
the stations, whether the front is closed, the mass matrix of the front and the
|
|
620
|
+
elements where ``θ`` is not zero; with ``restrict``, on a crack mesh of a morphology
|
|
621
|
+
(its sides apart from its phases), zero beyond ``r_in`` at the nodes outside the
|
|
622
|
+
material at the front (:func:`material_nodes`; see :meth:`release_rate`)."""
|
|
623
|
+
r_out = min(self._radius(r_out, 4.0), _reach(self.crack))
|
|
624
|
+
r_in = min(self._radius(r_in, 1.0), 0.5 * r_out)
|
|
625
|
+
r, _, d, _, s_nodes = self.crack.frame(self.mesh.nodes)
|
|
626
|
+
q = np.clip((r_out - r) / (r_out - r_in), 0.0, 1.0)
|
|
627
|
+
if restrict and self.mesh.side is not None:
|
|
628
|
+
if "material_nodes" not in self._cache:
|
|
629
|
+
self._cache["material_nodes"] = material_nodes(
|
|
630
|
+
self.mesh, self.materials, self.front_phase(), self.faces
|
|
631
|
+
)
|
|
632
|
+
q = np.where(self._cache["material_nodes"] | (r <= r_in), q, 0.0)
|
|
633
|
+
at, closed, s_front, lengths = self._stations(stations)
|
|
634
|
+
theta = np.einsum("nk,ni->kni", _hats(s_nodes, at, closed) * q[:, None], d)
|
|
635
|
+
front = _hats(s_front, at, closed)
|
|
636
|
+
mass = np.einsum("pk,pl,p->kl", front, front, lengths)
|
|
637
|
+
active = np.flatnonzero(np.any(q[self.mesh.elements] > 0, axis=1))
|
|
638
|
+
return theta, at, closed, mass, active
|
|
639
|
+
|
|
640
|
+
def release_rate(
|
|
641
|
+
self, r_in=None, r_out=None, stations: int | None = None, energy: str = "work"
|
|
642
|
+
):
|
|
643
|
+
"""The energy release rate by the G-θ method (see the module): its mean along the
|
|
644
|
+
front, or ``(s, G)`` at ``stations`` points along it (the coordinate ``s``: a length,
|
|
645
|
+
an angle on a penny; at least two elements apart); ``q`` from 1 within ``r_in`` (by
|
|
646
|
+
default one element) to 0 beyond ``r_out`` (four), within the reach of the lips.
|
|
647
|
+
``energy`` of an inelastic bulk (see the module): ``"work"``, the J of the
|
|
648
|
+
deformation theory; ``"free"``, the configurational force on the domain; ``"tip"``,
|
|
649
|
+
the driving force at the tip.
|
|
650
|
+
|
|
651
|
+
On a crack mesh of a morphology, the domain of ``"work"`` and ``"free"`` takes in
|
|
652
|
+
the other materials and the walls of the pores within it, their configurational
|
|
653
|
+
forces with it (the far J); that of ``"tip"`` is the material at the front: ``θ``
|
|
654
|
+
vanishes beyond ``r_in`` at the nodes of its interfaces with the other materials,
|
|
655
|
+
in them and on the walls of the pores, which leaves their configurational forces
|
|
656
|
+
out (the inhomogeneity term of Simha, Fischer, Kolednik & Chen 2003)."""
|
|
657
|
+
return self._release_rate(r_in, r_out, stations, energy, energy == "tip")
|
|
658
|
+
|
|
659
|
+
def _release_rate(self, r_in, r_out, stations, energy: str, restrict: bool):
|
|
660
|
+
theta, at, _, mass, active = self._theta(r_in, r_out, stations, restrict)
|
|
661
|
+
h, p, w, volumes, grads = (a[active] for a in self.stresses(energy))
|
|
662
|
+
elements = self.mesh.elements[active]
|
|
663
|
+
body = None
|
|
664
|
+
if energy == "tip" and self.bulk is not None:
|
|
665
|
+
body = self.bulk.configurational()[active] # Div (ψ I - Hᵀ P)
|
|
666
|
+
work = np.empty(len(theta))
|
|
667
|
+
for k, field_k in enumerate(theta):
|
|
668
|
+
g_theta = np.einsum("eai,eaj->eij", field_k[elements], grads)
|
|
669
|
+
eshelby = np.einsum("eik,eij,ekj->e", h, p, g_theta) - w * np.einsum("eii->e", g_theta)
|
|
670
|
+
work[k] = volumes @ eshelby
|
|
671
|
+
if body is not None:
|
|
672
|
+
work[k] -= volumes @ np.einsum("ek,ek->e", body, field_k[elements].mean(axis=1))
|
|
673
|
+
if self.contact and self.friction: # the work of the tractions of the lips that rub
|
|
674
|
+
work -= self._lips_work(theta)
|
|
675
|
+
g = np.linalg.solve(mass, work)
|
|
676
|
+
return float(g[0]) if at is None else (at, g)
|
|
677
|
+
|
|
678
|
+
def _sides(self) -> np.ndarray:
|
|
679
|
+
"""The side of the crack of each element (see :func:`element_sides`)."""
|
|
680
|
+
return element_sides(self.mesh, self.crack)
|
|
681
|
+
|
|
682
|
+
def _mean_gradients(self, active, at, closed: bool) -> np.ndarray:
|
|
683
|
+
"""The mean displacement gradients (stations x 3 x 3) of the elements ``active``
|
|
684
|
+
around the front."""
|
|
685
|
+
h, _, _, volumes, _ = self.stresses()
|
|
686
|
+
centroids = self.mesh.nodes[self.mesh.elements[active]].mean(axis=1)
|
|
687
|
+
weights = _hats(self.crack.frame(centroids)[4], at, closed) * volumes[active, None]
|
|
688
|
+
return np.einsum("ek,eij->kij", weights, h[active]) / weights.sum(axis=0)[:, None, None]
|
|
689
|
+
|
|
690
|
+
def _lips(self, theta, mu: float, nu: float) -> np.ndarray:
|
|
691
|
+
"""The work (stations x modes) of the tractions of the lips in contact on the
|
|
692
|
+
bodies in the virtual advances ``θ`` of the auxiliary displacements, ``∫ t · (∇u'
|
|
693
|
+
θ) dS`` over the two lips (see the module). The auxiliary gradient is singular at
|
|
694
|
+
the front, as ``r^(-1/2)``: each face is integrated at points graded towards its
|
|
695
|
+
corner nearest the front, then towards the next (``s = v²`` and ``t = w²`` in the
|
|
696
|
+
triangle collapsed on that corner, which make the integrand smooth whether the face
|
|
697
|
+
touches the front by a corner or by an edge), with the tractions of the linear
|
|
698
|
+
field through those of its three points."""
|
|
699
|
+
minus, plus = self.faces.minus[:, :3], self.faces.plus[:, :3]
|
|
700
|
+
u = self.displacement
|
|
701
|
+
xr = self.mesh.nodes[minus]
|
|
702
|
+
reference = np.cross(xr[:, 1] - xr[:, 0], xr[:, 2] - xr[:, 0])
|
|
703
|
+
area = 0.5 * np.linalg.norm(reference, axis=1)
|
|
704
|
+
if self.friction: # with the shear of the lips that stick or slide
|
|
705
|
+
tractions = self._lip_tractions()[0]
|
|
706
|
+
else:
|
|
707
|
+
x = xr + 0.5 * (u[minus] + u[plus]) if self.finite else xr # the frame of the law
|
|
708
|
+
normal = np.cross(x[:, 1] - x[:, 0], x[:, 2] - x[:, 0])
|
|
709
|
+
normal /= np.linalg.norm(normal, axis=1, keepdims=True)
|
|
710
|
+
shapes = np.array([[1.0 - xi - eta, xi, eta] for xi, eta in _LIP_POINTS])
|
|
711
|
+
jumps = np.einsum("gi,eij->egj", shapes, u[plus] - u[minus])
|
|
712
|
+
opening = np.einsum("egj,ej->eg", jumps, normal)
|
|
713
|
+
tractions = (self.contact * np.minimum(opening, 0.0))[:, :, None] * normal[:, None]
|
|
714
|
+
# the corners of each face from the nearest to the front
|
|
715
|
+
behind = -_local(self.crack, xr.reshape(-1, 3))[0].reshape(-1, 3)
|
|
716
|
+
order = np.argsort(behind, axis=1)
|
|
717
|
+
rows = np.arange(len(minus))
|
|
718
|
+
work = np.zeros((len(theta), 3))
|
|
719
|
+
for v, wv in zip(_LIP_GAUSS[0], _LIP_GAUSS[1], strict=True):
|
|
720
|
+
for w, ww in zip(_LIP_GAUSS[0], _LIP_GAUSS[1], strict=True):
|
|
721
|
+
s, t = v * v, w * w
|
|
722
|
+
shape = np.empty((len(minus), 3)) # of the corners of each face
|
|
723
|
+
shape[rows, order[:, 0]] = 1.0 - s
|
|
724
|
+
shape[rows, order[:, 1]] = s * (1.0 - t)
|
|
725
|
+
shape[rows, order[:, 2]] = s * t
|
|
726
|
+
weight = 8.0 * v**3 * w * wv * ww * area
|
|
727
|
+
# the tractions: linear through those of the points (1/6, 1/6), (2/3, 1/6)
|
|
728
|
+
# and (1/6, 2/3)
|
|
729
|
+
traction = (
|
|
730
|
+
tractions[:, 0]
|
|
731
|
+
+ 2.0 * (shape[:, 1] - 1.0 / 6.0)[:, None] * (tractions[:, 1] - tractions[:, 0])
|
|
732
|
+
+ 2.0 * (shape[:, 2] - 1.0 / 6.0)[:, None] * (tractions[:, 2] - tractions[:, 0])
|
|
733
|
+
)
|
|
734
|
+
point = np.einsum("ei,eij->ej", shape, xr)
|
|
735
|
+
x1, _ = _local(self.crack, point)
|
|
736
|
+
_, n, d, tangent, _ = self.crack.frame(point)
|
|
737
|
+
axes = np.stack([d, n, tangent], axis=2)
|
|
738
|
+
# the faces "plus" of the interface elements lie on either side of the crack
|
|
739
|
+
orient = np.where(np.einsum("ej,ej->e", reference, n) >= 0, 1.0, -1.0)
|
|
740
|
+
jump_aux = _auxiliary_along_lips(x1, 1.0, mu, nu) - _auxiliary_along_lips(
|
|
741
|
+
x1, -1.0, mu, nu
|
|
742
|
+
)
|
|
743
|
+
jump_aux = orient[:, None, None] * jump_aux # plus less minus
|
|
744
|
+
along = np.einsum("eai,emi->ema", axes, jump_aux) # the jump of ∂u'/∂d, global
|
|
745
|
+
# on the face plus the traction -t, on the face minus the traction t
|
|
746
|
+
per_face = -weight[:, None] * np.einsum("ea,ema->em", traction, along)
|
|
747
|
+
for k, field_k in enumerate(theta):
|
|
748
|
+
advance = np.einsum("ei,eij->ej", shape, field_k[minus])
|
|
749
|
+
work[k] += np.einsum("e,em->m", np.einsum("ej,ej->e", advance, d), per_face)
|
|
750
|
+
return work
|
|
751
|
+
|
|
752
|
+
def _lip_tractions(self):
|
|
753
|
+
"""The tractions on the side ``-`` of the lips that rub (and the jumps of the
|
|
754
|
+
displacement) at the three points of each face: those of the law at the end of
|
|
755
|
+
the solution."""
|
|
756
|
+
if "lips" not in self._cache:
|
|
757
|
+
if self.faces.order != 1:
|
|
758
|
+
raise ValueError("the driving forces of lips that rub: a mesh of 4-node tetrahedra")
|
|
759
|
+
law = Contact(float(self.contact), friction=float(self.friction))
|
|
760
|
+
self._cache["lips"] = lip_tractions(
|
|
761
|
+
self.mesh.nodes, self.faces, self.displacement, law, self.steps, self.finite
|
|
762
|
+
)
|
|
763
|
+
return self._cache["lips"]
|
|
764
|
+
|
|
765
|
+
def _closed_at_front(self, r_in=None) -> bool:
|
|
766
|
+
"""Whether the lips that rub press on each other at all their points within
|
|
767
|
+
``r_in`` of the front (by default one element): lips closed there open in no mode
|
|
768
|
+
I, whatever the errors of quadrature of its interaction integral."""
|
|
769
|
+
tractions, _ = self._lip_tractions()
|
|
770
|
+
minus = self.faces.minus[:, :3]
|
|
771
|
+
x = self.mesh.nodes[minus]
|
|
772
|
+
shapes = np.array([[1.0 - xi - eta, xi, eta] for xi, eta in _LIP_POINTS])
|
|
773
|
+
points = np.einsum("gi,eic->egc", shapes, x).reshape(-1, 3)
|
|
774
|
+
near = self.crack.frame(points)[0] <= self._radius(r_in, 1.0)
|
|
775
|
+
if not near.any():
|
|
776
|
+
return False
|
|
777
|
+
normal = np.cross(x[:, 1] - x[:, 0], x[:, 2] - x[:, 0])
|
|
778
|
+
normal /= np.linalg.norm(normal, axis=1, keepdims=True)
|
|
779
|
+
pressure = -np.einsum("egc,ec->eg", tractions, normal).ravel()
|
|
780
|
+
return bool(np.all(pressure[near] > 0.0))
|
|
781
|
+
|
|
782
|
+
def _lips_work(self, theta) -> np.ndarray:
|
|
783
|
+
"""The work (stations) of the tractions of the lips that rub on the two bodies in
|
|
784
|
+
the virtual advances ``θ`` of the actual displacement, ``∫ t · (∇u θ) dS`` over the
|
|
785
|
+
two lips: ``-∫ t · (∇[u] θ) dS`` with the jump ``[u]`` of the displacement, whose
|
|
786
|
+
gradient along the lips is that of the linear functions of each face."""
|
|
787
|
+
minus, plus = self.faces.minus, self.faces.plus
|
|
788
|
+
tractions, _ = self._lip_tractions()
|
|
789
|
+
xr = self.mesh.nodes[minus]
|
|
790
|
+
e1, e2 = xr[:, 1] - xr[:, 0], xr[:, 2] - xr[:, 0]
|
|
791
|
+
area = 0.5 * np.linalg.norm(np.cross(e1, e2), axis=1)
|
|
792
|
+
# the gradients of the functions of the nodes in the plane of each face
|
|
793
|
+
metric = np.stack(
|
|
794
|
+
[
|
|
795
|
+
np.stack([np.einsum("ei,ei->e", e1, e1), np.einsum("ei,ei->e", e1, e2)], axis=1),
|
|
796
|
+
np.stack([np.einsum("ei,ei->e", e1, e2), np.einsum("ei,ei->e", e2, e2)], axis=1),
|
|
797
|
+
],
|
|
798
|
+
axis=1,
|
|
799
|
+
)
|
|
800
|
+
dual = np.einsum("eab,ebi->eai", np.linalg.inv(metric), np.stack([e1, e2], axis=1))
|
|
801
|
+
grads = np.concatenate([-dual.sum(axis=1, keepdims=True), dual], axis=1) # e x 3 x 3
|
|
802
|
+
jump = self.displacement[plus] - self.displacement[minus] # at the nodes
|
|
803
|
+
gradient = np.einsum("eac,eai->eci", jump, grads) # d[u]_c / dx_i
|
|
804
|
+
work = np.zeros(len(theta))
|
|
805
|
+
for g, (xi, eta) in enumerate(((1 / 6, 1 / 6), (2 / 3, 1 / 6), (1 / 6, 2 / 3))):
|
|
806
|
+
shape = np.array([1.0 - xi - eta, xi, eta])
|
|
807
|
+
for k, field_k in enumerate(theta):
|
|
808
|
+
advance = np.einsum("i,eij->ej", shape, field_k[minus])
|
|
809
|
+
along = np.einsum("eci,ei->ec", gradient, advance)
|
|
810
|
+
work[k] -= (area / 3) @ np.einsum("ec,ec->e", tractions[:, g], along)
|
|
811
|
+
return work
|
|
812
|
+
|
|
813
|
+
def modes(self, r_in=None, r_out=None, stations: int | None = None, release_rate=None) -> dict:
|
|
814
|
+
"""The stress intensity factors of the three modes by the interaction integrals,
|
|
815
|
+
the energy release rate ``G`` by the G-θ method (or the value given, the same at all
|
|
816
|
+
the stations) shared between them (the same domain), and the angle of kinking (see
|
|
817
|
+
the module): floats, or arrays at the ``stations`` along the front (``"s"``). On a
|
|
818
|
+
crack mesh of a morphology, the domain is the material at the front (that of
|
|
819
|
+
:meth:`release_rate` with ``energy="tip"``), whose moduli the auxiliary fields
|
|
820
|
+
take."""
|
|
821
|
+
theta, at, closed, mass, active = self._theta(r_in, r_out, stations, True)
|
|
822
|
+
mesh = self.mesh
|
|
823
|
+
h, p, _, volumes, grads = (a[active] for a in self.stresses())
|
|
824
|
+
elements = mesh.elements[active]
|
|
825
|
+
centroids = mesh.nodes[elements].mean(axis=1)
|
|
826
|
+
material = self.materials[self.front_phase()]
|
|
827
|
+
young, nu = _isotropic_moduli(material)
|
|
828
|
+
mu = young / (2 * (1 + nu))
|
|
829
|
+
x1, x2 = _local(self.crack, centroids)
|
|
830
|
+
side = self._sides()[active] # behind the front, the branch of the side
|
|
831
|
+
reference = np.where(x1 < 0, np.arctan2(side * np.abs(x2), x1), np.arctan2(x2, x1))
|
|
832
|
+
g_aux, s_aux = _auxiliary_fields(self.crack, centroids, mu, nu, reference)
|
|
833
|
+
curved = _curved(self.crack) # straight fronts: zero
|
|
834
|
+
if curved:
|
|
835
|
+
dg, ds = _auxiliary_derivatives(self.crack, centroids, mu, nu, reference)
|
|
836
|
+
de = 0.5 * (dg + np.swapaxes(dg, 2, 3)) # of the auxiliary strain
|
|
837
|
+
mean = self._mean_gradients(active, at, closed)
|
|
838
|
+
m = np.empty((len(theta), 3))
|
|
839
|
+
for k, field_k in enumerate(theta):
|
|
840
|
+
g_theta = np.einsum("eai,eaj->eij", field_k[elements], grads)
|
|
841
|
+
if self.finite: # turned back by the rotation of the mean deformation gradient
|
|
842
|
+
u, _, vt = np.linalg.svd(np.eye(3) + mean[k])
|
|
843
|
+
rot = u @ vt
|
|
844
|
+
pt = np.einsum("ji,ejk->eik", rot, p)
|
|
845
|
+
ht = np.einsum("ji,ejk->eik", rot, np.eye(3) + h) - np.eye(3)
|
|
846
|
+
else: # less the mean rotation, which adds nothing but errors of quadrature
|
|
847
|
+
pt, ht = p, h - 0.5 * (mean[k] - mean[k].T)
|
|
848
|
+
eps = 0.5 * (ht + np.swapaxes(ht, 1, 2))
|
|
849
|
+
cross = (
|
|
850
|
+
np.einsum("eij,emik,ekj->em", pt, g_aux, g_theta)
|
|
851
|
+
+ np.einsum("emij,eik,ekj->em", s_aux, ht, g_theta)
|
|
852
|
+
- np.einsum("emij,eij->em", s_aux, eps) * np.einsum("eii->e", g_theta)[:, None]
|
|
853
|
+
)
|
|
854
|
+
if curved: # the divergence of the cross tensor: incompatibility, unbalance
|
|
855
|
+
advance = field_k[elements].mean(axis=1) # θ at the centroids
|
|
856
|
+
cross = cross + (
|
|
857
|
+
np.einsum("eij,emikj,ek->em", pt, dg, advance)
|
|
858
|
+
- np.einsum("eij,emijk,ek->em", pt, de, advance)
|
|
859
|
+
+ np.einsum("emijj,eik,ek->em", ds, ht, advance)
|
|
860
|
+
)
|
|
861
|
+
m[k] = volumes @ cross
|
|
862
|
+
if self.contact:
|
|
863
|
+
m -= self._lips(theta, mu, nu)
|
|
864
|
+
e_prime = young / (1 - nu**2)
|
|
865
|
+
k_int = np.linalg.solve(mass, m) * np.array([e_prime / 2, e_prime / 2, mu])
|
|
866
|
+
if self.contact: # lips closed at the front: no opening
|
|
867
|
+
k_int[:, 0] = np.maximum(k_int[:, 0], 0.0)
|
|
868
|
+
if self.friction and self._closed_at_front(r_in):
|
|
869
|
+
k_int[:, 0] = 0.0
|
|
870
|
+
moduli = np.array([e_prime, e_prime, 2 * mu])
|
|
871
|
+
shares = k_int**2 / moduli
|
|
872
|
+
if release_rate is None:
|
|
873
|
+
g = self._release_rate(r_in, r_out, stations, "work", True)
|
|
874
|
+
g = np.atleast_1d(g if at is None else g[1])
|
|
875
|
+
else:
|
|
876
|
+
g = np.full(len(theta), float(release_rate))
|
|
877
|
+
total = shares.sum(axis=1, keepdims=True)
|
|
878
|
+
split = g[:, None] * np.divide(shares, total, out=np.zeros_like(shares), where=total > 0)
|
|
879
|
+
out = {
|
|
880
|
+
"K_I": k_int[:, 0],
|
|
881
|
+
"K_II": k_int[:, 1],
|
|
882
|
+
"K_III": k_int[:, 2],
|
|
883
|
+
"G": g,
|
|
884
|
+
"G_I": split[:, 0],
|
|
885
|
+
"G_II": split[:, 1],
|
|
886
|
+
"G_III": split[:, 2],
|
|
887
|
+
"angle": np.array([kink_angle(a, b) for a, b in k_int[:, :2]]),
|
|
888
|
+
}
|
|
889
|
+
if at is None:
|
|
890
|
+
return {key: float(v[0]) for key, v in out.items()}
|
|
891
|
+
out["s"] = at
|
|
892
|
+
return out
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
def solve_crack(
|
|
896
|
+
mesh: TetMesh,
|
|
897
|
+
crack,
|
|
898
|
+
materials,
|
|
899
|
+
prescribed,
|
|
900
|
+
load: float = 1.0,
|
|
901
|
+
*,
|
|
902
|
+
kinematics: str = "small",
|
|
903
|
+
steps: int | None = None,
|
|
904
|
+
contact: float | bool | None = None,
|
|
905
|
+
friction: float = 0.0,
|
|
906
|
+
forces=None,
|
|
907
|
+
sides=None,
|
|
908
|
+
bulk: str = "auto",
|
|
909
|
+
initial: CrackSolution | None = None,
|
|
910
|
+
start: float | None = None,
|
|
911
|
+
transfer: str = "projection",
|
|
912
|
+
equilibrate: bool = True,
|
|
913
|
+
**options,
|
|
914
|
+
) -> CrackSolution:
|
|
915
|
+
"""Open the crack on its conforming mesh and solve the body (see the module):
|
|
916
|
+
``materials`` a material (all the phases) or a dict of the phases; ``prescribed`` the
|
|
917
|
+
entries ``(nodes, components, value)`` of
|
|
918
|
+
:meth:`~morphogen.fracture.cohesive.CohesiveProblem.run`, or a function of the opened
|
|
919
|
+
mesh returning them, and ``forces`` nodal forces (3 x nodes, or a function of the opened
|
|
920
|
+
mesh), both grown to ``load`` times their values in ``steps`` (by default 1, or 10 in
|
|
921
|
+
finite strains, with contact or an inelastic bulk); ``contact``: the penalty stiffness of
|
|
922
|
+
the contact of the lips (``True``: ``50 E / h``; none by default) and ``friction`` their
|
|
923
|
+
coefficient of friction (Coulomb: lips in contact stick or slide; see the module);
|
|
924
|
+
``bulk``: that of
|
|
925
|
+
:class:`~morphogen.fracture.cohesive.CohesiveProblem` (inelastic phases: their points);
|
|
926
|
+
``options``: those of the solver (``tol``, ``max_newton``, ``duration``...).
|
|
927
|
+
|
|
928
|
+
``initial``: the solution of another crack (another mesh) whose state goes on: its
|
|
929
|
+
displacement, and the internal variables of its points, are transferred to this mesh by
|
|
930
|
+
``transfer`` (:func:`~morphogen.fracture.ductile.transfer_state`), brought to
|
|
931
|
+
equilibrium (``equilibrate``) at the load ``start`` (by default the last of
|
|
932
|
+
``initial``), and the loading resumes from there up to ``load``."""
|
|
933
|
+
if friction and not contact:
|
|
934
|
+
raise ValueError("solve_crack: friction is that of lips in contact (contact=True)")
|
|
935
|
+
bonded = None
|
|
936
|
+
if friction: # with the ligament ahead of the front, which keeps the lips closed there
|
|
937
|
+
opened, faces, bonded = _faces_and_ligament(mesh, crack, sides)
|
|
938
|
+
else:
|
|
939
|
+
opened, faces = crack_faces(mesh, crack, sides)
|
|
940
|
+
materials = _as_materials(materials, opened)
|
|
941
|
+
if callable(prescribed):
|
|
942
|
+
prescribed = prescribed(opened)
|
|
943
|
+
if callable(forces):
|
|
944
|
+
forces = forces(opened)
|
|
945
|
+
if contact:
|
|
946
|
+
if contact is True:
|
|
947
|
+
x = opened.nodes[opened.elements]
|
|
948
|
+
size = float(np.mean(np.linalg.norm(x[:, 1] - x[:, 0], axis=1)))
|
|
949
|
+
young = max(_stiffest(m) for m in materials.values() if not m.void)
|
|
950
|
+
contact = 50.0 * young / size
|
|
951
|
+
interfaces, law = faces, Contact(float(contact), friction=float(friction))
|
|
952
|
+
else:
|
|
953
|
+
empty = np.zeros((0, 3), dtype=np.int64)
|
|
954
|
+
interfaces, law = Interfaces(empty, empty, np.zeros((0, 2), dtype=np.int64)), Contact(1.0)
|
|
955
|
+
problem = CohesiveProblem(opened, interfaces, materials, law, kinematics=kinematics, bulk=bulk)
|
|
956
|
+
if steps is None:
|
|
957
|
+
steps = 10 if kinematics == "finite" or contact or problem.bulk is not None else 1
|
|
958
|
+
if initial is not None:
|
|
959
|
+
from morphogen.fracture.ductile import transfer_displacement, transfer_state
|
|
960
|
+
|
|
961
|
+
start = float(initial.steps.loads[-1]) if start is None else float(start)
|
|
962
|
+
if problem.bulk is not None and initial.bulk is not None:
|
|
963
|
+
u0 = transfer_state(initial, opened, problem.bulk, crack, transfer)
|
|
964
|
+
else:
|
|
965
|
+
u0 = transfer_displacement(initial, opened, crack)
|
|
966
|
+
options = {**options, "start": start, "initial": u0, "equilibrate": equilibrate}
|
|
967
|
+
if bonded is not None:
|
|
968
|
+
options = {**options, "history": np.where(bonded, -1.0, 0.0)}
|
|
969
|
+
result = problem.run(prescribed, load, steps=steps, forces=forces, **options)
|
|
970
|
+
if bonded is not None: # the lips alone: their faces, the state of their points
|
|
971
|
+
faces = faces.subset(~bonded)
|
|
972
|
+
for name in ("history", "damage", "slip", "friction"):
|
|
973
|
+
setattr(result, name, getattr(result, name)[~bonded])
|
|
974
|
+
final = None if forces is None else load * np.asarray(forces, dtype=float).ravel()
|
|
975
|
+
return CrackSolution(opened, faces, crack, materials, kinematics == "finite",
|
|
976
|
+
result.displacement, result, final,
|
|
977
|
+
float(contact) if contact else None, bulk=problem.bulk,
|
|
978
|
+
friction=float(friction) if contact else 0.0) # fmt: skip
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
def _faces_and_ligament(mesh: TetMesh, crack, sides=None):
|
|
982
|
+
"""The mesh opened along the lips of a crack (:func:`~morphogen.fracture.lefm.
|
|
983
|
+
crack_faces`) and along the faces of its surface ahead of its front that touch them
|
|
984
|
+
(the ligament: one row of faces), the interface elements of both and the mask of
|
|
985
|
+
those of the ligament. Lips whose nodes of the front are shared cannot press on each
|
|
986
|
+
other there (the separation of a shared node is zero, and with it the pressure of the
|
|
987
|
+
penalty and Coulomb's limit): with the ligament opened and bonded by the same
|
|
988
|
+
penalty, the nodes of the front are split and the lips rub up to it."""
|
|
989
|
+
from morphogen.fracture.cohesive import insert_interfaces, interior_faces
|
|
990
|
+
|
|
991
|
+
if sides is None:
|
|
992
|
+
if mesh.side is not None:
|
|
993
|
+
sides = mesh.side
|
|
994
|
+
elif mesh.metadata.get("crack_sides") == "phase":
|
|
995
|
+
sides = mesh.phase
|
|
996
|
+
else:
|
|
997
|
+
sides = crack.phi(mesh.nodes[mesh.elements[:, :4]].mean(axis=1)) > 0
|
|
998
|
+
sides = np.asarray(sides)
|
|
999
|
+
corners, pairs = interior_faces(mesh)
|
|
1000
|
+
between = sides[pairs[:, 0]] != sides[pairs[:, 1]]
|
|
1001
|
+
lips = between & (crack.psi(mesh.nodes[corners].mean(axis=1)) < 0.0)
|
|
1002
|
+
touched = np.zeros(mesh.n_nodes, dtype=bool)
|
|
1003
|
+
touched[corners[lips]] = True
|
|
1004
|
+
ligament = between & ~lips & touched[corners].any(axis=1)
|
|
1005
|
+
opened, faces = insert_interfaces(mesh, lips | ligament)
|
|
1006
|
+
return opened, faces, ligament[lips | ligament]
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
def _stiffest(material) -> float:
|
|
1010
|
+
"""Young's modulus of a material, or the largest normal stiffness of its matrix."""
|
|
1011
|
+
if material.young:
|
|
1012
|
+
return float(material.young)
|
|
1013
|
+
return float(np.max(np.diag(np.asarray(material.stiffness, dtype=float))[:3]))
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
def kink_angle(k1: float, k2: float) -> float:
|
|
1017
|
+
"""The direction of the largest hoop stress (Erdogan & Sih), in radians from the
|
|
1018
|
+
direction of propagation towards the normal of the crack."""
|
|
1019
|
+
if abs(k2) <= 1e-12 * max(abs(k1), 1e-300):
|
|
1020
|
+
return 0.0
|
|
1021
|
+
return 2.0 * math.atan((k1 - math.sqrt(k1 * k1 + 8.0 * k2 * k2)) / (4.0 * k2))
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
def energy_release_rate(solve, crack, delta: float) -> float:
|
|
1025
|
+
"""``G = -(Π(a + δ) - Π(a - δ)) / (A(a + δ) - A(a - δ))``, the potential energies at fixed
|
|
1026
|
+
prescribed displacements and forces, ``solve(crack)`` returning the
|
|
1027
|
+
:class:`CrackSolution` of a crack: the check of the G-θ method (the mean along the
|
|
1028
|
+
front)."""
|
|
1029
|
+
plus, minus = solve(crack.grown(delta)), solve(crack.grown(-delta))
|
|
1030
|
+
return -(plus.potential() - minus.potential()) / (plus.area() - minus.area())
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
@dataclass
|
|
1034
|
+
class KinkedGrowth:
|
|
1035
|
+
"""The steps of a propagation: the cracks, their energy release rates, stress
|
|
1036
|
+
intensity factors (steps x 3), angles of their advances and cycles (Paris), with
|
|
1037
|
+
``keep`` the solutions; with a toughness, the critical load factor of each crack
|
|
1038
|
+
(``loads``: ``sqrt(Γ / G)`` of its advance at the load of the growth) and its advance
|
|
1039
|
+
(``advances``: the :class:`~morphogen.fracture.toughness.Advance` chosen; that of the last
|
|
1040
|
+
crack is not taken)."""
|
|
1041
|
+
|
|
1042
|
+
cracks: list
|
|
1043
|
+
rates: np.ndarray
|
|
1044
|
+
factors: np.ndarray
|
|
1045
|
+
angles: np.ndarray
|
|
1046
|
+
cycles: np.ndarray
|
|
1047
|
+
solutions: list = field(default_factory=list, repr=False)
|
|
1048
|
+
loads: np.ndarray | None = None
|
|
1049
|
+
advances: list = field(default_factory=list, repr=False)
|
|
1050
|
+
|
|
1051
|
+
def rows(self) -> list[dict]:
|
|
1052
|
+
rows = [
|
|
1053
|
+
{"step": k, "length": c.size, "x_tip": float(c.tip[0]), "y_tip": float(c.tip[1]),
|
|
1054
|
+
"z_tip": float(c.tip[2]), "G": float(g), "K_I": float(f[0]), "K_II": float(f[1]),
|
|
1055
|
+
"K_III": float(f[2]), "angle_deg": math.degrees(a), "N": float(n)}
|
|
1056
|
+
for k, (c, g, f, a, n) in enumerate(zip(self.cracks, self.rates, self.factors,
|
|
1057
|
+
self.angles, self.cycles, strict=True))
|
|
1058
|
+
] # fmt: skip
|
|
1059
|
+
if self.advances:
|
|
1060
|
+
for row, advance, load in zip(rows, self.advances, self.loads, strict=True):
|
|
1061
|
+
row.update(_advance_columns(advance))
|
|
1062
|
+
row["load_critical"] = float(load)
|
|
1063
|
+
return rows
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
def _advance_columns(advance) -> dict:
|
|
1067
|
+
"""The columns of an advance chosen by a toughness: into the bulk or along an
|
|
1068
|
+
interface, what it meets, its toughness and its ratio ``G(θ) / Γ(θ)``."""
|
|
1069
|
+
return {"path": advance.kind, "met": advance.label, "toughness": advance.toughness,
|
|
1070
|
+
"ratio": advance.ratio} # fmt: skip
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
def propagate_kinked(
|
|
1074
|
+
mesh_of,
|
|
1075
|
+
crack: KinkedCrack,
|
|
1076
|
+
materials,
|
|
1077
|
+
prescribed,
|
|
1078
|
+
load: float = 1.0,
|
|
1079
|
+
*,
|
|
1080
|
+
increment: float,
|
|
1081
|
+
steps: int,
|
|
1082
|
+
kinematics: str = "small",
|
|
1083
|
+
paris: tuple[float, float] | None = None,
|
|
1084
|
+
contact: float | bool | None = None,
|
|
1085
|
+
toughness=None,
|
|
1086
|
+
keep: bool = False,
|
|
1087
|
+
**options,
|
|
1088
|
+
) -> KinkedGrowth:
|
|
1089
|
+
"""Grow a kinked crack (see the module): ``mesh_of(crack)`` meshes the body conforming
|
|
1090
|
+
to it (:func:`~morphogen.fracture.lefm.crack_mesh`), ``prescribed`` (entries, or a
|
|
1091
|
+
function of the opened mesh) and ``load`` load it; each of the ``steps`` advances the
|
|
1092
|
+
front by ``increment`` in the direction of kinking; ``paris = (C, m)`` counts the
|
|
1093
|
+
cycles; ``options`` those of :func:`solve_crack`.
|
|
1094
|
+
|
|
1095
|
+
``toughness``: a :class:`~morphogen.fracture.toughness.Toughness` (or one value, or a
|
|
1096
|
+
dict of the phases): each advance is then the candidate of the largest ``G(θ) / Γ(θ)``,
|
|
1097
|
+
the kink of the bulk or along an interface within an increment ahead
|
|
1098
|
+
(:func:`~morphogen.fracture.toughness.advance_candidates`), and the critical load factor
|
|
1099
|
+
of each crack is ``load sqrt(Γ / G)`` of its advance (``G`` growing as the square of the
|
|
1100
|
+
load: small strains); one value for all the phases without interfaces gives the advances
|
|
1101
|
+
in the direction of kinking."""
|
|
1102
|
+
from morphogen.fracture.toughness import Toughness, advance_candidates, choose_advance
|
|
1103
|
+
|
|
1104
|
+
if not increment > 0:
|
|
1105
|
+
raise ValueError("propagate_kinked: a positive increment")
|
|
1106
|
+
rule = Toughness.of(toughness)
|
|
1107
|
+
cracks, rates, factors, angles, cycles, solutions = [], [], [], [], [], []
|
|
1108
|
+
loads, advances = [], []
|
|
1109
|
+
n = 0.0
|
|
1110
|
+
for step in range(int(steps) + 1):
|
|
1111
|
+
solution = solve_crack(mesh_of(crack), crack, materials, prescribed, load,
|
|
1112
|
+
kinematics=kinematics, contact=contact, **options) # fmt: skip
|
|
1113
|
+
modes = solution.modes()
|
|
1114
|
+
choice = None
|
|
1115
|
+
if rule is not None:
|
|
1116
|
+
choice = choose_advance(advance_candidates(solution, rule, increment, modes=modes))
|
|
1117
|
+
ratio = choice.ratio
|
|
1118
|
+
loads.append(float(load) / math.sqrt(ratio) if ratio > 0 else math.inf)
|
|
1119
|
+
advances.append(choice)
|
|
1120
|
+
cracks.append(crack)
|
|
1121
|
+
rates.append(modes["G"])
|
|
1122
|
+
factors.append((modes["K_I"], modes["K_II"], modes["K_III"]))
|
|
1123
|
+
angles.append(modes["angle"] if choice is None else choice.angle)
|
|
1124
|
+
cycles.append(n)
|
|
1125
|
+
if keep:
|
|
1126
|
+
solutions.append(solution)
|
|
1127
|
+
if step == steps:
|
|
1128
|
+
break
|
|
1129
|
+
grown = crack.grown(increment, modes["angle"]) if choice is None else choice.crack
|
|
1130
|
+
if paris is not None: # the moduli of the material at the front
|
|
1131
|
+
young, nu = _isotropic_moduli(solution.materials[solution.front_phase()])
|
|
1132
|
+
e_prime = young / (1 - nu**2)
|
|
1133
|
+
c, exponent = paris
|
|
1134
|
+
bulk = choice is None or choice.kind == "bulk"
|
|
1135
|
+
length = increment if bulk else grown.size - crack.size # along an interface
|
|
1136
|
+
n += length / (c * math.sqrt(e_prime * max(modes["G"], 1e-300)) ** exponent)
|
|
1137
|
+
crack = through_voids(grown, solution.mesh, increment)
|
|
1138
|
+
return KinkedGrowth(cracks, np.array(rates), np.array(factors), np.array(angles),
|
|
1139
|
+
np.array(cycles), solutions,
|
|
1140
|
+
None if rule is None else np.array(loads), advances) # fmt: skip
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
def inside_elements(mesh: TetMesh, points, k: int = 16, tol: float = 1e-9) -> np.ndarray:
|
|
1144
|
+
"""Whether points (rows) lie in an element of a mesh of linear tetrahedra (among the
|
|
1145
|
+
``k`` whose centroids are nearest; ``tol``: of their barycentric coordinates)."""
|
|
1146
|
+
from scipy.spatial import cKDTree
|
|
1147
|
+
|
|
1148
|
+
points = np.atleast_2d(np.asarray(points, dtype=float))
|
|
1149
|
+
x = mesh.nodes[mesh.elements[:, :4]]
|
|
1150
|
+
origin = x[:, 0]
|
|
1151
|
+
count = min(k, mesh.n_elements)
|
|
1152
|
+
_, near = cKDTree(x.mean(axis=1)).query(points, k=count)
|
|
1153
|
+
near = near.reshape(len(points), count)
|
|
1154
|
+
edges = np.stack([x[:, 1] - origin, x[:, 2] - origin, x[:, 3] - origin], axis=2)[near]
|
|
1155
|
+
local = np.linalg.solve(edges, (points[:, None, :] - origin[near])[..., None])[..., 0]
|
|
1156
|
+
smallest = np.minimum(local.min(axis=2), 1.0 - local.sum(axis=2))
|
|
1157
|
+
return np.any(smallest >= -tol, axis=1)
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
def through_voids(crack, mesh: TetMesh, increment: float, count: int = 64):
|
|
1161
|
+
"""The crack grown on through the voids of a mesh (its pores) in which its front would
|
|
1162
|
+
end: its last segment lengthened by halves of ``increment`` until most of the ``count``
|
|
1163
|
+
points of its front, and most of the points a quarter of ``increment`` behind them (on
|
|
1164
|
+
its lips), lie in elements again (:func:`inside_elements`), or its front leaves the box.
|
|
1165
|
+
A front that ran into a pore so goes through it, the crack then emanating from its far
|
|
1166
|
+
wall, its front a quarter to three quarters of ``increment`` beyond it."""
|
|
1167
|
+
lower, upper = mesh.nodes.min(axis=0), mesh.nodes.max(axis=0)
|
|
1168
|
+
span = float(np.max(upper - lower))
|
|
1169
|
+
for _ in range(int(4 * span / max(float(increment), 1e-300)) + 1):
|
|
1170
|
+
points, _ = crack.front(lower, upper, count)
|
|
1171
|
+
if not len(points):
|
|
1172
|
+
return crack
|
|
1173
|
+
behind = points - 0.25 * float(increment) * crack.frame(points)[2]
|
|
1174
|
+
inside = inside_elements(mesh, np.vstack([points, behind])).reshape(2, -1)
|
|
1175
|
+
if np.all(2 * np.count_nonzero(inside, axis=1) > len(points)):
|
|
1176
|
+
return crack
|
|
1177
|
+
crack = crack.grown(0.5 * float(increment))
|
|
1178
|
+
return crack
|