-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTutorial04.html
250 lines (244 loc) · 14.6 KB
/
Tutorial04.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.10.0"/>
<title>G+Smo: Tutorial 04: Writing code</title>
<link href="gismodoxy_tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://people.ricam.oeaw.ac.at/gismo/mj/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="gismodoxy.css" rel="stylesheet" type="text/css">
<!-- -->
<!-- <script type="text/javascript"> -->
<!-- </script> -->
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<!-- <a name="top"></a> -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="gslogo-doxy.jpg"/></td>
<td style="padding-left: 0.5em;">
<div id="projectname"><a href="index.html"><font style="font-variant:small-caps;">G+S</font><font style="font-variant:small-caps;"
color="#000000">mo</font></a>
 <span id="projectnumber">25.01.0</span>
</div>
<div id="projectbrief">Geometry + Simulation Modules</div>
</td>
<td> <div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<span id="MSearchSelect" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()"> </span>
<input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.10.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function(){initNavTree('Tutorial04.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div><div class="header">
<div class="headertitle"><div class="title">Tutorial 04: Writing code</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>In this tutorial we collect some tips and guidelines for writing code in G+Smo.</p>
<p>Information regarding code formatting are found in <a href="https://github.com/gismo/gismo/wiki/Contributing#code-style-and-formatting" target="_parent">the wiki</a>.</p>
<h1><a class="anchor" id="conf04"></a>
Configuration options</h1>
<p>Upon configuration, G+Smo presents a set of basic configuration options, which are ON (enabled):</p>
<pre class="fragment">Configuration:
CMAKE_BUILD_TYPE RelWithDebInfo
GISMO_COEFF_TYPE double
GISMO_BUILD_LIB ON
GISMO_BUILD_EXAMPLES ON
CMAKE_INSTALL_PREFIX /usr/local
</pre><p>The full list of options can be accessed using the <b>cmake-gui</b> utility, or using the command-line version:</p>
<pre class="fragment">ccmake .
</pre><p>inside the build folder.</p>
<ul>
<li><p class="startli">CMAKE_BUILD_TYPE</p>
<p class="startli">Available values are the standard CMake build configurations: Debug, Release, RelWithDebInfo?, MinSizeRel?.</p>
</li>
<li><p class="startli">GISMO_COEFF_TYPE</p>
<p class="startli">The arithmetic type to be used for all computations. Available options include double, long double, float. This is the type is alias as <em>real_t</em>.</p>
</li>
<li><p class="startli">GISMO_WITH_XDEBUG</p>
<p class="startli">If set to ON additional debugging tools are enabled during compilation. These include checked iterators for GCC and MSVC compilers and call stack back-trace printout when a runtime exception occurs.</p>
</li>
<li><p class="startli">GISMO_BUILD_LIB</p>
<p class="startli">If enabled a dynamic library is created using GISMO_COEFF_TYPE arithmetic. A target for a static library named gismo_static is also created but not compiled by default.</p>
</li>
<li><p class="startli">GISMO_BUILD_EXAMPLES</p>
<p class="startli">If enabled the programs in the examples folder are compiled, and executables are created in build-folder/bin.</p>
</li>
<li><p class="startli">GISMO_PLUGIN_AXL</p>
<p class="startli">If enabled the plugin for Axel modeler is compiled (requires Axel).</p>
</li>
<li><p class="startli">GISMO_WITH_PSOLID</p>
<p class="startli">If enabled the extensions using functionalities of Parasolid geometric kernel are compiled.(requires Parasolid).</p>
</li>
<li><p class="startli">gsOpennurbs</p>
<p class="startli">Extension for reading and writing of Rhinoceros' 3DM.</p>
</li>
<li><p class="startli">CMAKE_INSTALL_PREFIX</p>
<p class="startli">The location for installation of the library, e.g. /usr/local on some Linux systems.</p>
</li>
</ul>
<h1><a class="anchor" id="debug04"></a>
Debugging</h1>
<p>There are 2 main tools for debugging C++ code:</p>
<ul>
<li>The debugger, for instance GDB for GCC, and the Visual Studio debuggerfor Visual C++.</li>
<li>The memory checker, for instance valgrind on linux or the C Run-Time Libraries (CRT) on Visual studio.</li>
</ul>
<p>If the CMake option GISMO_WITH_XDEBUG is set to ON, more checks are performed while running the code. In particular the Standard library containers are checked for invalid access, invalid iterators, and so on. Also upon failure of the program the call stack is printed on the screen.</p>
<dl class="section note"><dt>Note</dt><dd>The setting GISMO_WITH_XDEBUG replaces the standard containers, for instance std::vector with debug types, eg std::debug_vector. This can cause problems when linking the resulting dynamic library with third-party codes which is not compiled with the same settings. Setting the option back to OFF restores the correct types.</dd></dl>
<p>CMake provides with a tool to execute programs and report the result status. Result status zero (main() function returns 0) means program succeded, return 1 means program failed. To run this check inside the build folder do:</p>
<pre class="fragment">ctest -j3
</pre><p>Problems or bugs might also be related to the platform or operating system. Nightly compilations and tests on several systems detects such problems. The CDash server:</p>
<p><a href="https://cdash-ci.irisa.fr/index.php?project=Gismo">https://cdash-ci.irisa.fr/index.php?project=Gismo</a></p>
<p>collects the result of compilation and testing from compilation nodes. To Submit your compilation and test log to the CDash server you can type: </p><pre class="fragment">make -j2 Experimental
</pre><p>inside the build folder. After building and executing all programs, a log file will be posted on the CDash server, under the section Experimental.</p>
<h1><a class="anchor" id="cxx"></a>
Gismo and Cxx Standards</h1>
<p>Gismo should be able to compile with C++98 and on different machines with different datatypes and maybe architectures. To ensure this, and still be able to use some of the benefits of newer compilers like C++11, there are some helping functions inside gsUtils and gsMemory that should be used instead of native C++11 calls. It is helpful to keep in mind that real_t and size_t are definitions that will be exchanged by cmake and should be used instead of double and int.</p>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">Cxx(11) </th><th class="markdownTableHeadNone">Gismo </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">std::move(...) </td><td class="markdownTableBodyNone">give(...) </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">double </td><td class="markdownTableBodyNone">real_t </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">int </td><td class="markdownTableBodyNone">index_t </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">std::unique_ptr </td><td class="markdownTableBodyNone">memory::unique_ptr or gs...::uPtr </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">std::shared_ptr </td><td class="markdownTableBodyNone">memory::shared_ptr or gs...::Ptr </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">std::to_string </td><td class="markdownTableBodyNone"><a class="el" href="group__Utils.html#ga44d2df1e1ffdb68edf7f80158fd5be22" title="Converts value to string, assuming "operator<<" defined on C.">util::to_string</a> </td></tr>
</table>
<p>Also keep in mind that C++98 std::ios doesn't like "strings". Therefore, just call .c_str() if you give a string to an fstream (like ofstream::open).</p>
<p>And please don't use auto and the fancy new foreach loop.</p>
<h1><a class="anchor" id="tips04"></a>
Quick Tips</h1>
<ul>
<li>Find intuitive names for your classes, prefix the names with "gs"</li>
<li>Prefer one header file for one class, with the same name. For several small objects, grouping in one file is an option.</li>
<li>Avoid statements like "using namespace std;" in the code. Prefer to just type eg "std::vector". The reason is that we do not want to pollute the <em>gismo</em> namespace with third-party functions.</li>
<li>The header file "gismo.h" contains all the headers of the library. It is intended to be used by clients using the library (such as the example programs). It should not be used as an included file in the source code of the library itself.</li>
<li>Avoid overloading the header files with a lot of included files. Prefer to put a header file in the .hpp (or .cpp) file rather than the .h file.</li>
<li>While coding, do frequent updates to your svn/git copy. This will keep your local copy up to date with the repository.</li>
<li>Avoid letting your program produce paraview files by default. Use a –plot switch to trigger output.</li>
<li>Try to fit your work in the general framework of Gismo, and derive your classes from the existing Core classes. For instance, if you implement a different function type, inherit from <a class="el" href="classgismo_1_1gsFunction.html" title="A function from a n-dimensional domain to an m-dimensional image.">gsFunction</a> and implement the evaluation interface.</li>
<li>Add Doxygen comments to all of your functions and classes. There are a lot of resources online in using Doxygen documentation. The basic usage is quite straightforward.<ul>
<li><a href="https://www.stack.nl/~dimitri/doxygen/manual/markdown.html" target="_blank">Doxygen manual pages</a>.</li>
<li><a href="http://www.digilife.be/quickreferences/QRC/Doxygen%20Quick%20Reference.pdf" target="_blank">Quick reference manual</a></li>
</ul>
</li>
<li>Add your name on the header of your files. Use the common header as follows: <pre class="fragment"> /** @file fitting_example.cpp
@brief Demonstrates adaptive fitting of data samples
This file is part of the G+Smo library.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Author(s): G. Kiss, A. Mantzaflaris
*/</pre></li>
<li>Get in touch with us on Github wiki: <a href="https://github.com/gismo/gismo/wiki">https://github.com/gismo/gismo/wiki</a> and issues: <a href="https://github.com/gismo/gismo/issues">https://github.com/gismo/gismo/issues</a> </li>
</ul>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated on Mon Feb 10 2025 09:21:44 for G+Smo by Doxygen v1.10.0 </li>
</ul>
</div>
<!-- Piwik -->
<!--
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://stats.sylphide-consulting.com/piwik/" : "http://stats.sylphide-consulting.com/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 20);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://stats.sylphide-consulting.com/piwik/piwik.php?idsite=20" style="border:0" alt="" /></p></noscript>
-->
<!-- End Piwik Tracking Code -->
</body>
</html>