Exercise 0: Introduction To Paraview and Python: 1 Subscribe To Stud - Ip
Exercise 0: Introduction To Paraview and Python: 1 Subscribe To Stud - Ip
Exercise 0: Introduction To Paraview and Python: 1 Subscribe To Stud - Ip
Lightweight construction
IFL
1 Subscribe to Stud.IP
Stud.IP is a web-based system to support the content and organization of the courses. You
will find the exercise documents, date announcement and a forum, regarding the lecture FEM 2.
Stud.IP is accessible via an Internet-Browser on the website of the TU Braunschweig.
https://studip.tu-braunschweig.de/ → Stud.IP
For login you need a valid y-number and your password. To find the course use the search function,
searching for Finite-Elemente-Methoden 2.
2 Introduction to ParaView
This section describes the program system which is used in the computer exercises.
IFL
In the Menu bar we focus on the buttons Sources and Filter. Sources are predefined cu-
stomizable data sets. Output data from other programs are often used as source for the
visualization. For visual manipulation, Filter are applied to the existing data. In this way it
is possible to e.g. display only the data which lie in a desired range of the dataset. In this
case a Threshold-Filter would be used. The pipeline, consisting of sources and filters, is shown
in the Pipeline Browser. The properties of the selected sources or filters, are in the Object
Inspector in the Properties-tab, which can be changed as desired. With the mapper settings
- meaning the surface design - the selected object can be defined under the Display-tab. The
Information-tab provides an overview of the object type and the associated values.
b.) Grid generation: Select the Plane in Menu Bar → Sources. In order to create a source, click
Apply in the Object Inspector. The visualisation in the 3D View happens automatically and
can be rotated and zoomed at will.
c.) Change the number of elements: In the Toolbar choose the drop-down menu in which
Surface is selected. Select: Surface with Edges. Under Properties set the X and Y resolu-
tion to 10. For the same plane-dimensions, the number of cell changes now to 100. The 3D
View updates automatically the new settings.
d.) Inserting a Glyph-Filter: Select in the Menu Bar → Filters → Common the filter Glyph.
Select: Apply. The filter creates an arrow at each grid point in the normal direction. The
3D View updates automatically the new settings. Under Properties the Glyph Type can be
customized. Select: Sphere. Change the radius to a value of 0.1 and select: Apply.
IFL
IFL
2. Basic elements:
• Operators: -, +, *, /, %
• Potencies: i=2**3 #2 to the power of 3
• Slicing:
s="Finite Elemente"
print s[7] #Output: "E"
print s[7:] #Output: "Elemente"
print s[7:10] #Output: "Ele"
print s[-1] #Output: "e"
print s[-5:] #Output: "mente"
Slicing also works with lists and tuples.
3. Control flow:
Note: In general, you have to indent the code in Python .
• Choice:
if i>5:
print "i greater than 5"
else:
print "i smaller than or equal to 5"
4. Modules:
A new module is defined by the keyword def, followed by the modules name and the parameter
list.
def plus(a,b):
return a+b
5. Classes:
• Classes are templates for data structures, containing methods and attributes.
• Objects are instances of classes.
• Methods are functions of objects.
• Attributes are the object data.
• The dot operator allows access to methods and attributes.
For example: A list of l=[8,9,7] is actually an object of the class List:
IFL
l=[8,9,7]
l.append(5)
print l[3] #Output: 5
l.sort()
print l #Output: [5,7,8,9]
• Custom classes are defined by the keyword class followed by class name.
6. Numeric package
• In the exercise the numerics package fem2 is used, which is based on the Standard-
Numeric-Package.
• The package is included with import fem2 in order to use the containing functions,
classes and methods.
• The package allows to instantiate matrices and vectors as objects in order to perform
easy calculations, such as inverse computation, transpose, determinant etc.
#import fem2
m1 = fem2.Identity(3) #creates a 3x3 unit-matrix
m2 = fem2.Zeros((3,3)) #creates a 3x3 null-Matrix
m3 = fem2.FMatrix( [[1,2],[3,4]] ) #creates a 2x2 matrix from lists
v1 = fem3.FVector([1,2,3]) #creates a vektor from a List
print m3**-1 #calculates the inverse of m3
print m3.I #calculates the inverse of m3
print m3.det() #calculates the determinant of m3
print m3.T #creates the transposed to m3
print m3.I * m3 #performes matrix-matrix-multiplication
print m1*v1 #performes matrix-vector-multiplication