Allow changing source interleave
... and of course a fix to the replicate math with a source interleave.
This commit is contained in:
parent
aee565dbb3
commit
32dd3814af
|
@ -53,6 +53,36 @@ pub fn TransferMenu() -> Html {
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let on_source_interleave_x_change = {
|
||||||
|
let ct_dispatch = ct_dispatch.clone();
|
||||||
|
|
||||||
|
Callback::from(move |e: Event| {
|
||||||
|
let target: Option<EventTarget> = e.target();
|
||||||
|
let input = target.and_then(|t| t.dyn_into::<HtmlInputElement>().ok());
|
||||||
|
if let Some(input) = input {
|
||||||
|
if let Ok(num) = input.value().parse::<i8>() {
|
||||||
|
ct_dispatch.reduce_mut(|state| {
|
||||||
|
state.transfer.interleave_source = (num, state.transfer.interleave_source.1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
let on_source_interleave_y_change = {
|
||||||
|
let ct_dispatch = ct_dispatch.clone();
|
||||||
|
|
||||||
|
Callback::from(move |e: Event| {
|
||||||
|
let target: Option<EventTarget> = e.target();
|
||||||
|
let input = target.and_then(|t| t.dyn_into::<HtmlInputElement>().ok());
|
||||||
|
if let Some(input) = input {
|
||||||
|
if let Ok(num) = input.value().parse::<i8>() {
|
||||||
|
ct_dispatch.reduce_mut(|state| {
|
||||||
|
state.transfer.interleave_source = (state.transfer.interleave_source.0, num);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
let on_dest_interleave_x_change = {
|
let on_dest_interleave_x_change = {
|
||||||
let ct_dispatch = ct_dispatch.clone();
|
let ct_dispatch = ct_dispatch.clone();
|
||||||
|
|
||||||
|
@ -100,11 +130,22 @@ pub fn TransferMenu() -> Html {
|
||||||
value={RegionDisplay::from(&ct_state.transfer.dest_region).text}/>
|
value={RegionDisplay::from(&ct_state.transfer.dest_region).text}/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
{"Source Interleave "}
|
||||||
|
<label for="source_interleave_x">{"Row:"}</label>
|
||||||
|
<input type="number" name="source_interleave_x"
|
||||||
|
onchange={on_source_interleave_x_change}
|
||||||
|
value={ct_state.transfer.interleave_source.0.to_string()}/>
|
||||||
|
<label for="source_interleave_y">{"Col:"}</label>
|
||||||
|
<input type="number" name="source_interleave_y"
|
||||||
|
onchange={on_source_interleave_y_change}
|
||||||
|
value={ct_state.transfer.interleave_source.1.to_string()}/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
{"Destination Interleave "}
|
{"Destination Interleave "}
|
||||||
<label for="dest_interleave_x">{"X:"}</label>
|
<label for="dest_interleave_x">{"Row:"}</label>
|
||||||
<input type="number" name="dest_interleave_x"
|
<input type="number" name="dest_interleave_x"
|
||||||
onchange={on_dest_interleave_x_change} value={ct_state.transfer.interleave_dest.0.to_string()}/>
|
onchange={on_dest_interleave_x_change} value={ct_state.transfer.interleave_dest.0.to_string()}/>
|
||||||
<label for="dest_interleave_y">{"Y:"}</label>
|
<label for="dest_interleave_y">{"Col:"}</label>
|
||||||
<input type="number" name="dest_interleave_y"
|
<input type="number" name="dest_interleave_y"
|
||||||
onchange={on_dest_interleave_y_change} value={ct_state.transfer.interleave_dest.1.to_string()}/>
|
onchange={on_dest_interleave_y_change} value={ct_state.transfer.interleave_dest.1.to_string()}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -157,20 +157,23 @@ impl TransferRegion {
|
||||||
d_br.1.checked_sub(d_ul.1).unwrap() + 1,
|
d_br.1.checked_sub(d_ul.1).unwrap() + 1,
|
||||||
);
|
);
|
||||||
let N_s = ( // Number of used source wells
|
let N_s = ( // Number of used source wells
|
||||||
s_dims.0.div_euclid(il_source.0.abs() as u8),
|
(s_dims.0 + il_source.0.abs() as u8 - 1).div_euclid(il_source.0.abs() as u8),
|
||||||
s_dims.1.div_euclid(il_source.1.abs() as u8),
|
(s_dims.1 + il_source.1.abs() as u8 - 1).div_euclid(il_source.1.abs() as u8),
|
||||||
);
|
);
|
||||||
let D_per_replicate = ( // How many wells are used per replicate?
|
let D_per_replicate = ( // How many wells are used per replicate?
|
||||||
(s_dims.0 * (il_dest.0.abs() as u8))
|
(N_s.0 * (il_dest.0.abs() as u8))
|
||||||
// Conditionally subtract one to ignore the trailing interleave well
|
// Conditionally subtract one to ignore the trailing interleave well
|
||||||
.saturating_sub(if il_dest.0.abs() > 1 {1} else {0}),
|
.saturating_sub(if il_dest.0.abs() > 1 {1} else {0}),
|
||||||
(s_dims.1 * (il_dest.1.abs() as u8))
|
(N_s.1 * (il_dest.1.abs() as u8))
|
||||||
.saturating_sub(if il_dest.1.abs() > 1 {1} else {0}),
|
.saturating_sub(if il_dest.1.abs() > 1 {1} else {0}),
|
||||||
);
|
);
|
||||||
let count = ( // How many times can we replicate?
|
let count = ( // How many times can we replicate?
|
||||||
d_dims.0.div_euclid(D_per_replicate.0),
|
d_dims.0.div_euclid(D_per_replicate.0),
|
||||||
d_dims.1.div_euclid(D_per_replicate.1),
|
d_dims.1.div_euclid(D_per_replicate.1),
|
||||||
);
|
);
|
||||||
|
let i = i.saturating_sub(s_ul.0).saturating_div(il_source.0.abs() as u8);
|
||||||
|
let j = j.saturating_sub(s_ul.1).saturating_div(il_source.1.abs() as u8);
|
||||||
|
log::debug!("s_dims: {:?}, N_s: {:?}", s_dims, N_s);
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
possible_destination_wells
|
possible_destination_wells
|
||||||
|
@ -178,13 +181,13 @@ impl TransferRegion {
|
||||||
.filter(|(x, _)| {
|
.filter(|(x, _)| {
|
||||||
x.checked_sub(d_ul.0).unwrap()
|
x.checked_sub(d_ul.0).unwrap()
|
||||||
% (N_s.0 * il_dest.0.abs() as u8) // Counter along x
|
% (N_s.0 * il_dest.0.abs() as u8) // Counter along x
|
||||||
== ((il_dest.0.abs() as u8 *(i).checked_sub(1u8).unwrap()))
|
== ((il_dest.0.abs() as u8 *i))
|
||||||
% (N_s.0 * il_dest.0.abs() as u8)
|
% (N_s.0 * il_dest.0.abs() as u8)
|
||||||
})
|
})
|
||||||
.filter(|(_, y)| {
|
.filter(|(_, y)| {
|
||||||
y.checked_sub(d_ul.1).unwrap()
|
y.checked_sub(d_ul.1).unwrap()
|
||||||
% (N_s.1 * il_dest.1.abs() as u8) // Counter along u
|
% (N_s.1 * il_dest.1.abs() as u8) // Counter along u
|
||||||
== ((il_dest.1.abs() as u8 *(j).checked_sub(1u8).unwrap()))
|
== ((il_dest.1.abs() as u8 *j))
|
||||||
% (N_s.1 * il_dest.1.abs() as u8)
|
% (N_s.1 * il_dest.1.abs() as u8)
|
||||||
})
|
})
|
||||||
.filter(|(x,y)| {
|
.filter(|(x,y)| {
|
||||||
|
|
Loading…
Reference in New Issue