Skip to content

Commit

Permalink
Git version (#1257)
Browse files Browse the repository at this point in the history
Add git version to the printed output when --print-parameters is on

Co-authored-by: Bruno Blais <blais.bruno@gmail.com>
Former-commit-id: 5885806
  • Loading branch information
peterrum and blaisb authored Aug 23, 2024
1 parent 64becd6 commit 6e8d08a
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
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
28 changes: 28 additions & 0 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;
pcout << std::endl;
pcout << std::endl;
}

if (dim == 2)
{
ParameterHandler prm;
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@"

0 comments on commit 6e8d08a

Please sign in to comment.