Skip to content

Commit

Permalink
add automatic convergence testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Amazingkivas committed Feb 21, 2024
1 parent 55f9ffb commit 5f11954
Show file tree
Hide file tree
Showing 5 changed files with 777 additions and 3 deletions.
3 changes: 2 additions & 1 deletion sln/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ cmake_minimum_required(VERSION 2.8)

project(FDTD)

include_directories(../include ../gtest)
include_directories(../include ../gtest ../test)


# BUILD
add_subdirectory(FDTD)
add_subdirectory(FDTD_test)
add_subdirectory(test_FDTD_method)
add_subdirectory(gtest)
add_subdirectory(sample)
4 changes: 2 additions & 2 deletions sln/FDTD_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
set(target FDTD_test)

file(GLOB hdrs "*.h*" "../../include/*.h" "../../gtest/*.h")
file(GLOB hdrs "*.h*" "../../include/*.h")
#file(GLOB hdrs "*.h*")
file(GLOB srcs "*.cpp" "../../src/*.cpp" "../../test/*.cpp")
file(GLOB srcs "*.cpp" "../../src/*.cpp")

add_executable(${target} ${srcs} ${hdrs})
target_link_libraries(${target} gtest)
Expand Down
8 changes: 8 additions & 0 deletions sln/test_FDTD_method/CmakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(target test_FDTD_method)

file(GLOB hdrs "*.h*" "../../include/*.h" "../../gtest/*.h")
#file(GLOB hdrs "*.h*")
file(GLOB srcs "*.cpp" "../../src/*.cpp" "../../test/*.cpp")

add_executable(${target} ${srcs} ${hdrs})
target_link_libraries(${target} gtest)
17 changes: 17 additions & 0 deletions src/FDTD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ double& Field::operator() (int i, int j, int k)

FDTD::FDTD(Parameters _parameters, double _dt) : parameters(_parameters), dt(_dt)
{
if (parameters.ax >= parameters.bx ||
parameters.ay >= parameters.by ||
parameters.az >= parameters.bz)
{
throw std::exception("ERROR: invalid parameters");
}
if (parameters.Ni <= 0 ||
parameters.Nj <= 0 ||
parameters.Nk <= 0 ||
dt <= 0)
{
throw std::exception("ERROR: invalid parameters");
}
Ex = Ey = Ez = Bx = By = Bz = Field(parameters.Ni, parameters.Nj, parameters.Nk);
}

Expand All @@ -61,6 +74,10 @@ Field& FDTD::get_field(Component this_field)

void FDTD::shifted_update_field(const int time)
{
if (time < 0)
{
throw std::exception("ERROR: Invalid update field argument");
}
double dx = parameters.dx;
double dy = parameters.dy;
double dz = parameters.dz;
Expand Down
Loading

0 comments on commit 5f11954

Please sign in to comment.