NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
AutoVerificationDriver.C
Go to the documentation of this file.
1 /*******************************************************************************
2 * Promesh *
3 * Copyright (C) 2022, IllinoisRocstar LLC. All rights reserved. *
4 * *
5 * Promesh is the property of IllinoisRocstar LLC. *
6 * *
7 * IllinoisRocstar LLC *
8 * Champaign, IL *
9 * www.illinoisrocstar.com *
10 * promesh@illinoisrocstar.com *
11 *******************************************************************************/
12 /*******************************************************************************
13 * This file is part of Promesh *
14 * *
15 * This version of Promesh is free software: you can redistribute it and/or *
16 * modify it under the terms of the GNU Lesser General Public License as *
17 * published by the Free Software Foundation, either version 3 of the License, *
18 * or (at your option) any later version. *
19 * *
20 * Promesh is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more *
23 * details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
27 * *
28 *******************************************************************************/
30 
32 #include "Mesh/meshBase.H"
33 
34 #ifdef HAVE_OPENMP
35 # include <omp.h>
36 #endif
37 
38 namespace NEM {
39 namespace DRV {
40 
41 AutoVerificationDriver::Files::Files(std::string coarseMesh,
42  std::string fineMesh,
43  std::string finerMesh)
44  : coarseMeshFile(std::move(coarseMesh)),
45  fineMeshFile(std::move(fineMesh)),
46  finerMeshFile(std::move(finerMesh)) {}
47 
48 AutoVerificationDriver::Opts::Opts(std::vector<int> arrayIds)
49  : arrayIds(std::move(arrayIds)) {}
50 
52  : files_(std::move(files)), opts_(std::move(opts)) {}
53 
55  : AutoVerificationDriver({{}, {}, {}}, Opts{{}}) {}
56 
58  return files_;
59 }
60 
62  this->files_ = std::move(files);
63 }
64 
66  return opts_;
67 }
68 
70  this->opts_ = std::move(opts);
71 }
72 
73 jsoncons::string_view AutoVerificationDriver::getProgramType() const {
74  return programType;
75 }
76 
78  auto coarseMesh = meshBase::CreateShared(this->files_.coarseMeshFile);
79  auto fineMesh = meshBase::CreateShared(this->files_.fineMeshFile);
80  auto finerMesh = meshBase::CreateShared(this->files_.finerMeshFile);
81 #ifdef HAVE_OPENMP
82  auto threads = this->opts_.numThreads.value_or(omp_get_max_threads());
83  omp_set_num_threads(threads);
84  std::cout << "Number of threads set to : " << threads << std::endl;
85 #else
86  if (this->opts_.numThreads) {
87  std::cerr << "OpenMP is not enabled. Verification will continue in serial."
88  << std::endl;
89  }
90 #endif
91  std::cout << "Running verification." << std::endl;
92  auto oac = std::make_shared<OrderOfAccuracy>(
93  coarseMesh.get(), fineMesh.get(), finerMesh.get(), this->opts_.arrayIds,
94  this->opts_.transferType, this->opts_.targetGCI);
95  std::cout << "Checking if in asymptotic range." << std::endl;
96  std::cout << "Target GCI is set to : " << oac->getTargetGCI() << std::endl;
97  auto asymp = oac->checkAsymptoticRange();
98  bool inRange = true;
99  for (int i = 0; i < asymp.size(); ++i) {
100  for (int j = 0; j < asymp[0].size(); ++j) {
101  double gci = asymp[i][j];
102  if (gci > oac->getTargetGCI()) {
103  std::cout << "GCI of " << gci;
104  std::cout << " exceeds target GCI of " << oac->getTargetGCI()
105  << std::endl;
106  std::cout << "at array " << i << ", component " << j << std::endl;
107  inRange = false;
108  }
109  }
110  }
111  if (inRange) {
112  std::cout << "Grid is in target asymptotic range." << std::endl;
113  } else {
114  std::cout << "Grid is not in target asymptotic range." << std::endl;
115  }
116 }
117 
118 } // namespace DRV
119 } // namespace NEM
void execute() const override
Run the workflow represented by the driver.
jsoncons::string_view getProgramType() const override
STL namespace.
std::vector< int > arrayIds
field ids for which we will evaluate the grid convergence index (GCI)
static constexpr const char * programType
std::string transferType
default is &#39;Consistent Interpolation&#39;, alternatives include &#39;Conservative Surface Transfer&#39; (if enabl...
This class drives the automatic verification (AV) in Nemosys.
jsoncons::optional< int > numThreads
sets number of threads used in transfer (if OpenMP enabled); if unset and OpenMP enabled, omp_get_max_threads used
static std::shared_ptr< meshBase > CreateShared(const std::string &fname)
Create shared ptr from fname.
Definition: meshBase.C:171
double targetGCI
the target GCI value, set to 1.1 by default