CECS Home | ANU Home | Search ANU
The Australian National University
ANU College of Engineering and Computer Science
School of Computer Science
Printer Friendly Version of this Document

UniSAFE

High Performance Scientific Computing

COMP3320/COMP6464 Cloth Dyanmics Project

D R A F T (No new content to add - just submission details and clarifications)

Worth 20%

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! If you inspect the code you will see that if the new coordinates for the cloth are within the ball, then that node of the cloth is moved back to the surface of the ball. This happens here

    	for node in nodes:
    		dist = node.pos-vector(myball.x,myball.y,myball.z)
    		if dist.mag < myball.radius:
    			fvector=dist/dist.mag*myball.radius
    			node.pos=vector(myball.x,myball.y,myball.z)+fvector
    
    A problem arises in that the velocity of the node remains the same. In this step modify the code such that the component of the velocity that is in the direction of fvector above is set to zero. In otherwords only the component of the velocity that is tangential to the surface is allowed to be non-zero following a collision of a cloth node with the ball. (If you are uncertain how to do this, try using forum, or talking to Pete or I).

STEP 2


    Now rewrite most of the computationally intensive part of the code in C (or C++). That is you should have a python front end that contains the simulation loop, requesting the C code to do a certain number of simulation steps before returning with updated geometry.

STEP 3:


    Parallelise the cloth simulation portion of your code that is written in C using OpenMP to run on partch. You are required to add another input flag to your program denoted -p, that reads in an integer that is used to set the maximum number of OpenMP threads used by your code. Perform a detailed performance analysis of your OpenMP code.

    Your performance analysis should include

    • consideration of how your code scales as the number of threads increases and with problem size
    • relate observed performance to what you have learnt in the course regarding Amdahl's law andthread synchronization.
    • discussion of TWO additional points that are NOT covered in the above.

STEP 4: COMP6464 ONLY


    Run your OpenMP code on Wallaman. Provide a detailed comparison of the parallel performance you see on Wallaman with that you see on Partch. Your comparison should relate performance to the hardware architectures. (You are required to provide a single makefile and source code that will build and run the cloth simulation on both Wallaman and Partch. The only difference between the two machines should be the instructions to make, eg make cloth_wallaman, or make cloth_partch. This difference should be explained in your README file.)

    Note that you will not be able to visualize your simulation on Wallaman, so you will need to produce a code fully implemented in C in order to gather performance data. For consistency, you may have to rerun some of your tests on Partch with the new C code.


BONUS STEP: Only if you complete the above steps to high standard


    You can gain 2 bonus marks (from 20 or 25) if you complete this section. These marks will add to your normal mark, with the latter capped at 20 (COMP3320) or 25 (COMNP6464). This section will NOT be marked unless you have completed the previous steps (1-3 for COMP3320, 1-4 for COMP6464) AND then only if you have obtained a mark of at least 12/20 for those steps.

    You task here is to implement a concept of the cloth ripping. To do this add another input parameter -r that reads in a floating point number greater than 1.0 that indicates how much one of the springs can extend before they break. Give this parameter a default value of 1.5. Augment your code to print out the number of broken springs (along with the potential energy) if run in verbose mode. Have the python code remove from the visualization any "convex" if any spring that connects any two of the four vertices is broken.


MARKING AND SUBMISSION


COMP3320 Marking Guide (out of 20)
  • Step 1: 2 Marks
  • Step 2: 8 Marks (4 Marks for Simulation, 4 Marks for Implementation)
  • Step 3: 10 Marks (4 Marks for Parallelization/Coding, 2 Marks for Speed, 4 Marks for Report)
COMP6464 Marking Guide (out of 25)
  • Step 1-3: As for COMP3320
  • Step 4: 5 Marks (2 for Working Code, 3 for Performance Comparison Report)

You are required to submit a 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