Commit 3a48ef99 authored by Jeremy BLEYER's avatar Jeremy BLEYER

Finished MFront example with install script

parent 8b0436d4
......@@ -22,8 +22,8 @@ import shutil
import zipfile
# extensions of files which must be copied with the demo when building docs
file_extensions = [".png",".gif", ".geo", ".xml", ".msh", ".pdf", ".mfront"]
zipfile_extensions = [".geo", ".msh", ".xml", ".py", ".ipynb", ".mfront"]
file_extensions = [".png",".gif", ".geo", ".xml", ".msh", ".pdf", ".mfront", ".sh"]
zipfile_extensions = [".geo", ".msh", ".xml", ".py", ".ipynb", ".mfront", ".sh"]
def process():
"""Copy demo rst files (C++ and Python) from the DOLFIN source tree
......
#! /usr/bin/env bash
# This scripts is meant to install the development versions of TFEL
# and MGIS.
# The user must change the PREFIX variable to match its needs.
# Once the script is finished you can use TFEL and MGIS by running:
# source <PREFIX>/codes/mgis/master/install/env.sh
# Before running the script, the user must install the appropriate
# prerequisites.
# On ubuntu, please run:
# sudo apt-get install cmake libboost-all-dev g++ gfortran
# sudo apt-get install git libqt5svg5-dev qtwebengine5-dev
# sudo apt-get install python3-matplotlib
# Note: by default, the FEniCS interface is disabled.
# If FEniCS is installed, you can unable it by changing
# `-Denable-fenics-bindings=OFF` to
# `-Denable-fenics-bindings=ON`
#
# Those bindings are *not* required to run the examples of Jérémy
# Bleyer which are based on the `python` bindings.
# See https://thelfer.github.io/mgis/web/FEniCSBindings.html
# for details.
set -e
PREFIX=$HOME
PYTHON_VERSION=$(python3 --version|awk '{print $2}'|awk 'BEGIN{FS="."} {print $1 "." $2}')
export TFELSRC=$PREFIX/codes/tfel/master/src
export MGISSRC=$PREFIX/codes/mgis/master/src
export TFELBASEHOME=$PREFIX/codes/tfel/master
export MGISBASEHOME=$PREFIX/codes/mgis/master
mkdir -p $TFELSRC
mkdir -p $MGISSRC
pushd $TFELSRC
if [ -d tfel ]
then
pushd tfel
git pull
popd
else
git clone https://github.com/thelfer/tfel.git
fi
popd
pushd $MGISSRC
if [ -d MFrontGenericInterfaceSupport ]
then
pushd MFrontGenericInterfaceSupport
git pull
popd
else
git clone https://github.com/thelfer/MFrontGenericInterfaceSupport.git
fi
popd
tfel_rev=$(cd $TFELSRC/tfel;git rev-parse HEAD)
mgis_rev=$(cd $MGISSRC/MFrontGenericInterfaceSupport;git rev-parse HEAD)
export TFELHOME=$TFELBASEHOME/install-${tfel_rev}
export MGISHOME=$MGISBASEHOME/install-${mgis_rev}
pushd $TFELBASEHOME
tfel_previous=$(ls -1dtr install-* | tail -1)
tfel_previous_rev=${tfel_previous#install-}
popd
echo "tfel current revision : $tfel_rev"
echo "tfel previous revision : $tfel_previous_rev"
if [ x"$tfel_previous_rev" != x"$tfel_rev" ];
then
pushd $TFELSRC
mkdir -p build
pushd build
cmake ../tfel -DCMAKE_BUILD_TYPE=Release -Dlocal-castem-header=ON -Denable-aster=ON -Denable-abaqus=ON -Denable-calculix=ON -Denable-ansys=ON -Denable-europlexus=ON -Denable-python=ON -Denable-python-bindings=ON -DPython_ADDITIONAL_VERSIONS=$PYTHON_VERSION -DCMAKE_INSTALL_PREFIX=$TFELHOME
make
make install
popd
popd
cat >> ${TFELHOME}/env.sh <<EOF
export TFELHOME=${TFELHOME}
export PATH=${TFELHOME}/bin:\$PATH
export LD_LIBRARY_PATH=${TFELHOME}/lib:\$LD_LIBRARY_PATH
export PYTHONPATH=${TFELHOME}/lib/python${PYTHON_VERSION}/site-packages/:\$PYTHONPATH
EOF
pushd $TFELBASEHOME
count=$(ls -1d install-* | wc -l)
if (( $count > 4 )) ; then
find . -maxdepth 1 -ctime +60 -name "install-*" -exec rm -rf {} \;
fi
last=$(ls -1dtr install-* | tail -1)
ln -nsf "${last}" install
fi
source ${TFELHOME}/env.sh
pushd $MGISBASEHOME
mgis_previous=$(ls -1dtr install-* | tail -1)
mgis_previous_rev=${mgis_previous#install-}
popd
if [ x"$tfel_previous_rev" != x"$tfel_rev" ] || [ x"$mgis_previous_rev" != x"$mgis_rev" ];
then
pushd $MGISSRC
mkdir -p build
pushd build
cmake ../MFrontGenericInterfaceSupport -DCMAKE_BUILD_TYPE=Release -Denable-python-bindings=ON -Denable-fortran-bindings=ON -Denable-c-bindings=ON -Denable-fenics-bindings=OFF -DCMAKE_INSTALL_PREFIX=$MGISHOME
make
make install
popd
popd
cat >> ${MGISHOME}/env.sh <<EOF
export MGISHOME=${MGISHOME}
source ${TFELHOME}/env.sh
export PATH=${MGISHOME}/bin:\$PATH
export LD_LIBRARY_PATH=${MGISHOME}/lib:\$LD_LIBRARY_PATH
export PYTHONPATH=${MGISHOME}/lib/python${PYTHON_VERSION}/site-packages/:\$PYTHONPATH
EOF
pushd $MGISBASEHOME
count=$(ls -1d install-* | wc -l)
if (( $count > 4 )) ; then
find . -maxdepth 1 -ctime +60 -name "install-*" -exec rm -rf {} \;
fi
last=$(ls -1dtr install-* | tail -1)
ln -nsf "${last}" install
fi
......@@ -8,6 +8,8 @@
Elasto-plastic analysis implemented using the `MFront` code generator
======================================================================
This numerical tour has been written in collaboration with **Thomas Helfer** (thomas.helfer@cea.fr), MFront's main developper.
-------------
Introduction
-------------
......@@ -32,21 +34,44 @@ to the previous tutorial for more details. The sources can be downloaded from
Let us point out that a pure FEniCS implementation was possible **only for this specific constitutive law**,
namely von Mises plasticity with isotropic linear hardening, since the return mapping step
is analytical in this case and can be expressed using simple UFL operators. The use of `MFront`
can therefore make it possible to consider more complex material laws. This will be
illustrated in forthcoming tutorials.
can therefore make it possible to consider more complex material laws. Indeed, one only has to change
the names of the behaviour and library generated by `MFront` to change the material behaviours, which
can be arbitraly complex (although limited to small strains). This will be illustrated in forthcoming tutorials.
Interested users may have a look at the examples of the `MFront` gallery to have a small overview of
`MFront` abilities: http://tfel.sourceforge.net/gallery.html
-------------
Prerequisites
-------------
In order to run this numerical tour, you must first install the TFEL library on which `MFront`
is built as well as MGIS (`MFrontGenericInterfaceSupport`). Please note that development
versions are used for now.
To proceed with the installation, we provide the following installation shell script :download:`install.sh`.
Before running it, please install the necessary prerequisites mentioned in the script, e.g. on Ubuntu run::
> sudo apt-get install cmake libboost-all-dev g++ gfortran
> sudo apt-get install git libqt5svg5-dev qtwebengine5-dev
> sudo apt-get install python3-matplotlib
Once the installation script finished installing TFEL and MGIS, you can use MGIS by running the
following command::
> source <PREFIX>/codes/mgis/master/install/env.sh
in which ``<PREFIX>`` is the installation directory you have chosen.
As recalled later in the tutorial, the MFront behaviour file must first be compiled before running
this Python script. The compilation command is::
> mfront --obuild --interface=generic IsotropicLinearHardeningPlasticity.mfront
-----------------
Problem position
-----------------
The present implementation will heavily rely on ``Quadrature`` elements to represent
previous and current stress states as well as internal state variables (cumulated
previous and current stress states, internal state variables (cumulated
equivalent plastic strain :math:`p` in the present case) as well as components
of the tangent stiffness matrix. The use of ``quadrature`` representation is therefore
still needed to circumvent the known issue with ``uflacs``::
......@@ -339,21 +364,49 @@ behaviour and the previous displacement variable are updated::
u.assign(u1)
# update the material
mgis_bv.update(m)
--------
Results
--------
# postprocessing results
file_results.write(u, t)
p_avg.assign(project(p, P0))
file_results.write(p_avg, t)
results[i+1, :] = (u(Ri, 0)[0], t)
import matplotlib.pyplot as plt
plt.plot(results[:, 0], results[:, 1], "-o")
plt.xlabel("Displacement of inner boundary")
plt.ylabel(r"Applied pressure $q/q_{lim}$")
plt.show()
.. note::
Note that we defined the cumulative plastic strain variable :math:`p` in FEniCS
only for post-processing purposes. In fact, FEniCS deals only with the global equilibrium
whereas `MFront` manages the history of internal state variables, so that this variable
would not have been needed if we were not interested in post-processing it.
-------------------------
Results and future works
-------------------------
We can verify that the convergence of the Newton-Raphson procedure is extremely similar
between the MFront-based implementation and the pure FEniCS one, the same number of
between the `MFront`-based implementation and the pure FEniCS one, the same number of
iterations per increment is obtained along with close values of the residual.
**Total computing time** took approximately:
* 5.9s for the present MFront implementation against
* 5.9s for the present `MFront` implementation against
* 6.8s for the previous FEniCS-only implementation
Several points need to be mentioned regarding this implementation efficiency:
* MGIS can handle parallel integration of the constitutive law which has not been used
for the present computation
* the present approach can be improved by letting MGIS reuse the memory already allocated
by FEniCS which will reduce information transfer times and memory consumption
* extension to large strains is a work in progress
* this FEniCS/MGIS coupling will make it possible, in a near future, to test in a rapid
manner generalized constitutive laws (higher-order theories, phase-field) and/or
multiphysics couplings
------------
References
------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment