Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print the results in Examples #12

Merged
merged 2 commits into from
Jan 23, 2025
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
11 changes: 0 additions & 11 deletions .github/workflows/test_and_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,3 @@ jobs:
- name: Run tests
run: |
RUST_BACKTRACE=1 cargo test -- --nocapture
- name: Install cargo-llvm-cov
run: |
curl -LsSf https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin
- name: Generate code coverage
run: |
cargo llvm-cov --all-features --workspace --ignore-filename-regex build.rs --lcov --output-path lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
files: lcov.info
fail_ci_if_error: true
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Triangle and tetrahedron mesh generators

[![codecov](https://codecov.io/gh/cpmech/tritet/branch/main/graph/badge.svg?token=2ALVRVWJ5W)](https://codecov.io/gh/cpmech/tritet)
[![Test & Coverage](https://github.com/cpmech/tritet/actions/workflows/test_and_coverage.yml/badge.svg)](https://github.com/cpmech/tritet/actions/workflows/test_and_coverage.yml)
[![Test](https://github.com/cpmech/tritet/actions/workflows/test_and_coverage.yml/badge.svg)](https://github.com/cpmech/tritet/actions/workflows/test_and_coverage.yml)
[![Windows & macOS](https://github.com/cpmech/tritet/actions/workflows/windows_and_macos.yml/badge.svg)](https://github.com/cpmech/tritet/actions/workflows/windows_and_macos.yml)

## Contents
Expand Down
27 changes: 27 additions & 0 deletions examples/tetgen_delaunay_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,33 @@ fn main() -> Result<(), StrError> {
// generate Delaunay triangulation
tetgen.generate_delaunay(false)?;

// print the results
println!("Number of points = {}", tetgen.out_npoint());
println!("Number of cells = {}", tetgen.out_ncell());
println!("Number of points in a cell = {}\n", tetgen.out_cell_npoint());
let ndim = 3;
for index in 0..tetgen.out_npoint() {
print!("Point {}: (", index);
for d in 0..ndim {
if d > 0 {
print!(", ");
}
print!("{}", tetgen.out_point(index, d));
}
println!(")");
}
println!();
for index in 0..tetgen.out_ncell() {
print!("Cell {} ({}): (", index, tetgen.out_cell_attribute(index));
for m in 0..tetgen.out_cell_npoint() {
if m > 0 {
print!(", ");
}
print!("{}", tetgen.out_cell_point(index, m));
}
println!(")");
}

// draw edges of tetrahedra
let mut plot = Plot::new();
tetgen.draw_wireframe(&mut plot, true, true, true, true, None, None, None);
Expand Down
27 changes: 27 additions & 0 deletions examples/tetgen_mesh_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,33 @@ fn main() -> Result<(), StrError> {
// generate mesh
tetgen.generate_mesh(false, false, None, None)?;

// print the results
println!("Number of points = {}", tetgen.out_npoint());
println!("Number of cells = {}", tetgen.out_ncell());
println!("Number of points in a cell = {}\n", tetgen.out_cell_npoint());
let ndim = 3;
for index in 0..tetgen.out_npoint() {
print!("Point {}: (", index);
for d in 0..ndim {
if d > 0 {
print!(", ");
}
print!("{}", tetgen.out_point(index, d));
}
println!(")");
}
println!();
for index in 0..tetgen.out_ncell() {
print!("Cell {} ({}): (", index, tetgen.out_cell_attribute(index));
for m in 0..tetgen.out_cell_npoint() {
if m > 0 {
print!(", ");
}
print!("{}", tetgen.out_cell_point(index, m));
}
println!(")");
}

// generate file for Paraview
tetgen.write_vtu("/tmp/tritet/example_tetgen_mesh_1.vtu")?;

Expand Down
27 changes: 27 additions & 0 deletions examples/triangle_delaunay_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,33 @@ fn main() -> Result<(), StrError> {
// generate Delaunay triangulation
trigen.generate_delaunay(true)?;

// print the results
println!("Number of points = {}", trigen.out_npoint());
println!("Number of cells = {}", trigen.out_ncell());
println!("Number of points in a cell = {}\n", trigen.out_cell_npoint());
let ndim = 2;
for index in 0..trigen.out_npoint() {
print!("Point {}: (", index);
for d in 0..ndim {
if d > 0 {
print!(", ");
}
print!("{}", trigen.out_point(index, d));
}
println!(")");
}
println!();
for index in 0..trigen.out_ncell() {
print!("Cell {} ({}): (", index, trigen.out_cell_attribute(index));
for m in 0..trigen.out_cell_npoint() {
if m > 0 {
print!(", ");
}
print!("{}", trigen.out_cell_point(index, m));
}
println!(")");
}

// draw triangles
let mut plot = Plot::new();
trigen.draw_triangles(&mut plot, true, true, true, true, None, None, None);
Expand Down
27 changes: 27 additions & 0 deletions examples/triangle_mesh_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,33 @@ fn main() -> Result<(), StrError> {
// generate mesh without constraints
trigen.generate_mesh(true, true, true, None, None)?;

// print the results
println!("Number of points = {}", trigen.out_npoint());
println!("Number of cells = {}", trigen.out_ncell());
println!("Number of points in a cell = {}\n", trigen.out_cell_npoint());
let ndim = 2;
for index in 0..trigen.out_npoint() {
print!("Point {}: (", index);
for d in 0..ndim {
if d > 0 {
print!(", ");
}
print!("{}", trigen.out_point(index, d));
}
println!(")");
}
println!();
for index in 0..trigen.out_ncell() {
print!("Cell {} ({}): (", index, trigen.out_cell_attribute(index));
for m in 0..trigen.out_cell_npoint() {
if m > 0 {
print!(", ");
}
print!("{}", trigen.out_cell_point(index, m));
}
println!(")");
}

// draw mesh
let mut plot = Plot::new();
trigen.draw_triangles(&mut plot, true, false, false, false, None, None, None);
Expand Down
Loading