Nektar++
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
Nektar::FieldUtils::OutputFileBase Class Referenceabstract

Converter from fld to vtk. More...

#include <OutputFileBase.h>

Inheritance diagram for Nektar::FieldUtils::OutputFileBase:
[legend]

Public Member Functions

 OutputFileBase (FieldSharedPtr f)
 
virtual ~OutputFileBase ()
 
- Public Member Functions inherited from Nektar::FieldUtils::OutputModule
 OutputModule (FieldSharedPtr p_f)
 
FIELD_UTILS_EXPORT void OpenStream ()
 Open a file for output. More...
 
- Public Member Functions inherited from Nektar::FieldUtils::Module
FIELD_UTILS_EXPORT Module (FieldSharedPtr p_f)
 
virtual ~Module ()=default
 
void Process (po::variables_map &vm)
 
std::string GetModuleName ()
 
std::string GetModuleDescription ()
 
const ConfigOptionGetConfigOption (const std::string &key) const
 
ModulePriority GetModulePriority ()
 
FIELD_UTILS_EXPORT void RegisterConfig (std::string key, std::string value="")
 Register a configuration option with a module. More...
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
FIELD_UTILS_EXPORT void AddFile (std::string fileType, std::string fileName)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Protected Member Functions

virtual void v_Process (po::variables_map &vm) override
 Write fld to output file. More...
 
virtual std::string v_GetModuleName () override
 
virtual std::string v_GetModuleDescription () override
 
virtual ModulePriority v_GetModulePriority () override
 
virtual void v_OutputFromPts (po::variables_map &vm)=0
 Write from pts to output file. More...
 
virtual void v_OutputFromExp (po::variables_map &vm)=0
 Write from m_exp to output file. More...
 
virtual void v_OutputFromData (po::variables_map &vm)=0
 Write from data to output file. More...
 
virtual fs::path v_GetPath (std::string &filename, po::variables_map &vm)
 
fs::path GetPath (std::string &filename, po::variables_map &vm)
 
virtual fs::path v_GetFullOutName (std::string &filename, po::variables_map &vm)
 
fs::path GetFullOutName (std::string &filename, po::variables_map &vm)
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
virtual void v_Process (po::variables_map &vm)
 
virtual std::string v_GetModuleName ()
 
virtual std::string v_GetModuleDescription ()
 
virtual ModulePriority v_GetModulePriority ()
 

Protected Attributes

bool m_requireEquiSpaced
 
- Protected Attributes inherited from Nektar::FieldUtils::OutputModule
std::ofstream m_fldFile
 Output stream. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 
std::set< std::string > m_allowedFiles
 List of allowed file formats. More...
 

Private Member Functions

bool WriteFile (std::string &filename, po::variables_map &vm)
 
void ConvertExpToEquispaced (po::variables_map &vm)
 
void PrintErrorFromPts ()
 
void PrintErrorFromExp ()
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 

Detailed Description

Converter from fld to vtk.

Definition at line 47 of file OutputFileBase.h.

Constructor & Destructor Documentation

◆ OutputFileBase()

Nektar::FieldUtils::OutputFileBase::OutputFileBase ( FieldSharedPtr  f)

Definition at line 49 of file OutputFileBase.cpp.

49 : OutputModule(f)
50{
51 m_requireEquiSpaced = false;
52 m_config["writemultiplefiles"] = ConfigOption(
53 true, "0",
54 "Write multiple files in parallel or when using nparts option");
55}
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:263
OutputModule(FieldSharedPtr p_f)
Definition: Module.cpp:68

References Nektar::FieldUtils::Module::m_config, and m_requireEquiSpaced.

◆ ~OutputFileBase()

Nektar::FieldUtils::OutputFileBase::~OutputFileBase ( )
virtual

Definition at line 57 of file OutputFileBase.cpp.

58{
59}

Member Function Documentation

◆ ConvertExpToEquispaced()

void Nektar::FieldUtils::OutputFileBase::ConvertExpToEquispaced ( po::variables_map &  vm)
private

Definition at line 307 of file OutputFileBase.cpp.

308{
309 // Information to create new expansion
310 int numFields = m_f->m_exp.size();
311 m_f->m_fielddef = m_f->m_exp[0]->GetFieldDefinitions();
312
313 // Set points to equispaced
314 int nPointsNew = 0;
315 if (vm.count("output-points"))
316 {
317 nPointsNew = vm["output-points"].as<int>();
318 }
319 m_f->m_graph->SetExpansionInfoToEvenlySpacedPoints(nPointsNew);
320
321 // Save original expansion
322 vector<MultiRegions::ExpListSharedPtr> expOld = m_f->m_exp;
323
324 // Create new expansion
325 m_f->m_exp[0] = m_f->SetUpFirstExpList(m_f->m_numHomogeneousDir, true);
326 for (int i = 1; i < numFields; ++i)
327 {
328 m_f->m_exp[i] = m_f->AppendExpList(m_f->m_numHomogeneousDir);
329 }
330
331 // Extract result to new expansion
332 for (int i = 0; i < numFields; ++i)
333 {
334 m_f->m_exp[i]->ExtractCoeffsToCoeffs(expOld[i], expOld[i]->GetCoeffs(),
335 m_f->m_exp[i]->UpdateCoeffs());
336 m_f->m_exp[i]->BwdTrans(m_f->m_exp[i]->GetCoeffs(),
337 m_f->m_exp[i]->UpdatePhys());
338 }
339 // Extract boundary expansion if needed
340 if (m_f->m_writeBndFld)
341 {
342 Array<OneD, const MultiRegions::ExpListSharedPtr> BndExpOld;
344
345 for (int i = 0; i < numFields; ++i)
346 {
347 BndExpOld = expOld[i]->GetBndCondExpansions();
348 for (int j = 0; j < BndExpOld.size(); ++j)
349 {
350 BndExp = m_f->m_exp[i]->UpdateBndCondExpansion(j);
351 BndExp->ExtractCoeffsToCoeffs(BndExpOld[j],
352 BndExpOld[j]->GetCoeffs(),
353 BndExp->UpdateCoeffs());
354 }
355 }
356 }
357 m_f->m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
358}
FieldSharedPtr m_f
Field object.
Definition: Module.h:234
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.

References Nektar::FieldUtils::Module::m_f.

Referenced by v_Process().

◆ GetFullOutName()

fs::path Nektar::FieldUtils::OutputFileBase::GetFullOutName ( std::string &  filename,
po::variables_map &  vm 
)
inlineprotected

Definition at line 99 of file OutputFileBase.h.

100 {
101 return v_GetFullOutName(filename, vm);
102 }
virtual fs::path v_GetFullOutName(std::string &filename, po::variables_map &vm)

References v_GetFullOutName().

Referenced by Nektar::FieldUtils::OutputVtkBase::PrepareOutput(), WriteFile(), and Nektar::FieldUtils::OutputTecplot::WriteTecplotFile().

◆ GetPath()

fs::path Nektar::FieldUtils::OutputFileBase::GetPath ( std::string &  filename,
po::variables_map &  vm 
)
inlineprotected

◆ PrintErrorFromExp()

void Nektar::FieldUtils::OutputFileBase::PrintErrorFromExp ( )
private

Definition at line 405 of file OutputFileBase.cpp.

