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,515 @@
|
|
|
1
|
+
"""The results of a run of OpenRadioss read back (:func:`read_explicit_run`): the nominal
|
|
2
|
+
stress and strain of the morphology over time (the reaction forces of its loaded faces
|
|
3
|
+
over the area of the face of its box, the displacement of the driven face over the
|
|
4
|
+
length of the box), its energies, the fields of its animations on its mesh (the
|
|
5
|
+
displacement, the von Mises stress, the plastic strain, the energy density, the
|
|
6
|
+
pressure and the status of each element), and the values that sum a test up
|
|
7
|
+
(:func:`summary`: the peak stress, the absorbed energy, the plateau stress and the
|
|
8
|
+
densification strain of a crushing, the equilibrium of the faces, the rebound of an
|
|
9
|
+
impact).
|
|
10
|
+
|
|
11
|
+
The forces come from the time history (``th_to_csv``) when its columns name the nodes of
|
|
12
|
+
the loaded faces, else from the reaction forces of the animations (``anim_to_vtk``), on
|
|
13
|
+
the nodes that the manifest of the run names; :func:`write_frames` writes the fields of
|
|
14
|
+
each animation as a ``.vtu`` file of tetrahedra (the bricks split in six) for the 3D views
|
|
15
|
+
of morphoGen."""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import re
|
|
20
|
+
from dataclasses import dataclass, field
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
import numpy as np
|
|
24
|
+
|
|
25
|
+
#: The fields of the animations, by the words of their names in the files of anim_to_vtk
|
|
26
|
+
#: (lower case), and the words that exclude a name
|
|
27
|
+
FIELDS = {
|
|
28
|
+
"displacement": (("disp",), ()),
|
|
29
|
+
"velocity": (("vel",), ("accel",)),
|
|
30
|
+
"reaction": (("reac",), ()),
|
|
31
|
+
"contact": (("cont",), ("contour",)),
|
|
32
|
+
"von_mises": (("vonm", "von_mises", "von mises", "vonmises", "von-mises"), ()),
|
|
33
|
+
"plastic_strain": (("epsp", "plastic"), ()),
|
|
34
|
+
"energy_density": (("ener",), ("hourg",)),
|
|
35
|
+
"pressure": (("pres",), ()),
|
|
36
|
+
"status": (("off", "status", "delet"), ("offset",)),
|
|
37
|
+
}
|
|
38
|
+
#: The fields of the elements kept in the frames written for the 3D views
|
|
39
|
+
CELL_FIELDS = ("von_mises", "plastic_strain", "energy_density", "pressure")
|
|
40
|
+
#: The 6 tetrahedra of a hexahedron in VTK's order (along its diagonal 0-6; positive)
|
|
41
|
+
KUHN = np.array(
|
|
42
|
+
[[0, 1, 2, 6], [0, 2, 3, 6], [0, 3, 7, 6], [0, 7, 4, 6], [0, 4, 5, 6], [0, 5, 1, 6]]
|
|
43
|
+
)
|
|
44
|
+
#: VTK's types of the solid cells
|
|
45
|
+
SOLID_TYPES = (12, 10, 24)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _find(arrays: dict, kind: str):
|
|
49
|
+
"""The array of a field (:data:`FIELDS`) among those of a file, or None."""
|
|
50
|
+
words, exclude = FIELDS[kind]
|
|
51
|
+
for name, values in arrays.items():
|
|
52
|
+
low = name.lower()
|
|
53
|
+
if any(w in low for w in words) and not any(x in low for x in exclude):
|
|
54
|
+
return values
|
|
55
|
+
if kind == "pressure":
|
|
56
|
+
for name, values in arrays.items():
|
|
57
|
+
if name.strip().lower() == "p":
|
|
58
|
+
return values
|
|
59
|
+
return None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _ids(arrays: dict, words=("node", "id")):
|
|
63
|
+
"""An array of identifiers (integers named like ``NODE_ID``), or None."""
|
|
64
|
+
for name, values in arrays.items():
|
|
65
|
+
low = name.lower().replace(" ", "_")
|
|
66
|
+
values = np.asarray(values)
|
|
67
|
+
if values.ndim == 1 and all(w in low for w in words) and np.all(np.mod(values, 1) == 0):
|
|
68
|
+
return values.astype(np.int64)
|
|
69
|
+
return None
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@dataclass
|
|
73
|
+
class ExplicitFrame:
|
|
74
|
+
"""An animation of a run on the mesh of the run: its time, the displacement and
|
|
75
|
+
reaction force of each node (None when the animation has none), the fields of the
|
|
76
|
+
elements and their status (1 active, 0 deleted)."""
|
|
77
|
+
|
|
78
|
+
time: float
|
|
79
|
+
displacement: np.ndarray | None
|
|
80
|
+
reaction: np.ndarray | None
|
|
81
|
+
cells: dict[str, np.ndarray] = field(default_factory=dict)
|
|
82
|
+
status: np.ndarray | None = None
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@dataclass
|
|
86
|
+
class ExplicitResult:
|
|
87
|
+
"""The results of a run (see the module): its ``manifest``, its ``mesh`` (nodes,
|
|
88
|
+
elements, phases and loaded faces), its ``curves`` (time, displacement, strain,
|
|
89
|
+
forces and nominal stresses of the upper and lower faces), its ``energies``
|
|
90
|
+
(time -> internal, kinetic... when the time history gives them), its ``frames``
|
|
91
|
+
and the ``source`` of its forces."""
|
|
92
|
+
|
|
93
|
+
directory: Path
|
|
94
|
+
manifest: dict
|
|
95
|
+
mesh: dict
|
|
96
|
+
curves: dict[str, np.ndarray]
|
|
97
|
+
energies: dict[str, np.ndarray]
|
|
98
|
+
frames: list[ExplicitFrame]
|
|
99
|
+
source: str
|
|
100
|
+
warnings: list[str] = field(default_factory=list)
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def name(self) -> str:
|
|
104
|
+
return self.manifest["name"]
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _times_of(grids: list[dict], titles: list[str], manifest: dict) -> np.ndarray:
|
|
108
|
+
"""The times of the animations: those their titles give, else their rank times the
|
|
109
|
+
interval of the animations (the first at 0)."""
|
|
110
|
+
times = []
|
|
111
|
+
for title in titles:
|
|
112
|
+
m = re.search(r"time\s*[=:]?\s*([-+]?\d+\.?\d*(?:[eEdD][-+]?\d+)?)", title, re.I)
|
|
113
|
+
times.append(float(m.group(1).replace("D", "E").replace("d", "e")) if m else None)
|
|
114
|
+
if all(t is not None for t in times) and len(set(times)) == len(times):
|
|
115
|
+
return np.array(times, dtype=float)
|
|
116
|
+
step = float(manifest["end_time"]) / int(manifest["frames"])
|
|
117
|
+
return np.arange(len(grids), dtype=float) * step
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _title(path: Path) -> str:
|
|
121
|
+
with open(path, "rb") as f:
|
|
122
|
+
f.readline()
|
|
123
|
+
return f.readline().decode("latin-1", "replace").strip()
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def read_frames(
|
|
127
|
+
directory, manifest: dict, mesh: dict, paths
|
|
128
|
+
) -> tuple[list[ExplicitFrame], list[str]]:
|
|
129
|
+
"""The animations (legacy VTK files of anim_to_vtk) on the mesh of the run: their
|
|
130
|
+
nodes matched by their identifiers (an array named like NODE_ID), by their order when
|
|
131
|
+
they are as many, else by their positions in the first animation; their elements
|
|
132
|
+
likewise (ELEMENT_ID)."""
|
|
133
|
+
from scipy.spatial import cKDTree
|
|
134
|
+
|
|
135
|
+
from morphogen.io.vtk import cells_of_type, read_vtk_grid
|
|
136
|
+
|
|
137
|
+
notes: list[str] = []
|
|
138
|
+
paths = list(paths)
|
|
139
|
+
if not paths:
|
|
140
|
+
return [], notes
|
|
141
|
+
nodes = np.asarray(mesh["nodes"], dtype=float)
|
|
142
|
+
n_nodes, n_elements = len(nodes), len(mesh["elements"])
|
|
143
|
+
grids = [read_vtk_grid(p) for p in paths]
|
|
144
|
+
times = _times_of(grids, [_title(Path(p)) for p in paths], manifest)
|
|
145
|
+
first = grids[0]
|
|
146
|
+
ids = _ids(first["point_data"]) if first["point_data"] else None
|
|
147
|
+
if ids is not None and ids.max(initial=0) <= n_nodes and ids.min(initial=1) >= 1:
|
|
148
|
+
node_index = ids - 1 # the point k of the files is the node node_index[k]
|
|
149
|
+
elif len(first["points"]) == n_nodes:
|
|
150
|
+
node_index = np.arange(n_nodes)
|
|
151
|
+
else:
|
|
152
|
+
u0 = _find(first["point_data"], "displacement")
|
|
153
|
+
ref = first["points"] - (0.0 if u0 is None else np.asarray(u0, dtype=float))
|
|
154
|
+
distance, node_index = cKDTree(nodes).query(ref)
|
|
155
|
+
far = distance > 1e-6 * float(np.ptp(nodes, axis=0).max())
|
|
156
|
+
if np.any(far):
|
|
157
|
+
notes.append(f"{int(far.sum())} points of the animations are not nodes of the mesh")
|
|
158
|
+
node_index = np.where(far, -1, node_index)
|
|
159
|
+
cell_index = None
|
|
160
|
+
for cell_type in SOLID_TYPES:
|
|
161
|
+
_, picked = cells_of_type(first, cell_type)
|
|
162
|
+
if len(picked):
|
|
163
|
+
eids = _ids(
|
|
164
|
+
{
|
|
165
|
+
k: np.asarray(v)[picked]
|
|
166
|
+
for k, v in first["cell_data"].items()
|
|
167
|
+
if np.ndim(v) == 1 and len(v) == len(first["types"])
|
|
168
|
+
},
|
|
169
|
+
("elem",),
|
|
170
|
+
)
|
|
171
|
+
if eids is not None and eids.min(initial=1) >= 1:
|
|
172
|
+
numbers = np.asarray(mesh["numbers"]) # element e has the number numbers[e]
|
|
173
|
+
lookup = np.full(int(max(eids.max(initial=0), numbers.max(initial=0))) + 1, -1)
|
|
174
|
+
lookup[numbers] = np.arange(n_elements)
|
|
175
|
+
cell_index = (picked, lookup[eids])
|
|
176
|
+
elif len(picked) == n_elements:
|
|
177
|
+
numbers = np.asarray(mesh["numbers"])
|
|
178
|
+
cell_index = (picked, np.argsort(numbers)) # the files in the order of the numbers
|
|
179
|
+
else:
|
|
180
|
+
notes.append(
|
|
181
|
+
f"{len(picked)} solid cells in the animations for {n_elements} elements: "
|
|
182
|
+
"their fields are left out"
|
|
183
|
+
)
|
|
184
|
+
break
|
|
185
|
+
valid = node_index >= 0
|
|
186
|
+
|
|
187
|
+
def on_nodes(values):
|
|
188
|
+
"""Values of the points of the files on the nodes of the mesh (0 elsewhere)."""
|
|
189
|
+
if values is None:
|
|
190
|
+
return None
|
|
191
|
+
values = np.asarray(values, dtype=float)
|
|
192
|
+
out = np.zeros((n_nodes, *values.shape[1:]))
|
|
193
|
+
out[node_index[valid]] = values[: len(node_index)][valid]
|
|
194
|
+
return out
|
|
195
|
+
|
|
196
|
+
frames = []
|
|
197
|
+
for t, grid in zip(times, grids, strict=True):
|
|
198
|
+
point = grid["point_data"]
|
|
199
|
+
u = on_nodes(_find(point, "displacement"))
|
|
200
|
+
if u is None and len(grid["points"]) == len(first["points"]):
|
|
201
|
+
u = on_nodes(grid["points"] - first["points"])
|
|
202
|
+
frame = ExplicitFrame(float(t), u, on_nodes(_find(point, "reaction")))
|
|
203
|
+
if cell_index is not None:
|
|
204
|
+
picked, elements = cell_index
|
|
205
|
+
data = {
|
|
206
|
+
k: np.asarray(v)[picked]
|
|
207
|
+
for k, v in grid["cell_data"].items()
|
|
208
|
+
if np.ndim(v) >= 1 and len(v) == len(grid["types"])
|
|
209
|
+
}
|
|
210
|
+
for kind in (*CELL_FIELDS, "status"):
|
|
211
|
+
values = _find(data, kind)
|
|
212
|
+
if values is None:
|
|
213
|
+
continue
|
|
214
|
+
values = np.asarray(values, dtype=float)
|
|
215
|
+
if values.ndim > 1: # a tensor or a vector: its norm
|
|
216
|
+
values = np.linalg.norm(values, axis=1)
|
|
217
|
+
out = np.full(n_elements, np.nan)
|
|
218
|
+
ok = elements >= 0
|
|
219
|
+
out[elements[ok]] = values[ok]
|
|
220
|
+
if kind == "status":
|
|
221
|
+
frame.status = np.where(np.isnan(out), 1.0, out)
|
|
222
|
+
else:
|
|
223
|
+
frame.cells[kind] = out
|
|
224
|
+
frames.append(frame)
|
|
225
|
+
return frames, notes
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def _face_forces_th(th: dict, manifest: dict, mesh: dict):
|
|
229
|
+
"""The forces of the loaded faces along the drive from the time history, when its
|
|
230
|
+
columns name the nodes (``L<id>``, ``U<id>``, or their identifiers): (lower, upper),
|
|
231
|
+
or None."""
|
|
232
|
+
letter = "XYZ"[int(manifest["driven"])]
|
|
233
|
+
lower_ids = set((np.asarray(mesh["lower_nodes"]) + 1).tolist())
|
|
234
|
+
upper_ids = set((np.asarray(mesh["upper_nodes"]) + 1).tolist())
|
|
235
|
+
sums = {"lower": None, "upper": None}
|
|
236
|
+
counts = {"lower": 0, "upper": 0}
|
|
237
|
+
for name, values in th.items():
|
|
238
|
+
up = name.upper()
|
|
239
|
+
if f"REAC{letter}" not in up:
|
|
240
|
+
continue
|
|
241
|
+
m = re.search(r"(?<![A-Z0-9])([LU])(\d+)(?![0-9])", up)
|
|
242
|
+
if m:
|
|
243
|
+
face = "lower" if m.group(1) == "L" else "upper"
|
|
244
|
+
else:
|
|
245
|
+
numbers = {int(x) for x in re.findall(r"\d+", up)}
|
|
246
|
+
if numbers & lower_ids and not numbers & upper_ids:
|
|
247
|
+
face = "lower"
|
|
248
|
+
elif numbers & upper_ids and not numbers & lower_ids:
|
|
249
|
+
face = "upper"
|
|
250
|
+
else:
|
|
251
|
+
continue
|
|
252
|
+
sums[face] = values.copy() if sums[face] is None else sums[face] + values
|
|
253
|
+
counts[face] += 1
|
|
254
|
+
expected = {"lower": len(lower_ids), "upper": len(upper_ids)}
|
|
255
|
+
if any(counts[f] != expected[f] for f in counts):
|
|
256
|
+
return None
|
|
257
|
+
return sums["lower"], sums["upper"]
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def _energies_th(th: dict) -> dict[str, np.ndarray]:
|
|
261
|
+
"""The energies and momenta of the time history (its columns IE, KE, HE, XMOM...,
|
|
262
|
+
summed over the parts; the global ones alone when it has them)."""
|
|
263
|
+
kinds = {
|
|
264
|
+
"IE": "internal",
|
|
265
|
+
"KE": "kinetic",
|
|
266
|
+
"HE": "hourglass",
|
|
267
|
+
"XMOM": "momentum_x",
|
|
268
|
+
"YMOM": "momentum_y",
|
|
269
|
+
"ZMOM": "momentum_z",
|
|
270
|
+
}
|
|
271
|
+
columns: dict[str, list[tuple[bool, np.ndarray]]] = {}
|
|
272
|
+
for name, values in th.items():
|
|
273
|
+
tokens = re.split(r"[^A-Z0-9]+", name.upper())
|
|
274
|
+
for token, kind in kinds.items():
|
|
275
|
+
if token in tokens:
|
|
276
|
+
columns.setdefault(kind, []).append(
|
|
277
|
+
("GLOBAL" in tokens or "GLOB" in tokens, values)
|
|
278
|
+
)
|
|
279
|
+
out = {}
|
|
280
|
+
for kind, found in columns.items():
|
|
281
|
+
chosen = [v for g, v in found if g] or [v for _, v in found]
|
|
282
|
+
out[kind] = np.sum(chosen, axis=0)
|
|
283
|
+
if out:
|
|
284
|
+
out["time"] = th["time"]
|
|
285
|
+
return out
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def read_explicit_run(directory) -> ExplicitResult:
|
|
289
|
+
"""The results of a run of OpenRadioss in ``directory`` (see the module), from its
|
|
290
|
+
manifest and mesh (:func:`morphogen.io.write_radioss`), its animations converted to
|
|
291
|
+
VTK and its time history converted to CSV (:func:`morphogen.dynamics.convert_outputs`)."""
|
|
292
|
+
from morphogen.io.radioss import read_manifest, read_radioss_th
|
|
293
|
+
|
|
294
|
+
directory = Path(directory)
|
|
295
|
+
manifest = read_manifest(directory)
|
|
296
|
+
name = manifest["name"]
|
|
297
|
+
with np.load(directory / f"{name}_mesh.npz") as data:
|
|
298
|
+
mesh = {k: data[k] for k in data.files}
|
|
299
|
+
notes: list[str] = []
|
|
300
|
+
vtk = sorted(directory.glob(f"{name}A*.vtk"), key=lambda p: p.name)
|
|
301
|
+
frames, more = read_frames(directory, manifest, mesh, vtk)
|
|
302
|
+
notes += more
|
|
303
|
+
th, energies = {}, {}
|
|
304
|
+
csvs = sorted(directory.glob(f"{name}T01*.csv"))
|
|
305
|
+
if csvs:
|
|
306
|
+
try:
|
|
307
|
+
th = read_radioss_th(csvs[0])
|
|
308
|
+
energies = _energies_th(th)
|
|
309
|
+
except ValueError as exc:
|
|
310
|
+
notes.append(f"time history not read: {exc}")
|
|
311
|
+
lengths = np.asarray(manifest["lengths"], dtype=float)
|
|
312
|
+
axis, drive, sign = int(manifest["axis"]), int(manifest["driven"]), float(manifest["sign"])
|
|
313
|
+
area = float(manifest["area"])
|
|
314
|
+
from morphogen.dynamics.model import ExplicitLoading
|
|
315
|
+
|
|
316
|
+
loading = ExplicitLoading.from_config(manifest["loading"])
|
|
317
|
+
curves: dict[str, np.ndarray] = {}
|
|
318
|
+
source = "none"
|
|
319
|
+
forces = _face_forces_th(th, manifest, mesh) if th and loading.kind != "impact" else None
|
|
320
|
+
if forces is not None:
|
|
321
|
+
times = np.asarray(th["time"], dtype=float)
|
|
322
|
+
lower, upper = forces
|
|
323
|
+
source = "time history"
|
|
324
|
+
elif frames and loading.kind != "impact" and frames[0].reaction is not None:
|
|
325
|
+
times = np.array([f.time for f in frames])
|
|
326
|
+
upper = np.array([f.reaction[mesh["upper_nodes"], drive].sum() for f in frames])
|
|
327
|
+
lower = np.array([f.reaction[mesh["lower_nodes"], drive].sum() for f in frames])
|
|
328
|
+
source = "animations"
|
|
329
|
+
else:
|
|
330
|
+
times, lower, upper = None, None, None
|
|
331
|
+
if times is not None:
|
|
332
|
+
u = loading.displacement(times, lengths)
|
|
333
|
+
curves = {
|
|
334
|
+
"time": times,
|
|
335
|
+
"displacement": u,
|
|
336
|
+
"strain": sign * u / lengths[axis],
|
|
337
|
+
"force_upper": sign * upper,
|
|
338
|
+
"force_lower": -sign * lower,
|
|
339
|
+
}
|
|
340
|
+
curves["stress_upper"] = curves["force_upper"] / area
|
|
341
|
+
curves["stress_lower"] = curves["force_lower"] / area
|
|
342
|
+
elif loading.kind == "impact" and energies.get(f"momentum_{'xyz'[axis]}") is not None:
|
|
343
|
+
t = np.asarray(energies["time"], dtype=float)
|
|
344
|
+
p = np.asarray(energies[f"momentum_{'xyz'[axis]}"], dtype=float)
|
|
345
|
+
force = -sign * np.gradient(p, t) if len(t) > 1 else np.zeros_like(p)
|
|
346
|
+
curves = {"time": t, "momentum": p, "force_wall": force, "stress_wall": force / area}
|
|
347
|
+
source = "momentum"
|
|
348
|
+
if not curves and loading.kind != "impact":
|
|
349
|
+
notes.append(
|
|
350
|
+
"no forces of the faces: neither the time history nor the animations give "
|
|
351
|
+
"them (are anim_to_vtk and th_to_csv in the installation?)"
|
|
352
|
+
)
|
|
353
|
+
return ExplicitResult(directory, manifest, mesh, curves, energies, frames, source, notes)
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
# -- summary -------------------------------------------------------------------------------
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def _integral(y: np.ndarray, x: np.ndarray) -> np.ndarray:
|
|
360
|
+
"""The cumulative integral of y dx (trapezoids), from 0."""
|
|
361
|
+
out = np.zeros_like(np.asarray(y, dtype=float))
|
|
362
|
+
if len(x) > 1:
|
|
363
|
+
out[1:] = np.cumsum(0.5 * (y[1:] + y[:-1]) * np.diff(x))
|
|
364
|
+
return out
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def summary(result: ExplicitResult) -> dict:
|
|
368
|
+
"""The values that sum a run up, in the units of the run: the final and peak nominal
|
|
369
|
+
stresses and strains, the energy absorbed per unit volume of the box (the integral of
|
|
370
|
+
the nominal stress over the nominal strain) and per unit mass, the mean gap between
|
|
371
|
+
the stresses of the two faces over the second half of the run (the equilibrium of a
|
|
372
|
+
quasi-static test: small when the waves have settled), the plateau stress (the mean
|
|
373
|
+
between 20 and 40 % strain, after Ashby) and the densification strain (where the
|
|
374
|
+
energy efficiency, the absorbed energy over the stress, peaks: Avalle et al., 2001)
|
|
375
|
+
of a crushing; for an impact, the peak force on the wall and the kinetic energies;
|
|
376
|
+
the energies at the end when the time history gives them; the size of the run."""
|
|
377
|
+
m = result.manifest
|
|
378
|
+
out: dict = {
|
|
379
|
+
"loading": m["loading"]["kind"],
|
|
380
|
+
"elements": m["n_elements"],
|
|
381
|
+
"nodes": m["n_nodes"],
|
|
382
|
+
"end time": m["end_time"],
|
|
383
|
+
"stable time step (estimate)": m["critical_time_step"],
|
|
384
|
+
"cycles (estimate)": round(m["cycles"]),
|
|
385
|
+
"mass": m["mass"],
|
|
386
|
+
"solid fraction": m["solid_volume"] / m["volume"],
|
|
387
|
+
}
|
|
388
|
+
c = result.curves
|
|
389
|
+
if "stress_upper" in c and len(c["time"]) > 1:
|
|
390
|
+
strain, stress = np.asarray(c["strain"]), np.asarray(c["stress_upper"])
|
|
391
|
+
lower = np.asarray(c["stress_lower"])
|
|
392
|
+
k = int(np.argmax(stress))
|
|
393
|
+
work = _integral(stress, strain)
|
|
394
|
+
out.update(
|
|
395
|
+
{
|
|
396
|
+
"final strain": float(strain[-1]),
|
|
397
|
+
"final stress": float(stress[-1]),
|
|
398
|
+
"peak stress": float(stress[k]),
|
|
399
|
+
"strain at the peak": float(strain[k]),
|
|
400
|
+
"absorbed energy per volume": float(work[-1]),
|
|
401
|
+
"absorbed energy per mass": float(work[-1] * m["volume"] / m["mass"]),
|
|
402
|
+
}
|
|
403
|
+
)
|
|
404
|
+
half = strain >= 0.5 * strain[-1]
|
|
405
|
+
scale = np.maximum(np.abs(stress[half]), 1e-12 * max(np.max(np.abs(stress)), 1e-300))
|
|
406
|
+
out["face stress gap (second half)"] = float(
|
|
407
|
+
np.mean(np.abs(stress[half] - lower[half]) / scale)
|
|
408
|
+
)
|
|
409
|
+
if m["loading"]["kind"] == "compression":
|
|
410
|
+
if strain[-1] >= 0.4:
|
|
411
|
+
window = (strain >= 0.2) & (strain <= 0.4)
|
|
412
|
+
out["plateau stress (20-40 %)"] = float(np.mean(stress[window]))
|
|
413
|
+
efficiency = np.where(stress > 0, work / np.maximum(stress, 1e-300), 0.0)
|
|
414
|
+
j = int(np.argmax(efficiency))
|
|
415
|
+
if 0 < j < len(efficiency) - 1 and strain[j] > 0.1:
|
|
416
|
+
out["densification strain"] = float(strain[j])
|
|
417
|
+
elif "force_wall" in c and len(c["time"]) > 1:
|
|
418
|
+
out["peak force on the wall"] = float(np.max(c["force_wall"]))
|
|
419
|
+
e = result.energies
|
|
420
|
+
for kind in ("internal", "kinetic", "hourglass"):
|
|
421
|
+
if kind in e and len(e[kind]):
|
|
422
|
+
out[f"{kind} energy at the end"] = float(e[kind][-1])
|
|
423
|
+
if m["loading"]["kind"] == "impact" and "kinetic" in e and len(e["kinetic"]) > 1:
|
|
424
|
+
k0, k1 = float(e["kinetic"][0]), float(e["kinetic"][-1])
|
|
425
|
+
out["initial kinetic energy"] = k0
|
|
426
|
+
if k0 > 0:
|
|
427
|
+
out["kinetic energy kept"] = k1 / k0
|
|
428
|
+
out["rebound speed / impact speed"] = float(np.sqrt(max(k1, 0.0) / k0))
|
|
429
|
+
return out
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
# -- frames for the 3D views ---------------------------------------------------------------
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
def display_cells(elements: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
|
|
436
|
+
"""The tetrahedra that draw a mesh (its tetrahedra, or six per brick) and the element
|
|
437
|
+
of each."""
|
|
438
|
+
elements = np.asarray(elements, dtype=np.int64)
|
|
439
|
+
if elements.shape[1] != 8:
|
|
440
|
+
return elements, np.arange(len(elements))
|
|
441
|
+
tets = elements[:, KUHN].reshape(-1, 4)
|
|
442
|
+
return tets, np.repeat(np.arange(len(elements)), len(KUHN))
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
def write_frames(result: ExplicitResult, folder, *, prefix: str = "frame") -> list[Path]:
|
|
446
|
+
"""Write each animation of a run as ``<prefix>_0001.vtu``... in ``folder``: the
|
|
447
|
+
elements still active (the bricks split in six tetrahedra), their phase and fields,
|
|
448
|
+
the displacement of the nodes, the box (morphoGen's 3D views draw the last one)."""
|
|
449
|
+
from morphogen.io.vtk import write_vtu
|
|
450
|
+
|
|
451
|
+
folder = Path(folder)
|
|
452
|
+
folder.mkdir(parents=True, exist_ok=True)
|
|
453
|
+
mesh = result.mesh
|
|
454
|
+
nodes = np.asarray(mesh["nodes"], dtype=float)
|
|
455
|
+
tets, owner = display_cells(mesh["elements"])
|
|
456
|
+
cell_type = 10 if tets.shape[1] == 4 else 24
|
|
457
|
+
box = {
|
|
458
|
+
"box_lower": np.asarray(result.manifest["lower"], dtype=float),
|
|
459
|
+
"box_upper": np.asarray(result.manifest["upper"], dtype=float),
|
|
460
|
+
}
|
|
461
|
+
written = []
|
|
462
|
+
for k, frame in enumerate(result.frames, start=1):
|
|
463
|
+
keep = np.ones(len(tets), dtype=bool)
|
|
464
|
+
if frame.status is not None:
|
|
465
|
+
keep = frame.status[owner] > 0
|
|
466
|
+
if not keep.any():
|
|
467
|
+
continue
|
|
468
|
+
data = {"phase": np.asarray(mesh["phase"])[owner][keep].astype(np.int32)}
|
|
469
|
+
for kind, values in frame.cells.items():
|
|
470
|
+
data[kind] = np.nan_to_num(values[owner][keep])
|
|
471
|
+
point = {}
|
|
472
|
+
if frame.displacement is not None:
|
|
473
|
+
point["displacement"] = frame.displacement
|
|
474
|
+
path = folder / f"{prefix}_{k:04d}.vtu"
|
|
475
|
+
write_vtu(
|
|
476
|
+
path,
|
|
477
|
+
nodes,
|
|
478
|
+
tets[keep],
|
|
479
|
+
cell_type,
|
|
480
|
+
data,
|
|
481
|
+
point_data=point,
|
|
482
|
+
field_data={**box, "time": np.array([frame.time])},
|
|
483
|
+
)
|
|
484
|
+
written.append(path)
|
|
485
|
+
return written
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
def frames_mesh(result: ExplicitResult):
|
|
489
|
+
"""The mesh of the frames as a :class:`~morphogen.mesh.tetra.TetMesh` (the bricks
|
|
490
|
+
split in six), for the videos of :mod:`morphogen.viz.video`."""
|
|
491
|
+
from morphogen.mesh.tetra import TetMesh
|
|
492
|
+
|
|
493
|
+
tets, owner = display_cells(result.mesh["elements"])
|
|
494
|
+
m = result.manifest
|
|
495
|
+
return TetMesh(
|
|
496
|
+
np.asarray(result.mesh["nodes"], dtype=float),
|
|
497
|
+
tets,
|
|
498
|
+
np.asarray(result.mesh["phase"])[owner],
|
|
499
|
+
m["lower"],
|
|
500
|
+
m["upper"],
|
|
501
|
+
), owner
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
def write_tables(result: ExplicitResult, folder) -> list[Path]:
|
|
505
|
+
"""The curves and energies of a run as ``curves.csv`` and ``energies.csv``."""
|
|
506
|
+
from morphogen.io.tables import write_table
|
|
507
|
+
|
|
508
|
+
folder = Path(folder)
|
|
509
|
+
return [
|
|
510
|
+
write_table(
|
|
511
|
+
folder / f"{name}.csv", {k: np.asarray(v, dtype=float) for k, v in columns.items()}
|
|
512
|
+
)
|
|
513
|
+
for name, columns in (("curves", result.curves), ("energies", result.energies))
|
|
514
|
+
if columns
|
|
515
|
+
]
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""Fracture: cohesive zone elements along interfaces and crack paths, in small and finite
|
|
2
|
+
strains (:mod:`morphogen.fracture.cohesive`), the interfaces of the phases of periodic
|
|
3
|
+
cells that debond along the loading paths of the homogenization
|
|
4
|
+
(:mod:`morphogen.fracture.periodic`), the linear elastic fracture mechanics of 3D
|
|
5
|
+
cracks, their energy release rate and propagation on conforming (remeshed) meshes or by
|
|
6
|
+
XFEM (:mod:`morphogen.fracture.lefm`), and mixed-mode cracks (I, II, III) in small and
|
|
7
|
+
finite strains: the G-θ method, the interaction integrals, kinked cracks and their growth
|
|
8
|
+
(:mod:`morphogen.fracture.mixed`), with the behaviours of morphoGen's points as their bulk
|
|
9
|
+
(elasto-viscoplasticity, porous and crystal plasticity, MFront; :mod:`morphogen.fracture.bulk`),
|
|
10
|
+
and their ductile growth on remeshed meshes, the state of the points transferred from mesh to
|
|
11
|
+
mesh, grain by grain in polycrystals (:mod:`morphogen.fracture.ductile`); cracks through a
|
|
12
|
+
morphology, its phases and pores on the crack meshes (:func:`crack_mesh` with ``morphology``),
|
|
13
|
+
the sides of the crack apart, which feel the toughness of each phase and of the interfaces
|
|
14
|
+
between them: deflected along weak interfaces, held back by tough phases
|
|
15
|
+
(:mod:`morphogen.fracture.toughness`); cracks of any surface and front, each point of
|
|
16
|
+
which advances and kinks on its own (:mod:`morphogen.fracture.surface`); and the
|
|
17
|
+
brittle fracture of voxel images by the
|
|
18
|
+
phase-field method, whose cracks start, branch and merge without being tracked
|
|
19
|
+
(:mod:`morphogen.fracture.phasefield`; in finite strains, the rubbers and soft solids of
|
|
20
|
+
:mod:`morphogen.fracture.phasefield_finite`)."""
|
|
21
|
+
|
|
22
|
+
from morphogen.fracture.bulk import PointBulk
|
|
23
|
+
from morphogen.fracture.cohesive import (
|
|
24
|
+
Bilinear,
|
|
25
|
+
CohesiveProblem,
|
|
26
|
+
CohesiveResult,
|
|
27
|
+
Contact,
|
|
28
|
+
Exponential,
|
|
29
|
+
Interfaces,
|
|
30
|
+
cohesive_zone_length,
|
|
31
|
+
dcb_beam_theory,
|
|
32
|
+
dcb_specimen,
|
|
33
|
+
insert_interfaces,
|
|
34
|
+
traction,
|
|
35
|
+
turon_strength,
|
|
36
|
+
)
|
|
37
|
+
from morphogen.fracture.ductile import (
|
|
38
|
+
DuctileGrowth,
|
|
39
|
+
dissipation,
|
|
40
|
+
propagate_ductile,
|
|
41
|
+
transfer_displacement,
|
|
42
|
+
transfer_state,
|
|
43
|
+
)
|
|
44
|
+
from morphogen.fracture.lefm import (
|
|
45
|
+
XFEM,
|
|
46
|
+
Crack,
|
|
47
|
+
Propagation,
|
|
48
|
+
conforming_work_of,
|
|
49
|
+
crack_faces,
|
|
50
|
+
crack_mesh,
|
|
51
|
+
cut_mesh,
|
|
52
|
+
face_forces,
|
|
53
|
+
interface_nodes,
|
|
54
|
+
open_crack,
|
|
55
|
+
phase_mesh,
|
|
56
|
+
phases_at,
|
|
57
|
+
propagate,
|
|
58
|
+
quarter_points,
|
|
59
|
+
refine_front,
|
|
60
|
+
release_rate,
|
|
61
|
+
sent_factor,
|
|
62
|
+
snap_front,
|
|
63
|
+
with_grains,
|
|
64
|
+
with_phases,
|
|
65
|
+
without_voids,
|
|
66
|
+
xfem_work,
|
|
67
|
+
)
|
|
68
|
+
from morphogen.fracture.mixed import (
|
|
69
|
+
CrackSolution,
|
|
70
|
+
KinkedCrack,
|
|
71
|
+
KinkedGrowth,
|
|
72
|
+
energy_release_rate,
|
|
73
|
+
inside_elements,
|
|
74
|
+
kink_angle,
|
|
75
|
+
material_groups,
|
|
76
|
+
material_nodes,
|
|
77
|
+
propagate_kinked,
|
|
78
|
+
solve_crack,
|
|
79
|
+
through_voids,
|
|
80
|
+
)
|
|
81
|
+
from morphogen.fracture.periodic import CohesiveCell, interface_law, open_cell
|
|
82
|
+
from morphogen.fracture.phasefield import (
|
|
83
|
+
PhaseField,
|
|
84
|
+
PhaseFieldProblem,
|
|
85
|
+
PhaseFieldResult,
|
|
86
|
+
phase_field_fracture,
|
|
87
|
+
)
|
|
88
|
+
from morphogen.fracture.phasefield_finite import FinitePhaseFieldProblem
|
|
89
|
+
from morphogen.fracture.surface import FrontGrowth, SurfaceCrack, propagate_front
|
|
90
|
+
from morphogen.fracture.toughness import (
|
|
91
|
+
Advance,
|
|
92
|
+
Toughness,
|
|
93
|
+
advance_candidates,
|
|
94
|
+
choose_advance,
|
|
95
|
+
interface_paths,
|
|
96
|
+
kinked_factors,
|
|
97
|
+
kinked_release_rate,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
__all__ = [
|
|
101
|
+
"XFEM",
|
|
102
|
+
"Advance",
|
|
103
|
+
"Bilinear",
|
|
104
|
+
"CohesiveCell",
|
|
105
|
+
"CohesiveProblem",
|
|
106
|
+
"CohesiveResult",
|
|
107
|
+
"Contact",
|
|
108
|
+
"Crack",
|
|
109
|
+
"CrackSolution",
|
|
110
|
+
"DuctileGrowth",
|
|
111
|
+
"Exponential",
|
|
112
|
+
"FinitePhaseFieldProblem",
|
|
113
|
+
"FrontGrowth",
|
|
114
|
+
"Interfaces",
|
|
115
|
+
"KinkedCrack",
|
|
116
|
+
"KinkedGrowth",
|
|
117
|
+
"PhaseField",
|
|
118
|
+
"PhaseFieldProblem",
|
|
119
|
+
"PhaseFieldResult",
|
|
120
|
+
"PointBulk",
|
|
121
|
+
"Propagation",
|
|
122
|
+
"SurfaceCrack",
|
|
123
|
+
"Toughness",
|
|
124
|
+
"advance_candidates",
|
|
125
|
+
"choose_advance",
|
|
126
|
+
"cohesive_zone_length",
|
|
127
|
+
"conforming_work_of",
|
|
128
|
+
"crack_faces",
|
|
129
|
+
"crack_mesh",
|
|
130
|
+
"cut_mesh",
|
|
131
|
+
"dcb_beam_theory",
|
|
132
|
+
"dcb_specimen",
|
|
133
|
+
"dissipation",
|
|
134
|
+
"energy_release_rate",
|
|
135
|
+
"face_forces",
|
|
136
|
+
"insert_interfaces",
|
|
137
|
+
"inside_elements",
|
|
138
|
+
"interface_law",
|
|
139
|
+
"interface_nodes",
|
|
140
|
+
"interface_paths",
|
|
141
|
+
"kink_angle",
|
|
142
|
+
"kinked_factors",
|
|
143
|
+
"kinked_release_rate",
|
|
144
|
+
"material_groups",
|
|
145
|
+
"material_nodes",
|
|
146
|
+
"open_cell",
|
|
147
|
+
"open_crack",
|
|
148
|
+
"phase_field_fracture",
|
|
149
|
+
"phase_mesh",
|
|
150
|
+
"phases_at",
|
|
151
|
+
"propagate",
|
|
152
|
+
"propagate_ductile",
|
|
153
|
+
"propagate_front",
|
|
154
|
+
"propagate_kinked",
|
|
155
|
+
"quarter_points",
|
|
156
|
+
"refine_front",
|
|
157
|
+
"release_rate",
|
|
158
|
+
"sent_factor",
|
|
159
|
+
"snap_front",
|
|
160
|
+
"solve_crack",
|
|
161
|
+
"through_voids",
|
|
162
|
+
"traction",
|
|
163
|
+
"transfer_displacement",
|
|
164
|
+
"transfer_state",
|
|
165
|
+
"turon_strength",
|
|
166
|
+
"with_grains",
|
|
167
|
+
"with_phases",
|
|
168
|
+
"without_voids",
|
|
169
|
+
"xfem_work",
|
|
170
|
+
]
|