Skip to content

Commit

Permalink
Deploying to main from @ capytaine/capytaine@73728f9 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
mancellin committed Jul 3, 2024
1 parent a9b6ff8 commit 9e61ab5
Show file tree
Hide file tree
Showing 13 changed files with 198 additions and 101 deletions.
61 changes: 47 additions & 14 deletions master/_modules/capytaine/bem/solver.html

Large diffs are not rendered by default.

45 changes: 43 additions & 2 deletions master/_modules/capytaine/bodies/bodies.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@

<h1>Source code for capytaine.bodies.bodies</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;Floating bodies to be used in radiation-diffraction problems.&quot;&quot;&quot;</span>
<span class="c1"># Copyright (C) 2017-2019 Matthieu Ancellin</span>
<span class="c1"># See LICENSE file at &lt;https://github.com/mancellin/capytaine&gt;</span>
<span class="c1"># Copyright (C) 2017-2024 Matthieu Ancellin</span>
<span class="c1"># See LICENSE file at &lt;https://github.com/capytaine/capytaine&gt;</span>

<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">copy</span>
Expand All @@ -54,6 +54,7 @@ <h1>Source code for capytaine.bodies.bodies</h1><div class="highlight"><pre>

<span class="kn">from</span> <span class="nn">capytaine.meshes.collections</span> <span class="kn">import</span> <span class="n">CollectionOfMeshes</span>
<span class="kn">from</span> <span class="nn">capytaine.meshes.geometry</span> <span class="kn">import</span> <span class="n">Abstract3DObject</span><span class="p">,</span> <span class="n">ClippableMixin</span><span class="p">,</span> <span class="n">Plane</span><span class="p">,</span> <span class="n">inplace_transformation</span>
<span class="kn">from</span> <span class="nn">capytaine.meshes.properties</span> <span class="kn">import</span> <span class="n">connected_components</span><span class="p">,</span> <span class="n">connected_components_of_waterline</span>
<span class="kn">from</span> <span class="nn">capytaine.meshes.meshes</span> <span class="kn">import</span> <span class="n">Mesh</span>
<span class="kn">from</span> <span class="nn">capytaine.meshes.symmetric</span> <span class="kn">import</span> <span class="n">build_regular_array_of_meshes</span>
<span class="kn">from</span> <span class="nn">capytaine.bodies.dofs</span> <span class="kn">import</span> <span class="n">RigidBodyDofsPlaceholder</span>
Expand Down Expand Up @@ -1222,6 +1223,46 @@ <h1>Source code for capytaine.bodies.bodies</h1><div class="highlight"><pre>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="mi">8</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh</span><span class="o">.</span><span class="n">faces_radiuses</span><span class="o">.</span><span class="n">max</span><span class="p">()</span>

<div class="viewcode-block" id="FloatingBody.first_irregular_frequency_estimate">
<a class="viewcode-back" href="../../../developer_manual/api/capytaine.bodies.bodies.html#capytaine.bodies.bodies.FloatingBody.first_irregular_frequency_estimate">[docs]</a>
<span class="k">def</span> <span class="nf">first_irregular_frequency_estimate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">g</span><span class="o">=</span><span class="mf">9.81</span><span class="p">):</span>
<span class="w"> </span><span class="sa">r</span><span class="sd">&quot;&quot;&quot;Estimates the angular frequency of the lowest irregular</span>
<span class="sd"> frequency.</span>
<span class="sd"> This is based on the formula for the lowest irregular frequency of a</span>
<span class="sd"> parallelepiped of size :math:`L \times B` and draft :math:`H`:</span>

<span class="sd"> .. math::</span>
<span class="sd"> \omega = \sqrt{</span>
<span class="sd"> \frac{\pi g \sqrt{\frac{1}{B^2} + \frac{1}{L^2}}}</span>
<span class="sd"> {\tanh\left(\pi H \sqrt{\frac{1}{B^2} + \frac{1}{L^2}} \right)}</span>
<span class="sd"> }</span>

<span class="sd"> The formula is applied to all shapes to get an estimate that is usually</span>
<span class="sd"> conservative.</span>
<span class="sd"> The definition of a lid (supposed to be fully covering and horizontal)</span>
<span class="sd"> is taken into account.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lid_mesh</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">draft</span> <span class="o">=</span> <span class="nb">abs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh</span><span class="o">.</span><span class="n">vertices</span><span class="p">[:,</span> <span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">min</span><span class="p">())</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">draft</span> <span class="o">=</span> <span class="nb">abs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lid_mesh</span><span class="o">.</span><span class="n">vertices</span><span class="p">[:,</span> <span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">min</span><span class="p">())</span>
<span class="k">if</span> <span class="n">draft</span> <span class="o">&lt;</span> <span class="mf">1e-6</span><span class="p">:</span>
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">inf</span>

<span class="c1"># Look for the x and y span of each components (e.g. for multibody) and</span>
<span class="c1"># keep the one causing the lowest irregular frequency.</span>
<span class="c1"># The draft is supposed to be same for all components.</span>
<span class="n">omega</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">inf</span>
<span class="k">for</span> <span class="n">comp</span> <span class="ow">in</span> <span class="n">connected_components</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh</span><span class="p">):</span>
<span class="k">for</span> <span class="n">ccomp</span> <span class="ow">in</span> <span class="n">connected_components_of_waterline</span><span class="p">(</span><span class="n">comp</span><span class="p">):</span>
<span class="n">x_span</span> <span class="o">=</span> <span class="n">ccomp</span><span class="o">.</span><span class="n">vertices</span><span class="p">[:,</span> <span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">max</span><span class="p">()</span> <span class="o">-</span> <span class="n">ccomp</span><span class="o">.</span><span class="n">vertices</span><span class="p">[:,</span> <span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">min</span><span class="p">()</span>
<span class="n">y_span</span> <span class="o">=</span> <span class="n">ccomp</span><span class="o">.</span><span class="n">vertices</span><span class="p">[:,</span> <span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">max</span><span class="p">()</span> <span class="o">-</span> <span class="n">ccomp</span><span class="o">.</span><span class="n">vertices</span><span class="p">[:,</span> <span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">min</span><span class="p">()</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hypot</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x_span</span><span class="p">,</span> <span class="mi">1</span><span class="o">/</span><span class="n">y_span</span><span class="p">)</span>
<span class="n">omega_comp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">pi</span><span class="o">*</span><span class="n">g</span><span class="o">*</span><span class="n">p</span><span class="o">/</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">tanh</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">pi</span><span class="o">*</span><span class="n">draft</span><span class="o">*</span><span class="n">p</span><span class="p">)))</span>
<span class="n">omega</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">omega</span><span class="p">,</span> <span class="n">omega_comp</span><span class="p">)</span>
<span class="k">return</span> <span class="n">omega</span></div>


<div class="viewcode-block" id="FloatingBody.cluster_bodies">
<a class="viewcode-back" href="../../../developer_manual/api/capytaine.bodies.bodies.html#capytaine.bodies.bodies.FloatingBody.cluster_bodies">[docs]</a>
<span class="k">def</span> <span class="nf">cluster_bodies</span><span class="p">(</span><span class="o">*</span><span class="n">bodies</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
Expand Down
2 changes: 1 addition & 1 deletion master/_modules/capytaine/meshes/meshes.html
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ <h1>Source code for capytaine.meshes.meshes</h1><div class="highlight"><pre>
<span class="c1"># For lid meshes for irregular frequencies removal</span>
<span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">allclose</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">faces_normals</span><span class="p">[:,</span> <span class="mi">2</span><span class="p">],</span> <span class="n">np</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="bp">self</span><span class="o">.</span><span class="n">nb_faces</span><span class="p">,))):</span>
<span class="c1"># The mesh is horizontal with normal vectors going up</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Inverting the direction of the normal vectors of </span><span class="si">{</span><span class="bp">self</span><span class="si">}</span><span class="s2"> to be upward.&quot;</span><span class="p">)</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Inverting the direction of the normal vectors of </span><span class="si">{</span><span class="bp">self</span><span class="si">}</span><span class="s2"> to be downward.&quot;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">faces</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">faces</span><span class="p">[:,</span> <span class="p">::</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span>
Expand Down
1 change: 1 addition & 0 deletions master/_sources/changelog.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Major changes

* Add ``lid_mesh`` argument to :class:`~capytaine.bodies.bodies.FloatingBody` for irregular frequencies removal (:pull:`521`).
Add :meth:`~capytaine.meshes.meshes.Mesh.extract_lid` method to manipulate lids (:pull:`559`).
Add a warning to the user if irregular frequencies can be expected (:pull:`564`).