406{
407 int coordim =
408 m_f->m_exp[0]->GetExp(0)->GetCoordim() + m_f->m_numHomogeneousDir;
409 int totpoints = m_f->m_exp[0]->GetTotPoints();
410 std::string coordVars[] = {"x", "y", "z"};
411
412 // Set up storage for coordinates
413 Array<OneD, Array<OneD, NekDouble>> coords(coordim);
414 for (int i = 0; i < coordim; ++i)
415 {
416 coords[i] = Array<OneD, NekDouble>(totpoints);
417 }
418
419 // Get coordinates
420 if (coordim == 1)
421 {
422 m_f->m_exp[0]->GetCoords(coords[0]);
423 }
424 else if (coordim == 2)
425 {
426 m_f->m_exp[0]->GetCoords(coords[0], coords[1]);
427 }
428 else
429 {
430 m_f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
431 }
432
433 for (int j = 0; j < coordim; ++j)
434 {
435 NekDouble l2err = m_f->m_exp[0]->L2(coords[j]);
436 NekDouble linferr = m_f->m_exp[0]->Linf(coords[j]);
437
438 if (m_f->m_comm->GetSpaceComm()->TreatAsRankZero())
439 {
440 cout << "L 2 error (variable " << coordVars[j] << ") : " << l2err
441 << endl;
442
443 cout << "L inf error (variable " << coordVars[j]
444 << ") : " << linferr << endl;
445 }
446 }
447
448 for (int j = 0; j < m_f->m_exp.size(); ++j)
449 {
450 NekDouble l2err = m_f->m_exp[j]->L2(m_f->m_exp[j]->GetPhys());
451 NekDouble linferr = m_f->m_exp[j]->Linf(m_f->m_exp[j]->GetPhys());
452
453 if (m_f->m_comm->GetSpaceComm()->TreatAsRankZero() &&
454 m_f->m_variables.size() > 0)
455 {
456 cout << "L 2 error (variable " << m_f->m_variables[j]
457 << ") : " << l2err << endl;
458
459 cout << "L inf error (variable " << m_f->m_variables[j]
460 << ") : " << linferr << endl;
461 }
462 }
463}
double NekDouble

References Nektar::FieldUtils::Module::m_f.

Referenced by v_Process().

◆ PrintErrorFromPts()

void Nektar::FieldUtils::OutputFileBase::PrintErrorFromPts ( )
private

Definition at line 360 of file OutputFileBase.cpp.

361{
362 int coordim = m_f->m_fieldPts->GetDim();
363 std::string coordVars[] = {"x", "y", "z"};
364
365 vector<string> variables = m_f->m_variables;
366 variables.insert(variables.begin(), coordVars, coordVars + coordim);
367 // Get fields and coordinates
368 Array<OneD, Array<OneD, NekDouble>> fields(variables.size());
369
370 // We can just grab everything from points. This should be a
371 // reference, not a copy.
372 m_f->m_fieldPts->GetPts(fields);
373 for (int i = 0; i < fields.size(); ++i)
374 {
375 // calculate L2 and Linf value
376 int npts = fields[i].size();
377
378 NekDouble l2err = 0.0;
379 NekDouble linferr = 0.0;
380 for (int j = 0; j < npts; ++j)
381 {
382 l2err += fields[i][j] * fields[i][j];
383 linferr = max(linferr, fabs(fields[i][j]));
384 }
385
386 m_f->m_comm->GetSpaceComm()->AllReduce(l2err, LibUtilities::ReduceSum);
387 m_f->m_comm->GetSpaceComm()->AllReduce(npts, LibUtilities::ReduceSum);
388 m_f->m_comm->GetSpaceComm()->AllReduce(linferr,
390
391 l2err /= npts;
392 l2err = sqrt(l2err);
393
394 if (m_f->m_comm->GetSpaceComm()->TreatAsRankZero())
395 {
396 cout << "L 2 error (variable " << variables[i] << ") : " << l2err
397 << endl;
398
399 cout << "L inf error (variable " << variables[i]
400 << ") : " << linferr << endl;
401 }
402 }
403}
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294

References Nektar::FieldUtils::Module::m_f, Nektar::LibUtilities::ReduceMax, Nektar::LibUtilities::ReduceSum, and tinysimd::sqrt().

Referenced by v_Process().

◆ v_GetFullOutName()

virtual fs::path Nektar::FieldUtils::OutputFileBase::v_GetFullOutName ( std::string &  filename,
po::variables_map &  vm 
)
inlineprotectedvirtual

Reimplemented in Nektar::FieldUtils::OutputFld, Nektar::FieldUtils::OutputPts, Nektar::FieldUtils::OutputTecplot, and Nektar::FieldUtils::OutputVtkBase.

Definition at line 92 of file OutputFileBase.h.

94 {
95 boost::ignore_unused(filename, vm);
96 NEKERROR(ErrorUtil::efatal, "v_OutputFromExp not coded");
97 return fs::path();
98 }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:209

References Nektar::ErrorUtil::efatal, and NEKERROR.

Referenced by GetFullOutName().

◆ v_GetModuleDescription()

virtual std::string Nektar::FieldUtils::OutputFileBase::v_GetModuleDescription ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 62 of file OutputFileBase.h.

63 {
64 return "Writing file";
65 }

◆ v_GetModuleName()

virtual std::string Nektar::FieldUtils::OutputFileBase::v_GetModuleName ( )
inlineoverrideprotectedvirtual

◆ v_GetModulePriority()

virtual ModulePriority Nektar::FieldUtils::OutputFileBase::v_GetModulePriority ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 67 of file OutputFileBase.h.

68 {
69 return eOutput;
70 }

References Nektar::FieldUtils::eOutput.

◆ v_GetPath()

virtual fs::path Nektar::FieldUtils::OutputFileBase::v_GetPath ( std::string &  filename,
po::variables_map &  vm 
)
inlineprotectedvirtual

Reimplemented in Nektar::FieldUtils::OutputFld, Nektar::FieldUtils::OutputPts, Nektar::FieldUtils::OutputTecplot, and Nektar::FieldUtils::OutputVtkBase.

Definition at line 81 of file OutputFileBase.h.

82 {
83 boost::ignore_unused(filename, vm);
84 NEKERROR(ErrorUtil::efatal, "v_GetPath not coded");
85 return fs::path();
86 }

References Nektar::ErrorUtil::efatal, and NEKERROR.

Referenced by GetPath().

◆ v_OutputFromData()

virtual void Nektar::FieldUtils::OutputFileBase::v_OutputFromData ( po::variables_map &  vm)
protectedpure virtual

◆ v_OutputFromExp()

virtual void Nektar::FieldUtils::OutputFileBase::v_OutputFromExp ( po::variables_map &  vm)
protectedpure virtual

◆ v_OutputFromPts()

virtual void Nektar::FieldUtils::OutputFileBase::v_OutputFromPts ( po::variables_map &  vm)
protectedpure virtual

◆ v_Process()

void Nektar::FieldUtils::OutputFileBase::v_Process ( po::variables_map &  vm)
overrideprotectedvirtual

Write fld to output file.

Reimplemented from Nektar::FieldUtils::Module.

Reimplemented in Nektar::FieldUtils::OutputTecplot.

Definition at line 61 of file OutputFileBase.cpp.

62{
63 m_f->SetUpExp(vm);
64
65 string filename = m_config["outfile"].as<string>();
66
67 if (m_f->m_fieldPts != LibUtilities::NullPtsField)
68 {
69 ASSERTL0(!m_f->m_writeBndFld, "Boundary can't be obtained from pts.");
70 if (WriteFile(filename, vm))
71 {
73
74 if (vm.count("error"))
75 {
77 }
78 }
79 }
80 else if (m_f->m_exp.size())
81 {
82 // reset expansion definition to use equispaced points if required.
83 if (m_requireEquiSpaced && (vm.count("noequispaced") == 0) &&
84 m_f->m_exp[0]->GetNumElmts() != 0)
85 {
87 }
88 if (m_f->m_writeBndFld)
89 {
90 if (m_f->m_verbose &&
91 m_f->m_comm->GetSpaceComm()->TreatAsRankZero())
92 {
93 cout << "\t" << GetModuleName()
94 << ": Writing boundary file(s): ";
95 for (int i = 0; i < m_f->m_bndRegionsToWrite.size(); ++i)
96 {
97 cout << m_f->m_bndRegionsToWrite[i];
98 if (i < m_f->m_bndRegionsToWrite.size() - 1)
99 {
100 cout << ", ";
101 }
102 }
103 cout << endl;
104 }
105
106 int nfields = m_f->m_variables.size();
107 int normdim = m_f->m_graph->GetMeshDimension();
108
109 // Prepare for normals output
110 if (m_f->m_addNormals)
111 {
112 // Prepare for creating expansions for normals
113 m_f->m_exp.resize(nfields + normdim);
114
115 // Include normal name in m_variables
116 string normstr[3] = {"Norm_x", "Norm_y", "Norm_z"};
117 for (int j = 0; j < normdim; ++j)
118 {
119 m_f->m_exp[nfields + j] =
120 m_f->AppendExpList(m_f->m_numHomogeneousDir);
121 m_f->m_variables.push_back(normstr[j]);
122 }
123 }
124
125 // Move m_exp to a new expansion vector
126 vector<MultiRegions::ExpListSharedPtr> exp(m_f->m_exp.size());
127 exp.swap(m_f->m_exp);
128
129 Array<OneD, Array<OneD, const MultiRegions::ExpListSharedPtr>>
130 BndExp(exp.size());
131 for (int i = 0; i < exp.size(); ++i)
132 {
133 BndExp[i] = exp[i]->GetBndCondExpansions();
134 }
135
136 // get hold of partition boundary regions so we can match it to
137 // desired region extraction
138 SpatialDomains::BoundaryConditions bcs(m_f->m_session,
139 exp[0]->GetGraph());
141 bcs.GetBoundaryRegions();
142 map<int, int> BndRegionMap;
143 map<int, LibUtilities::CommSharedPtr> BndRegionComm;
144 int cnt = 0;
145 for (auto &breg_it : bregions)
146 {
147 BndRegionMap[breg_it.first] = cnt++;
148 BndRegionComm[breg_it.first] =
149 bcs.GetBoundaryCommunicators()[breg_it.first];
150 }
151
152 // find ending of output file and insert _b1, _b2
153 int dot = filename.find_last_of('.') + 1;
154 string ext = filename.substr(dot, filename.length() - dot);
155 string name = filename.substr(0, dot - 1);
156
157 // Store temporary communicator
158 LibUtilities::CommSharedPtr tmpComm = m_f->m_comm;
159
160 for (int i = 0; i < m_f->m_bndRegionsToWrite.size(); ++i)
161 {
162 string outname =
163 name + "_b" +
164 boost::lexical_cast<string>(m_f->m_bndRegionsToWrite[i]) +
165 "." + ext;
166
167 if (!WriteFile(outname, vm))
168 {
169 continue;
170 }
171 RegisterConfig("outfile", outname);
172
173 if (BndRegionMap.count(m_f->m_bndRegionsToWrite[i]) == 1)
174 {
175 m_f->m_comm = BndRegionComm[m_f->m_bndRegionsToWrite[i]];
176
177 int Border = BndRegionMap[m_f->m_bndRegionsToWrite[i]];
178
179 // set up m_exp to point to boundary expansion
180 for (int j = 0; j < exp.size(); ++j)
181 {
182 m_f->m_exp[j] = BndExp[j][Border];
183 }
184
185 for (int j = 0; j < exp.size(); ++j)
186 {
187 m_f->m_exp[j] = BndExp[j][Border];
188 m_f->m_exp[j]->BwdTrans(m_f->m_exp[j]->GetCoeffs(),
189 m_f->m_exp[j]->UpdatePhys());
190 }
191
192 if (m_f->m_addNormals)
193 {
194 // Get normals
195 Array<OneD, Array<OneD, NekDouble>> NormPhys;
196 exp[0]->GetBoundaryNormals(Border, NormPhys);
197
198 // add normal coefficients to expansions
199 for (int j = 0; j < normdim; ++j)
200 {
201 m_f->m_exp[nfields + j] =
202 BndExp[nfields + j][Border];
204 m_f->m_exp[nfields + j]->GetTotPoints(),
205 NormPhys[j], 1,
206 m_f->m_exp[nfields + j]->UpdatePhys(), 1);
207 m_f->m_exp[nfields + j]->FwdTransLocalElmt(
208 m_f->m_exp[nfields + j]->GetPhys(),
209 m_f->m_exp[nfields + j]->UpdateCoeffs());
210 }
211 }
212 v_OutputFromExp(vm);
213 // output error for regression checking.
214 if (vm.count("error"))
215 {
217 }
218
219 // Reset communicator
220 m_f->m_comm = tmpComm;
221 }
222
223 // put outfile back to filename in case of nparts option
224 RegisterConfig("outfile", filename);
225 }
226 // Restore m_exp
227 exp.swap(m_f->m_exp);
228 }
229 else
230 {
231 if (WriteFile(filename, vm))
232 {
233 v_OutputFromExp(vm);
234 // output error for regression checking.
235 if (vm.count("error"))
236 {
238 }
239 }
240 }
241 }
242 else if (m_f->m_data.size())
243 {
244 ASSERTL0(!m_f->m_writeBndFld, "Boundary extraction requires xml file.");
245 if (WriteFile(filename, vm))
246 {
248 }
249 }
250}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
FIELD_UTILS_EXPORT void RegisterConfig(std::string key, std::string value="")
Register a configuration option with a module.
Definition: Module.cpp:102
std::string GetModuleName()
Definition: Module.h:200
virtual void v_OutputFromExp(po::variables_map &vm)=0
Write from m_exp to output file.
bool WriteFile(std::string &filename, po::variables_map &vm)
void ConvertExpToEquispaced(po::variables_map &vm)
virtual void v_OutputFromData(po::variables_map &vm)=0
Write from data to output file.
virtual void v_OutputFromPts(po::variables_map &vm)=0
Write from pts to output file.
static PtsFieldSharedPtr NullPtsField
Definition: PtsField.h:191
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:57
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
Definition: Conditions.h:210
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1191

