diff --git a/doc/sphinx/source/conf.py b/doc/sphinx/source/conf.py index e108df3..69fdd99 100644 --- a/doc/sphinx/source/conf.py +++ b/doc/sphinx/source/conf.py @@ -1,211 +1,211 @@ # -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # import os import re # import sys # sys.path.insert(0, os.path.abspath('.')) import subprocess # -- Project information ----------------------------------------------------- project = 'Tamaas' -copyright = "2019-2020, EPFL (École Polytechnique Fédérale de Lausanne)," \ +copyright = "2019-2021, EPFL (École Polytechnique Fédérale de Lausanne)," \ + " Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)" author = 'Lucas Frérot, Guillaume Anciaux, Valentine Rey, Son Pham-ba, ' \ 'Jean Fraçois Molinari' # Extracting version info with open('../../../SConstruct', 'r') as sconstruct: version_re = re.compile('version=["\']((\d+\.\d+)\.\d+-?(\d+)?)["\']') match = version_re.search(sconstruct.read()) # The short X.Y version version = match.group(2) # The full version, including alpha/beta/rc tags release = match.group(1) # -- General configuration --------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.mathjax', 'sphinx.ext.viewcode', 'sphinx.ext.intersphinx', 'breathe', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['.templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The master toctree document. master_doc = 'index' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns = [] # The name of the Pygments (syntax highlighting) style to use. pygments_style = None # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = 'sphinx_rtd_theme' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # # html_theme_options = {} html_logo = '../../icon.svg' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['.static'] # Custom sidebar templates, must be a dictionary that maps document names # to template names. # # The default sidebars (for documents that don't match any pattern) are # defined by theme itself. Builtin themes are using these templates by # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', # 'searchbox.html']``. # # html_sidebars = {} # -- Options for HTMLHelp output --------------------------------------------- # Output file base name for HTML help builder. htmlhelp_basename = 'Tamaasdoc' # -- Options for LaTeX output ------------------------------------------------ latex_engine = 'lualatex' latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'Tamaas.tex', 'Tamaas Documentation', author, 'manual'), ] # -- Options for manual page output ------------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'tamaas', 'Tamaas Documentation', [author], 1) ] # -- Options for Texinfo output ---------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'Tamaas', 'Tamaas Documentation', author, 'Tamaas', 'One line description of project.', 'Miscellaneous'), ] # -- Options for Epub output ------------------------------------------------- # Bibliographic Dublin Core info. epub_title = project # The unique identifier of the text. This can be a ISBN number # or the project homepage. # # epub_identifier = '' # A unique identification for the text. # # epub_uid = '' # A list of files that should not be packed into the epub file. epub_exclude_files = ['search.html'] # -- Extension configuration ------------------------------------------------- # If on RTD build, run doxygen on_read_the_docs = os.environ.get('READTHEDOCS') == 'True' if on_read_the_docs: subprocess.call('cd ../../; mkdir -p build/doxygen; ' + 'doxygen doxygen/Doxyfile', shell=True) breathe_projects = { 'tamaas': '../../build/doxygen/xml' } breathe_default_project = 'tamaas' intersphinx_mapping = { 'numpy': ('https://numpy.org/doc/stable/', None), 'scipy': ('https://docs.scipy.org/doc/scipy/reference', None), } diff --git a/examples/pipe_tools/contact b/examples/pipe_tools/contact index 3f8c891..65b6e87 100755 --- a/examples/pipe_tools/contact +++ b/examples/pipe_tools/contact @@ -1,59 +1,59 @@ #!/usr/bin/env python3 # -*- mode: python; coding: utf-8 -*- # vim: set ft=python: """ Read from stdin a surface profile and solve an elastic contact problem with load given as an argument. """ import argparse import sys import tamaas as tm import numpy as np from tamaas.dumpers import NumpyDumper __author__ = "Lucas Frérot" __copyright__ = ( - "Copyright (©) 2019-2020, EPFL (École Polytechnique Fédérale de Lausanne)," + "Copyright (©) 2019-2021, EPFL (École Polytechnique Fédérale de Lausanne)," "\nLaboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)" ) __license__ = "AGPL" __email__ = "lucas.frerot@gmail.com" tm.set_log_level(tm.LogLevel.error) parser = argparse.ArgumentParser( description="Compute the elastic contact solution with a given surface") parser.add_argument("--input", "-i", help="Rough surface file (default read from stdin)") parser.add_argument("--tol", type=float, default=1e-12, help="Solver tolerance") parser.add_argument("load", type=float, help="Applied average pressure") args = parser.parse_args() if not args.input: input = sys.stdin else: input = args.input surface = np.loadtxt(input) discretization = surface.shape system_size = [1., 1.] model = tm.ModelFactory.createModel(tm.model_type.basic_2d, system_size, discretization) solver = tm.PolonskyKeerRey(model, surface, args.tol) solver.solve(args.load) dumper = NumpyDumper('numpy', 'traction', 'displacement') dumper.dump_to_file(sys.stdout.buffer, model) diff --git a/examples/pipe_tools/plot b/examples/pipe_tools/plot index cd7548e..0fa79ab 100755 --- a/examples/pipe_tools/plot +++ b/examples/pipe_tools/plot @@ -1,50 +1,50 @@ #!/usr/bin/env python3 # -*- mode: python; coding: utf-8 -*- # vim: set ft=python: """ Read Numpy data from standard input, plot contact tractions and displacements. """ import sys import io import matplotlib.pyplot as plt import numpy as np __author__ = "Lucas Frérot" __copyright__ = ( - "Copyright (©) 2019-2020, EPFL (École Polytechnique Fédérale de Lausanne)," + "Copyright (©) 2019-2021, EPFL (École Polytechnique Fédérale de Lausanne)," "\nLaboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)" ) __license__ = "AGPL" __email__ = "lucas.frerot@gmail.com" def load_stream(stream): """ Load numpy from binary stream (allows piping) Code from https://gist.github.com/CMCDragonkai/3c99fd4aabc8278b9e17f50494fcc30a """ np_magic = stream.read(6) # use the sys.stdin.buffer to read binary data np_data = stream.read() # read it all into an io.BytesIO object return io.BytesIO(np_magic + np_data) fig, (ax_traction, ax_displacement) = plt.subplots(1, 2) ax_traction.set_title('Traction') ax_displacement.set_title('Displacement') with load_stream(sys.stdin.buffer) as f_np: data = np.load(f_np) ax_traction.imshow(data['traction']) ax_displacement.imshow(data['displacement']) fig.set_size_inches(10, 6) fig.tight_layout() plt.show() diff --git a/examples/pipe_tools/surface b/examples/pipe_tools/surface index 18bdfe5..8cccabf 100755 --- a/examples/pipe_tools/surface +++ b/examples/pipe_tools/surface @@ -1,78 +1,78 @@ #!/usr/bin/env python3 # -*- mode: python; coding: utf-8 -*- # vim: set ft=python: """ Create a random self-affine rough surface from command line parameters. """ import argparse import sys import time import tamaas as tm import numpy as np __author__ = "Lucas Frérot" __copyright__ = ( - "Copyright (©) 2019-2020, EPFL (École Polytechnique Fédérale de Lausanne)," + "Copyright (©) 2019-2021, EPFL (École Polytechnique Fédérale de Lausanne)," "\nLaboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)" ) __license__ = "AGPL" __email__ = "lucas.frerot@gmail.com" parser = argparse.ArgumentParser( description="Generate a self-affine rough surface" ) parser.add_argument("--cutoffs", "-K", nargs=3, type=int, help="Long, rolloff and short wavelength cutoffs", metavar=('k_l', 'k_r', 'k_s'), required=True) parser.add_argument("--sizes", nargs=2, type=int, help="Number of points", metavar=('nx', 'ny'), required=True) parser.add_argument("--hurst", "-H", type=float, help="Hurst exponent", required=True) parser.add_argument("--rms", type=float, help="Root-mean-square of slopes", default=1.) parser.add_argument("--seed", type=int, help="Random seed", default=int(time.time())) parser.add_argument("--generator", help="Generation method", choices=('random_phase', 'filter'), default='random_phase') parser.add_argument("--output", "-o", help="Output file name (compressed if .gz)") args = parser.parse_args() if args.generator == 'random_phase': generator = tm.SurfaceGeneratorRandomPhase2D(args.sizes) elif args.generator == 'filter': generator = tm.SurfaceGeneratorFilter2D(args.sizes) else: raise ValueError('Unknown generator method {}'.format(args.generator)) generator.spectrum = tm.Isopowerlaw2D() generator.spectrum.q0 = args.cutoffs[0] generator.spectrum.q1 = args.cutoffs[1] generator.spectrum.q2 = args.cutoffs[2] generator.spectrum.hurst = args.hurst generator.random_seed = args.seed surface = generator.buildSurface() / generator.spectrum.rmsSlopes() * args.rms output = args.output if args.output is not None else sys.stdout np.savetxt(output, surface) diff --git a/src/model/hooke.cpp b/src/model/hooke.cpp index c48607d..c5aa1e2 100644 --- a/src/model/hooke.cpp +++ b/src/model/hooke.cpp @@ -1,70 +1,69 @@ /** * @file * @section LICENSE * - * Copyright (©) 2016-2020 EPFL (École Polytechnique Fédérale de Lausanne), + * Copyright (©) 2016-2021 EPFL (École Polytechnique Fédérale de Lausanne), * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /* -------------------------------------------------------------------------- */ #include "hooke.hh" #include "influence.hh" #include "loop.hh" #include "model.hh" /* -------------------------------------------------------------------------- */ namespace tamaas { template void Hooke::apply(GridBase& strain, GridBase& stress) const { constexpr auto dim = model_type_traits::dimension; const influence::ElasticHelper elasticity( this->model->getShearModulus(), this->model->getPoissonRatio()); // Checking incompressibility if (elasticity.nu == 0.5) TAMAAS_EXCEPTION("Incompressibility error"); // Checking number of components if (strain.getNbComponents() == dim * dim) { - Loop::loop([&elasticity](auto sigma, auto epsilon) { sigma = elasticity(epsilon); }, range>(stress), range>(strain)); } // in case we have voigt notation else if (strain.getNbComponents() == voigt_size::value) { Loop::loop([&elasticity](auto sigma, auto epsilon) { sigma = elasticity(epsilon); }, range>(stress), range>(strain)); } else TAMAAS_EXCEPTION("Strain components do not match dimension"); } /* -------------------------------------------------------------------------- */ template class Hooke; template class Hooke; template class Hooke; template class Hooke; template class Hooke; template class Hooke; } // namespace tamaas