-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlooidsArray.cpp
More file actions
49 lines (40 loc) · 999 Bytes
/
FlooidsArray.cpp
File metadata and controls
49 lines (40 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <fstream>
#include <string>
#include <iostream>
#include "FlooidsArray.hpp"
void Grid::shout() {
std::cout << "Haliboombah!" << std::endl;
}
void Flooid::shout() {
std::cout << "SlurpySlurpy" << std::endl;
}
int Grid::index(const int i, const int j) {
return i*nx_ + j;
}
int Flooid::index(const int i, const int j) {
return i*nx_ + j;
}
void Grid::WriteData(const std::string filename) {
std::ofstream outfile(filename,std::ios::binary);
for (int i=0; i<nx_; ++i) {
double val = data_[i];
outfile.write(reinterpret_cast<const char*>(&val), sizeof(val));
}
outfile.close();
}
void Flooid::WriteData() {
rho->WriteData("rho.dat");
}
void Grid::PrintAll() {
for (int i=0; i<nx_; i++) {
for (int j=0; j<nx_; j++) {
std::cout << i << "," << j << ": " << 0. << std::endl;
}
}
}
double Grid::GetVal(const int i, const int j) {
return data_[index(i,j)];
}
void Flooid::Print() {
rho->PrintAll();
}