forked from NaluCFD/NaluSandBox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
naluSandBox.C
222 lines (182 loc) · 7.1 KB
/
naluSandBox.C
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/*------------------------------------------------------------------------*/
/* Copyright 2014 Sandia Corporation. */
/* This software is released under the license detailed */
/* in the file, LICENSE, which is located in the top-level Nalu */
/* directory structure */
/*------------------------------------------------------------------------*/
// nalu
#include <NaluEnv.h>
#include <element_promotion/PromoteElementTest.h>
#include <element_promotion/QuadratureRuleTest.h>
#include <element_promotion/MasterElementHOTest.h>
#include <element_promotion/PromoteElementRestartTest.h>
#include <element_promotion/HighOrderPoissonTest.h>
#include <element_promotion/new_assembly/TensorProductPoissonTest.h>
#include <element_promotion/new_assembly/TensorProductPoissonTest3D.h>
#include <element_promotion/new_assembly/HighOrderOperatorsTest.h>
#include <mpi.h>
#include <overset/Overset.h>
#include <surfaceFields/SurfaceFields.h>
#include <superElement/SuperElement.h>
#include <iostream>
#include <stdexcept>
#include <string>
#include <boost/program_options.hpp>
int main( int argc, char ** argv )
{
// start up MPI
if ( MPI_SUCCESS != MPI_Init( &argc , &argv ) ) {
throw std::runtime_error("MPI_Init failed");
}
// NaluEnv singleton
sierra::naluUnit::NaluEnv &naluEnv = sierra::naluUnit::NaluEnv::self();
// command line options.
std::string inputFileName, logFileName;
boost::program_options::options_description desc("Nalu Supported Options");
desc.add_options()
("help,h","Help message")
("version,v", "Code Version 1.0")
("log-file,o", boost::program_options::value<std::string>(&logFileName),
"Analysis log file");
boost::program_options::variables_map vm;
boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
boost::program_options::notify(vm);
// deal with some default parameters
if ( vm.count("help") ) {
if (!naluEnv.parallel_rank())
std::cerr << desc << std::endl;
return 0;
}
if (vm.count("version")) {
if (!naluEnv.parallel_rank())
std::cerr << "Version: Nalu1.0" << std::endl;
return 0;
}
// deal with logfile name; if none supplied, go with naluInit.log
if (!vm.count("log-file")) {
logFileName = "naluUnit.log";
}
// deal with log file stream
naluEnv.set_log_file_stream(logFileName);
naluEnv.naluOutputP0() << "NaluUnit Shall Commence" << std::endl;
//==============================
// create; execute; delete
//==============================
// superElement
const bool doSuperElement = true;
if ( doSuperElement ) {
sierra::naluUnit::SuperElement *superElement = new sierra::naluUnit::SuperElement();
superElement->execute();
delete superElement;
}
// overset
const bool doOverset = false;
if ( doOverset ) {
sierra::naluUnit::Overset *overset = new sierra::naluUnit::Overset();
overset->execute();
delete overset;
}
// surface
const bool doSurfaceFields = false;
if ( doSurfaceFields ) {
sierra::naluUnit::SurfaceFields *surfaceFields = new sierra::naluUnit::SurfaceFields();
surfaceFields->execute();
delete surfaceFields;
}
//==============================
// Elem promotion unit test options
const bool doQuadrature = true;
const bool doHighOrderOperatorsHex = true;
const bool doMasterElementQuad = true;
const bool doMasterElementHex= true;
const bool doPromotionQuadGaussLegendre = true;
const bool doPromotionQuadSGL = true;
const bool doPromotionHexGaussLegendre = true;
const bool doPromotionHexSGL = true;
const bool doQuadPoissonSGL = true && naluEnv.parallel_size() == 1; // serial test
const bool doHexPoissonSGL = true && naluEnv.parallel_size() == 1; // serial test
const bool doQuadTensorProductPoisson = true && naluEnv.parallel_size() == 1; //serial test
const bool doHexTensorProductPoisson = true && naluEnv.parallel_size() == 1; //serial test
const bool doRestartQuad = true;
const bool doRestartHex = true;
const int maxQuadOrder = 5;
const int maxHexOrder = 5;
// The dual nodal volume test assumes a uniform mesh
// The projected nodal gradient test should always work
// The node count test assumes a uniform mesh with a square/cubic domain on every core
//std::string quadMesh = "test_meshes/1x1_tquad4_R0.g";
std::string quadMesh = "test_meshes/quad4_64.g";
//std::string hexMesh = "test_meshes/thex8_8.g";
std::string hexMesh = "test_meshes/hex8_4.g";
//==============================
if ( doQuadrature ) {
sierra::naluUnit::QuadratureRuleTest().execute();
}
if (doHighOrderOperatorsHex) {
sierra::naluUnit::HighOrderOperatorsHexTest().execute();
}
if ( doMasterElementQuad ) {
for (int j = 1; j <= maxQuadOrder; ++j) {
sierra::naluUnit::MasterElementHOTest(2, j).execute();
}
}
if (doMasterElementHex ) {
for (int j = 1; j <= maxHexOrder; ++j) {
sierra::naluUnit::MasterElementHOTest(3, j).execute();
}
}
if (doPromotionQuadGaussLegendre) {
for (int j = 1; j <= maxQuadOrder; ++j) {
sierra::naluUnit::PromoteElementTest(2, j, quadMesh, "GaussLegendre").execute();
}
}
if (doPromotionQuadSGL) {
for (int j = 1; j <= maxQuadOrder; ++j) {
sierra::naluUnit::PromoteElementTest(2, j, quadMesh, "SGL").execute();
}
}
if (doPromotionHexGaussLegendre) {
for (int j = 1; j <= maxHexOrder; ++j) {
sierra::naluUnit::PromoteElementTest(3, j, hexMesh, "GaussLegendre").execute();
}
}
if (doPromotionHexSGL) {
for (int j = 1; j <= maxHexOrder; ++j) {
sierra::naluUnit::PromoteElementTest(3, j, hexMesh, "SGL").execute();
}
}
if ( doQuadTensorProductPoisson ) {
int polyOrder = 10;
bool printTiming = true;
sierra::naluUnit::TensorProductPoissonTest("test_meshes/tquad4_4.g", polyOrder, printTiming).execute();
}
if ( doHexTensorProductPoisson ) {
int polyOrder = 12;
bool printTiming = true;
sierra::naluUnit::TensorProductPoissonTest3D("test_meshes/hex8_1.g", polyOrder, printTiming).execute();
}
if ( doQuadPoissonSGL ) {
sierra::naluUnit::HighOrderPoissonTest("test_meshes/quad4_2.g").execute();
}
if (doHexPoissonSGL) {
sierra::naluUnit::HighOrderPoissonTest("test_meshes/hex8_2.g").execute();
}
if (doRestartQuad) {
for (int j = 1; j <= maxQuadOrder; ++j) {
unsigned nodesPerElem = (j+1)*(j+1);
std::string restartName = "test_output/restart/Quad" + std::to_string(nodesPerElem) + ".rs";
std::string outputName = "test_output/restart/Quad" + std::to_string(nodesPerElem) + "_rs.e";
sierra::naluUnit::PromoteElementRestartTest(restartName,outputName).execute();
}
}
if (doRestartHex) {
for (int j = 1; j <= maxHexOrder; ++j) {
unsigned nodesPerElem = (j+1)*(j+1)*(j+1);
std::string restartName = "test_output/restart/Hex" + std::to_string(nodesPerElem) + ".rs";
std::string outputName = "test_output/restart/Hex" + std::to_string(nodesPerElem) + "_rs.e";
sierra::naluUnit::PromoteElementRestartTest(restartName,outputName).execute();
}
}
// all done
return 0;
}