OpenLB 1.7
Loading...
Searching...
No Matches
fileName.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2015 Albert Mink
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef FILE_NAME_HH
25#define FILE_NAME_HH
26
27#include <sstream>
28#include <iomanip>
29
30
31namespace olb {
32
34std::string createFileName(std::string name)
35{
36 std::stringstream fNameStream;
37 fNameStream << name;
38 return fNameStream.str();
39}
40
42std::string createFileName(std::string name, int iT)
43{
44 std::stringstream fNameStream;
45 fNameStream << name << "_"
46 << "iT" << std::setw(7) << std::setfill('0') << iT ;
47 return fNameStream.str();
48}
49
51std::string createParallelFileName(std::string name, bool withSize)
52{
53 std::stringstream fNameStream;
54
55 std::stringstream fNameStreamTmp;
56 fNameStreamTmp << singleton::mpi().getSize();
57 std::size_t stringLength = fNameStream.str().length();
58
59 fNameStream << name << "_rank" << std::setw(stringLength) << std::setfill('0') << singleton::mpi().getRank();
60 if (withSize) {
61 fNameStream << "_size" << std::setw(stringLength) << std::setfill('0') << singleton::mpi().getSize();
62 }
63 return fNameStream.str();
64}
65
67std::string createFileName(std::string name, int iT, int iC)
68{
69 std::stringstream fNameStream;
70 fNameStream << name << "_"
71 << "iT" << std::setw(7) << std::setfill('0') << iT
72 << "iC" << std::setw(5) << std::setfill('0') << iC ;
73 return fNameStream.str();
74}
75
77std::string createFileName(std::string name, std::string functor, int iT)
78{
79 std::stringstream fNameStream;
80 fNameStream << name <<"_"<< functor << "iT" << std::setw(7) << std::setfill('0') << iT;
81 return fNameStream.str();
82}
83
85std::string createFileName(std::string name, std::string functor, int iT, int iC)
86{
87 std::stringstream fNameStream;
88 fNameStream << name <<"_"<< functor << "iT" << std::setw(7) << std::setfill('0') << iT
89 << "iC" << std::setw(5) << std::setfill('0') << iC ;
90 return fNameStream.str();
91}
92
93}
94
95#endif
int getSize() const
Returns the number of processes.
int getRank() const
Returns the process ID.
MpiManager & mpi()
Top level namespace for all of OpenLB.
std::string createFileName(std::string name)
for .pvd masterFile
Definition fileName.hh:34
std::string createParallelFileName(std::string name, bool withSize=true)
for parallel io, e.g. adds "_rank0000001" for rank=1, and optional "_size0000016" if withSize==true
Definition fileName.hh:51