264 {
267
268 unsigned int n_threads = std::thread::hardware_concurrency();
269 if (input.cmdOptionExists("-nThreads"))
270 n_threads = std::stoul(input.getCmdOption("-nThreads"));
273
274 double final_time = 0.0030;
275 size_t num_steps = 30000;
276 if (input.cmdOptionExists("-finalTime"))
277 final_time = std::stod(input.getCmdOption("-finalTime"));
278 if (input.cmdOptionExists("-numSteps"))
279 num_steps = std::stoul(input.getCmdOption("-numSteps"));
280
281 const double mesh_size = 0.00010;
282 const double horizon = 3.0 * mesh_size;
283
284 namespace fs = std::filesystem;
285 const fs::path cwd = fs::current_path();
286 fs::path out_dir = cwd / "out";
287 fs::path inp_dir = cwd / "inp";
288 if (input.cmdOptionExists("-outputDir")) {
289 fs::path p = input.getCmdOption("-outputDir");
290 out_dir = p.is_absolute() ? std::move(p) : cwd / p;
291 }
292 if (input.cmdOptionExists("-inputDir")) {
293 fs::path p = input.getCmdOption("-inputDir");
294 inp_dir = p.is_absolute() ? std::move(p) : cwd / p;
295 } else if (input.cmdOptionExists("-outputDir")) {
296 inp_dir = out_dir.parent_path() / "inp";
297 }
298 fs::create_directories(out_dir);
299 fs::create_directories(inp_dir);
300
302 const fs::path mesh_tri = inp_dir / "mesh_triangle.msh";
303 const fs::path mesh_ell = inp_dir / "mesh_hollow_ellipse.msh";
304
305 auto j =
buildInputJson(output_path, mesh_tri, mesh_ell, final_time, num_steps, mesh_size,
306 horizon);
307 {
308 std::ofstream ofs(inp_dir / "input.json");
309 ofs << std::setw(2) << j << std::endl;
310 }
311
312
313
314 if (input.cmdOptionExists("-deckOnly")) {
317 return 0;
318 }
319
320
321 if (j["Particle"]["Set_2"]["Type"] != "ellipse_minus_ellipse")
322 throw std::runtime_error("ellipse_triangle: Particle Set_2 must be ellipse_minus_ellipse");
323
325 "[ellipse_triangle] Type={}, T={}, Nt={}, mesh={:.4e}, out={}\n",
326 j["Particle"]["Set_2"]["Type"].get<std::string>(), final_time, num_steps, mesh_size,
327 out_dir.string()));
328
329 auto deck = std::make_shared<inp::Input>(j);
331 dem.run(deck);
332
333 return 0;
334}
std::string directoryPathWithTrailingSep(const std::filesystem::path &dir)
json buildInputJson(const std::string &output_path, const std::filesystem::path &mesh_tri, const std::filesystem::path &mesh_ell, double final_time, size_t num_steps, double mesh_size, double horizon)
void print(const T &msg, int nt=print_default_tab, int printMpiRank=print_default_mpi_rank)
Prints formatted information.
unsigned int getNThreads()
Get number of threads to be used by taskflow.
void initNThreads(unsigned int nThreads=std::thread::hardware_concurrency())
Initializes MpiStatus struct.
void initMpi(int argc=0, char *argv[]=nullptr)
Initializes MPI and also creates MpiStatus struct.
void finalizeMpi()
Call MPI_Finalize if this process initialized MPI.