1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//! CREATE THE COMPLETE CFD REPORT
//use chrono::Local;
use parse_monitors::{cfd, report, report::Report};
//, fs::File, io::Write};
use clap::Parser;
use std::{error::Error, sync::Arc, time::Instant};
//use tectonic;
use std::thread;
#[derive(Debug, Parser)]
struct Cli {
// #[structopt(name = "CFD 2021 Census", about = "Building 2021 CFD census report")]
// struct Opt {
#[arg(long)]
full: bool,
#[arg(long)]
domeseeing: bool,
#[arg(long)]
windloads: bool,
#[arg(long)]
htc: bool,
}
const CFD_YEAR: u32 = 2025;
fn main() -> anyhow::Result<()> {
let opt = Cli::parse();
/*let cases: Arc<Option<Vec<cfd::CfdCase<2021>>>> =
Arc::new(Some(vec![cfd::CfdCase::<2021>::colloquial(
30, 45, "cd", 12,
)?]));*/
let cases: Arc<Option<Vec<cfd::CfdCase<CFD_YEAR>>>> = Arc::new(Some(
cfd::Baseline::<CFD_YEAR>::default()
.into_iter()
.skip(20)
.take(20)
.collect(),
));
let parts_base = 0;
let mut tjh = vec![];
let now = Instant::now();
println!("Building the different parts of the report ...");
if opt.domeseeing || opt.full {
let cases = cases.clone();
tjh.push(thread::spawn(move || {
report::DomeSeeingPart::new(1 + parts_base, 0f64)
.part_with(cases.as_deref())
.unwrap();
}));
}
if opt.htc || opt.full {
let cases = cases.clone();
tjh.push(thread::spawn(move || {
report::HTC::new(3 + parts_base, 400f64)
.part_with(cases.as_deref())
.unwrap();
}));
}
if opt.windloads || opt.full {
let cases = cases.clone();
tjh.push(thread::spawn(move || {
report::WindLoads::new(2 + parts_base, 400f64)
.exclude_monitors("floor|enclosure|screen|shutter|M1level")
.keep_last(400)
//.show_m12_pressure()
.part_with(cases.as_deref())
.unwrap();
}));
}
for t in tjh {
t.join().unwrap();
}
println!(" ... report parts build in {}s", now.elapsed().as_secs());
/*
let latex = format!(
r#"
\documentclass{{report}}
\usepackage[colorlinks=true,linkcolor=blue]{{hyperref}}\usepackage{{graphicx}}
\usepackage{{booktabs}}
\usepackage{{longtable}}
\addtolength{{\textwidth}}{{3cm}}
\addtolength{{\headheight}}{{5mm}}
\addtolength{{\evensidemargin}}{{-2cm}}
\addtolength{{\oddsidemargin}}{{-1cm}}
\setcounter{{tocdepth}}{{3}}
\title{{GMT Observatory {} Computational Fluid Dynamics Census}}
\author{{R. Conan, K. Vogiatzis, H. Fitzpatrick}}
\date{{{:?}}}
\begin{{document}}
\maketitle
\tableofcontents
\listoffigures
\listoftables
\part{{Dome Seeing}}
\include{{report/part1.chapter1}}
\include{{report/part1.chapter2}}
\include{{report/part1.chapter3}}
\part{{Wind Loads}}
\include{{report/part2.chapter1}}
\include{{report/part2.chapter2}}
\include{{report/part2.chapter3}}
\part{{Heat Transfer Coefficients}}
\include{{report/part3.chapter1}}
\include{{report/part3.chapter2}}
\include{{report/part3.chapter3}}
\end{{document}}
"#,
CFD_YEAR,
&Local::now().to_rfc2822(),
);
let now = Instant::now();
println!("Compiling the report ...");
let pdf_data: Vec<u8> = tectonic::latex_to_pdf(latex).expect("processing failed");
let mut doc = File::create(format!("report/gmto.cfd{}.pdf", CFD_YEAR))?;
doc.write_all(&pdf_data)?;
println!(" ... report compiled in {}s", now.elapsed().as_secs());
*/
Ok(())
}