Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git version #1257

Merged
merged 4 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to the Lethe project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [Master] - 2024-08-23

### Added

- MINOR Added the capacity to print the parameter from the parameter file that were changed compared to the default parameters as well as the lethe and deal.II commit hash. This is achieved by adding the runtime argument --print-parameters to the command line arguments. [#1255](https://github.com/chaos-polymtl/lethe/pull/1255) and [#1257](https://github.com/chaos-polymtl/lethe/pull/1257)

## [Master] - 2024-08-09

### Changed
Expand Down
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ find_package(deal.II 9.5.0 QUIET REQUIRED
HINTS "${deal.II_DIR}" "${DEAL_II_DIR}" "$ENV{DEAL_II_DIR}")
deal_ii_initialize_cached_variables()

deal_ii_query_git_information(LETHE)

CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/include/core/revision.h.in
${CMAKE_CURRENT_BINARY_DIR}/include/core/revision.h
)

project(lethe VERSION 0.1 LANGUAGES CXX)

# Check for deal.II features after the PROJECT call — but still as close
Expand Down Expand Up @@ -131,6 +138,8 @@ endif()


add_subdirectory(source)
target_include_directories(lethe-solvers PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)

add_subdirectory(applications)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
Expand Down
46 changes: 36 additions & 10 deletions applications/lethe-fluid-matrix-free/fluid_dynamics_matrix_free.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@

#include "solvers/fluid_dynamics_matrix_free.h"

#include <core/revision.h>

#include <deal.II/base/revision.h>

std::string
concatenate_strings(const int argc, char **argv)
{
std::string result = std::string(argv[0]);

for (int i = 1; i < argc; ++i)
result = result + " " + std::string(argv[i]);

return result;
}

int
main(int argc, char *argv[])
{
Expand Down Expand Up @@ -42,6 +57,19 @@ main(int argc, char *argv[])
MPI_COMM_WORLD) == 0) &&
print_parameters);

if (print_parameters)
{
pcout << "Running: " << concatenate_strings(argc, argv) << std::endl;
pcout << " - deal.II (branch: " << DEAL_II_GIT_BRANCH
<< "; revision: " << DEAL_II_GIT_REVISION
<< "; short: " << DEAL_II_GIT_SHORTREV << ")" << std::endl;
pcout << " - Lethe (branch: " << LETHE_GIT_BRANCH
<< "; revision: " << LETHE_GIT_REVISION
<< "; short: " << LETHE_GIT_SHORTREV << ")" << std::endl;
Comment on lines +62 to +68
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to printing the parameters, I think printing the git version is also useful. These both informations allow to easily reproduce experiments from output files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh this is a good idea. I like this.

pcout << std::endl;
pcout << std::endl;
}

if (dim == 2)
{
ParameterHandler prm;
Expand All @@ -56,11 +84,10 @@ main(int argc, char *argv[])
ParameterHandler::OutputStyle::PRM |
ParameterHandler::OutputStyle::Short |
ParameterHandler::KeepDeclarationOrder
#if DEAL_II_VERSION_GTE(9, 7, 0)
|
ParameterHandler::KeepOnlyChanged
#endif
);
#if DEAL_II_VERSION_GTE(9, 7, 0)
| ParameterHandler::KeepOnlyChanged
#endif
);
pcout << std::endl << std::endl;

FluidDynamicsMatrixFree<2> problem(NSparam);
Expand All @@ -81,11 +108,10 @@ main(int argc, char *argv[])
ParameterHandler::OutputStyle::PRM |
ParameterHandler::OutputStyle::Short |
ParameterHandler::KeepDeclarationOrder
#if DEAL_II_VERSION_GTE(9, 7, 0)
|
ParameterHandler::KeepOnlyChanged
#endif
);
#if DEAL_II_VERSION_GTE(9, 7, 0)
| ParameterHandler::KeepOnlyChanged
#endif
);
pcout << std::endl << std::endl;

FluidDynamicsMatrixFree<3> problem(NSparam);
Expand Down
31 changes: 31 additions & 0 deletions include/core/revision.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* ---------------------------------------------------------------------
*
* Copyright (C) 2024 - by the Lethe authors
*
* This file is part of the Lethe library
*
* The Lethe library is free software; you can use it, redistribute
* it, and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either
* version 3.1 of the License, or (at your option) any later version.
* The full text of the license can be found in the file LICENSE at
* the top level of the Lethe distribution.
*
---------------------------------------------------------------------*/

#pragma once

/**
* Name of the local git branch of the source directory.
*/
#define LETHE_GIT_BRANCH "@LETHE_GIT_BRANCH@"

/**
* Full sha1 revision of the current git HEAD.
*/
#define LETHE_GIT_REVISION "@LETHE_GIT_REVISION@"

/**
* Short sha1 revision of the current git HEAD.
*/
#define LETHE_GIT_SHORTREV "@LETHE_GIT_SHORTREV@"
Loading