Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
fenicsx [2023/03/24 14:37] – bdatta1 | fenicsx [2024/04/18 10:33] (current) – [Learning FEniCSx] bdatta1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== What is FEniCSx ===== | + | ===== FEniCSx ===== |
- | FEniCSx is an open source multi-platform computing environment to solve partial differential equations using finite element method. FEniCSx supports parallel computing with Python and C++ interface. FEniCSx is comprised of the libraries UFL, Basix, FFCx and DOLFINx which are the build blocks of it. To learn more about FEniCSx: https:// | + | FEniCSx is an open-source multi-platform computing environment to solve partial differential equations using the finite element method. FEniCSx supports parallel computing with Python and C++ interface. FEniCSx is comprised of the libraries UFL, Basix, FFCx, and DOLFINx which are the build blocks of it. To learn more about FEniCSx: |
- | The FEniCS project originally started in 2003 and was known as FEniCS. In 2020, the developers released a new version of the library and renamed FEniCS as FEniCSx. The latest stable version of legacy FEniCS was released | + | The FEniCS project originally started in 2003 and was known as FEniCS. In 2020, the developers released a new version of the library and renamed FEniCS as FEniCSx. The latest stable version of legacy FEniCS was released |
- | Both FEniCSx and FEniCS are available on Linux, macOS, and Windows. You can download and install it in different ways. Check out the options here for FEniCSx: https:// | + | Both FEniCSx and FEniCS are available on Linux, macOS, and Windows. You can download and install it in different ways. Check out the options here for FEniCSx: |
- | ===== Installation on Windows ===== | + | |
+ | ==== Installation on Windows ===== | ||
This step in only applicable if you are using Windows. You will have to set up Windows Subsystem for Linux (WSL) to use Anaconda based installation of FEniCSx and legacy FEniCS. WSL is a virtual Linux environment within Windows which allows you to use Linux command line tools and GUI applications (GUI is natively supported on Windows 11). If you are on macOS or Linux, you can skip this step. If you are on Windows and already have installed WSL, it still might be interesting to download the recommended applications/ | This step in only applicable if you are using Windows. You will have to set up Windows Subsystem for Linux (WSL) to use Anaconda based installation of FEniCSx and legacy FEniCS. WSL is a virtual Linux environment within Windows which allows you to use Linux command line tools and GUI applications (GUI is natively supported on Windows 11). If you are on macOS or Linux, you can skip this step. If you are on Windows and already have installed WSL, it still might be interesting to download the recommended applications/ | ||
- | ===== Get your tools ready first ===== | + | ==== Get your tools ready first ===== |
==== PowerShell 7 ==== | ==== PowerShell 7 ==== | ||
Line 25: | Line 26: | ||
Windows Terminal is a command line tool, available on **Microsoft Store** (https:// | Windows Terminal is a command line tool, available on **Microsoft Store** (https:// | ||
- | ===== Windows Subsystem for Linux (WSL) ===== | + | ==== Windows Subsystem for Linux (WSL) ===== |
The current stable version for Windows Subsystem for Linux is WSL2 and this is the default installation. | The current stable version for Windows Subsystem for Linux is WSL2 and this is the default installation. | ||
- Open PowerShell 7.X.Y (your current installation version) as **administrator** using the Terminal app from the Windows Start menu and then type the following command: < | - Open PowerShell 7.X.Y (your current installation version) as **administrator** using the Terminal app from the Windows Start menu and then type the following command: < | ||
- | | + | $ wsl --list --online </ |
- Install the latest LTS version of Ubuntu which is Ubuntu 22.04.02 LTS. < | - Install the latest LTS version of Ubuntu which is Ubuntu 22.04.02 LTS. < | ||
- We will now update the Ubuntu distribution and install two packages for WSL virtual display settings. < | - We will now update the Ubuntu distribution and install two packages for WSL virtual display settings. < | ||
Line 37: | Line 38: | ||
- You can open the WSL home directory and browse, copy, and move files like Windows. Once you have installed Ubuntu in WSL and VS Code, you can follow these tutorials to get yourself more familiarized with the VS Code environments and capabilities in WSL: https:// | - You can open the WSL home directory and browse, copy, and move files like Windows. Once you have installed Ubuntu in WSL and VS Code, you can follow these tutorials to get yourself more familiarized with the VS Code environments and capabilities in WSL: https:// | ||
- | ===== Anaconda on Linux (WSL) and macOS ===== | + | ==== Anaconda on Linux (WSL) and macOS ===== |
If this is the first time you are using Python, then seat back, it is going to get confusing like this xkcd comic. Even if you are experienced in Python, you might find this interesting (https:// | If this is the first time you are using Python, then seat back, it is going to get confusing like this xkcd comic. Even if you are experienced in Python, you might find this interesting (https:// | ||
Line 43: | Line 44: | ||
Most of the Python based libraries and packages often depend on other libraries and packages (called dependencies). Installing the right version of those packages and maintaining them is often a complex task even for experienced developers. So, we will use a popular Python distribution, | Most of the Python based libraries and packages often depend on other libraries and packages (called dependencies). Installing the right version of those packages and maintaining them is often a complex task even for experienced developers. So, we will use a popular Python distribution, | ||
- | - This step is only for macOS. We will install '' | + | - This step is only for macOS. We will install '' |
- | - Download Anaconda from here based on your operating system and architecture: | + | (base) $ xcode-select --install </ |
- | - For WSL, you will download the installation script. Open Ubuntu terminal and use the following command to copy this script from your Windows Downloads folder to WSL home directory: < | + | - Download Anaconda from here based on your operating system and architecture: |
- | - '' | + | - For WSL, you will download the installation script. Open Ubuntu terminal and use the following command to copy this script from your Windows Downloads folder to WSL home directory: < |
- | - Please make sure to use the version you downloaded. It will ask you to read the license agreement and your permission for installation. Proceed as needed. Close the Ubuntu terminal and open it back, you will see the base environment for Anaconda is now available. This is how your terminal is going to look like: < | + | - Once it is downloaded to the home directory, you can run the following command on Ubuntu terminal for installation: |
+ | - Please make sure to use the version you downloaded. It will ask you to read the license agreement and your permission for installation. Proceed as needed. Close the Ubuntu terminal and open it back, you will see the base environment for Anaconda is now available. This is how your terminal is going to look like: < | ||
+ | (base) $ </ | ||
- Check out these operations and commands for using Conda: https:// | - Check out these operations and commands for using Conda: https:// | ||
- | ===== FEniCSx on Linux and macOS ===== | + | ==== FEniCSx on Linux and macOS ===== |
As of March 2023, the latest stable release of '' | As of March 2023, the latest stable release of '' | ||
- | - Once Anaconda is properly installed, create an environment for FEniCSx. In addition to the '' | + | - Once Anaconda is properly installed, create an environment for FEniCSx. In addition to the '' |
(base) | (base) | ||
(base) | (base) | ||
Line 63: | Line 66: | ||
(base) | (base) | ||
- | ===== Legacy FEniCS on Linux and macOS (optional) ===== | + | ==== Legacy FEniCS on Linux and macOS (optional) ===== |
A lots of the tutorials, examples, and published codes are still written in legacy FEniCS. So, you may want to install the legacy version in case you want to run codes written in legacy FEniCS. | A lots of the tutorials, examples, and published codes are still written in legacy FEniCS. So, you may want to install the legacy version in case you want to run codes written in legacy FEniCS. | ||
Line 76: | Line 79: | ||
(base) | (base) | ||
- | ===== An alternative way to install on Ubuntu (not recommended) ===== | + | ==== An alternative way to install on Ubuntu (not recommended) ===== |
- On Ubuntu, we can also install FEniCSx using '' | - On Ubuntu, we can also install FEniCSx using '' | ||
Line 88: | Line 91: | ||
$ sudo apt purge --auto-remove fenicsx </ | $ sudo apt purge --auto-remove fenicsx </ | ||
- | ===== Visual Studio Code (optional but recommended) ===== | + | ==== Visual Studio Code (optional but recommended) ===== |
Visual Studio Code is a cross-platform code editor from Microsoft. You can install different extensions within VS Code to enable features for code development such as remote SSH, debugging, compiling, etc. If you have another favorite IDE (e.g., Spyder or PyCharm) or code editor (e.g., Sublime text, Atom, Notepad++) you like to use, you can configure it yourself. | Visual Studio Code is a cross-platform code editor from Microsoft. You can install different extensions within VS Code to enable features for code development such as remote SSH, debugging, compiling, etc. If you have another favorite IDE (e.g., Spyder or PyCharm) or code editor (e.g., Sublime text, Atom, Notepad++) you like to use, you can configure it yourself. | ||
Line 97: | Line 100: | ||
- Once installed, add the extension packs for Python, Remote Development, | - Once installed, add the extension packs for Python, Remote Development, | ||
- | ===== Test your FEniCSx installation ===== | + | ==== Test your FEniCSx installation ===== |
We will now demonstrate how to run a simple FEniCSx example code here using VS Code. If you open Ubuntu or macOS terminal now, you will see the '' | We will now demonstrate how to run a simple FEniCSx example code here using VS Code. If you open Ubuntu or macOS terminal now, you will see the '' | ||
Line 198: | Line 201: | ||
</ | </ | ||
- Now run the python code from the Ubuntu terminal: < | - Now run the python code from the Ubuntu terminal: < | ||
- | - This should save '' | + | - This should |
- | ===== A few more settings ===== | + | ==== A few more settings ===== |
If this is the first time you are setting up Python and Anaconda on macOS or WSL, you may need to follow a few more steps for smooth operation. If you have done used Anaconda + VS Code combination before, you might find some of these steps redundant. | If this is the first time you are setting up Python and Anaconda on macOS or WSL, you may need to follow a few more steps for smooth operation. If you have done used Anaconda + VS Code combination before, you might find some of these steps redundant. | ||
Line 228: | Line 231: | ||
- This will return the following on your terminal: < | - This will return the following on your terminal: < | ||
- | ===== Known issues with PyVista ===== | + | ==== Known issues with PyVista ===== |
- PyVista plot window needs to be closed before proceeding to the next action (saving the file or plotting another image). To take screenshot on Windows (or WSL), use '' | - PyVista plot window needs to be closed before proceeding to the next action (saving the file or plotting another image). To take screenshot on Windows (or WSL), use '' | ||
- WSL on Windows 10 lacks native X-11 forwarding support. When the code is run from the terminal or a Python file from VS Code, plotting through '' | - WSL on Windows 10 lacks native X-11 forwarding support. When the code is run from the terminal or a Python file from VS Code, plotting through '' | ||
- If you are running the Python code interactively from VS Code on WSL, it can show the interactive plot within the Jupyter notebook environment but it has trouble saving the screenshot as '' | - If you are running the Python code interactively from VS Code on WSL, it can show the interactive plot within the Jupyter notebook environment but it has trouble saving the screenshot as '' | ||
- | - PyVista has trouble rendering higher order ($p \ge 2$) Quadrilateral and Hexahedron elements. For 2nd order Hexahedron element, it renders Tetrahedron. Visualization in ParaView works properly. | + | - PyVista has trouble rendering higher order (2nd order or higher) Quadrilateral and Hexahedron elements. For 2nd order Hexahedron element, it renders Tetrahedron. Visualization in ParaView works properly. |
+ | |||
+ | ==== Learning FEniCSx ==== | ||
+ | |||
+ | Since FEniCSx was released very recently, there aren't many tutorial or resources available based on FEniCSx. Please check the first two web resources which demonstrates some wonderful problems using FEniCSx. On the other hand, legacy FEniCS has numerous hands-on tutorials, books, and lecture series available. Fortunately, | ||
+ | |||
+ | - The FEniCx tutorial: https:// | ||
+ | - Numerical tours of computational mechanics with FEniCSx: https:// | ||
+ | - FEniCSx demos on the official site: https:// | ||
+ | - Legacy FEniCS demos on the official site: https:// | ||
+ | - Logg, Anders, Kent-Andre Mardal, and Garth Wells, eds. Automated solution of differential equations by the finite element method: The FEniCS book. Vol. 84. Springer Science & Business Media, 2012. (https:// | ||
+ | - Langtangen, Hans Petter, and Anders Logg. Solving PDEs in python: the FEniCS tutorial I. Springer Nature, 2017. (https:// | ||
+ | - Courses offered using FEniCS: https:// | ||