mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-13 17:38:23 +01:00
Merge branch 'timer' into 'main'
Adding timer to simulate See merge request mluebke/diffusion!9
This commit is contained in:
commit
1cc6b247b9
@ -53,7 +53,10 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// Now we simulate and output 8 steps à 1 sec
|
||||
for (int t = 1; t < 6; t++) {
|
||||
diffu.simulate(field.data(), alpha.data(), bc.data());
|
||||
double time = diffu.simulate(field.data(), alpha.data(), bc.data());
|
||||
|
||||
cerr << "time elapsed: " << time << " seconds" << endl;
|
||||
|
||||
cout << t;
|
||||
|
||||
for (int i=0; i < m*n; i++) {
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <iomanip>
|
||||
#include <iterator>
|
||||
@ -286,8 +287,13 @@ void Diffusion::BTCSDiffusion::setTimestep(double time_step) {
|
||||
this->time_step = time_step;
|
||||
}
|
||||
|
||||
void Diffusion::BTCSDiffusion::simulate(double *c, double *alpha,
|
||||
Diffusion::boundary_condition *bc) {
|
||||
auto Diffusion::BTCSDiffusion::simulate(double *c, double *alpha,
|
||||
Diffusion::boundary_condition *bc)
|
||||
-> double {
|
||||
|
||||
std::chrono::high_resolution_clock::time_point start =
|
||||
std::chrono::high_resolution_clock::now();
|
||||
|
||||
if (this->grid_dim == 1) {
|
||||
Eigen::Map<DVectorRowMajor> c_in(c, this->grid_cells[0]);
|
||||
Eigen::Map<const DVectorRowMajor> alpha_in(alpha, this->grid_cells[0]);
|
||||
@ -307,6 +313,14 @@ void Diffusion::BTCSDiffusion::simulate(double *c, double *alpha,
|
||||
|
||||
simulate2D(c_in, alpha_in, bc_in);
|
||||
}
|
||||
|
||||
std::chrono::high_resolution_clock::time_point end =
|
||||
std::chrono::high_resolution_clock::now();
|
||||
|
||||
std::chrono::duration<double> duration =
|
||||
std::chrono::duration_cast<std::chrono::duration<double>>(end - start);
|
||||
|
||||
return duration.count();
|
||||
}
|
||||
|
||||
inline auto Diffusion::BTCSDiffusion::getBCFromFlux(boundary_condition bc,
|
||||
|
||||
@ -88,11 +88,16 @@ public:
|
||||
/*!
|
||||
* With given ghost zones simulate diffusion. Only 1D allowed at this moment.
|
||||
*
|
||||
* @param c Pointer to continious memory describing the current concentration state of each grid cell.
|
||||
* @param alpha Pointer to memory area of diffusion coefficients for each grid element.
|
||||
* @param c Pointer to continious memory describing the current concentration
|
||||
* state of each grid cell.
|
||||
* @param alpha Pointer to memory area of diffusion coefficients for each grid
|
||||
* element.
|
||||
* @param bc Pointer to memory setting boundary conidition of each grid cell.
|
||||
*
|
||||
* @return Time in seconds [s] used to simulate one iteration.
|
||||
*/
|
||||
void simulate(double *c, double *alpha, Diffusion::boundary_condition *bc);
|
||||
auto simulate(double *c, double *alpha, Diffusion::boundary_condition *bc)
|
||||
-> double;
|
||||
|
||||
/*!
|
||||
* Set the timestep of the simulation
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user