Skip Navigation | ANU Home | Search ANU | Search FEIT | Feedback
The Australian National University
Faculty of Engineering and Information Technology (FEIT)
Department of Computer Science
Printer Friendly Version of this Document
High Performance Scientific Computing COMP3320

COMP3320/COMP6464 Cloth Dyanmics Project

D R A F T

Worth 20%, due by 18:00 on Friday 30 May 2008

This project extends the concepts introduced in assignment 1 to build a simulation of a cloth falling under gravity on a stationary spherical object. The cloth is modelled as a 2-D rectangular network, where node (x,y) (x and y are integers) in an (N*N) square network interacts with all other nodes (x+delta,y+delta) where delta is some (low value) integer. Thus if delta=1 a typical node will interact with 8 neigbouring nodes, while if delta=2 there are 24 interactions to consider. When a node is located on the cloth there may be fewer interactions. Thus in contrast to the MD simulation each node in the network interacts with a finite number of other nodes, making evaluation of the total interaction potential O(n), where n is the number of nodes.

Between each pair of nodes we define an interaction given by Hookes law.

PE12 = K*(R12-Eq12)2
Fx12 = K*(R12-Eq12)*(X1-X2)/R12

Where K is the force constant determining how stiff the spring is, R12 is the Euclidean distance between the two nodes and Eq12 is the equilibrium distance between these two nodes. For example if node (1,1) and node (1,2) have Eq12=1*d then node (1,1) and node (2,2) have Eq12=sqrt(2)*d.

Each node we will assign a mass, noting that the force and accelaration are related by F=ma. The cloth is initially positioned in the xz plane and subjected to a gravitational force g in the y direction. As a consequence the cloth will slowly fall under gravity.

Positioned below the cloth is a ball of radius, r, such that the centre of the cloth is located 1+r units above the centre of the ball. The cloth is allowed to fall under gravity until it collides with the ball. You follow the motions of the nodes using the same velocity verlet algorithm that you used for the MD. The difference arises when a node in the cloth hits the ball. You detect this by noticing that the updated position of the node is within the radius of the ball. At this point you move the node to the nearest point on the surface of the ball.

While building on the understanding you gained in assignment 1 concerning numerical simulation, an important part of this assignment will be parallelising your simulation code. I will detail what is required for the parallelisation later, when we have covered the relevant material in lectures. Before getting to that part, however, there is considerable work to do and things you need to fully appreciate!


STEP 1


    I have written python code cloth1.py that performs this basic simulation. Download and run this code. Make sure you understand what this code is doing.
    • As discussed in lectures, something is not quite right! Your first objective will be to implement the fixes discussed in lectures. (If you did not attend the lecture, listen to the recording. The problem with the code is NOT a fundamental programming error, rather the code correctly implements the velocity verlet algorithm for the network of nodes that we use to model the cloth. The issue is that we need to make some more modifications to the simulation in order to make it behave in the way we want it to for this problem.)
    • DON'T DO THIS NOW - GOTO STEP 2: Your second objective is to rewrite most of the code in C or C++. Reproduce something like what I demonstrate in lectures. Namely the C code should do the majority of the simulation. Your python front end contains the simulation loop, requesting the C code to do a certain number of simulation steps before returning with updated geometry. (Note - you can begin this work even if you have not fixed the problem in the original python code. Any fix you implement will be easy to put into the C code.)

STEP 2:


    This part of the assignment will be discussed in detail in the lecture on Wednesday 7th May. Accounts for fremont are only available from me or Rui in your lab.

    Rather than using C and Python, we are going to use C with OpenGL running the application of machine fremont. Your fellow student Ben Murphy has kindly written the OpenGL stuff. Your task is to write the bit of C code for the cloth simulation that goes with this. You should download file comp3320-cloth-fremont.tar copy it to fremont and untar the file. You will find a README file telling you what to do. If you are having any problems with this part of the assignment you need to see me. I don't want anyone spending more than 5 hours trying to complete the C code - it should take less than this.


STEP 3:


    Your task is to parallelise cloth simulation portion of your C/OpenGL code using OpenMP and analyse its performance on fremont.
    • Notes:
      • There was an error in the way I was calculating the potential in the testcloth.o distributed with the original tar file. The tar file was replaced. See message on forum about this.
      • Also my testcloth.o is not using the mass (essentially assuming each node is of unit mass). This also means that the force due to gravity is not scaled by the mass. Your code should reproduce my code (inclusive of the wrong physics!).
    • You are only required to parallelise the code that you write to implement the operations of loopcloth and initialize, i.e. what you will put in file mycloth.c.
    • You are required to add another input flag to your program (possibly to file opengl_stuff.c), denoted as -p, that reads in an integer that is used to set the maximum number of OpenMP threads (or light weight processes) used by your code.
    • Your code will be tested to ensure the visualization is working, but for evaluating performance visualization will be switched off. The following are two typical input data sets that may be use to assess the performance of your code (there will be others):
            ./testcloth -n 50 -x 10001 -u 500 -p 1
            ./testcloth -n 100 -s 0.25 -x 10001 -u 500 -p 16
      

    As for assignment 1 you are required to submit a single tar file using the submit tool on one of the student computers:

        submit comp3320 cloth_project cloth.tar
    
    or if you are a COMP6464 student
        submit comp6464 cloth_project cloth.tar
    
    The tar file should expand to give a directory that contains the following
    • All the source code together with a Makefile that will build your version of mycloth by just typing "make". (You should have learnt from assignment 1 that I do expect you to modify the original Makefile provided with the initial tar file to include appropriate compiler optimisation flags!).
    • A plain text file (not a PDF) called README that tells the user (me) exactly how to run your code and either contains or points the user to some sample input/output data so they can verify that your code works (or gives identical results to what you got).
    • A plain text file (not a PDF) called WRITEUP that details how long it took you to complete this assignment, states whether you completed this assignment by yourself or whom you collaborated with, and provides a critical analysis of your code and its parallel performance. (Note this was something that almost all of you did quite poorly for assignment 1 - I'm looking for something better this time.)
    • The requirements for COMP3320 and COMP6464 are the same for this assignment.
    Your code will be tested on fremont - so make sure it works on this system. Within reason you can use anything you find generally available (not something you installed in your directory) on fremont (including libraries).
    Marks will be awarded as follows:
    • 7/20 marks on the content of your WRITEUP file
    • 7/20 marks for a functionally correct code that is documented well (in README and source files).
    • 6/20 marks for the measured performance of your code