Minor changes
~~~~~~~~~~~~~
Expand Down
3 changes: 2 additions & 1 deletion master/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ <h3>Major changes<a class="headerlink" href="#major-changes" title="Link to this
<ul class="simple">
<li><p>Experimental support for panels on the free surface. (<a class="reference external" href="https://github.com/capytaine/capytaine/pull/419">PR 419</a>)</p></li>
<li><p>Add <code class="docutils literal notranslate"><span class="pre">lid_mesh</span></code> argument to <a class="reference internal" href="developer_manual/api/capytaine.bodies.bodies.html#capytaine.bodies.bodies.FloatingBody" title="capytaine.bodies.bodies.FloatingBody"><code class="xref py py-class docutils literal notranslate"><span class="pre">FloatingBody</span></code></a> for irregular frequencies removal (<a class="reference external" href="https://github.com/capytaine/capytaine/pull/521">PR 521</a>).
Add <a class="reference internal" href="developer_manual/api/capytaine.meshes.meshes.html#capytaine.meshes.meshes.Mesh.extract_lid" title="capytaine.meshes.meshes.Mesh.extract_lid"><code class="xref py py-meth docutils literal notranslate"><span class="pre">extract_lid()</span></code></a> method to manipulate lids (<a class="reference external" href="https://github.com/capytaine/capytaine/pull/559">PR 559</a>).</p></li>
Add <a class="reference internal" href="developer_manual/api/capytaine.meshes.meshes.html#capytaine.meshes.meshes.Mesh.extract_lid" title="capytaine.meshes.meshes.Mesh.extract_lid"><code class="xref py py-meth docutils literal notranslate"><span class="pre">extract_lid()</span></code></a> method to manipulate lids (<a class="reference external" href="https://github.com/capytaine/capytaine/pull/559">PR 559</a>).
Add a warning to the user if irregular frequencies can be expected (<a class="reference external" href="https://github.com/capytaine/capytaine/pull/564">PR 564</a>).</p></li>
</ul>
</section>
<section id="minor-changes">
Expand Down
18 changes: 18 additions & 0 deletions master/developer_manual/api/capytaine.bodies.bodies.html
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,24 @@
The lid_mesh, center_of_mass, mass and hydrostatics data are discarded.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="capytaine.bodies.bodies.FloatingBody.first_irregular_frequency_estimate">
<span class="sig-name descname"><span class="pre">first_irregular_frequency_estimate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">9.81</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/capytaine/bodies/bodies.html#FloatingBody.first_irregular_frequency_estimate"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#capytaine.bodies.bodies.FloatingBody.first_irregular_frequency_estimate" title="Link to this definition"></a></dt>
<dd><p>Estimates the angular frequency of the lowest irregular
frequency.
This is based on the formula for the lowest irregular frequency of a
parallelepiped of size <span class="math notranslate nohighlight">\(L \times B\)</span> and draft <span class="math notranslate nohighlight">\(H\)</span>:</p>
<div class="math notranslate nohighlight" id="equation-developer-manual-api-capytaine-bodies-bodies-0">
<span class="eqno">(12)<a class="headerlink" href="#equation-developer-manual-api-capytaine-bodies-bodies-0" title="Link to this equation"></a></span>\[\omega = \sqrt{
\frac{\pi g \sqrt{\frac{1}{B^2} + \frac{1}{L^2}}}
{\tanh\left(\pi H \sqrt{\frac{1}{B^2} + \frac{1}{L^2}} \right)}
}\]</div>
<p>The formula is applied to all shapes to get an estimate that is usually
conservative.
The definition of a lid (supposed to be fully covering and horizontal)
is taken into account.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="capytaine.bodies.bodies.FloatingBody.from_file">
<em class="property"><span class="pre">static</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">from_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">file_format</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#capytaine.bodies.bodies.FloatingBody" title="capytaine.bodies.bodies.FloatingBody"><span class="pre">FloatingBody</span></a></span></span><a class="reference internal" href="../../_modules/capytaine/bodies/bodies.html#FloatingBody.from_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#capytaine.bodies.bodies.FloatingBody.from_file" title="Link to this definition"></a></dt>
Expand Down
1 change: 1 addition & 0 deletions master/developer_manual/api/capytaine.bodies.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ <h2>Submodules<a class="headerlink" href="#submodules" title="Link to this headi
<li class="toctree-l3"><a class="reference internal" href="capytaine.bodies.bodies.html#capytaine.bodies.bodies.FloatingBody.dof_normals"><code class="docutils literal notranslate"><span class="pre">FloatingBody.dof_normals()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="capytaine.bodies.bodies.html#capytaine.bodies.bodies.FloatingBody.each_hydrostatic_stiffness"><code class="docutils literal notranslate"><span class="pre">FloatingBody.each_hydrostatic_stiffness()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="capytaine.bodies.bodies.html#capytaine.bodies.bodies.FloatingBody.extract_faces"><code class="docutils literal notranslate"><span class="pre">FloatingBody.extract_faces()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="capytaine.bodies.bodies.html#capytaine.bodies.bodies.FloatingBody.first_irregular_frequency_estimate"><code class="docutils literal notranslate"><span class="pre">FloatingBody.first_irregular_frequency_estimate()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="capytaine.bodies.bodies.html#capytaine.bodies.bodies.FloatingBody.from_file"><code class="docutils literal notranslate"><span class="pre">FloatingBody.from_file()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="capytaine.bodies.bodies.html#capytaine.bodies.bodies.FloatingBody.from_meshio"><code class="docutils literal notranslate"><span class="pre">FloatingBody.from_meshio()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="capytaine.bodies.bodies.html#capytaine.bodies.bodies.FloatingBody.integrate_pressure"><code class="docutils literal notranslate"><span class="pre">FloatingBody.integrate_pressure()</span></code></a></li>
Expand Down
Loading

0 comments on commit 9e61ab5

Please sign in to comment.