Skip to content

Commit

Permalink
fix openMP
Browse files Browse the repository at this point in the history
  • Loading branch information
Amazingkivas committed Dec 5, 2023
1 parent 09ecacf commit 7ef1cf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions include/FDTD.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class FDTD

Field& get_field(Component);

void update_field(const int&);
void shifted_update_field(const int&);
void update_field(const int);
void shifted_update_field(const int);

int get_Ni() { return Ni; }
int get_Nj() { return Nj; }
Expand Down
19 changes: 7 additions & 12 deletions src/FDTD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,13 @@ Field& FDTD::get_field(Component this_field)
}
}

void FDTD::update_field(const int& time)
void FDTD::update_field(const int time)
{
for (double t = 0; t <= time; ++t)
{
#pragma omp parallel for
#pragma omp parallel for collapse(2)
for (int j = 0; j < Nj; ++j)
{
#pragma ivdep
for (int i = 0; i < Ni; ++i)
{
Ex(i, j) += FDTD_Const::C * dt * (Bz(i, j + 1) - Bz(i, j - 1)) / (2.0 * dy);
Expand All @@ -78,10 +77,9 @@ void FDTD::update_field(const int& time)
}
}

#pragma omp parallel for
#pragma omp parallel for collapse(2)
for (int j = 0; j < Nj; ++j)
{
#pragma ivdep
for (int i = 0; i < Ni; ++i)
{
Bx(i, j) -= FDTD_Const::C * dt * (Ez(i, j + 1) - Ez(i, j - 1)) / (2.0 * dy);
Expand All @@ -92,14 +90,13 @@ void FDTD::update_field(const int& time)
}
}

void FDTD::shifted_update_field(const int& time)
void FDTD::shifted_update_field(const int time)
{
for (double t = 0; t <= time; ++t)
{
#pragma omp parallel for
#pragma omp parallel for collapse(2)
for (int j = 0; j < Nj; ++j)
{
#pragma ivdep
for (int i = 0; i < Ni; ++i)
{
Bx(i, j) -= FDTD_Const::C * dt / 2.0 * (Ez(i, j + 1) - Ez(i, j)) / dy;
Expand All @@ -108,10 +105,9 @@ void FDTD::shifted_update_field(const int& time)
}
}

#pragma omp parallel for
#pragma omp parallel for collapse(2)
for (int j = 0; j < Nj; ++j)
{
#pragma ivdep
for (int i = 0; i < Ni; ++i)
{
Ex(i, j) += FDTD_Const::C * dt * (Bz(i, j) - Bz(i, j - 1)) / dy;
Expand All @@ -120,10 +116,9 @@ void FDTD::shifted_update_field(const int& time)
}
}

#pragma omp parallel for
#pragma omp parallel for collapse(2)
for (int j = 0; j < Nj; ++j)
{
#pragma ivdep
for (int i = 0; i < Ni; ++i)
{
Bx(i, j) -= FDTD_Const::C * dt / 2.0 * (Ez(i, j + 1) - Ez(i, j)) / dy;
Expand Down

0 comments on commit 7ef1cf0

Please sign in to comment.