Add the test assemblies for the demo
These are partial setups of the tetrahedron radius ratio problem and the Irisawa hexlet problem.
This commit is contained in:
parent
eba15a6e83
commit
6928ac8765
2 changed files with 272 additions and 6 deletions
|
@ -534,6 +534,9 @@ pub struct Assembly {
|
|||
pub elements: Signal<BTreeSet<Rc<dyn Element>>>,
|
||||
pub regulators: Signal<BTreeSet<Rc<dyn Regulator>>>,
|
||||
|
||||
// a flag that tells us whether the assembly is realized
|
||||
pub realized: Signal<bool>,
|
||||
|
||||
// solution variety tangent space. the basis vectors are stored in
|
||||
// configuration matrix format, ordered according to the elements' column
|
||||
// indices. when you realize the assembly, every element that's present
|
||||
|
@ -552,12 +555,24 @@ pub struct Assembly {
|
|||
|
||||
impl Assembly {
|
||||
pub fn new() -> Assembly {
|
||||
Assembly {
|
||||
// create an assembly
|
||||
let assembly = Assembly {
|
||||
elements: create_signal(BTreeSet::new()),
|
||||
regulators: create_signal(BTreeSet::new()),
|
||||
realized: create_signal(true),
|
||||
tangent: create_signal(ConfigSubspace::zero(0)),
|
||||
elements_by_id: create_signal(BTreeMap::default())
|
||||
}
|
||||
};
|
||||
|
||||
// realize the assembly whenever the `realized` flag is set to `false`
|
||||
let assembly_for_effect = assembly.clone();
|
||||
create_memo(move || {
|
||||
if !assembly_for_effect.realized.get() {
|
||||
assembly_for_effect.realize();
|
||||
}
|
||||
});
|
||||
|
||||
assembly
|
||||
}
|
||||
|
||||
// --- inserting elements and regulators ---
|
||||
|
@ -627,7 +642,7 @@ impl Assembly {
|
|||
console_log!("Updated regulator with subjects {:?}", regulator.subjects());
|
||||
|
||||
if regulator.try_activate() {
|
||||
self_for_effect.realize();
|
||||
self_for_effect.realized.set(false);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -710,6 +725,9 @@ impl Assembly {
|
|||
);
|
||||
}
|
||||
|
||||
// update the realization flag
|
||||
self.realized.set(true);
|
||||
|
||||
// save the tangent space
|
||||
self.tangent.set_silent(tangent);
|
||||
}
|
||||
|
@ -802,7 +820,7 @@ impl Assembly {
|
|||
// bring the configuration back onto the solution variety. this also
|
||||
// gets the elements' column indices and the saved tangent space back in
|
||||
// sync
|
||||
self.realize();
|
||||
self.realized.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue