63 string filename =
m_config[
"outfile"].as<
string>();
74 ASSERTL0(!
m_f->m_writeBndFld,
"Boundary can't be obtained from pts.");
79 if (vm.count(
"error"))
91 if (
m_f->m_exp.size())
97 m_f->SetUpExp(vm,
true);
105 if (!
m_f->m_exp.size())
107 if (
m_f->m_data.size())
110 "Boundary extraction requires xml file.");
118 if (
m_f->m_writeBndFld)
120 if (
m_f->m_verbose &&
121 m_f->m_comm->GetSpaceComm()->TreatAsRankZero())
124 <<
": Writing boundary file(s): ";
125 for (
int i = 0; i <
m_f->m_bndRegionsToWrite.size(); ++i)
127 cout <<
m_f->m_bndRegionsToWrite[i];
128 if (i < m_f->m_bndRegionsToWrite.size() - 1)
136 int nfields =
m_f->m_variables.size();
137 int normdim =
m_f->m_graph->GetMeshDimension();
140 if (
m_f->m_addNormals)
143 m_f->m_exp.resize(nfields + normdim);
146 string normstr[3] = {
"Norm_x",
"Norm_y",
"Norm_z"};
147 for (
int j = 0; j < normdim; ++j)
149 m_f->m_exp[nfields + j] =
150 m_f->AppendExpList(
m_f->m_numHomogeneousDir);
151 m_f->m_variables.push_back(normstr[j]);
156 vector<MultiRegions::ExpListSharedPtr> exp(
m_f->m_exp.size());
157 exp.swap(
m_f->m_exp);
161 for (
int i = 0; i < exp.size(); ++i)
163 BndExp[i] = exp[i]->GetBndCondExpansions();
172 map<int, int> BndRegionMap;
173 map<int, LibUtilities::CommSharedPtr> BndRegionComm;
177 std::set<int> ProcessBnd;
178 if (
m_f->m_session->DefinesTag(
"CreateBndRegions"))
181 vector<unsigned int> bndRegions;
184 m_f->m_session->GetTag(
"CreateBndRegions"), bndRegions),
185 "Failed to interpret bnd values string");
187 for (
auto &bnd : bndRegions)
189 if (bregions.count(bnd) == 1)
191 ProcessBnd.insert(bnd);
197 for (
auto &it : bregions)
199 ProcessBnd.insert(it.first);
204 for (
auto &breg_it : bregions)
206 if (ProcessBnd.count(breg_it.first))
208 BndRegionMap[breg_it.first] = cnt++;
209 BndRegionComm[breg_it.first] =
215 int dot = filename.find_last_of(
'.') + 1;
216 string ext = filename.substr(dot, filename.length() - dot);
217 string name = filename.substr(0, dot - 1);
222 for (
int i = 0; i <
m_f->m_bndRegionsToWrite.size(); ++i)
224 string outname = name +
"_b" +
225 std::to_string(
m_f->m_bndRegionsToWrite[i]) +
234 if (BndRegionMap.count(
m_f->m_bndRegionsToWrite[i]) == 1)
236 m_f->m_comm = BndRegionComm[
m_f->m_bndRegionsToWrite[i]];
238 int Border = BndRegionMap[
m_f->m_bndRegionsToWrite[i]];
241 for (
int j = 0; j < exp.size(); ++j)
243 m_f->m_exp[j] = BndExp[j][Border];
246 for (
int j = 0; j < exp.size(); ++j)
248 m_f->m_exp[j] = BndExp[j][Border];
249 m_f->m_exp[j]->BwdTrans(
m_f->m_exp[j]->GetCoeffs(),
250 m_f->m_exp[j]->UpdatePhys());
253 if (
m_f->m_addNormals)
257 exp[0]->GetBoundaryNormals(Border, NormPhys);
260 for (
int j = 0; j < normdim; ++j)
262 m_f->m_exp[nfields + j] =
263 BndExp[nfields + j][Border];
265 m_f->m_exp[nfields + j]->GetTotPoints(),
267 m_f->m_exp[nfields + j]->UpdatePhys(), 1);
268 m_f->m_exp[nfields + j]->FwdTransLocalElmt(
269 m_f->m_exp[nfields + j]->GetPhys(),
270 m_f->m_exp[nfields + j]->UpdateCoeffs());
275 if (vm.count(
"error"))
281 m_f->m_comm = tmpComm;
288 exp.swap(
m_f->m_exp);
296 if (vm.count(
"error"))
315 if (vm.count(
"nparts"))
321 outFile =
GetPath(filename, vm);
334 int count = fs::exists(outFile) ? 1 : 0;
338 if (count && (vm.count(
"force-output") == 0))
340 if (vm.count(
"nparts") == 0)
344 if (comm->GetSpaceComm()->TreatAsRankZero())
347 cout <<
"Did you wish to overwrite " << outFile <<
" (y/n)? ";
348 getline(cin, answer);
349 if (answer.compare(
"y") == 0)
355 cout <<
"Not writing file '" << filename
356 <<
"' because it already exists" << endl;
362 return (writeFile == 0) ? false :
true;
368 int numFields =
m_f->m_exp.size();
369 m_f->m_fielddef =
m_f->m_exp[0]->GetFieldDefinitions();
373 if (vm.count(
"output-points"))
375 nPointsNew = vm[
"output-points"].as<
int>();
377 m_f->m_graph->SetExpansionInfoToEvenlySpacedPoints(nPointsNew);
380 vector<MultiRegions::ExpListSharedPtr> expOld =
m_f->m_exp;
383 m_f->m_exp[0] =
m_f->SetUpFirstExpList(
m_f->m_numHomogeneousDir,
true);
384 for (
int i = 1; i < numFields; ++i)
386 m_f->m_exp[i] =
m_f->AppendExpList(
m_f->m_numHomogeneousDir);
390 for (
int i = 0; i < numFields; ++i)
392 m_f->m_exp[i]->ExtractCoeffsToCoeffs(expOld[i], expOld[i]->GetCoeffs(),
393 m_f->m_exp[i]->UpdateCoeffs());
394 m_f->m_exp[i]->BwdTrans(
m_f->m_exp[i]->GetCoeffs(),
395 m_f->m_exp[i]->UpdatePhys());
399 if (
m_f->m_writeBndFld)
404 for (
int i = 0; i < numFields; ++i)
406 BndExpOld = expOld[i]->GetBndCondExpansions();
407 for (
int j = 0; j < BndExpOld.size(); ++j)
409 BndExp =
m_f->m_exp[i]->UpdateBndCondExpansion(j);
410 BndExp->ExtractCoeffsToCoeffs(BndExpOld[j],
411 BndExpOld[j]->GetCoeffs(),
412 BndExp->UpdateCoeffs());
417 m_f->m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
425 int coordim =
m_f->m_fieldPts->GetDim();
426 std::string coordVars[] = {
"x",
"y",
"z"};
428 vector<string> variables =
m_f->m_variables;
429 variables.insert(variables.begin(), coordVars, coordVars + coordim);
435 m_f->m_fieldPts->GetPts(fields);
436 for (
int i = 0; i < fields.size(); ++i)
439 int npts = fields[i].size();
443 for (
int j = 0; j < npts; ++j)
445 l2err += fields[i][j] * fields[i][j];
446 linferr =
max(linferr, fabs(fields[i][j]));
451 m_f->m_comm->GetSpaceComm()->AllReduce(linferr,
457 if (
m_f->m_comm->GetSpaceComm()->TreatAsRankZero())
459 cout <<
"L 2 error (variable " << variables[i] <<
") : " << l2err
462 cout <<
"L inf error (variable " << variables[i]
463 <<
") : " << linferr << endl;
471 m_f->m_exp[0]->GetExp(0)->GetCoordim() +
m_f->m_numHomogeneousDir;
472 int totpoints =
m_f->m_exp[0]->GetTotPoints();
473 std::string coordVars[] = {
"x",
"y",
"z"};
477 for (
int i = 0; i < coordim; ++i)
485 m_f->m_exp[0]->GetCoords(coords[0]);
487 else if (coordim == 2)
489 m_f->m_exp[0]->GetCoords(coords[0], coords[1]);
493 m_f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
496 for (
int j = 0; j < coordim; ++j)
501 if (
m_f->m_comm->GetSpaceComm()->TreatAsRankZero())
503 cout <<
"L 2 error (variable " << coordVars[j] <<
") : " << l2err
506 cout <<
"L inf error (variable " << coordVars[j]
507 <<
") : " << linferr << endl;
511 for (
int j = 0; j <
m_f->m_exp.size(); ++j)
516 if (
m_f->m_comm->GetSpaceComm()->TreatAsRankZero() &&
517 m_f->m_variables.size() > 0)
519 cout <<
"L 2 error (variable " <<
m_f->m_variables[j]
520 <<
") : " << l2err << endl;
522 cout <<
"L inf error (variable " <<
m_f->m_variables[j]
523 <<
") : " << linferr << endl;
std::map< int, LibUtilities::CommSharedPtr > GetBoundaryCommunicators() const
const BoundaryRegionCollection & GetBoundaryRegions(void) const
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection