MaMiCo 1.2
Loading...
Searching...
No Matches
ReadFromFile.h
1// This file is part of the Mamico project. For conditions of distribution
2// and use, please see the copyright notice in Mamico's main folder, or at
3// www5.in.tum.de/mamico
4
5#pragma once
6#include "coupling/filtering/interfaces/FilterInterface.h"
7
8#include <fstream>
9#include <string>
10#include <vector>
11
12// #define DEBUG_READ_FROM_FILE
13
14namespace coupling {
15namespace filtering {
16template <unsigned int dim> class ReadFromFile;
17}
18} // namespace coupling
19
20/*
21 * Filter that reads cell data from a specified file in .csv format and then
22 * writes that data to its output cells.
23 *
24 * Input format must be compliant to the usual MaMiCo CSV format (using ';' as
25 * separator). The following order is assumed:
26 * - current iteration
27 * - scalar cell properties
28 * - vector cell properties
29 *
30 * The input file must contain one separate line per cell.
31 *
32 * @Author Felix Maurer
33 */
34template <unsigned int dim> class coupling::filtering::ReadFromFile : public coupling::filtering::FilterInterface<dim> {
35public:
36 ReadFromFile(const std::vector<coupling::datastructures::CouplingCell<dim>*>& inputCellVector,
37 const std::vector<coupling::datastructures::CouplingCell<dim>*>& outputCellVector, const std::array<bool, 7> filteredValues,
38 std::string location)
39 : coupling::filtering::FilterInterface<dim>(inputCellVector, outputCellVector, filteredValues, "RFF"), _location(location), _iteration(0) {
40#ifdef DEBUG_READ_FROM_FILE
41 std::cout << " RFF: Read from file instance created. Will read from: " << _location << "." << std::endl;
42#endif
43 }
44
45 ~ReadFromFile() {
46#ifdef DEBUG_READ_FROM_FILE
47 std::cout << " RFF: Read from file instance deconstructed." << std::endl;
48#endif
49 }
50
51 void operator()();
52
53private:
54 std::string _location;
55 unsigned int _iteration;
56
57 std::ifstream _file;
58};
59
60// include implementation of header
61#include "ReadFromFile.cpph"
defines the cell type with cell-averaged quantities only (no linked cells).
Definition CouplingCell.h:29
Definition FilterInterface.h:32
Definition ReadFromFile.h:34
Definition FilterPipeline.h:21
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15