قُلْ إِنَّ صَلَاتِي وَنُسُكِي وَمَحْيَايَ وَمَمَاتِي لِلَّـهِ رَبِّ الْعَالَمِينَ - الأنعام: ١٦٢

Showing posts with label SC. Show all posts
Showing posts with label SC. Show all posts

Monday, August 9, 2010

Scientific Computing [2/2]

السلام عليكم و رحمة الله و بركاته
Well, that was supposed to be posted a little bit earlier...


Here we are, SC Part 2 :)
[This was part 1: Scientific Computing [1/2]]



The subjects for the 2nd term were in the alphabetic order:
  • Computational Geometry
  • Distributed Computing
  • Environmental
  • Theory of Computations
  • Selected Topic


Computational Geometry was one of the good classes...we learned many algorithms & we brainstormed for solutions together. At the end of the year we made a package that could (test for line intersections, construct convex hull, test for point location & test for star shaped polygons and gets their kernel)

[some snapshots]

Distributed Computing...In this subject we studied the structure of parallel platforms...the control, communication and networks...The goal was to run an algorithm on more than one machine in parallel.
We studied many algorithms. For every algorithm, we studied how it works in series, in parallel and analyzed it.
It was an interesting subject and I enjoyed it's study...


Environmental...I can not stop remembering Dr.M.Hashim entering our exam and saying: "Any Questions?"...we replied that we're SC so we don't take security (lucky us :D) so he said: "3andoko emta7an bee2a!" (the translation for environmental) :D 
So what's about this subject?..It's name is Environmental and Global Change.
Statistical: is the set of mathematical equations that describe the behavior of an object in terms of random variables and their distributions (studied first term in Simulation)
Deterministic: outcomes are precisely determined through the relationships between the states and events in the system without using random variables (we are interested in this)

We studied the ODEs (Ordinary Differential Equations) & the PDEs (Partial Differential Equations)...how to solve them using a number of methods & how to evaluate them.
At the end we made a package that could solve differential equations in a generic way with most of the techniques.

Theory of Computations...This subject has lots of similarities with Automata (studied in our 3rd year). First we decide if a given problem is computable or not...then we study those computable problems...we find the order (P, NP),  construct a machine that would represent this problem or write a program (sometimes we're only allowed 4 basic instructions in writing our program)

Selected Topic...This is a course that you get to choose regardless to your department.
I chose to study Java with IBM corporation. I don't know whether it was the best choice or not...As a whole package (system, organizing, syllabus) I wouldn't take it again. At the beginning there was lots of problems about the groups. I lost some of the lectures..then I ended up in a group that hated their instructor! He was changed, but what do you expect from the new instructor who knows she came to substitute the one we didn't like?
Anywayz the time was also not enough for her to give us the whole syllabus...I knew the basics of Java (applications/web) and I tried to get the most benefit out of what was left

This was the 2nd term. I enjoyed being an SCian for this year.

I hope you find this post useful. May you choose the best department that would suit you. May you be compatible with it & enjoy your last year ever as an undergraduate student.

[You might be interested to look at this topic too: Starting your GP?]

Saturday, July 10, 2010

Scientific Computing [1/2]




السلام عليكم و رحمة الله و بركاته



I never thought I’d be writing this post. Actually I still have my doubts :D. I just know now, It wasn’t CSys. I love coding more than this & debugging hardware wasn’t very fun (sorry simoz :D). Definitely not IS :D (no offense :D). May be CS was a choice, but guess what?
I enjoyed my year in SC J with all the ups & downs…I took the whole package & I’d take it once more if I had the choice J

So how did it go?
1st you need to know that whatever you choose…whether it is CS, IS, CSys or SC…you’ll still be an FCISian & you’ll work wherever you want. The department does NOT define you. It’s you who define your own self. You learn, understand, solve, win, achieve, think or do whatever…not the department!
You can get the BEST of what you have just by keeping your positive attitude.

Back to SC, my dear department (a)
Visualization
Simulation
Finite Elements
High Performance Computing
Mathematical Programming
Those are the subjects for the 1st term.

Let’s start with Visualization…It’s my favorite J
1st I need to make a confession…This was one of the main subjects that attracted me to SC. During the 1st couple of lectures I totally HATED it & I thought it was gonna be the worst subject ever! Then things turned out to be VERY different. Again it became my favorite J
Dr. Ashraf Saad is really different. I was told by a friend from the previous batch that he really loved us (my class) and that he treated us differently. I learned from him how to think outside the triangle I was fitting myself in. He always had some time for free discussion…things related to the subject, but not the exam ;).
When we studied his subject (I’ll tell you later about the “we” J) we always needed to be online. Youtube & Wikipedia were our best friends, along wiz some googling of course.
The exam was way different than all the previous exams…what do you expect? He loved our class :D :D
The subject itself wasn’t complicated; we just needed to read more in order to understand. Most of the study was reflected in real life. I guess that’s why it seemed attractive to me.
Those were some related posts:

Next comes the Simulation. This was common with CS.
The core of the subject was to simulate some real system. Example: Some customers in a supermarket, they come with a certain rate that is governed by a distribution, they are serviced in a certain time & we need to find out whether the system is efficient or not.
It was nice to know that almost any real system can be simulated & studied with computers.
The thing I hated about it was the amount of rules we had to memorize. I generally don't like to memorize rules & I don't study from the beginning of the year, so I don't practice a lot. Totally my fault J.

The third subject was HPC which stands for High Performance Computing. The very special thing about this subject was the exam. It was an open everything exam...yes EVERYTHING :D
Bring all what you can bring (notes, books, summaries, exams wiz solutions, laptops & even USB modems!)
It's one of the exams where you actually use your brain and think :D
Dr.Hossam may sometimes seem to be offensive, but he really wanted our own good. He wanted us to learn right & to get the most benefit out of the subject. 
This is one of the subjects that you'll enjoy...and never forget our BEST friend...Google ;)

Next will be the Finite Elements...well I got its goal very late...and this was the main reason why I didn't like it much. We studied the materials and how the bodies are affected by tension, pressure & heat.
It wasn't very much related to our field, but you can always try to find an application that you'd relate to all the year J. After all, we're having a +ve attitude :D, aren't we?
Like simulation we needed to know many rules...so u do the math.

Finally comes the Mathematical...It was one of the nice & light subjects.
Our midterm was a take-home exam & we delivered it via mail. (Interesting, huh :D?)
It's mostly about algorithms & problem solving.
Network Flow, Graph Coloring, Assignment Problem, Queuing System, Scheduling...Along with some old algorithms like Kruskal, Prim...


I totally enjoyed the Visualization, HPC & Mathematical. I liked the Simulation & I went over the Finite Elements.

The "we" I said about earlier was SC gals. We always studied together. We used to divide each subject upon us & met to study together. Sometimes we met offline at college while others were skype conference calls. We enjoyed it a lot & it was surely beneficial.

And this was my first term in SC J
I hope it will be somehow useful J


Scientific Computing [2/2]

Saturday, April 24, 2010

Last Midterms!

السلام عليكم و رحمة الله و بركاته

I decided to keep track of every single moment that is left in college
"The Last midterms EVER" thought, has made it quite clear for me that I love FCIS & that I'll certainly miss looots of stuff when I graduate insha'Allah.
It has been 3 days now (3rd day in midterms week) & I actually feel nothing..not a single different feeling.
but the fact that i know that those moments won't EVER come again, is what makes them special.
Here are some snippets of each exam I had & 2 lessons learned (not necessarily from the exam).

First Exam
As usual I was late in the morning...I wake up early, but I have too many morning activities.
I didn't read/hear about most of the subject; as i skipped some sessions & it didn't feel like studying!
Anywayz I tried to do my best in the time I had & El7amdulellah the exam went fine :)

2 lessons:
  • "You can't go back and make a new start, but you can start now & make a new end" [persistence]
  • "وَعَلَى اللَّـهِ فَتَوَكَّلُوا إِن كُنتُم مُّؤْمِنِينَ"


Second Exam

 I studied online wiz my friends till 2:30am & woke up @ 5:00am. I had a good feeling about the subject & -not as usual- I finished studying b4 the exam starts :D (Y)


2 lessons:
  • Studying wiz my friends is Fun 
  • Even an exam could be enjoyed :D [if you wanna do it, do it wiz a style B-)]



Third Exam
I think they should call the subject Automata. Same old machines.

2 lessons:
  • Sometimes we need to write fast in order to have enough time to think :D
  • Documenting doesn't necessarily be text [A picture worth 1000 words]





Fourth Exam
I arrived 30mins late & the doctor told me that I'll have no extra time (her right :))..Thanks to Allah I managed to finish & handed my paper 3 mins before the time ends :)

2 lessons:
  • "Start where you are. Use what you have. Do what you can."
  • Re-reading the Questions will most probably Help :D

Fifth Exam
I was super tired this night so I slept & woke up the next day...I always found that studying after fajr is the Best timing ever. I started reading from the book & the time was more than enough (we took few sections)

I wrote this on my room's wall b4 going to the exam


The main problem I had was writing my answers in the exam, but the day went on & the last midterm EVER was over!!
Still can't believe that I'm going through these moments..
Since this was our last exam, we decided to celebrate :D...we had looooooots of fun and the day was really nice.. :)
my friends & I wrote these stuff on the board

The one thing i'm looking forward to now -by finishing college- is having a healthy life :D

الْحَمْدُ لِلَّـهِ الَّذِي هَدَانَا لِهَـٰذَا وَمَا كُنَّا لِنَهْتَدِيَ لَوْلَا أَنْ هَدَانَا اللَّـهُ


Finally
"If you live each day as if it was your last, someday you'll most certainly be right" Steve Jobs

Thursday, January 14, 2010

My Visualization Package

Al Salam 3alikom w ra7mat Allah w barakatoh :)

yesterday we had our visualization practical exam. I really enjoyed the package we did in that subject. I learned a lot & had fun debugging the colors :D

Here it is...


Visualizing scalar data using the following techniques
-Edge coding
-Face coding
-Line contouring
-Flooded contouring
-Iso surface [marching cubes]

How to Use it?
Getting Started
Open a file [included with the setup file]
File->Open->browse for a file

Apply any of the algorithms
File->Apply->select an algorithm

Select a variable to visualize (if there exist multi variables in the file)
Properties->Visualized Data->select from the combo-box (if there exist other variables for the file)

Mesh visibility
you can choose whether the original mesh is visible or not
Properties->Mesh visibility->Show/Hide

Choose a coloring style
Properties->Color map style->LUT/TF

Mouse Interaction

There is also some friendly interaction with the mesh using the mouse

Zooming
press 'z' to enable/disable zooming
zoom in: double click
zoom out: right click



Translation
press 't' to enable/disable translation
now drag & drop the mesh (it doesn't move while dragging)

Rotation
press 'r' to enable/disable rotation
just like in translation u'll act as if you are dragging the mesh in order to rotate it...also doesn't rotate except when you release the mouse hold.

Here is a sample output
This project is built using C# & OpenGL

Find the project & some sample data files in my shared files =)


Marching Cubes works on some special meshes (3D)
use order1.dat





Despite all the negative energy I had this term :D
This project, this subject & this doctor...really made SC Rocks :D

Related Links:
color map editor: The basic idea of the whole thing
Contouring: I remember when I wrote this post, wasn't actually understanding what I was trying to do :D

Monday, November 2, 2009

Contouring

Al salam 3alikom w ra7mat Allah w'barakatoh

These are my notes about our next assignment in visualization.

(Polygon Filling Algorithm)

1st we'll be using the loader to load the mesh we need to color. This mesh consists of polygons. We'll be coloring these polygons.

We'll make a function with the following specifications
Input:
  • The polygon to be colored
  • The contours that we did last week
Output:
  • An array of lines with their corresponding colors (we'll get them from the color map editor we did 2 weeks ago)
How will we color the regions of the polygon??

using the lines from the array we just got [L1 & L2]. We'll iterate on all the vertices we have in this polygon [V1, V2, V3 & V4] and check if the region we are coloring contains this vertex or not.
If it contains the vertex, then add the vertex to -say- an array of points that defines this region.
After we finish this iteration, we'll be having a set of points that defines the regions to be colored.

in this example we'll have 3 arrays:
[L1, V1] [L1, L2, V2, V4] [L2, V3]
These defines the 3 regions [R1, R2 & R3]
Now What?

can we start coloring?
No, we still need to sort these points, to be able to color the regions.
How will we sort them?
take any vertex as a reference point, then draw the main coordinates (wiz respect to this vertex) & calculate the angles between the main coordinates and the lines.
Sort the angles & start coloring.

Here we took V4 as a reference point.
The Orange lines represent the main axes.
and the angles are (1, 2 & 3)


(Texture Mapping)

This should be faster than the "polygon filling" algorithm and easier to implement.
say we have 8 colors. We'll store them as 8 pixels in the memory.
We should normalize the values, so that they range from 0 to 1.
Also the values of pixels in the polygon, should range from 0 to 1.
Now we'll iterate on the polygon's pixels and get the required pixel (color) directly from the memory.
No distribution is used. We get the color directly from the pixels we stored.


I hope you find this post useful :)
Al Salam 3alikom w ra7mat Allah w'barakatoh

Thursday, October 29, 2009

Color Map Editor

Al Salam 3alikom w ra7mat Allah w barakatoh :)




It's an assignment we took in visualization. The color map editor.


Does this picture look familiar?
I guess most of us has seen similar pics in our geography study @ school

How was this picture drawn??
As u can see, the brown parts represent high areas (like mountains), green parts are just ground & blue will be the see level.
These colors map to specific heights. This is shown in the gradient between colors. like this between beige & brown.
This is color mapping!

Why do we need this?!
We need color mapping because if this data was given in its numerical form, it would be really difficult for ppl to interpret. This visual form makes things easier & more fun.

How do we make this color mapping?
we have 2 main methods to this
  1. using a look-up table
  2. using a transfer function
what are these methods, and which one will we be using?
It depends on the problem we have.
If we have specific discrete values, we can use the look-up table. It will probably do the job required and it is easier to implement.
If we have continuous values (like the gradient mentioned above), we'll need to use the transfer function. Because when we use the transfer function we not only map 2 colors (for example) but we map all the gradients that lies between them, which represents more data.

Now let's talk about the 2 methods we have
Look-up table (LUT)
as mentioned b4, it is suitable when we have specific discrete data.
as you can see here, there are only 6 colors that represent some ranges of data
  • less than 18 --> baby blue
  • 18 - 20 --> light blue
  • 20 - 22 --> off white
  • 22 - 24 --> orange
  • more than 24 --> red
  • if the depth is less than 1000m then it's mapped to white
this can be reflected in a table that contains these colors (array).
when given a value "S", this value is mapped to a color "C".
Index(c)=([(S-Smin)/(Smax-Smin)]*numberOfColors)
if S was the min value, then Index(c) will be equal to 0*numberOfColors = 0 (1st color)
if S was the max value, then Index(c) will be 1*numberOfColors = numberOfColors (last color)
and of course if it was in between them it will give us an index in the array of colors we have.

This is briefly how the LUT works.

Now what about the transfer function?
What's special about it?

Transfer Function
The special part about the transfer function is mapping every gradient between any 2 colors.
as you can see in this picture, every color is a start in a range of values, till another range begins.

How will we get a value to a specific degree of the color?
Using Interpolation.
Let's start with an easy example.
if the first color is red (C1) & the 2nd color is yellow (C2)
C1 represents a value of 100 and C2 represents 200
and we want to know the value of the color corresponding 150
what will we do?
This is a simple case, as we know that the required color (C3) lies exactly in the middle of C1 & C2
so we deduce that C3=0.5*C1 + 0.5*C2

what if it didn't lie exactly @ the middle of 2 colors?
We'll calculate where exactly does it lies. This will be i (index of previous color) + f (fraction). (i+f) will be smaller than (i+1), as it lies between i & (i+1).
i = floor ((S-Smin)/∆S)
f= (S-Smin)/∆S – i
then, C = (1-f)*Ci + f*C(i+1)




i: is the index of a color
f: is the fraction in a given index

This will give us the exact color of any value in our continuous data. Hence, we'll be able to formulate a visualization like the one shown above :)

I hope you find this post interesting & useful :)



Al Salam 3alikom w ra7mat Allah w barakatoh