Skip to content

Commit

Permalink
Apply cargo linting hints
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonis committed Feb 19, 2024
1 parent e8a82c8 commit f81ee9a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
13 changes: 6 additions & 7 deletions elastic-tube-1d/fluid-rust/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use precice;
use std::env;
use std::process::ExitCode;

Expand All @@ -20,7 +19,7 @@ fn main() -> ExitCode {
const DOMAIN_SIZE: usize = 100;
const CHUNK_SIZE: usize = DOMAIN_SIZE + 1;

let mut participant = precice::Participant::new("Fluid", &config, 0, 1);
let mut participant = precice::Participant::new("Fluid", config, 0, 1);

println!("preCICE configured...");

Expand All @@ -42,9 +41,9 @@ fn main() -> ExitCode {
const P0: f64 = 0.0;
let vel_in0: f64 = U0 + AMPL * (FREQUENCY * T_SHIFT * std::f64::consts::PI).sin();

let mut pressure: Vec<f64> = vec![P0; CHUNK_SIZE as usize];
let mut cross_section_length: Vec<f64> = vec![A0; CHUNK_SIZE as usize];
let mut velocity: Vec<f64> = vec![vel_in0; CHUNK_SIZE as usize];
let mut pressure: Vec<f64> = vec![P0; CHUNK_SIZE];
let mut cross_section_length: Vec<f64> = vec![A0; CHUNK_SIZE];
let mut velocity: Vec<f64> = vec![vel_in0; CHUNK_SIZE];

let mut pressure_old = pressure.clone();

Expand All @@ -54,7 +53,7 @@ fn main() -> ExitCode {
let mut v: Vec<f64> = vec![0_f64; grid_size];
for i in 0..CHUNK_SIZE {
let idx = i * dimensions as usize;
v[idx] = i as f64 * CELLWIDTH as f64;
v[idx] = i as f64 * CELLWIDTH;
}
v
};
Expand Down Expand Up @@ -156,5 +155,5 @@ fn main() -> ExitCode {
println!("Exiting FluidSolver at t={}", t);
participant.finalize();

return ExitCode::SUCCESS;
ExitCode::SUCCESS
}
2 changes: 1 addition & 1 deletion elastic-tube-1d/fluid-rust/src/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn fluid_compute_solution(
pressure: &mut [f64],
) {
// Initial guess
pressure.copy_from_slice(&pressure_old[..]);
pressure.copy_from_slice(pressure_old);

const E: f64 = 10000_f64;
//const C_MK2 : f64 = E / std::f64::consts::FRAC_2_SQRT_PI;
Expand Down
22 changes: 11 additions & 11 deletions elastic-tube-1d/fluid-rust/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,37 @@ pub fn write_vtk(
write!(f, "DATASET UNSTRUCTURED_GRID\n\n")?;
write!(f, "POINTS {n_points} float\n\n")?;
for i in 0..n_points {
write!(
writeln!(
f,
"{:.16e} 0.0000000000000000e+00 0.0000000000000000e+00\n",
"{:.16e} 0.0000000000000000e+00 0.0000000000000000e+00",
i as f64 * dx
)?;
}
writeln!(f)?;

write!(f, "POINT_DATA {n_points}\n\n")?;

write!(f, "VECTORS velocity float\n")?;
writeln!(f, "VECTORS velocity float")?;
for v in velocity {
write!(
writeln!(
f,
"{:.16e} 0.0000000000000000e+00 0.0000000000000000e+00\n",
"{:.16e} 0.0000000000000000e+00 0.0000000000000000e+00",
v
)?;
}
writeln!(f)?;

write!(f, "SCALARS pressure float\n")?;
write!(f, "LOOKUP_TABLE default\n")?;
writeln!(f, "SCALARS pressure float")?;
writeln!(f, "LOOKUP_TABLE default")?;
for v in pressure {
write!(f, "{:.16e}\n", v)?;
writeln!(f, "{:.16e}", v)?;
}
writeln!(f)?;

write!(f, "SCALARS diameter float\n")?;
write!(f, "LOOKUP_TABLE default\n")?;
writeln!(f, "SCALARS diameter float")?;
writeln!(f, "LOOKUP_TABLE default")?;
for v in cross_section_length {
write!(f, "{:.16e}\n", v)?;
writeln!(f, "{:.16e}", v)?;
}
writeln!(f)?;
Ok(())
Expand Down
9 changes: 4 additions & 5 deletions elastic-tube-1d/solid-rust/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use precice;
use std::env;
use std::process::ExitCode;

Expand All @@ -20,7 +19,7 @@ fn main() -> ExitCode {
const CHUNK_SIZE: usize = DOMAIN_SIZE + 1;
const TUBE_LENGTH: f64 = 10.0;

let mut participant = precice::Participant::new("Solid", &config, 0, 1);
let mut participant = precice::Participant::new("Solid", config, 0, 1);

println!("preCICE configured...");

Expand All @@ -29,8 +28,8 @@ fn main() -> ExitCode {
assert!(participant.get_data_dimensions(mesh_name, "CrossSectionLength") == 1);
assert!(participant.get_data_dimensions(mesh_name, "Pressure") == 1);

let mut pressure: Vec<f64> = vec![0.0; CHUNK_SIZE as usize];
let mut cross_section_length: Vec<f64> = vec![1.0; CHUNK_SIZE as usize];
let mut pressure: Vec<f64> = vec![0.0; CHUNK_SIZE];
let mut cross_section_length: Vec<f64> = vec![1.0; CHUNK_SIZE];

let grid_size = CHUNK_SIZE * dimensions as usize;
let grid: Vec<f64> = {
Expand Down Expand Up @@ -99,5 +98,5 @@ fn main() -> ExitCode {
println!("Exiting SolidSolver at t={}", t);
participant.finalize();

return ExitCode::SUCCESS;
ExitCode::SUCCESS
}

0 comments on commit f81ee9a

Please sign in to comment.