Skip to content

Commit

Permalink
todo: updating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus committed Aug 26, 2022
1 parent 87a8cac commit 0e63cc1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 140 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ jobs:
- name: Run Python tests
run: python -m unittest discover tests

- name: Run examples (statics)
working-directory: docs/examples/statics
run: |
python fixed-displacement_elastic.py
python fixed-displacement_elastic_manual-partition.py
python partial-periodic_elastic.py
python periodic_elastoplastic.py
python periodic_elastoplastic_finite-strain.py
- name: Build doxygen-docs (error on warning)
if: runner.os == 'macOS'
working-directory: build
Expand Down
180 changes: 40 additions & 140 deletions docs/examples/statics_linear.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This problem can be modelled and discretised using symmetry as show below.
In this example we will furthermore assume that the bar is sufficiently thick
in the out-of-plane direction to be modelled using two-dimensional plane strain.

.. image:: statics/FixedDisplacements_LinearElastic/problem-sketch.svg
.. image:: statics/fixed-displacement_elastic_sketch.svg
:width: 300px
:align: center

Expand All @@ -21,107 +21,42 @@ For simplicity the material model is taken from
not about constitutive modelling.
The full example can be downloaded run as follows:

.. tabs::

.. group-tab:: C++

:download:`CMakeLists.txt <statics/FixedDisplacements_LinearElastic/CMakeLists.txt>`
:download:`example.cpp <statics/FixedDisplacements_LinearElastic/example.cpp>`
:download:`plot.py <statics/FixedDisplacements_LinearElastic/plot.py>`

To compile we can use for example *CMake*:

.. literalinclude:: statics/FixedDisplacements_LinearElastic/CMakeLists.txt
:language: cmake
:lines: 1-13

Whereby we notice the use of *GMatElastic* as described,
but also *HighFive* illustrate a way of storing data and then plotting it with Python.

Proceed for example as follows:

1. Get the prerequisites::

conda install -c conda-forge goosefem gmatelastic highfive python goosempl

2. Compile::

cmake -Bbuild
cd build
cmake --build .

3. Run::

./example

4. Plot::

python ../plot.py

.. group-tab:: Python

| :download:`example.py <statics/FixedDisplacements_LinearElastic/example.py>`
| :download:`example.py <statics/fixed-displacement_elastic.py>`
In this example we illustrate some basic plotting.
In this example we illustrate some basic plotting.

Proceed for example as follows:
Proceed for example as follows:

1. Get the prerequisites::
1. Get the prerequisites::

conda install -c conda-forge python-goosefem python-gmatelastic goosempl
conda install -c conda-forge python-goosefem python-gmatelastic goosempl

2. Run (and plot)::
2. Run (and plot)::

python example.py
python fixed-displacement_elastic.py --plot

Include library
===============

.. tabs::

.. group-tab:: C++

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.cpp
:language: cpp
:lines: 1-4
:emphasize-lines: 2-3

.. group-tab:: Python

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
:language: python
:lines: 1-9
:emphasize-lines: 4

The first step is to include the header-only library.
Some dependencies are included for convenience.
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 1-6
:emphasize-lines: 4

Define mesh
===========

.. tabs::

.. group-tab:: C++

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.cpp
:language: cpp
:dedent: 4
:lines: 11-30
:emphasize-lines: 2

.. group-tab:: Python

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
:language: python
:lines: 14-33
:emphasize-lines: 2
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 11-24
:emphasize-lines: 2

A mesh is defined using *GooseFEM*.
As observed the *mesh* is a class that has methods to extract the relevant information
such as the nodal coordinates (*coor*), the connectivity (*conn*),
the degrees-of-freedom per node (*dofs*) and several node-sets that
will be used to impose the sketched boundary conditions
(*nodesLft*, *nodesRgt*, *nodesTop*, *nodesBot*).
(*nodesRightEdge*, *nodesTopEdge*, *nodesLeftEdge*, *nodesBottomEdge*).

Note that:

Expand All @@ -140,20 +75,9 @@ Note that:
Define partitioning
===================

.. tabs::

.. group-tab:: C++

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.cpp
:language: cpp
:dedent: 4
:lines: 35-40

.. group-tab:: Python

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
:language: python
:lines: 38-45
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 27-34

We will reorder such that degrees-of-freedom are ordered such that

Expand All @@ -173,22 +97,10 @@ To achieve this we start by collecting all prescribed degrees-of-freedom in *iip
(Avoid) Book-keeping
====================

.. tabs::

.. group-tab:: C++

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.cpp
:language: cpp
:dedent: 4
:lines: 45
:emphasize-lines: 1

.. group-tab:: Python

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
:language: python
:lines: 51
:emphasize-lines: 1
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 40
:emphasize-lines: 1

To switch between the three of *GooseFEM*'s data-representations,
an instance of the *Vector* class is used.
Expand Down Expand Up @@ -219,22 +131,10 @@ This instance, *vector*, will enable us to switch between a vector field (e.g. t
System matrix
=============

.. tabs::

.. group-tab:: C++

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.cpp
:language: cpp
:dedent: 4
:lines: 48-49
:emphasize-lines: 1

.. group-tab:: Python

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
:language: python
:lines: 54-55
:emphasize-lines: 1
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 43-33
:emphasize-lines: 1

We now also allocate the system/stiffness system (stored as sparse matrix).
Like vector, it can accept and return different vector representations,
Expand Down Expand Up @@ -287,7 +187,7 @@ and allow a generic API:

.. group-tab:: Python

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 57-64

Expand Down Expand Up @@ -351,7 +251,7 @@ Element definition

.. group-tab:: Python

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 70-71

Expand Down Expand Up @@ -392,7 +292,7 @@ Material definition

.. group-tab:: Python

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 74

Expand Down Expand Up @@ -428,7 +328,7 @@ Allocate integration point tensors

.. group-tab:: Python

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 77-79

Expand Down Expand Up @@ -489,7 +389,7 @@ Compute strain

.. tab:: pre-allocate

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 85-86
:emphasize-lines: 2
Expand Down Expand Up @@ -539,7 +439,7 @@ Compute stress and tangent

.. tab:: pre-allocate

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 89-91

Expand Down Expand Up @@ -581,7 +481,7 @@ Assemble system

.. tab:: pre-allocate

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 93-99

Expand Down Expand Up @@ -643,7 +543,7 @@ Solve

.. tab:: pre-allocate

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 101-111

Expand Down Expand Up @@ -696,7 +596,7 @@ Strain and stress

.. tab:: pre-allocate

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 118-120

Expand Down Expand Up @@ -744,7 +644,7 @@ Residual force

.. tab:: pre-allocate

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 122-133

Expand Down Expand Up @@ -781,12 +681,12 @@ Plot

Let's extract the average stress per element:

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 135-137

And plot an equivalent stress on a deformed mesh:

.. literalinclude:: statics/FixedDisplacements_LinearElastic/example.py
.. literalinclude:: statics/fixed-displacement_elastic.py
:language: python
:lines: 149-189

0 comments on commit 0e63cc1

Please sign in to comment.