1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! External nodal forces of a `Model` — the **right** side of the balance
//! `Σ f_int = Σ f_ext`.
//!
//! The counterpart of
//! [`crate::ops::node_field::internal_forces`](fn@crate::ops::node_field::internal_forces),
//! and with it the nodal mirror of [`crate::ops::matrix`]: where an assembly
//! asks every sub-model for its blocks of `∂r/∂u`, these two ask every
//! sub-model for its term of `r`, on one side of the equals sign or the other.
//!
//! Splitting the two sides is what keeps signs out of the physics files. An
//! author writes `∫ Bᵀ σ` on the internal side and `∫ N φ` on the external one,
//! both positive, exactly as the weak form reads; the single subtraction that
//! turns them into a residual lives in the caller. Whether a term belongs left
//! or right is a question of physics — the side of the equals sign it sits on —
//! not of bookkeeping.
//!
//! A physics whose term is entirely a response to `u` (elasticity, conduction,
//! a bar) has nothing here and declares nothing. The ambient of a boundary
//! transfer and a distributed flux load do.
use crateAggregate;
use crateElementField;
use crateModel;
use crateNodeField;
use crate;
use crateHandle;
use crate;
/// External nodal forces of `model` — the right side of `Σ f_int = Σ f_ext`.
///
/// Asks every sub-model for its terms on this side, through
/// [`SubModelKind::external_force_contribution`](crate::models::SubModelKind::external_force_contribution),
/// resolves the material each integrated term reads — exactly as
/// [`crate::ops::matrix::assemble_kind()`] resolves it before asking for a
/// block — drives the kernel and gathers the result: the terms loading one node
/// are **added**, in a single zone over every loaded node.
///
/// A model whose every term is a response to `u` yields an empty field, which is
/// the honest answer rather than a failure.
///
/// ```
/// # use pyrucast::models::symmetry::MaterialSymmetry;
/// # use pyrucast::aggregate::Aggregate;
/// # use pyrucast::atoms::{ElementType, Node};
/// # use pyrucast::containers::element_field::ElementField;
/// # use pyrucast::containers::field::SubField;
/// # use pyrucast::containers::finite_element_space::FiniteElementSpace;
/// # use pyrucast::containers::mesh::{Mesh, SubMesh};
/// # use pyrucast::coords::Coords;
/// # use pyrucast::handle::Handle;
/// # use pyrucast::models::Physics;
/// # use pyrucast::ops::{model, node_field};
/// # let coords = Handle::new(Coords::new(2).unwrap());
/// # let n: Vec<Node> = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]]
/// # .iter().map(|p| Node::create_in(coords.clone(), p).unwrap()).collect();
/// # let mut sm = SubMesh::new(coords.clone(), ElementType::TRI3);
/// # sm.add_cell(&[n[0].id(), n[1].id(), n[2].id()]).unwrap();
/// # let fes = FiniteElementSpace::lagrange1(&Mesh::from_submesh(sm)).unwrap();
/// # let mut mat = ElementField::new(&fes, vec!["k".into()])?;
/// # mat.get(0)?.write().set_uniform("k", 1.0)?;
/// let volume = model::heat_conduction(&fes, MaterialSymmetry::Isotropic)?;
/// // Conduction alone has no term on the right of the equals sign: the field
/// // comes back empty, and that is the right answer.
/// assert_eq!(node_field::external_forces(&volume, &mat)?.len(), 0);
/// # Ok::<(), pyrucast::PyrucastError>(())
/// ```