mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-15 18:38:23 +01:00
Merge branch 'hannes-philipp' of git.gfz-potsdam.de:naaice/tug into hannes-philipp
This commit is contained in:
commit
ea7c9f0df3
@ -5,8 +5,8 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
int row = 11;
|
int row = 50;
|
||||||
int col = 11;
|
int col = 50;
|
||||||
int domain_row = 10;
|
int domain_row = 10;
|
||||||
int domain_col = 10;
|
int domain_col = 10;
|
||||||
|
|
||||||
@ -45,14 +45,11 @@ int main(int argc, char *argv[]) {
|
|||||||
// Simulation
|
// Simulation
|
||||||
Simulation sim = Simulation(grid, bc, FTCS_APPROACH);
|
Simulation sim = Simulation(grid, bc, FTCS_APPROACH);
|
||||||
sim.setTimestep(0.001);
|
sim.setTimestep(0.001);
|
||||||
sim.setIterations(7000);
|
sim.setIterations(100);
|
||||||
sim.setOutputCSV(CSV_OUTPUT_ON);
|
sim.setOutputCSV(CSV_OUTPUT_OFF);
|
||||||
sim.setOutputConsole(CONSOLE_OUTPUT_ON);
|
sim.setOutputConsole(CONSOLE_OUTPUT_OFF);
|
||||||
|
|
||||||
|
|
||||||
// RUN
|
// RUN
|
||||||
sim.run();
|
sim.run();
|
||||||
|
|
||||||
cout << grid.getConcentrations() << endl;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -9,6 +9,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <tug/Boundary.hpp>
|
#include <tug/Boundary.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <omp.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -277,6 +278,8 @@ static void FTCS_2D(Grid &grid, Boundary &bc, double ×tep) {
|
|||||||
|
|
||||||
// inner cells
|
// inner cells
|
||||||
// these are independent of the boundary condition type
|
// these are independent of the boundary condition type
|
||||||
|
omp_set_num_threads(10);
|
||||||
|
#pragma omp parallel for
|
||||||
for (int row = 1; row < rowMax-1; row++) {
|
for (int row = 1; row < rowMax-1; row++) {
|
||||||
for (int col = 1; col < colMax-1; col++) {
|
for (int col = 1; col < colMax-1; col++) {
|
||||||
concentrations_t1(row, col) = grid.getConcentrations()(row, col)
|
concentrations_t1(row, col) = grid.getConcentrations()(row, col)
|
||||||
@ -296,6 +299,7 @@ static void FTCS_2D(Grid &grid, Boundary &bc, double ×tep) {
|
|||||||
// left without corners / looping over rows
|
// left without corners / looping over rows
|
||||||
// hold column constant at index 0
|
// hold column constant at index 0
|
||||||
int col = 0;
|
int col = 0;
|
||||||
|
#pragma omp parallel for
|
||||||
for (int row = 1; row < rowMax-1; row++) {
|
for (int row = 1; row < rowMax-1; row++) {
|
||||||
concentrations_t1(row, col) = grid.getConcentrations()(row,col)
|
concentrations_t1(row, col) = grid.getConcentrations()(row,col)
|
||||||
+ timestep / (deltaCol*deltaCol)
|
+ timestep / (deltaCol*deltaCol)
|
||||||
@ -312,6 +316,7 @@ static void FTCS_2D(Grid &grid, Boundary &bc, double ×tep) {
|
|||||||
// right without corners / looping over rows
|
// right without corners / looping over rows
|
||||||
// hold column constant at max index
|
// hold column constant at max index
|
||||||
col = colMax-1;
|
col = colMax-1;
|
||||||
|
#pragma omp parallel for
|
||||||
for (int row = 1; row < rowMax-1; row++) {
|
for (int row = 1; row < rowMax-1; row++) {
|
||||||
concentrations_t1(row,col) = grid.getConcentrations()(row,col)
|
concentrations_t1(row,col) = grid.getConcentrations()(row,col)
|
||||||
+ timestep / (deltaCol*deltaCol)
|
+ timestep / (deltaCol*deltaCol)
|
||||||
@ -329,6 +334,7 @@ static void FTCS_2D(Grid &grid, Boundary &bc, double ×tep) {
|
|||||||
// top without corners / looping over columns
|
// top without corners / looping over columns
|
||||||
// hold row constant at index 0
|
// hold row constant at index 0
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
#pragma omp parallel for
|
||||||
for (int col=1; col<colMax-1;col++){
|
for (int col=1; col<colMax-1;col++){
|
||||||
concentrations_t1(row, col) = grid.getConcentrations()(row, col)
|
concentrations_t1(row, col) = grid.getConcentrations()(row, col)
|
||||||
+ timestep / (deltaRow*deltaRow)
|
+ timestep / (deltaRow*deltaRow)
|
||||||
@ -345,6 +351,7 @@ static void FTCS_2D(Grid &grid, Boundary &bc, double ×tep) {
|
|||||||
// bottom without corners / looping over columns
|
// bottom without corners / looping over columns
|
||||||
// hold row constant at max index
|
// hold row constant at max index
|
||||||
row = rowMax-1;
|
row = rowMax-1;
|
||||||
|
#pragma omp parallel for
|
||||||
for(int col=1; col<colMax-1;col++){
|
for(int col=1; col<colMax-1;col++){
|
||||||
concentrations_t1(row, col) = grid.getConcentrations()(row, col)
|
concentrations_t1(row, col) = grid.getConcentrations()(row, col)
|
||||||
+ timestep / (deltaRow*deltaRow)
|
+ timestep / (deltaRow*deltaRow)
|
||||||
|
|||||||
@ -154,7 +154,7 @@ void Simulation::run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (approach == FTCS_APPROACH) {
|
if (approach == FTCS_APPROACH) {
|
||||||
|
auto begin = std::chrono::high_resolution_clock::now();
|
||||||
for (int i = 0; i < iterations; i++) {
|
for (int i = 0; i < iterations; i++) {
|
||||||
if (console_output == CONSOLE_OUTPUT_VERBOSE && i > 0) {
|
if (console_output == CONSOLE_OUTPUT_VERBOSE && i > 0) {
|
||||||
printConcentrationsConsole();
|
printConcentrationsConsole();
|
||||||
@ -165,6 +165,9 @@ void Simulation::run() {
|
|||||||
|
|
||||||
FTCS(grid, bc, timestep);
|
FTCS(grid, bc, timestep);
|
||||||
}
|
}
|
||||||
|
auto end = std::chrono::high_resolution_clock::now();
|
||||||
|
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin);
|
||||||
|
std::cout << milliseconds.count() << endl;
|
||||||
|
|
||||||
} else if (approach == BTCS_APPROACH) {
|
} else if (approach == BTCS_APPROACH) {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user