diff --git a/doc/manual/libmultiscale_doc_parser.cc b/doc/manual/libmultiscale_doc_parser.cc index 3c6afa5..54905a5 100644 --- a/doc/manual/libmultiscale_doc_parser.cc +++ b/doc/manual/libmultiscale_doc_parser.cc @@ -1,358 +1,358 @@ /** * @file libmultiscale_doc_parser.cc * * @author Guillaume Anciaux * * @date Fri Oct 10 16:40:09 2014 * * @brief Manual parser * * @section LICENSE * * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * LibMultiScale is free software: you can 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 of the License, or (at your option) any * later version. * * LibMultiScale 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 Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with LibMultiScale. If not, see . * */ /* -------------------------------------------------------------------------- */ #include "libmultiscale_doc_parser.hh" /* -------------------------------------------------------------------------- */ #include #include #include #include #include -#include -#include +#include +#include #include #include #include using namespace boost::filesystem; /* -------------------------------------------------------------------------- */ using namespace boost::spirit; /* -------------------------------------------------------------------------- */ typedef unsigned int UInt; /* -------------------------------------------------------------------------- */ -#define _call(x) boost::phoenix::bind(&LibMultiScaleDocParser::x,*this) -#define _call1(x,p1) boost::phoenix::bind(&LibMultiScaleDocParser::x,*this,p1) -#define _call2(x,p1,p2) boost::phoenix::bind(&LibMultiScaleDocParser::x,*this,p1,p2) -#define _call3(x,p1,p2,p3) boost::phoenix::bind(&LibMultiScaleDocParser::x,*this,p1,p2,p3) -#define _call4(x,p1,p2,p3,p4) boost::phoenix::bind(&LibMultiScaleDocParser::x,*this,p1,p2,p3,p4) +#define _call(x) boost::phoenix::bind(&LibMultiScaleDocParser::x,this) +#define _call1(x,p1) boost::phoenix::bind(&LibMultiScaleDocParser::x,this,p1) +#define _call2(x,p1,p2) boost::phoenix::bind(&LibMultiScaleDocParser::x,this,p1,p2) +#define _call3(x,p1,p2,p3) boost::phoenix::bind(&LibMultiScaleDocParser::x,this,p1,p2,p3) +#define _call4(x,p1,p2,p3,p4) boost::phoenix::bind(&LibMultiScaleDocParser::x,this,p1,p2,p3,p4) /* -------------------------------------------------------------------------- */ std::string debug(const std::string & v){ std::cerr << "AAAAAAAAAA " << v << " AAAAAAAAAAAAA" << std::endl; return v; } #define _dbg(x,p1) boost::phoenix::bind(&debug,p1) /* -------------------------------------------------------------------------- */ template LibMultiScaleDocParser::LibMultiScaleDocParser() : LibMultiScaleDocParser::base_type(start,"start") { std::string stag_desc = "/* LMDESC"; std::string etag_desc = "*/"; std::string stag_keyword = "/* LMKEYWORD"; std::string etag_keyword = "*/"; std::string stag_heritance = "/* LMHERITANCE"; std::string etag_heritance = "*/"; std::string stag_example = "/* LMEXAMPLE"; std::string etag_example = "*/"; using qi::char_; using qi::print; using qi::space; using qi::alnum; using qi::alpha; using qi::string; using qi::lexeme; using qi::on_error; using qi::fail; using boost::phoenix::ref; using boost::phoenix::val; using boost::phoenix::construct; using boost::phoenix::at_c; using boost::phoenix::push_back; start = text(stag_desc) > description[_val = _1] >> *(*(char_ - string(stag_keyword) - string(stag_heritance) - string(stag_example)) >> (heritance[at_c<7>(_val) = _1] | keyword[push_back(at_c<3>(_val),_1)] | example[at_c<8>(_val) = _1] ) ); lookup_todo = *(char_ - string("TODO")) > eoi; lookup_type = *(string("return") | (char_ - declaration(_r1))) > declaration(_r1)[_val = _1]; lookup_syntax = *(char_ - string("LMSYNTAX")) > eoi; // quantity_type = string("Quantity<") > name > string(">"); vec_quantity_type = string("Quantity<") > name > - string(",") > *(char_ - '>') > string(">"); c_type = +(char_ - "return" - eol - space - "{" - "}" - "<<" - ">>" ); declaration = ( vec_quantity_type // | quantity_type | c_type)[_val = _1] >> +space >> string(_r1) >> brackets[_val += _1] >> ';'; brackets = -(string("[") > *(char_ -string("]")) > string("]")); description = lit(stag_desc) > (*space) > name[at_c<0>(_val) = _1] > *(space-eol) > eol[at_c<1>(_val) = val("class")] > innertext(etag_desc)[at_c<2>(_val) = _1] > lit(etag_desc); defaults = *(char_-')'); keyword = lit(stag_keyword) > name[at_c<0>(_val) = _1] > eol > innertext(etag_desc)[at_c<2>(_val) = _1] > lit(etag_keyword) > *eol > ((( string("this->parseTag")[at_c<1>(_val) = "Tag"] |string("this->parseKeyword")[at_c<1>(_val) = "Keyword"] ) > "(\"" > string(at_c<0>(_val)) > "\"," > *string("this->") > name[at_c<4>(_val) = _1] > *(char_-")"-",") > -(string(",") > defaults[at_c<9>(_val) = _1])) |(string("this->parseVectorKeyword")[at_c<1>(_val) = "Keyword ["] > "(\"" > string(at_c<0>(_val)) > "\"," > expr[at_c<1>(_val) += _1 + val(std::string("]"))] > "," > *string("this->") > name[at_c<4>(_val) = _1] > -( string(",") > string("VEC_DEFAULTS(") > defaults[at_c<9>(_val) = _1] > string(")"))) ) > string(");"); expr = *(char_ - string(",") - space); heritance = lit(stag_heritance) > (*space) > *(name[push_back(_val,_1)] > *(space-eol)) > lit(etag_heritance) > eol; example = lit(stag_example) > (*space) > *(char_ - string(etag_example)) > lit(etag_example) > eol; // parse everything but a starting tag text = *(char_ - string(_r1)); // // parse a single name name = +(alnum|string("_")); // // parse everything but the end tag innertext = *(char_ - string(_r1)); description.name("description"); lookup_type.name("lookup_type"); lookup_todo.name("lookup_todo"); heritance.name("heritance"); start.name("start"); c_type.name("c_type"); declaration.name("declaration"); name.name("name"); text.name("text"); innertext.name("innertext"); keyword.name("keyword"); expr.name("expr"); example.name("example"); on_error(start,_call4(errorHandlerMain,_1,_2,_3,_4)); on_error(lookup_type,_call4(errorHandlerMain,_1,_2,_3,_4)); on_error(lookup_todo,_call4(errorHandlerTodo,_1,_2,_3,_4)); on_error(lookup_syntax,_call4(errorHandlerSyntax,_1,_2,_3,_4)); } /* -------------------------------------------------------------------------- */ template bool LibMultiScaleDocParser::parse(LMDocData & result, std::set & internal_key_list){ fname = result.filename.native(); std::ifstream file(result.filename.c_str()); if (!file.good()) std::cerr << "could not open file: " << result.filename << std::endl; std::string str((std::istreambuf_iterator(file)), std::istreambuf_iterator()); iter = str.begin(); end = str.end(); bool parsed = qi::phrase_parse(iter, end, start, boost::spirit::ascii::blank,result); result.filename = fname; if (result.example == "" && internal_key_list.count(result.name) == 0){ std::cerr << fname << ":0:Warning: no LMEXAMPLE found in that class" << std::endl; } else if (result.example != "" && internal_key_list.count(result.name) != 0){ std::cerr << fname << ":0:Warning: an example was provided for an internal class" << std::endl; } if (!parsed) return parsed; iter = str.begin(); std::string todo; qi::parse(iter, end, lookup_todo,todo); if (!parsed) return parsed; iter = str.begin(); std::string syntax; qi::parse(iter, end, lookup_syntax,syntax); for (UInt i = 0; i < result.children.size(); ++i) { LMDocData & child = result.children[i]; // if (child.type == "Tag" || // child.type == "Keyword" || // child.type == "Keyword []"){ path cc_file = result.filename; path hh_file = cc_file.replace_extension(path(".hh")); std::string h_fname = hh_file.native(); std::ifstream hfile(h_fname.c_str()); if (hfile.is_open() == false){ std::cerr << "fname:0:Error: cannot find header file " << h_fname << std::endl; return false; } std::string hstr((std::istreambuf_iterator(hfile)), std::istreambuf_iterator()); iter = hstr.begin(); end = hstr.end(); std::string c_type; // std::cerr << "look for parameter " << child.name << " " << child.var_name << " " << child.type << std::endl; parsed &= qi::parse(iter, end, lookup_type(child.var_name),c_type); if (!parsed){ std::cerr << h_fname << ":" << 0 << ":Error could not parse variable " << child.name << " " << child.var_name << " " << child.type << std::endl; return parsed; } // std::cerr << "found parameter " << child.name << " " << child.var_name << " " << c_type << std::endl; child.c_type = c_type; // } iter = hstr.begin(); std::string todo; qi::parse(iter, end, lookup_todo,todo); if (!parsed) return parsed; iter = hstr.begin(); std::string syntax; qi::parse(iter, end, lookup_syntax,syntax); } return parsed; } /* -------------------------------------------------------------------------- */ template int LibMultiScaleDocParser::getLineNumber(const std::string & text, std::string & now_parsing){ int last_index = 0; UInt count_lines = 0; size_t index = text.find_first_of("\n", 0); while (index != text.npos){ count_lines++; last_index = index; index = text.find_first_of("\n", last_index + 1); // std::cerr << last_index << " " << index << std::endl; } // std::cerr << last_index << " " << index << std::endl; now_parsing = text.substr(last_index+1,index); return count_lines; } /* -------------------------------------------------------------------------- */ template void LibMultiScaleDocParser::errorHandlerMain(const std::string::const_iterator & a, const std::string::const_iterator& b, const std::string::const_iterator & c, const info & what){ std::string already_parsed(a,c); std::string now_parsing; UInt count_lines = getLineNumber(already_parsed,now_parsing); std::string not_parsed = std::string(c,b); int index = not_parsed.find_first_of("\n",0); std::string mess = now_parsing + " ^^^^ " + not_parsed.substr(0,index); std::cerr << fname << ":" << count_lines+1 << ":Error Expecting " << what << " here: \"" << mess << "\"" << std::endl; } /* -------------------------------------------------------------------------- */ template void LibMultiScaleDocParser::errorHandlerTodo(const std::string::const_iterator & a, const std::string::const_iterator& b, const std::string::const_iterator & c, const info & what){ std::string already_parsed(a,c); // std::cerr << "already parsed " << already_parsed << std::endl; std::string now_parsing; UInt count_lines = getLineNumber(already_parsed,now_parsing); std::cerr << fname << ":" << count_lines+1 << ":Warning TODO remaining: " << what << ": " << now_parsing < void LibMultiScaleDocParser::errorHandlerSyntax(const std::string::const_iterator & a, const std::string::const_iterator& b, const std::string::const_iterator & c, const info & what){ std::string already_parsed(a,c); // std::cerr << "already parsed " << already_parsed << std::endl; std::string now_parsing; UInt count_lines = getLineNumber(already_parsed,now_parsing); std::cerr << fname << ":" << count_lines+1 << ":Warning old Syntax remaining: " << what << ": " << now_parsing <; diff --git a/doc/manual/manual.sty b/doc/manual/manual.sty index 419b030..cfd3518 100644 --- a/doc/manual/manual.sty +++ b/doc/manual/manual.sty @@ -1,307 +1,315 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% %% LaTeX STYLE SHEET for LibMultiScale DOCUMENTATION %% %% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Nice coloring +\usepackage[dvipsnames]{xcolor} +\definecolor{RED}{rgb}{1,0,0} +\definecolor{cppbg}{HTML}{EBF2F2} +\definecolor{shellbg}{HTML}{F5EDE4} +\definecolor{commentcolor}{HTML}{101280} + % Geometry \usepackage{a4wide} \usepackage{geometry} +\usepackage{amsmath,amssymb} +\usepackage{fancyvrb} +\usepackage{url} +\usepackage{textcomp} +\usepackage{parskip} +\usepackage{lmodern} +\usepackage{xspace} +\usepackage{listings} + \geometry{ pdftex=true, twoside=true, margin=20mm, bottom=20mm, top=20mm, bindingoffset=5.5mm } % Font encoding \usepackage[T1]{fontenc} \usepackage{palatino} -\usepackage{xspace} % Line spacing \linespread{1.05}\selectfont % Allow spaces to be added at the end of macro \usepackage{xspace} % Mathematics (including correct font encoding, after amsmath) \usepackage{amsmath} \usepackage{amssymb} -\usepackage{pxfonts} +%\usepackage{pxfonts} %\setlength\mathindent{2em} % Some unit stuff \usepackage[squaren]{SIunits} % Easy tables \usepackage{booktabs} \usepackage{longtable} \usepackage{rotating} % For sideways tables \usepackage{multirow} % For larger cells % A special environment for element tables \newcommand\elemline{\hline}%{\noalign{\smallskip}\hline\noalign{\smallskip}} \newcommand\elemcooroned{\ensuremath{\left(\xi\right)}} \newcommand\elemcoortwod{\ensuremath{\left(\xi\;,\;\eta\right)}} \newcommand\elemcoorthreed{\ensuremath{\left(\xi\;,\;\eta\;,\;\zeta\right)}} \newcommand\elemdshapeoned{\ensuremath{\left(\partial N_i/\partial\xi\right)}} \newcommand\elemdshapetwod{\ensuremath{\left(\partial N_i/\partial\xi\;,\;\partial N_i/\partial\eta\right)}} \newcommand\elemdshapethreed{\ensuremath{\left(\partial N_i/\partial\xi\;,\;\partial N_i/\partial\eta\;,\;\partial N_i/\partial\zeta\right)}} \newcommand\inelemone[1]{\ensuremath{#1}} %\newcommand\inelemtwo[2]{\ensuremath{\begin{pmatrix} {\; #1} & \!,\! & {#2 \;} \end{pmatrix}}} %\newcommand\inelemthree[3]{\ensuremath{\begin{pmatrix} {\; #1} & \!,\! & {#2} & \!,\! & {#3 \;} \end{pmatrix}}} \newcommand\inelemtwo[2]{\ensuremath{\left( {\; #1} \; , \; {#2 \;} \right)}} \newcommand\inelemthree[3]{\ensuremath{\left( {\; #1} \; , \; {#2} \; , \; {#3 \;} \right)}} \newcommand\inquadone[1]{\ensuremath{#1}} \newcommand\inquadtwo[2]{\ensuremath{\left(\, #1 \, , \, #2 \,\right)}} \newcommand\inquadthree[3]{\ensuremath{\left(\, #1 \, , \, #2 \, , \, #3 \,\right)}} %\newcommand\quada{\tfrac{1}{20}\left(5-\sqrt{5}\right)} %\newcommand\quadb{\tfrac{1}{20}\left(5+3\sqrt{5}\right)} \newcommand\quada{\tfrac{\left(5-\sqrt{5}\right)}{20}} \newcommand\quadb{\tfrac{\left(5+3\sqrt{5}\right)}{20}} \newenvironment{Element}[1] {\begin{table*}[!htbp]\footnotesize \ifthenelse{\equal{#1}{1D}}{\renewcommand{\arraystretch}{1.50}}{} \ifthenelse{\equal{#1}{2D}}{\renewcommand{\arraystretch}{1.60}}{} \ifthenelse{\equal{#1}{3D}}{\renewcommand{\arraystretch}{1.70}}{} \textbf{{\normalsize Element properties}}\newline\vspace*{0.5\baselineskip} \begin{tabular}{c|c|c|c} %\multicolumn{4}{l}{\textbf{{\normalsize Element properties}}} \\ Node ($i$) & Coord. \ifthenelse{\equal{#1}{1D}}{\elemcooroned}{} \ifthenelse{\equal{#1}{2D}}{\elemcoortwod}{} \ifthenelse{\equal{#1}{3D}}{\elemcoorthreed}{} & Shape function ($N_{i}$) & {Derivative \ifthenelse{\equal{#1}{1D}}{\elemdshapeoned}{} \ifthenelse{\equal{#1}{2D}}{\elemdshapetwod}{} \ifthenelse{\equal{#1}{3D}}{\elemdshapethreed}{} }\\ \elemline } {\end{tabular}\end{table*}} \newenvironment{QuadPoints}%[1] {\vspace*{-\baselineskip} \begin{table*}[!htbp]\footnotesize \renewcommand{\arraystretch}{1.50} \textbf{{\normalsize Gaussian quadrature points}}\newline\vspace*{0.5\baselineskip} } {\end{table*}} -% Nice coloring -%\usepackage[dvipsnames,usenames,table]{xcolor} -\usepackage[dvipsnames]{xcolor} -\definecolor{RED}{rgb}{1,0,0} -\definecolor{cppbg}{HTML}{EBF2F2} -\definecolor{shellbg}{HTML}{F5EDE4} -\definecolor{commentcolor}{HTML}{101280} % Allow for the use of listings \usepackage{listings} % Create an index \usepackage{makeidx} % Figure handling \usepackage{graphics} \usepackage{epsfig} \usepackage[lofdepth,lotdepth]{subfig} \usepackage{tikz} \usetikzlibrary{decorations} \renewcommand{\floatpagefraction}{.6} % default: .5 \renewcommand\topfraction{0.9} % 90% of page top can be a float (Standard 0.7) \renewcommand\bottomfraction{0.1} % 10% of page bottom can be a float (Standard 0.3) \renewcommand\textfraction{0.1} % only 10% of page must to be text (Standard 0.2) % Removes parenthese around subfig number \renewcommand*{\thesubfigure}{\alph{subfigure}} % Create a new list style for C++ \lstdefinestyle{C++}{ language=C++, % the language of the code basicstyle=\small\ttfamily, % Without beramono, we'd get cmtt, the teletype font. commentstyle=\color{commentcolor}\itshape, keywordstyle=\color{DarkOrchid}\bfseries, % fontadjust, % numbers=left, % where to put the line-numbers % numberstyle=\tiny, % the size of the fonts that are used for the line-numbers % stepnumber=2, % the step between two line-numbers. If it's 1, each line will % be numbered % numbersep=5pt, % how far the line-numbers are from the code % showspaces=false, % show spaces adding particular underscores showstringspaces=false, % underline spaces within strings % showtabs=false, % show tabs within strings adding particular underscores % frame=llines, % adds a frame around the code % frame=tb, tabsize=2, % sets default tabsize to 2 spaces captionpos=b, % sets the caption-position to bottom breaklines=true, % sets automatic line breaking breakatwhitespace=false, % sets if automatic breaks should only happen at % whitespace % title=\lstname, % show the filename of files included with \lstinputlisting; % also try caption instead of title % escapeinside={\%*}{*)}, % if you want to add a comment within your code xleftmargin=1cm, xrightmargin=1cm, mathescape=true, escapechar=\%, morekeywords={Real, UInt, Int}, columns=flexible, keepspaces=true, backgroundcolor=\color{cppbg} } % Create new list style for the shell \lstdefinestyle{shell}{ language=bash, % the language of the code basicstyle=\scriptsize\ttfamily, % Without beramono, we'd get cmtt, the teletype font. showstringspaces=false, % underline spaces within strings tabsize=2, % sets default tabsize to 2 spaces captionpos=b, % sets the caption-position to bottom breaklines=true, % sets automatic line breaking breakatwhitespace=false, xleftmargin=1cm, xrightmargin=1cm, escapechar=\%, morekeywords={mkdir, make, ccmake, cmake}, columns=flexible, keepspaces=true, backgroundcolor=\color{shellbg} } \lstdefinelanguage{lmconfig} {morekeywords={Section,endSection,LET,GEOMETRY,FILTER,KEYWORD,PRINT,FOR,endFOR,range, in}, sensitive=true, morecomment=[l]{\#}, } \lstdefinestyle{config}{ language=lmconfig, % the language of the code basicstyle=\small\ttfamily, % Without beramono, we'd get cmtt, the teletype font. commentstyle=\color{commentcolor}\itshape, keywordstyle=\color{DarkOrchid}\bfseries, showstringspaces=false, % underline spaces within strings tabsize=2, % sets default tabsize to 2 spaces captionpos=b, % sets the caption-position to bottom breaklines=true, % sets automatic line breaking breakatwhitespace=false, xleftmargin=1cm, xrightmargin=1cm, escapechar=\%, morekeywords={mkdir, make, ccmake, cmake}, columns=flexible, keepspaces=true, backgroundcolor=\color{cppbg} } % Set some derived listing environments \lstnewenvironment{cpp}{\lstset{style=C++}}{} \lstnewenvironment{lmconfig}{\lstset{style=config}}{} \lstnewenvironment{command}{\lstset{style=shell}}{} % Make sure outputspace is white \makeatletter \def\lst@outputspace{{\ifx\lst@bkgcolor\empty\color{white}\else\lst@bkgcolor\fi\lst@visiblespace}} \makeatother % Renow a label in the itemized lists \renewcommand{\labelitemi}{$\mathbf{\circ}$} % Don't care so much about overfull h-boxes \sloppy % Penalty adjusments %\widowpenalty=10000 % Single lines/word on beginning of page %\clubpenalty=10000 % Single lines/word at end of page %\hyphenpenalty=2000 % Hyphenate words %\tolerance=250 % To adjust the hyphenation of words, increase the tolerance to discourage hyphenation % the higher the value, the more ugly the gaps between words % default \tolerance=200 %\hfuzz=10000pt % threshold when an overfull hbox is reported, default \hfuzz=0.1pt %\vfuzz=10000pt % threshold to report an overfull vbox, default \vfuzz=0.1pt %\hbadness=10000 % threshold to report an underfull \hbox %\vbadness=10000 % threshold to report an underfull \vbox protokolliert wird. \emergencystretch=0pt % causes a third attempt to fix bad paragraphs and defines a maximum limit to stretch them % Insert an empty or a blank page \newcommand{\insertemptypage}{\newpage\hbox{}\newpage} \newcommand{\insertblankpage}{\newpage\thispagestyle{empty}\hbox{}\newpage} % No page number on an empty page \let\origdoublepage\cleardoublepage \newcommand{\clearemptydoublepage}{% \clearpage {\thispagestyle{empty}\origdoublepage}% } \let\cleardoublepage\clearemptydoublepage % A new ruler for in chapters \newcommand\InChapterRule{\addvspace{\baselineskip}\rule{0.3\linewidth}{0.25pt}} % New footnote style %\def\@fnsymbol#1{\ifcase#1\or *\or \dagger\or \ddagger\or \mathchar "278\or \mathchar "27B\or \|\or **\or \dagger\dagger \or \ddagger\ddagger \else\@ctrerr\fi\relax} \def\@fnsymbol#1{*\xspace\relax} \renewcommand{\thefootnote}{\fnsymbol{footnote}} % Symbols rather than numbers \def\footnoterule{\vspace*{0.5\baselineskip}\InChapterRule\vspace*{0.25\baselineskip}} % Improved look of the Table of Contents \usepackage[nottoc,notbib]{tocbibind} \usepackage[dotinlabels]{titletoc} \titlecontents{chapter}[1.4pc] {\addvspace{0.6pc}\large\bfseries\filright} {\contentslabel[\thecontentslabel.]{1.4pc}} {\hspace{-1.4pc}} {\hfill\contentspage} [\addvspace{2pt}] \titlecontents{section}[3.4pc] {\filright} {\contentslabel[\thecontentslabel]{2pc}} {\hspace{-2pc}} {\titlerule*[6pt]{.}\contentspage} [] \titlecontents{subsection}[5.0pc] {\filright} {\contentslabel[\thecontentslabel]{2.4pc}} {} {\titlerule*[6pt]{.}\contentspage} [] \setcounter{tocdepth}{2} \newcommand\addspaceintoc{\addtocontents{toc}{\protect\addvspace{20pt}}} % Change the appearance of the bibliography %\bibliographystyle{manual-bibliographystyle} \renewcommand\bibname{References} \usepackage{cite} % To sort citations: [2,10-14] \let\oldthebibliography=\thebibliography \let\endoldthebibliography=\endthebibliography \renewenvironment{thebibliography}[1] { \begin{oldthebibliography}{#1} % \small \addcontentsline{toc}{chapter}{\bibname} \setlength{\labelsep}{2mm} \setlength{\parskip}{0\baselineskip} \setlength{\itemsep}{0.24\baselineskip} } { \end{oldthebibliography} } \newcommand{\libmultiscale}{\textit{LibMultiScale}\xspace} % Hyperref \usepackage{url} \usepackage[pdftex, bookmarks=true, bookmarksnumbered=true, linkbordercolor={1 1 1}, pdfborder={0 0 0}, pdfpagemode=UseOutlines ]{hyperref} \hypersetup{ pdfauthor={Computational Solid Mechanics Laboratory - EPFL}, pdftitle={LibMultiScale User's Guide}, pdfsubject={Open Source Coupling framewwork - \libmultiscale} } diff --git a/src/common/action_interface.cc b/src/common/action_interface.cc index abf20e7..ad5e520 100644 --- a/src/common/action_interface.cc +++ b/src/common/action_interface.cc @@ -1,200 +1,200 @@ /** * @file action_interface.cc * * @author Guillaume Anciaux * @author Till Junge * * @date Mon Sep 08 23:40:22 2014 * * @brief This is the interface to all action objects * * @section LICENSE * * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * LibMultiScale is free software: you can 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 of the License, or (at your option) any * later version. * * LibMultiScale 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 Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with LibMultiScale. If not, see . * */ #include "lm_common.hh" #include "action_interface.hh" #include "filter_interface.hh" #include "factory_multiscale.hh" __BEGIN_LIBMULTISCALE__ /* -------------------------------------------------------------------------- */ ActionInterface::ActionInterface(const std::string & name){ setDefaults(); this->ID = name; } /* -------------------------------------------------------------------------- */ void ActionInterface::printself(std::ostream & stream, int indent) const{ stream << "Action " << ID << " " << "action_step " << action_step << " " << "start_step " << start_step << " " << "end_step " << end_step << " " << "frequency " << frequency << " " << "name " << ID << std::endl; } /* -------------------------------------------------------------------------- */ void ActionInterface::setDefaults(){ action_step = 0; frequency = 1; start_step = 0; end_step = UINT_MAX; one_shot = UINT_MAX; } /* -------------------------------------------------------------------------- */ bool ActionInterface::shouldMakeAction(){ if ((current_stage == PRE_FATAL) && (stage_mask & PRE_FATAL) ) return true; bool sM = doesStageMaskMatch(); if (!sM) return false; setOneStep(); DUMP("for action " << ID << " freq " << frequency << " step " << action_step,DBG_INFO); if (end_step >= current_step && start_step <= current_step) if (frequency != UINT_MAX && current_step%frequency == 0){ DUMP("should proceed action " << ID << " current_step = " << current_step << " start " << start_step << " end " << end_step,DBG_INFO); return true; } return false; } /* -------------------------------------------------------------------------- */ void ActionInterface::setOneStep(){ if (one_shot != UINT_MAX) end_step = start_step = one_shot; } /* -------------------------------------------------------------------------- */ bool ActionInterface::doesStageMaskMatch(){ if (stage_mask.isNone()) stage_mask = PRE_STEP1; if (!(stage_mask & current_stage)) return false; return true; } /* -------------------------------------------------------------------------- */ void ActionInterface::action(){ ++action_step; } /* -------------------------------------------------------------------------- */ /* LMDESC ActionInterface This describe the generic keywords which all actions inheritate from. */ void ActionInterface::declareParams(){ /* LMKEYWORD FREQ Fix the frequency at which action should be called */ this->parseKeyword("FREQ",frequency,1u); /* LMKEYWORD START Fix the first step at which action should start */ this->parseKeyword("START",start_step,0u); /* LMKEYWORD END Fix the last step at which action should be performed */ this->parseKeyword("END",end_step,lm_uint_max); /* LMKEYWORD ONESHOT Set the action to be called only at a given step. */ this->parseKeyword("ONESHOT",one_shot,lm_uint_max); /* LMKEYWORD STAGE Set the stage within generic explicit integration scheme at which the action should be called. The possible values are: \begin{itemize} \item PRE\_DUMP \item PRE\_STEP1 \item PRE\_STEP2 \item PRE\_STEP3 \item PRE\_STEP4 \item PRE\_STEP5 \item PRE\_STEP6 \item PRE\_STEP7 \end{itemize} The keyword STAGE can be called more than once and the result will be a bit-mask value so that an action can be called at several stages within a given timestep.\\ These stages are identified depending on the implemented integration scheme. For instance the classical Verlet integration scheme is coded in a loop in the AMEL executable as follows: \textit{ for (current\_step = 0; current\_step < nb\_step ; ++current\_step, current\_time += dt) \\ \{ \\ ~~... \\ \\ ~~stimulator.stimulate(PRE\_DUMP);\\ \\ ~~dumper.dump();\\ \\ ~~stimulator.stimulate(PRE\_STEP1);\\ \\ ~~dom.performStep1();\\ ~~dom.coupling(COUPLING\_STEP1);\\ \\ ~~stimulator.stimulate(PRE\_STEP2);\\ \\ ~~dom.performStep2();\\ ~~dom.coupling(COUPLING\_STEP2);\\ \\ ~~stimulator.stimulate(PRE\_STEP3);\\ ~~dom.performStep3();\\ \\ ~~dom.coupling(COUPLING\_STEP3);\\ ~~stimulator.stimulate(PRE\_STEP4);\\ ~~dom.coupling(COUPLING\_STEP4);\\ \\ ~~...\\ \}\\ } For a classical Verlet integration scheme performStep1() is the initial velocity and position update, performStep2() is the force computation, and performStep3() is the velocity correction. - If the stage value is kept to NONE, the default of PRE_STEP1 will apply automatically + If the stage value is kept to NONE, the default of PRE\_STEP1 will apply automatically */ this->parseKeyword("STAGE",stage_mask,NONE_STEP); } /* -------------------------------------------------------------------------- */ __END_LIBMULTISCALE__