Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeOShannessy committed Jun 9, 2024
0 parents commit 5932641
Show file tree
Hide file tree
Showing 5 changed files with 566 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Publish

on:
push:
branches:
- master

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # The OIDC ID token is used for authentication with JSR.
steps:
- uses: actions/checkout@v4
- run: npx jsr publish
8 changes: 8 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@smoke-cloud/fds-inspect-cli",
"version": "0.1.0",
"exports": "./main.ts",
"tasks": {
"dev": "deno run --watch main.ts"
}
}
106 changes: 106 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

200 changes: 200 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
import {
countCells,
type FdsFile,
type InputSummary,
type Resolution,
summarise_input,
type VerificationSummary,
verifyInput,
} from "jsr:@smoke-cloud/[email protected]";
import "jsr:@smoke-cloud/[email protected]";
import { Command } from "jsr:@cliffy/[email protected]";
import { open } from "./open.ts";
import * as path from "jsr:@std/[email protected]";
import { getJson, verifyInputRender } from "jsr:@smoke-cloud/[email protected]";

await new Command()
.name("tway-server-manager")
.description("A simple reverse proxy example cli.")
.version("v1.0.0")
// .option("-p, --port <port:number>", "The port number for the local server.", {
// default: 8080,
// })
// .option("--host <hostname>", "The host name for the local server.", {
// default: "localhost",
// })
// .arguments("[domain]")
// .action(() => console.log("Main command called."))
// Child command 1.
.command("count-cells", "Count the total number of cells")
// .option("-f, --foo", "Foo option.")
.arguments("<input-path:string>")
.action(async (_options, ...args) => {
const fdsFile = await getJson(args[0]);
const nCells = countCells(fdsFile);
console.log(nCells);
})
// Get Threadway Send
.command("meshes", "Display information on each mesh")
// .option("--master", "Pull the master branch version.")
.arguments("<input-path:string>")
.action(async () => {
// const fdsFile = await getJson(args[0]);
// // use fute_core::FdsFileExt;
// use prettytable::{Attr, Cell, Row, Table};
// // use fute_core::FdsFile;
// // use fute_core::parse_and_decode_fds_input_file;
// use num_format::{Locale, ToFormattedString};

// let fds_file = parse_and_decode_fds_input_file(fds_path).unwrap();
// let meshes = fds_file.mesh;
// let mut table = Table::new();
// table.set_titles(Row::new(vec![
// Cell::new("#").with_style(Attr::Bold),
// Cell::new("Mesh Id.").with_style(Attr::Bold),
// Cell::new("# Cells").with_style(Attr::Bold),
// Cell::new("I-J-K").with_style(Attr::Bold),
// Cell::new("Δx-Δy-Δz").with_style(Attr::Bold),
// Cell::new("Aspect Ratio").with_style(Attr::Bold),
// ]));
// let mut n_cells_total: u64 = 0;
// for (i, mesh) in meshes.iter().enumerate() {
// let xb = mesh.xb;
// let ijk = mesh.ijk;
// let n_cell = Cell::new(&format!("{}", i + 1));
// let id_cell = Cell::new(mesh.id.as_ref().unwrap_or(&"Unnamed MESH".to_string()));
// let n_cells = ijk.i * ijk.j * ijk.k;
// let quantity_cell = Cell::new(&n_cells.to_formatted_string(&Locale::en));
// let ijk_cell = Cell::new(&format!("{}-{}-{}", ijk.i, ijk.j, ijk.k));
// let dx = (xb.x2 - xb.x1) / (ijk.i as f64);
// let dy = (xb.y2 - xb.y1) / (ijk.j as f64);
// let dz = (xb.z2 - xb.z1) / (ijk.k as f64);
// let dxyz_cell = Cell::new(&format!("{:.2}-{:.2}-{:.2}", dx, dy, dz));
// let max_dx = if dx >= dy && dx >= dz {
// dx
// } else if dy >= dz {
// dy
// } else {
// dz
// };
// let min_dx = if dx <= dy && dx <= dz {
// dx
// } else if dy <= dz {
// dy
// } else {
// dz
// };
// let aspect_ratio_cell = Cell::new(&format!("{:.2}", max_dx / min_dx));
// table.add_row(Row::new(vec![
// n_cell,
// id_cell,
// quantity_cell,
// ijk_cell,
// dxyz_cell,
// aspect_ratio_cell,
// ]));
// n_cells_total += n_cells as u64;
// }
// table.add_row(Row::new(vec![
// Cell::new("Total"),
// Cell::new(""),
// Cell::new(&n_cells_total.to_formatted_string(&Locale::en)),
// Cell::new(""),
// Cell::new(""),
// Cell::new(""),
// ]));
// table.printstd();
})
// Update Threadway Send
.command("plot-hrr", "Plot the HRR")
// .option("--master", "Pull the master branch version.")
.arguments("<input-path:string>")
.action(async () => {
// const fdsFile = await getJson(args[0]);
})
// Get Threadway
.command("show-hrr", "Plot and show the HRR")
// .option("--master", "Pull the master branch version.")
.arguments("<input-path:string>")
.action(async () => {
// const fdsFile = await getJson(args[0]);
})
// Get Aff-Docs
.command("peak-hrr", "Print the highest HRR value from available data")
.option("--master", "Pull the master branch version.")
.arguments("<input-path:string>")
.action(async () => {
// const fdsFile = await getJson(args[0]);
})
.command("verify-input", "Copy input and relevant output files.")
// .option("-f, --foo", "Foo option.")
.arguments("<input-path:string>")
.action(async (_options, ...args) => {
const inputPath = args[0];
const fdsFile: FdsFile = await getJson(inputPath);
const rendered = await verifyInputRender(fdsFile);
const htmlOutput = path.join(path.dirname(inputPath), "Verification.html");
await Deno.writeTextFile(
htmlOutput,
rendered,
);
await open(htmlOutput);
})
.command("copy-inputs", "Bar sub-command.")
.option("--master", "Pull the master branch version.")
.arguments("<input-path:string>")
.action(async () => {
// const fdsFile = await getJson(args[0]);
})
.command("verify", "Verify both the input and the output")
// .option("--master", "Pull the master branch version.")
.arguments("<input-path:string>")
.action(async () => {
// const fdsFile = await getJson(args[0]);
})
.command("rename", "Rename a simulation")
// .option("--master", "Pull the master branch version.")
.arguments("<input-path:string>")
.action(async () => {
// const fdsFile = await getJson(args[0]);
})
.command(
"compare",
"Compare data vectors from multiple different simulations",
)
.option("--master", "Pull the master branch version.")
.arguments("<input-path:string>")
.action(async () => {
// const fdsFile = await getJson(args[0]);
})
.command("new-rev", "Create a new revision of a simulation")
// .option("--master", "Pull the master branch version.")
.arguments("<input-path:string>")
.action(async () => {
// const fdsFile = await getJson(args[0]);
})
.command("current-progress", "Output the current progress of the simulation")
.option("--master", "Pull the master branch version.")
.arguments("<input-path:string>")
.action(async () => {
// const fdsFile = await getJson(args[0]);
})
.command("chart", "Compile a summary of information")
// .option("--master", "Pull the master branch version.")
.arguments("<input-path:string>")
.action(async () => {
// const fdsFile = await getJson(args[0]);
})
.command("read-out", "Read .out info")
.option("--master", "Pull the master branch version.")
.arguments("<input-path:string>")
.action(async () => {
// const fdsFile = await getJson(args[0]);
})
.command("hrr-vector", "Output HRR vector")
// .option("--master", "Pull the master branch version.")
.arguments("<input-path:string>")
.action(async () => {
// const fdsFile = await getJson(args[0]);
})
.parse(Deno.args);
Loading

0 comments on commit 5932641

Please sign in to comment.