Commit 8bf424ec authored by GILLES Sebastien's avatar GILLES Sebastien

#1198 Scripts: the remaining Python scripts have been updated and cleaned-up;...

#1198 Scripts: the remaining Python scripts have been updated and cleaned-up; some that were not actually used were removed.
parent 2a453175
......@@ -23,6 +23,7 @@ A HPC finite element library developed for the implementation of the models of M
* [Doxygen](#doxygen)
* [Introduction talks](#introduction-talks)
* [Lexicon](#lexicon)
* [ModelTutorial](#modeltutorial)
* [Coding standards](#coding-standards)
- [Getting help](#getting-help)
......@@ -12,6 +12,21 @@ This script installs properly the commit hook and help the user set up its gitco
For macOS users, the script also set up the XCode templates that allows to create an empty shell for different types of MoReFEM file (skeleton of a Model class, of a main, etc...)
_Frequency:_ ideally each time a new header file is created, and at least before emitting a merge request.
This script sieves all the header files in the repository and check the header guards are the expected ones (to ensure unicity the header guard is generated from its location in the repository).
It is advised to run this with a clean git state and to check with `git diff` the modifications are relevant: the script is rather brutal (it rewrites the files for which the header guard was not correct).
_Frequency:_ each time a new file is added.
This script generates in most of the directories a file named `SourceList.cmake` which is truly a CMakeLists.txt named differently to indicate it was generated automatically.
## For macOS users only
......@@ -27,6 +42,10 @@ For macOS users, copy the code templates from the MoReFEM repository in the loca
A Python script that uses up [cloc]( under the hood to compute number of lines statistics for each module.
This script assumes cppcheck is installed and available in your path. This script is a thin wrapper which calls cppcheck with few default options.
# Miscellaneous
......@@ -35,6 +54,14 @@ A Python script that uses up [cloc]( under the
A utility to generate a 1D mesh representing a bar wiath arbitrary length and number of discretization points.
_Frequency:_ each time you worked on a Markdown file.
This script updates the table of contents of the markdown files. It assumes markdown-toc is installed on your computer.
## Internal
### commit_hook,py
......@@ -2,19 +2,23 @@ import os
import subprocess
if __name__ == "__main__":
morefem_source_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "Sources")
cmd = \
This diff is collapsed.
import os
def ReadVertexList(filename):
"""Read crudely the vertice part of a Medit mesh."""
vertex_list = []
FILE = open(filename)
is_reading_vertice_list = False
just_read_keyword = False
for line in FILE:
line = line.strip()
if line == "Vertices":
is_reading_vertice_list = True
just_read_keyword = True
if not is_reading_vertice_list:
if just_read_keyword:
Nvertex = int(line)
just_read_keyword = False
splitted = line.split()
if len(splitted) != 3:
splitted = splitted[:-1]
values = [float(x) for x in splitted]
return vertex_list
def CreateInterpolationFile(mesh1, mesh2, out):
"""Quick-and-dirty creation of the file matching vertices of two meshes, that is determined through the look up of float coordinates."""
vertex_list_1 = ReadVertexList(mesh1)
vertex_list_2 = ReadVertexList(mesh2)
Nvertex_1 = len(vertex_list_1)
FILE_out = open(out, 'w')
FILE_out.write("# Vertex index in mesh 1 / vertex index in mesh 2\n")
print vertex_list_1
for vertex_index_1 in range(0, Nvertex_1):
vertex = vertex_list_1[vertex_index_1]
position_list = [1 + i for i,x in enumerate(vertex_list_2) if x == vertex]
assert(len(position_list) < 2)
if position_list:
FILE_out.write("{1} {0}\n".format(vertex_index_1 + 1, position_list[0]))
if __name__ == "__main__":
\ No newline at end of file
import os
import Utilities
def FilterCppFiles(file_list):
"""Keep in the \a file_list given in input only the files which extension is cpp, hpp or hxx.
......@@ -38,12 +36,11 @@ def FilterCppFiles(file_list):
def GenerateInModule(morefem_directory, subdirectory, module_alias, ignore_list = None):
\param[in] morefem_directory Path to the Morefem directory. Current file should be in {morefem_directory}/Scripts directory.
\param[in] morefem_directory Path to the MoReFEM directory.
\param[in] subdirectory Name of the subdirectory being investigated, within "Sources" directory. e.g 'Utilities', 'ThirdParty', etc...
\param[in] module_alias Alias to the library being built, e.g. 'MOREFEM_UTILITIES'. If BUILD_MOREFEM_UNIQUE_LIBRARY is set, this alias will actually point to the MoReFEM library.
\param[in] ignore_list If None, all subdirectories of \a subdirectory are included. If a list is given, each subfolder named after an element of the list is ignored. For instance for 'ThirdParty' there is 'Tclap'in the list; Tclap is a header only library embedded in MoReFEM which source files aren't required in the build.
morefem_directory = Utilities.SubstituteEnvVariable(morefem_directory)
source_directory = directory = os.path.join(morefem_directory, "Sources")
directory = os.path.join(source_directory, subdirectory)
......@@ -87,7 +84,7 @@ def GenerateInModule(morefem_directory, subdirectory, module_alias, ignore_list
if __name__ == "__main__":
morefem_path = "${HOME}/Codes/Morefem/CoreLibrary"
morefem_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
GenerateInModule(morefem_path, "Utilities", "MOREFEM_UTILITIES", None)
GenerateInModule(morefem_path, "ThirdParty", "MOREFEM_UTILITIES", ['Source'])
import os
import sys
import tempfile
import Utilities
utilities_abspath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "Utilities")
from substitute_env_variable import SubstituteEnvVariable
class HeaderGuards():
......@@ -9,7 +14,7 @@ class HeaderGuards():
self._project_name_in_header_guard = self.GenerateHeaderGuardName(project_name)
self._directory = Utilities.SubstituteEnvVariable(directory)
self._directory = SubstituteEnvVariable(directory)
if not os.path.exists(self._directory):
print("[WARNING] Directory {0} not found; couldn't correct header guards inside.".format(self._directory))
......@@ -35,7 +40,7 @@ class HeaderGuards():
modified_ignore_list = []
for item in ignore_list:
item = Utilities.SubstituteEnvVariable(item)
item = SubstituteEnvVariable(item)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment