{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from fsi_reader import FsiDataReader\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from matplotlib.tri import Triangulation\n", "from matplotlib.animation import FuncAnimation\n", "from scipy.interpolate import griddata\n", "from plotting import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Loading and Visualizing the Dataset\n", "\n", "In this section, we will explore how to load the fluid-solid interaction simulation dataset and visualize it.\n", "\n", "We will specifically load the simulation data for \\( \\mu = 1.0 \\), where the inlet parameter \\( x_1 = 0.0 \\) and the all inlet parameters for \\( x_2 \\) will be considered as provided in the dataset.\n", "\n", "Let's begin by loading the data and visualizing it to better understand its structure and behavior.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = FsiDataReader('./fsi-data/', mu=['1.0'], in_lets_x1=['0.0'])\n", "mesh = data.input_mesh\n", "print(mesh.shape)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data_loader = data.get_loader(batch_size=1, shuffle=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualization\n", "\n", "In this section, we will visualize the pressure field from the fluid-solid interaction simulation dataset.\n", "\n", "### **Loaded Variables**\n", "The dataset includes the following variables for each time step `t`:\n", "\n", "- `vx`, `vy`: The velocity components in the `x` and `y` directions, respectively.\n", "- `P`: The pressure field.\n", "- `dx`, `dy`: The displacement components in the `x` and `y` directions, respectively.\n", "\n", "These variables are loaded and will be used to generate the visualizations.\n", "\n", "### **Mesh Update**\n", "The mesh, initially given as a 2D grid, is updated at each time step based on the displacement field. Specifically, the updated mesh at time `t` is:\n", "\n", "`M_t = M_0 + d_t`\n", "\n", "where `M_0` is the initial mesh, and `d_t` represents the displacement at time `t`.\n", "\n", "### **Pressure Field Visualization**\n", "Now, we will visualize the pressure field `P_t` overlaid on the updated mesh at each time step. This will help us understand how the pressure evolves and interacts with the deformed mesh over time.\n", "\n", "Let's begin by plotting the pressure field and the updated mesh to observe their changes visually.\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "frames = 200\n", "data_list = []\n", "mesh_list = []\n", "for idx, (i,j) in enumerate(data_loader):\n", " if idx%10 !=0:\n", " continue\n", " updated_mesh = mesh + i[0,:,-2:]\n", " data_list.append(i[:,:,2].numpy()) \n", " mesh_list.append(updated_mesh.numpy())\n", " frames -= 1\n", " if frames == 0:\n", " break" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "create_field_animation(data_list, mesh_list, interval=100, save_path='fsi_animation_pressue.gif')" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "torch.Size([1317, 2])\n", "file not found for mu=1.0, x1=0.0, x2=-4.0\n", "file not found for mu=1.0, x1=0.0, x2=-2.0\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 1])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 1])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 1])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 1])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "file not found for mu=10.0, x1=0.0, x2=-4.0\n", "file not found for mu=10.0, x1=0.0, x2=-2.0\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 1])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 1])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 1])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n", "Loaded tensor Size: torch.Size([1001, 1317, 1])\n", "Loaded tensor Size: torch.Size([1001, 1317, 3])\n" ] } ], "source": [ "data = FsiDataReader('./fsi-data/', mu=['1.0', '10.0'], in_lets_x1=['0.0'])\n", "mesh = data.input_mesh\n", "print(mesh.shape)\n", "data_loader = data.get_loader(batch_size=1, shuffle=False)" ] } ], "metadata": { "kernelspec": { "display_name": "neuralop", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.9" } }, "nbformat": 4, "nbformat_minor": 2 }