Skip to content

Commit ebf344a

Browse files
authored
Merge pull request #12 from cpmech/improve-examples
Print the results in Examples
2 parents 5b364b1 + 9a02b21 commit ebf344a

File tree

6 files changed

+109
-13
lines changed

6 files changed

+109
-13
lines changed

.github/workflows/test_and_coverage.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,3 @@ jobs:
1111
- name: Run tests
1212
run: |
1313
RUST_BACKTRACE=1 cargo test -- --nocapture
14-
- name: Install cargo-llvm-cov
15-
run: |
16-
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
17-
- name: Generate code coverage
18-
run: |
19-
cargo llvm-cov --all-features --workspace --ignore-filename-regex build.rs --lcov --output-path lcov.info
20-
- name: Upload to codecov.io
21-
uses: codecov/codecov-action@v3
22-
with:
23-
files: lcov.info
24-
fail_ci_if_error: true

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Triangle and tetrahedron mesh generators
22

3-
[![codecov](https://codecov.io/gh/cpmech/tritet/branch/main/graph/badge.svg?token=2ALVRVWJ5W)](https://codecov.io/gh/cpmech/tritet)
4-
[![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)
3+
[![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)
54
[![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)
65

76
## Contents

examples/tetgen_delaunay_1.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,33 @@ fn main() -> Result<(), StrError> {
1919
// generate Delaunay triangulation
2020
tetgen.generate_delaunay(false)?;
2121

22+
// print the results
23+
println!("Number of points = {}", tetgen.out_npoint());
24+
println!("Number of cells = {}", tetgen.out_ncell());
25+
println!("Number of points in a cell = {}\n", tetgen.out_cell_npoint());
26+
let ndim = 3;
27+
for index in 0..tetgen.out_npoint() {
28+
print!("Point {}: (", index);
29+
for d in 0..ndim {
30+
if d > 0 {
31+
print!(", ");
32+
}
33+
print!("{}", tetgen.out_point(index, d));
34+
}
35+
println!(")");
36+
}
37+
println!();
38+
for index in 0..tetgen.out_ncell() {
39+
print!("Cell {} ({}): (", index, tetgen.out_cell_attribute(index));
40+
for m in 0..tetgen.out_cell_npoint() {
41+
if m > 0 {
42+
print!(", ");
43+
}
44+
print!("{}", tetgen.out_cell_point(index, m));
45+
}
46+
println!(")");
47+
}
48+
2249
// draw edges of tetrahedra
2350
let mut plot = Plot::new();
2451
tetgen.draw_wireframe(&mut plot, true, true, true, true, None, None, None);

examples/tetgen_mesh_1.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,33 @@ fn main() -> Result<(), StrError> {
107107
// generate mesh
108108
tetgen.generate_mesh(false, false, None, None)?;
109109

110+
// print the results
111+
println!("Number of points = {}", tetgen.out_npoint());
112+
println!("Number of cells = {}", tetgen.out_ncell());
113+
println!("Number of points in a cell = {}\n", tetgen.out_cell_npoint());
114+
let ndim = 3;
115+
for index in 0..tetgen.out_npoint() {
116+
print!("Point {}: (", index);
117+
for d in 0..ndim {
118+
if d > 0 {
119+
print!(", ");
120+
}
121+
print!("{}", tetgen.out_point(index, d));
122+
}
123+
println!(")");
124+
}
125+
println!();
126+
for index in 0..tetgen.out_ncell() {
127+
print!("Cell {} ({}): (", index, tetgen.out_cell_attribute(index));
128+
for m in 0..tetgen.out_cell_npoint() {
129+
if m > 0 {
130+
print!(", ");
131+
}
132+
print!("{}", tetgen.out_cell_point(index, m));
133+
}
134+
println!(")");
135+
}
136+
110137
// generate file for Paraview
111138
tetgen.write_vtu("/tmp/tritet/example_tetgen_mesh_1.vtu")?;
112139

examples/triangle_delaunay_1.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,33 @@ fn main() -> Result<(), StrError> {
2626
// generate Delaunay triangulation
2727
trigen.generate_delaunay(true)?;
2828

29+
// print the results
30+
println!("Number of points = {}", trigen.out_npoint());
31+
println!("Number of cells = {}", trigen.out_ncell());
32+
println!("Number of points in a cell = {}\n", trigen.out_cell_npoint());
33+
let ndim = 2;
34+
for index in 0..trigen.out_npoint() {
35+
print!("Point {}: (", index);
36+
for d in 0..ndim {
37+
if d > 0 {
38+
print!(", ");
39+
}
40+
print!("{}", trigen.out_point(index, d));
41+
}
42+
println!(")");
43+
}
44+
println!();
45+
for index in 0..trigen.out_ncell() {
46+
print!("Cell {} ({}): (", index, trigen.out_cell_attribute(index));
47+
for m in 0..trigen.out_cell_npoint() {
48+
if m > 0 {
49+
print!(", ");
50+
}
51+
print!("{}", trigen.out_cell_point(index, m));
52+
}
53+
println!(")");
54+
}
55+
2956
// draw triangles
3057
let mut plot = Plot::new();
3158
trigen.draw_triangles(&mut plot, true, true, true, true, None, None, None);

examples/triangle_mesh_1.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,33 @@ fn main() -> Result<(), StrError> {
8282
// generate mesh without constraints
8383
trigen.generate_mesh(true, true, true, None, None)?;
8484

85+
// print the results
86+
println!("Number of points = {}", trigen.out_npoint());
87+
println!("Number of cells = {}", trigen.out_ncell());
88+
println!("Number of points in a cell = {}\n", trigen.out_cell_npoint());
89+
let ndim = 2;
90+
for index in 0..trigen.out_npoint() {
91+
print!("Point {}: (", index);
92+
for d in 0..ndim {
93+
if d > 0 {
94+
print!(", ");
95+
}
96+
print!("{}", trigen.out_point(index, d));
97+
}
98+
println!(")");
99+
}
100+
println!();
101+
for index in 0..trigen.out_ncell() {
102+
print!("Cell {} ({}): (", index, trigen.out_cell_attribute(index));
103+
for m in 0..trigen.out_cell_npoint() {
104+
if m > 0 {
105+
print!(", ");
106+
}
107+
print!("{}", trigen.out_cell_point(index, m));
108+
}
109+
println!(")");
110+
}
111+
85112
// draw mesh
86113
let mut plot = Plot::new();
87114
trigen.draw_triangles(&mut plot, true, false, false, false, None, None, None);

0 commit comments

Comments
 (0)