Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ members = [
"rust/libceed",
"rust/libceed-sys",
"examples/rust/ex1-volume",
"examples/rust/ex1-volume-vector",
"examples/rust/ex2-surface",
"examples/rust/ex3-vector-volume",
"examples/rust/ex4-vector-surface",
"examples/rust/ex2-surface-vector",
"examples/rust/ex3-volume",
"examples/rust/ex3-volume-vector",
"examples/rust/mesh",
]
2 changes: 1 addition & 1 deletion examples/deal.II/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.0)

FIND_PACKAGE(deal.II 8.0 QUIET
HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ex3-vector-volume"
name = "ex1-volume-vector"
version = "0.11.0"
authors = [
"Jeremy L Thompson <thompson.jeremy.luke@gmail.com>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ mod transform;
// ----------------------------------------------------------------------------
fn main() -> libceed::Result<()> {
let options = opt::Opt::parse();
example_3(options)
example_1_vector(options)
}

#[allow(clippy::erasing_op)]
#[allow(clippy::identity_op)]
fn example_3(options: opt::Opt) -> libceed::Result<()> {
fn example_1_vector(options: opt::Opt) -> libceed::Result<()> {
// Process command line arguments
let opt::Opt {
ceed_spec,
Expand Down Expand Up @@ -304,7 +304,7 @@ mod tests {
use super::*;

#[test]
fn example_3_1d() {
fn example_1_vector_1d() {
let options = opt::Opt {
ceed_spec: "/cpu/self/ref/serial".to_string(),
dim: 1,
Expand All @@ -316,11 +316,11 @@ mod tests {
quiet: true,
gallery: false,
};
assert!(example_3(options).is_ok());
assert!(example_1_vector(options).is_ok());
}

#[test]
fn example_3_2d() {
fn example_1_vector_2d() {
let options = opt::Opt {
ceed_spec: "/cpu/self/ref/serial".to_string(),
dim: 2,
Expand All @@ -332,11 +332,11 @@ mod tests {
quiet: true,
gallery: false,
};
assert!(example_3(options).is_ok());
assert!(example_1_vector(options).is_ok());
}

#[test]
fn example_3_3d() {
fn example_1_vector_3d() {
let options = opt::Opt {
ceed_spec: "/cpu/self/ref/serial".to_string(),
dim: 3,
Expand All @@ -348,11 +348,11 @@ mod tests {
quiet: false,
gallery: false,
};
assert!(example_3(options).is_ok());
assert!(example_1_vector(options).is_ok());
}

#[test]
fn example_3_1d_gallery() {
fn example_1_vector_1d_gallery() {
let options = opt::Opt {
ceed_spec: "/cpu/self/ref/serial".to_string(),
dim: 1,
Expand All @@ -364,11 +364,11 @@ mod tests {
quiet: true,
gallery: true,
};
assert!(example_3(options).is_ok());
assert!(example_1_vector(options).is_ok());
}

#[test]
fn example_3_2d_gallery() {
fn example_1_vector_2d_gallery() {
let options = opt::Opt {
ceed_spec: "/cpu/self/ref/serial".to_string(),
dim: 2,
Expand All @@ -380,11 +380,11 @@ mod tests {
quiet: true,
gallery: true,
};
assert!(example_3(options).is_ok());
assert!(example_1_vector(options).is_ok());
}

#[test]
fn example_3_3d_gallery() {
fn example_1_vector_3d_gallery() {
let options = opt::Opt {
ceed_spec: "/cpu/self/ref/serial".to_string(),
dim: 3,
Expand All @@ -396,7 +396,7 @@ mod tests {
quiet: true,
gallery: true,
};
assert!(example_3(options).is_ok());
assert!(example_1_vector(options).is_ok());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ pub(crate) fn transform_mesh_coordinates(
// Exact volume of transformed region
let exact_volume = match dim {
1 => 1.0,
_ => 3.0 / 4.0 * std::f64::consts::PI as libceed::Scalar,
2 | 3 => 3.0 / 4.0 * std::f64::consts::PI as libceed::Scalar,
_ => unreachable!(),
};
Ok(exact_volume)
}
Expand Down
3 changes: 2 additions & 1 deletion examples/rust/ex1-volume/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ pub(crate) fn transform_mesh_coordinates(
// Exact volume of transformed region
let exact_volume = match dim {
1 => 1.0,
_ => 3.0 / 4.0 * std::f64::consts::PI as libceed::Scalar,
2 | 3 => 3.0 / 4.0 * std::f64::consts::PI as libceed::Scalar,
_ => unreachable!(),
};
Ok(exact_volume)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ex4-vector-surface"
name = "ex2-surface-vector"
version = "0.11.0"
authors = [
"Jeremy L Thompson <thompson.jeremy.luke@gmail.com>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ mod transform;
// ----------------------------------------------------------------------------
fn main() -> libceed::Result<()> {
let options = opt::Opt::parse();
example_4(options)
example_2_vector(options)
}

#[allow(clippy::erasing_op)]
#[allow(clippy::identity_op)]
fn example_4(options: opt::Opt) -> libceed::Result<()> {
fn example_2_vector(options: opt::Opt) -> libceed::Result<()> {
// Process command line arguments
let opt::Opt {
ceed_spec,
Expand Down Expand Up @@ -256,7 +256,7 @@ fn example_4(options: opt::Opt) -> libceed::Result<()> {
match dim {
1 => {
let q = qdata.len();
for c in 0..3 {
for c in 0..ncomp_u {
vg.iter_mut()
.skip(c * q)
.zip(ug.iter().skip(c * q).zip(qdata.iter()))
Expand All @@ -266,12 +266,12 @@ fn example_4(options: opt::Opt) -> libceed::Result<()> {
2 => {
let q = qdata.len() / 3;
for i in 0..q {
let dxdxdxdx_t = [
[qdata[i + 0 * q], qdata[i + 2 * q]],
[qdata[i + 2 * q], qdata[i + 1 * q]],
];
for c in 0..ncomp_u {
let du = [ug[i + (c + 0 * ncomp_u) * q], ug[i + (c + 1 * ncomp_u) * q]];
let dxdxdxdx_t = [
[qdata[i + 0 * q], qdata[i + 2 * q]],
[qdata[i + 2 * q], qdata[i + 1 * q]],
];
for j in 0..dim {
vg[i + (c + j * ncomp_u) * q] =
du[0] * dxdxdxdx_t[0][j] + du[1] * dxdxdxdx_t[1][j];
Expand All @@ -282,17 +282,17 @@ fn example_4(options: opt::Opt) -> libceed::Result<()> {
3 => {
let q = qdata.len() / 6;
for i in 0..q {
let dxdxdxdx_t = [
[qdata[i + 0 * q], qdata[i + 5 * q], qdata[i + 4 * q]],
[qdata[i + 5 * q], qdata[i + 1 * q], qdata[i + 3 * q]],
[qdata[i + 4 * q], qdata[i + 3 * q], qdata[i + 2 * q]],
];
for c in 0..ncomp_u {
let du = [
ug[i + (c + 0 * ncomp_u) * q],
ug[i + (c + 1 * ncomp_u) * q],
ug[i + (c + 2 * ncomp_u) * q],
];
let dxdxdxdx_t = [
[qdata[i + 0 * q], qdata[i + 5 * q], qdata[i + 4 * q]],
[qdata[i + 5 * q], qdata[i + 1 * q], qdata[i + 3 * q]],
[qdata[i + 4 * q], qdata[i + 3 * q], qdata[i + 2 * q]],
];
for j in 0..dim {
vg[i + (c + j * ncomp_u) * q] = du[0] * dxdxdxdx_t[0][j]
+ du[1] * dxdxdxdx_t[1][j]
Expand Down Expand Up @@ -395,7 +395,7 @@ mod tests {
use super::*;

#[test]
fn example_4_1d() {
fn example_2_vector_1d() {
let options = opt::Opt {
ceed_spec: "/cpu/self/ref/serial".to_string(),
dim: 1,
Expand All @@ -407,11 +407,11 @@ mod tests {
quiet: true,
gallery: false,
};
assert!(example_4(options).is_ok());
assert!(example_2_vector(options).is_ok());
}

#[test]
fn example_4_2d() {
fn example_2_vector_2d() {
let options = opt::Opt {
ceed_spec: "/cpu/self/ref/serial".to_string(),
dim: 2,
Expand All @@ -423,11 +423,11 @@ mod tests {
quiet: true,
gallery: false,
};
assert!(example_4(options).is_ok());
assert!(example_2_vector(options).is_ok());
}

#[test]
fn example_4_3d() {
fn example_2_vector_3d() {
let options = opt::Opt {
ceed_spec: "/cpu/self/ref/serial".to_string(),
dim: 3,
Expand All @@ -439,11 +439,11 @@ mod tests {
quiet: false,
gallery: false,
};
assert!(example_4(options).is_ok());
assert!(example_2_vector(options).is_ok());
}

#[test]
fn example_4_1d_gallery() {
fn example_2_vector_1d_gallery() {
let options = opt::Opt {
ceed_spec: "/cpu/self/ref/serial".to_string(),
dim: 1,
Expand All @@ -455,11 +455,11 @@ mod tests {
quiet: true,
gallery: true,
};
assert!(example_4(options).is_ok());
assert!(example_2_vector(options).is_ok());
}

#[test]
fn example_4_2d_gallery() {
fn example_2_vector_2d_gallery() {
let options = opt::Opt {
ceed_spec: "/cpu/self/ref/serial".to_string(),
dim: 2,
Expand All @@ -471,11 +471,11 @@ mod tests {
quiet: true,
gallery: true,
};
assert!(example_4(options).is_ok());
assert!(example_2_vector(options).is_ok());
}

#[test]
fn example_4_3d_gallery() {
fn example_2_vector_3d_gallery() {
let options = opt::Opt {
ceed_spec: "/cpu/self/ref/serial".to_string(),
dim: 3,
Expand All @@ -487,7 +487,7 @@ mod tests {
quiet: true,
gallery: true,
};
assert!(example_4(options).is_ok());
assert!(example_2_vector(options).is_ok());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ pub(crate) fn transform_mesh_coordinates(
let exact_area = match dim {
1 => 2.0,
2 => 4.0,
_ => 6.0,
3 => 6.0,
_ => unreachable!(),
};
Ok(exact_area)
}
Expand Down
1 change: 0 additions & 1 deletion examples/rust/ex2-surface/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ fn example_2(options: opt::Opt) -> libceed::Result<()> {
dim * (dim + 1) / 2,
num_qpts,
)?;

let (rstr_solution, _) =
mesh::build_cartesian_restriction(&ceed, dim, num_xyz, solution_degree, 1, num_qpts)?;
let mesh_size = rstr_mesh.lvector_size();
Expand Down
3 changes: 2 additions & 1 deletion examples/rust/ex2-surface/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ pub(crate) fn transform_mesh_coordinates(
let exact_area = match dim {
1 => 2.0,
2 => 4.0,
_ => 6.0,
3 => 6.0,
_ => unreachable!(),
};
Ok(exact_area)
}
Expand Down
2 changes: 2 additions & 0 deletions examples/rust/ex3-volume-vector/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target
Cargo.lock
15 changes: 15 additions & 0 deletions examples/rust/ex3-volume-vector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "ex3-volume-vector"
version = "0.11.0"
authors = [
"Jeremy L Thompson <thompson.jeremy.luke@gmail.com>",
]
edition = "2018"

[dependencies]
clap = { version = "4.0.17", features = ["derive"] }
libceed = { path = "../../../rust/libceed" }
mesh = { path = "../mesh" }

[package.metadata.release]
release = false
Loading