-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix test_FDTD: add strustures, fix convergence
- Loading branch information
1 parent
348ffb4
commit 3253ada
Showing
9 changed files
with
181 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <cmath> | ||
#include <iostream> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#pragma once | ||
|
||
#include <fstream> | ||
|
||
#include "FDTD.h" | ||
|
||
void write_x(Field& this_field, std::ofstream& fout) | ||
{ | ||
for (int j = 0; j < this_field.get_Nj(); ++j) | ||
{ | ||
for (int i = 0; i < this_field.get_Ni(); ++i) | ||
{ | ||
fout << this_field(i, j); | ||
if (i == this_field.get_Ni() - 1) | ||
{ | ||
fout << std::endl; | ||
} | ||
else | ||
{ | ||
fout << ";"; | ||
} | ||
} | ||
} | ||
fout << std::endl << std::endl; | ||
} | ||
void write_y(Field& this_field, std::ofstream& fout) | ||
{ | ||
for (int i = 0; i < this_field.get_Ni(); ++i) | ||
{ | ||
for (int j = 0; j < this_field.get_Nj(); ++j) | ||
{ | ||
fout << this_field(i, j); | ||
if (j == this_field.get_Nj() - 1) | ||
{ | ||
fout << std::endl; | ||
} | ||
else | ||
{ | ||
fout << ";"; | ||
} | ||
} | ||
} | ||
fout << std::endl << std::endl; | ||
} | ||
|
||
void write_all(FDTD& test, char axis, char* file_path) | ||
{ | ||
std::ofstream test_fout; | ||
test_fout.open(file_path); | ||
|
||
if (!test_fout.is_open()) | ||
{ | ||
std::cout << "ERROR: Failed to open OutFile.csv" << std::endl; | ||
exit(1); | ||
} | ||
for (int i = static_cast<int>(Component::EX); i <= static_cast<int>(Component::BZ); ++i) | ||
{ | ||
if (axis == 'x') | ||
{ | ||
write_x(test.get_field(static_cast<Component>(i)), test_fout); | ||
} | ||
else write_y(test.get_field(static_cast<Component>(i)), test_fout); | ||
} | ||
test_fout.close(); | ||
} | ||
|
||
//#ifndef __DEBUG__ | ||
//test_fout.open("OutFile.csv"); | ||
//#else | ||
//test_fout.open("../../PlotScript/OutFile.csv"); | ||
//#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.