Update the tangent test with uniform coordinates
The motions we feed into the projection map now need to be expressed in uniform coordinates. I've verified by hand that `tangent_motions_unif` and `tangent_motions_std` represent the same motions.
This commit is contained in:
parent
21cefa9f8a
commit
e61047cb86
@ -554,8 +554,6 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn tangent_test() {
|
fn tangent_test() {
|
||||||
const SCALED_TOL: f64 = 1.0e-12;
|
const SCALED_TOL: f64 = 1.0e-12;
|
||||||
const ELEMENT_DIM: usize = 5;
|
|
||||||
const ASSEMBLY_DIM: usize = 3;
|
|
||||||
let gram = {
|
let gram = {
|
||||||
let mut gram_to_be = PartialMatrix::new();
|
let mut gram_to_be = PartialMatrix::new();
|
||||||
for j in 0..3 {
|
for j in 0..3 {
|
||||||
@ -580,29 +578,42 @@ mod tests {
|
|||||||
assert_eq!(history.scaled_loss.len(), 1);
|
assert_eq!(history.scaled_loss.len(), 1);
|
||||||
|
|
||||||
// confirm that the tangent space has dimension five or less
|
// confirm that the tangent space has dimension five or less
|
||||||
let ConfigSubspace(ref tangent_basis) = tangent;
|
assert_eq!(tangent.basis_std.len(), 5);
|
||||||
assert_eq!(tangent_basis.len(), 5);
|
|
||||||
|
|
||||||
// confirm that the tangent space contains all the motions we expect it
|
// confirm that the tangent space contains all the motions we expect it
|
||||||
// to. since we've already bounded the dimension of the tangent space,
|
// to. since we've already bounded the dimension of the tangent space,
|
||||||
// this confirms that the tangent space is what we expect it to be
|
// this confirms that the tangent space is what we expect it to be
|
||||||
let tangent_motions = vec![
|
const UNIFORM_DIM: usize = 4;
|
||||||
basis_matrix((0, 1), ELEMENT_DIM, ASSEMBLY_DIM),
|
let element_dim = guess.nrows();
|
||||||
basis_matrix((1, 1), ELEMENT_DIM, ASSEMBLY_DIM),
|
let assembly_dim = guess.ncols();
|
||||||
basis_matrix((0, 2), ELEMENT_DIM, ASSEMBLY_DIM),
|
let tangent_motions_unif = vec![
|
||||||
basis_matrix((1, 2), ELEMENT_DIM, ASSEMBLY_DIM),
|
basis_matrix((0, 1), UNIFORM_DIM, assembly_dim),
|
||||||
DMatrix::<f64>::from_column_slice(ELEMENT_DIM, 3, &[
|
basis_matrix((1, 1), UNIFORM_DIM, assembly_dim),
|
||||||
0.0, 0.0, 0.0, 0.0, 0.0,
|
basis_matrix((0, 2), UNIFORM_DIM, assembly_dim),
|
||||||
|
basis_matrix((1, 2), UNIFORM_DIM, assembly_dim),
|
||||||
|
DMatrix::<f64>::from_column_slice(UNIFORM_DIM, assembly_dim, &[
|
||||||
|
0.0, 0.0, 0.0, 0.0,
|
||||||
|
0.0, 0.0, -0.5, -0.5,
|
||||||
|
0.0, 0.0, -0.5, 0.5
|
||||||
|
])
|
||||||
|
];
|
||||||
|
let tangent_motions_std = vec![
|
||||||
|
basis_matrix((0, 1), element_dim, assembly_dim),
|
||||||
|
basis_matrix((1, 1), element_dim, assembly_dim),
|
||||||
|
basis_matrix((0, 2), element_dim, assembly_dim),
|
||||||
|
basis_matrix((1, 2), element_dim, assembly_dim),
|
||||||
|
DMatrix::<f64>::from_column_slice(element_dim, assembly_dim, &[
|
||||||
|
0.0, 0.0, 0.0, 0.00, 0.0,
|
||||||
0.0, 0.0, -1.0, -0.25, -1.0,
|
0.0, 0.0, -1.0, -0.25, -1.0,
|
||||||
0.0, 0.0, -1.0, 0.25, 1.0
|
0.0, 0.0, -1.0, 0.25, 1.0
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
let tol_sq = ((ELEMENT_DIM * ASSEMBLY_DIM) as f64) * SCALED_TOL * SCALED_TOL;
|
let tol_sq = ((element_dim * assembly_dim) as f64) * SCALED_TOL * SCALED_TOL;
|
||||||
for motion in tangent_motions {
|
for (motion_unif, motion_std) in tangent_motions_unif.into_iter().zip(tangent_motions_std) {
|
||||||
let motion_proj: DMatrix<_> = motion.column_iter().enumerate().map(
|
let motion_proj: DMatrix<_> = motion_unif.column_iter().enumerate().map(
|
||||||
|(k, v)| tangent.proj(&v, k)
|
|(k, v)| tangent.proj(&v, k)
|
||||||
).sum();
|
).sum();
|
||||||
assert!((motion - motion_proj).norm_squared() < tol_sq);
|
assert!((motion_std - motion_proj).norm_squared() < tol_sq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user