Filter a 3D scalar field
Exercise 02
In this section you'll learn how to filter a 3D field using the Scalar3D class.
Make sure to download the data folder from the GitHub repo to be able to do this tutorial until the end
"""
Created on Fri May 24 12:00:20 2024
@author: lorenzo piu
"""Import and define array
First of all, it's necessary to import the modules that we will use in this tutorial
>>> import aPrioriDNS.DNS as DNS
>>> from aPrioriDNS.DNS import Scalar3DAgain we are going to use the class Scalar3D object assigning a value, which is not the main purpose of the class, but it can be useful to have this option.
Let's define a 3d numpy vector:
>>> shape = [4, 2, 4]
>>> array = np.ones(shape)
>>> array[2:3, :, 2:3] = 2
>>> print(array)
[[[1. 1. 1. 1.]
[1. 1. 1. 1.]]
[[1. 1. 1. 1.]
[1. 1. 1. 1.]]
[[1. 1. 2. 1.]
[1. 1. 2. 1.]]
[[1. 1. 1. 1.]
[1. 1. 1. 1.]]]Filter 3D array
Filter the field with a Gaussian filter:
At this point let's see how we can filter a scalar inside our DNS field. The procedure to load the files' information is the same as in the previous tutorial
Define Temperature field as a Scalar3D object
Filter the scalar with a Gaussian filter
Filter the scalar with a Box filter
I know it's not optimal to visualize the effect of the filtering operation in this way, so if you're curious to see how this affects the temperature field, I suggest reading the next two exercises.
Last updated