AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
ASCII.hpp
Go to the documentation of this file.
1/*
2 * This file is part of AQUAgpusph, a free CFD program based on SPH.
3 * Copyright (C) 2012 Jose Luis Cercos Pita <jl.cercos@upm.es>
4 *
5 * AQUAgpusph is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * AQUAgpusph is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with AQUAgpusph. If not, see <http://www.gnu.org/licenses/>.
17 */
18
24
25#ifndef ASCII_H_INCLUDED
26#define ASCII_H_INCLUDED
27
29#include "Particles.hpp"
30
31namespace Aqua {
32namespace InputOutput {
33
58class ASCII : public Particles
59{
60 public:
70 ASCII(ProblemSetup& sim_data,
71 unsigned int iset,
72 size_t offset,
73 size_t n = 0,
74 const std::string file_ext = ".dat");
75
77 virtual ~ASCII();
78
81 virtual void load();
82
83 virtual inline void print_file() { print_file(',', ' '); }
84
85 protected:
89 virtual void print_header(std::ofstream& f) const;
90
94 virtual void formatLine(std::string& l);
95
103 virtual std::string readField(const std::string field,
104 const std::string line,
105 size_t index,
106 void* data);
107
112 virtual size_t readNParticles(std::ifstream& f);
113
120 void print_file(const char sep, const char comp_sep);
121 private:
125 size_t compute_n();
126
127
134 unsigned int readNFields(std::string l);
135
140 void create(std::ofstream& f);
141
143 unsigned int _next_file_index;
144
146 std::string _file_ext;
147}; // class InputOutput
148
149}
150} // namespaces
151
152#endif // ASCII_H_INCLUDED
Particles files manager. (See Aqua::InputOutput::Particles for details)
virtual void print_file()
Print the data to a file.
Definition ASCII.hpp:83
virtual size_t readNParticles(std::ifstream &f)
Count the number of particles present in the input file.
Definition ASCII.cpp:353
virtual std::string readField(const std::string field, const std::string line, size_t index, void *data)
Extract the field value from a line.
Definition ASCII.cpp:429
ASCII(ProblemSetup &sim_data, unsigned int iset, size_t offset, size_t n=0, const std::string file_ext=".dat")
Constructor.
Definition ASCII.cpp:36
virtual void load()
Load the data.
Definition ASCII.cpp:53
virtual void formatLine(std::string &l)
Conveniently format a read line.
Definition ASCII.cpp:374
virtual void print_header(std::ofstream &f) const
Write the file header.
Definition ASCII.cpp:310
virtual ~ASCII()
Destructor.
Definition ASCII.cpp:50
std::map< std::string, void * > data() const
Get the stored memory objects where the device data has been downloaded.
Definition Particles.hpp:222
Particles(ProblemSetup &sim_data, unsigned int iset, size_t offset, size_t n=0)
Constructor.
Definition Particles.cpp:34
size_t n() const
Get the number of particles managed by this instance.
Definition Particles.hpp:80
Simulation configuration data.
Definition ProblemSetup.hpp:91
Input/Output data interfaces.
Definition ArgumentsManager.cpp:51
Main AQUAgpusph namespace.
Definition ArgumentsManager.cpp:50
Set of definitions and macros related with the implementation.