References ASSERTL0, ConvertExpToEquispaced(), Nektar::SpatialDomains::BoundaryConditions::GetBoundaryCommunicators(), Nektar::SpatialDomains::BoundaryConditions::GetBoundaryRegions(), Nektar::FieldUtils::Module::GetModuleName(), Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, m_requireEquiSpaced, CellMLToNektar.pycml::name, Nektar::LibUtilities::NullPtsField, PrintErrorFromExp(), PrintErrorFromPts(), Nektar::FieldUtils::Module::RegisterConfig(), v_OutputFromData(), v_OutputFromExp(), v_OutputFromPts(), Vmath::Vcopy(), and WriteFile().

Referenced by Nektar::FieldUtils::OutputTecplot::v_Process().

◆ WriteFile()

bool Nektar::FieldUtils::OutputFileBase::WriteFile ( std::string &  filename,
po::variables_map &  vm 
)
private

Definition at line 252 of file OutputFileBase.cpp.

253{
254 // Get path to file. If procid was defined, get the full name
255 // to avoid checking files from other partitions
256 fs::path outFile;
257 if (vm.count("nparts"))
258 {
259 outFile = GetFullOutName(filename, vm);
260 }
261 else
262 {
263 outFile = GetPath(filename, vm);
264 }
265
267 if (m_f->m_comm)
268 {
269 comm = m_f->m_comm;
270 }
271 else
272 {
273 comm = LibUtilities::GetCommFactory().CreateInstance("Serial", 0, 0);
274 }
275
276 int count = fs::exists(outFile) ? 1 : 0;
277 comm->GetSpaceComm()->AllReduce(count, LibUtilities::ReduceSum);
278
279 int writeFile = 1;
280 if (count && (vm.count("forceoutput") == 0))
281 {
282 if (vm.count("nparts") == 0) // do not do check if --nparts is enabled.
283 {
284 writeFile = 0; // set to zero for reduce all to be correct.
285
286 if (comm->GetSpaceComm()->TreatAsRankZero())
287 {
288 string answer;
289 cout << "Did you wish to overwrite " << outFile << " (y/n)? ";
290 getline(cin, answer);
291 if (answer.compare("y") == 0)
292 {
293 writeFile = 1;
294 }
295 else
296 {
297 cout << "Not writing file '" << filename
298 << "' because it already exists" << endl;
299 }
300 }
301 comm->GetSpaceComm()->AllReduce(writeFile, LibUtilities::ReduceSum);
302 }
303 }
304 return (writeFile == 0) ? false : true;
305}
fs::path GetFullOutName(std::string &filename, po::variables_map &vm)
fs::path GetPath(std::string &filename, po::variables_map &vm)
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:144
CommFactory & GetCommFactory()

References CellMLToNektar.enum::answer, Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::LibUtilities::GetCommFactory(), GetFullOutName(), GetPath(), Nektar::FieldUtils::Module::m_f, and Nektar::LibUtilities::ReduceSum.

Referenced by v_Process().

Member Data Documentation

◆ m_requireEquiSpaced

bool Nektar::FieldUtils::OutputFileBase::m_requireEquiSpaced
protected