Skip to content

Commit

Permalink
Add C++ timer for mesh reading and time integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ImperatorS79 committed May 1, 2019
1 parent 2910f54 commit d9ca68f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
19 changes: 18 additions & 1 deletion srcs/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <chrono>
#include <iostream>
#include <string>
#if defined(_OPENMP)
Expand Down Expand Up @@ -47,14 +48,22 @@ int main(int argc, char **argv)
<< std::endl
<< "================================================================"
<< std::endl;

Mesh mesh;
auto startTime = std::chrono::high_resolution_clock::now();
if(!readMesh(mesh, std::string(argv[1]), solverParams.spaceIntType,
solverParams.basisFuncType))
{
std::cerr << "Something went wrong when reading mesh file: "
<< argv[1] << std::endl;
return -1;
}
}
auto endTime = std::chrono::high_resolution_clock::now();
auto ellapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);

std::cout << "Ellapsed time for mesh reading: "
<< static_cast<double>(ellapsedTime.count())/1000.0
<< " s" << std::endl;

// displayMesh(mesh);
std::cout << "================================================================"
Expand All @@ -63,11 +72,19 @@ int main(int argc, char **argv)
<< std::endl
<< "================================================================"
<< std::endl;

startTime = std::chrono::high_resolution_clock::now();
if(!timeInteg(mesh, solverParams, std::string(argv[1])))
{
std::cerr << "Something went wrong when time integrating" << std::endl;
return -1;
}
endTime = std::chrono::high_resolution_clock::now();
ellapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);

std::cout << "Ellapsed time for time integration: "
<< static_cast<double>(ellapsedTime.count())/1000.0
<< " s" << std::endl;

return 0;
}
3 changes: 0 additions & 3 deletions srcs/solver/timeInteg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ bool timeInteg(const Mesh& mesh, const SolverParams& solverParams,
for(unsigned int nbrStep = 1 ; nbrStep < nTimeSteps + 1 ;
nbrStep++)
{

// display progress
ratio = int(100*double(nbrStep - 1)/double(nTimeSteps));
if(ratio >= currentDecade)
Expand All @@ -223,10 +222,8 @@ bool timeInteg(const Mesh& mesh, const SolverParams& solverParams,
currentDecade = ratio + 1;
}


integScheme(t, field, partialField, matrix, mesh, solverParams, temp, usedF);


// check that it does not diverge
// assert(field.u[0].maxCoeff() <= 1E5);

Expand Down

0 comments on commit d9ca68f

Please sign in to comment.