Showing posts with label GeForce. Show all posts
Showing posts with label GeForce. Show all posts

Monday, 7 July 2025

A Simplified Immersed Boundary Method using Ray Casting

     Yours truly is an avid gamer, @fadoobaba (YouTube). The ray casting algorithm๐Ÿ›ธ; a fundamental ๐Ÿงฑ technique used in video game ๐ŸŽฎ development and computer graphics, has been implemented within the finite difference method ๐Ÿ code yours truly has been developing. In abundant spare time, of course๐Ÿ˜ผ. In this post, this method is explained. For details about ray casting using matplotlib.path, refer to here. For validation of the code, refer to here, backwards-facing step, curved boundaries, here (moving cylinder) and here.

NOTE: This method requires a GPU, if dear readers don't have a GPU then please stop being peasants... ๐Ÿ™‰

     If you plan to use these codes in your scholarly work, do cite this blog as:

     Fahad Butt (2025). S-IBM (https://fluiddynamicscomputer.blogspot.com/2025/07/a-simplified-immersed-boundary-method.html), Blogger. Retrieved Month Date, Year

     The first step is to setup the polygon ๐Ÿ . The polygon = cp.column_stack((x1, y1)) statement is used to combine x1 and y1 into a single array representing the polygon vertices. The following statements are used to store the x and y coordinates of the polygon vertices and nvert is the total number of vertices.

px = polygon[:, 0]

py = polygon[:, 1]

nvert = len(polygon)

     The boolean masks ๐Ÿ‘บ are then initialized. The following arrays track whether a grid point is inside the polygon based on horizontal and vertical ray intersections. False = outside ❌, True = inside ✅. Then a loop is implemented to for each edge ๐Ÿ“ of the polygon, defined by vertices i (current) and j (previous), with % nvert ensuring the polygon is closed (last vertex connects back to the first). (xi, yi) and (xj, yj) define the current edge and previous edge.

horizontal_inside = cp.zeros_like(test_x, dtype=bool) 

vertical_inside = cp.zeros_like(test_x, dtype=bool) 

for i in range(nvert):

    j = (i - 1) % nvert

xi, yi = px[i], py[i]

xj, yj = px[j], py[j]

     A check ⁉️ is performed to ensure a ray crosses the polygon edge once. cond1 statement checks if the test point lies between the y-values of the edge's endpoints i.e., a ray could cross it. intersect_x finds where the edge crosses a horizontal line at test_y. cond2 checks if the intersection lies to the right of the test point. ^= is XOR toggles the "inside" state each time the ray crosses an edge. The addition of small term ~1e-16 prevents division by zero for horizontal edges. Similar method is applied to verify the points using vertical ray. cond3 checks if the edge crosses a vertical ray (top to bottom) from (test_x, test_y). slope1 and intersect_y computes where the vertical ray at x=test_x intersects the edge. A point is inside only if both horizontal and vertical rays classify it as inside. A point is considered inside the foil only if both ray checks are true. curve is the 2D boolean mask of grid points inside the foil body.

cond1 = ((yi > test_y) != (yj > test_y))

slope = (xj - xi) / (yj - yi + 1e-16)

intersect_x = slope * (test_y - yi) + xi

cond2 = test_x < intersect_x 

horizontal_inside ^= cond1 & cond2

cond3 = ((xi > test_x) != (xj > test_x))

slope1 = (yj - yi) / (xj - xi + 1e-16)

intersect_y = slope1 * (test_x - xi) + yi

cond4 = test_y < intersect_y

vertical_inside ^= cond3 & cond4

inside = horizontal_inside & vertical_inside

curve = inside.reshape(X.T.shape)

     Using both horizontal and vertical rays reduces false positives (e.g., near sharp corners). The & ensures only points unambiguously inside are marked. Within Fig. 1, the points on the shape boundary, points inside ๐Ÿชฐ and outside ๐ŸŒ the shape boundary are shown. A point is a boundary if it is inside the body, but any of its neighbors is outside. Following statements are used to mark the boundary of the object. Boundary detects the "skin" of the body for applying no-slip, force, or stress conditions.

interior = curve[1:-1, 1:-1]

right = curve[2:, 1:-1]

left = curve[:-2, 1:-1]

top = curve[1:-1, 2:]

bottom = curve[1:-1, :-2]

boundary = interior & ~(right & left & top & bottom)

     The statements boundary_indices = cp.where(boundary_mask) ... valid_right = (boundary_indices[0] + 1 < X.shape[0]) & (~curve[right_neighbors]) ... etc. extract boundary indices and their valid neighbors i.e. these lines extract the (i, j) grid indices of the surface and locate which neighbor cells are valid fluid neighbors (outside the body and within domain bounds). These are needed to compute normals or apply boundary conditions via interpolation or extrapolation from the fluid.
Fig. 1, Mesh cells


     For validation of the results from present simulations, the case of flow around a circular cylinder is selected. Fig. 1 shows the results from the code at Re 200. The drag coefficient obtained from this code is 1.396 while from the literature, the value is at 1.4 [1]. The lift coefficient from the code is at 0.000134. Within Fig. 2, top row shows u and v velocity components and bottom row shows pressure and vorticity.


Fig. 2, The flow-field

     For the second an more complex validation case, a swimming fish is simulated. The lift and drag coefficients obtained from the simulation are compared with experimental results. The drag coefficient from the current code is at 0.342 while from the published literature, the value is at 0.348. Maximum lift coefficient is at 7.243 and 8 from the present code as compared to the published literature [2]. Within Fig. 3 the u and v velocities, pressure and velocity streamlines are shown for St = 0.8 and Reynolds number of 500. The computational mesh near the fish is shown in Fig. 4. Within Fig.4, a zoomed in view towards the right shows the mesh at the trailing edge of the fish.


Fig.3, Post-processing of results

Fig. 4, The mesh

     This method allows handling arbitrary deforming / non-deforming shapes on a fixed Cartesian grid. In summary, the method has the following steps.

1. Generate polygon shape (e.g., airfoil, cylinder)

2. Flatten mesh for vectorized testing

3. Use ray casting to check if points are inside shape

4. Build a boolean mask of body region

5. Identify surface (boundary) points

6. Extract boundary indices for physics coupling


References

     [1] Braza M, Chassaing P, Minh HH. Numerical study and physical analysis of the pressure and velocity fields in the near wake of a circular cylinder. Journal of Fluid Mechanics. 1986;165:79-130. doi:10.1017/S0022112086003014

     [2] Fulong ShiJianjian XinChuanzhong OuZhiwei LiXing ChangLing Wan; Effects of the Reynolds number and attack angle on wake dynamics of fish swimming in oblique flows. Physics of Fluids 1 February 2025; 37 (2): 025205 doi.org/10.1063/5.0252506

     Thank you for reading! If you want to hire me as a post-doc researcher in the fields of thermo-fluids and / or fracture mechanics, do reach out!

Monday, 9 July 2018

Desktop Computer Part List (Summer 2018-Pakistan Market)

     At the time of writing, 1 USD = Rs. 121.936. The prices mentioned in this post are based on the local market prices of computer components in Pakistan. Please remember that, prices vary from city-to-city within the country and shop-to-shop within a city. This is the reason why a price range is mentioned.

CPUs

     Intel Core i7-8700 for Rs. 41,500-Rs. 43,500. Top of the line processor from Intel. Always prefer a Core i7 or a Core i9 processor.

     Intel Core i5-8400 Processor Rs. 26,000-Rs. 28,000. Only buy this processor if there is a budget constraint.

Motherboard

     Gigabyte Z370 AORUS Gaming 3 for Rs. 21,200-Rs. 21,500. This motherboard has many USB ports and also comes equipped with a USB type-C port and M.2 slots etc. for future proofing.

Storage

     WD Blue 500GB Solid State Drive - WDS500G1B0A for Rs. 16,500-Rs. 17,500. Please do not buy a hard drive with rotating mechanism, it's 2018! When later in the year the SSD's prices go down, probably around November-December 2018, then buy another ~500 GB SSD. Do not waste money on a legacy hard drive.

Memory

     Corsair Vengeance LPX 16GB (1x16GB) DDR4 DRAM 3000MHz Rs. 25,800-Rs. 32,000. Please do not buy two sticks of 8 GB each. Save the remaining memory slots for future upgrading. Memory prices will fall significantly in October-November 2018 once the Chinese memory plants become operational. Don't fall for the shop keepers trickery. A common ploy employed by shopkeepers is that 1x16GB memory modules don't work in single channel mode for the 2400 MHz+ modules. It works perfectly well.

Casing

     Corsair Carbide Series® 100R Mid-Tower Case Rs.6,650-Rs. 7,500. This is the best option, really. Don't waste money on casing, it's just a box.

Power Supply

     Corsair VS550 - 550 Watt Power Supply Rs.5,800 -Rs. 6,000. A 550 Watt power supply for an i7 8700 CPU, 4 sticks of 1x16GB DDR4 memory modules, 1 SSD and up to a GTX 1x70 level graphic cards without any over clocking and 16 hours per day usage will be enough. May be this power supply will even be enough for GTX 1180 graphic card, as the graphic card chips are becoming more and more energy efficient. Yet again, do not fall for the shop keepers ploys.

Graphic Card

     Wait for the graphic new graphic cards from NVidia. The new cards are just around the corner. Local shops in Pakistan are selling 2 year old graphic cards, the GTX 10 series, at much inflated prices as compared to the rest of the world.

Conclusion

     This system will last at least 5 years, in terms of gaming with a GTX 1x70 level graphics card. It will even perform well for 10+ years if you keep upgrading it and take care of it cooling wise. Upgrade to a PCIe-NVMe SSD down the road when the prices drop, add more memory and update the graphic card every 5 years etc. Currently, the system will cost anywhere between Rs. 118,000 -Rs. 128,000, depending on you city and the shop, with an i7 processor.

     If you'd like to collaborate on research projects, please reach out. Thank you for reading.

Monday, 7 October 2013

Entry Level CPU Build Guide for Word Processing and Browsing; for October 2013 (Pakistan Market Prices and Parts Availability)

 
 
This is the least expensive, the most basic build guide, based on the parts available in Pakistan. This build is recommended for casual users and students wanting a basic computer for Microsoft® Office work. And for those who run games on consoles.

CPU

Intel® Pentium™ G-2020 Processor (3M Cache, up to 2.90 GHz) ~6,500 PKR, It has 2 cores and no HT technology, will perform everyday tasks like charm! It will struggle a with the running games at medium-low resolution. Just recommended for word processing and Internet.

Motherboard

Intel® Desktop Board DH61CR ~5,500 PKR, using 3rd party mother boards is not recommended in Pakistan because of no-warranty issues. Most of the importers buy from Intel and they come with warranty, others simply don't. This board supports 4 3 GB/s SATA, USB and PCI-e 2.1.

PSU + Case + Extra Fan

~3,000 PKR. For this build you can go for the built in 300 Watt power supply that comes with you casing, but due to large time spent gaming and/or rendering and due to hot temperature in Pakistan, the system heats up pretty bad, so be SURE to buy and add an extra 90 mm fan.

RAM

Kingston® KVR16N11/2 2 GB DDR 3 1600 MHz, ~2,000PKR  x1, as RAM is expensive these days, was at around half the price last year, so go for 1 DIMM 2 GB memory. (capacity of the recommended motherboard is 8GBx2 = 16 GB maximum).

HD

Seagate® Barracuda™ 7200 rpm 32 MB Cache 500 GB ~6,500 PKR. Buy the smallest/cheapest capacity/price available because most of us pre own portable hard drives anyway, use them for backup.

Optical Drive

Yeah, it was something too, something dinosaurs used! NOT recommended. Just wastage of money! We use USB ports to install any of the current OS, obviously. but of you don't have the ability to install the OS from USB port, or are afraid to make changes to your BIOS, please buy yourself a Super Drive.

WIFI

TP Link® WN722N ~1,000 PKR, it is a must as most of us have WIFI routers these days, so to get internet to your desktop, you will have to use this or a ~2,500 PKR 50+ meter LAN cable. The choice is yours! This isn't even a hard one!
This all adds up to 27,000 PKR without Graphics Card, Keyboard, Mouse, Speakers and a Monitor which most of us pre own and do not change for ~8-10 years.
If you are buying everything from start, add ~2,500 PKR for keyboard and mouse, and ~12,000 for 900p monitor (Dell® or HP® only because of warranty issues).

 
 
For suggestions, send an email to fadoobaba@live.com , tweet @fadoobaba, PM at https://www.facebook.com/ThreeDimensionalDesign or https://grabcad.com/fahad.rafi.butt or comment with your contact details and I will contact you!. Thank you for reading!

Do comment and share!

Haswell Powered CPU Build Guide for Low End Gaming, Word Processing and Browsing; for October 2013 (Pakistan Market Prices and Parts Availability)

This build is recommended for casual CAD users, rendering at very high resolution will take lot of time on this build, nearly impossible and very casual gamers.

CPU

Intel® Core™ i3-4130 Processor (3M Cache, up to 3.40 GHz) ~15,000 PKR, average rendering performance, it will stay for 3 years easy! It has 2 cores and HT technology, will perform everyday tasks and simple CAD tasks like charm! It will struggle a bit with the rendering software and large CAD assemblies, and of course running games at high resolution.

Motherboard

Intel® Desktop Board DB85FL ~10,000 PKR, using 3rd party mother boards is not recommended in Pakistan because of no-warranty issues. Most of the importers buy from Intel and they come with warranty, others simply don't. This board supports 4 6 GB/s SATA, USB and PCI-e 3.0.

PSU + Case + Extra Fan

~3,000 PKR. For this build you can go for the built in 300 Watt power supply that comes with you casing, but due to large time spent gaming and/or rendering and due to hot temperature in Pakistan, the system heats up pretty bad, so be SURE to buy and add an extra 120 mm fan.

RAM

Kingston® KVR16N11/4 4 GB DDR 3 1600 MHz, ~4,000PKR  x1, as RAM is expensive these days, was at around half the price last year, so go for 1 DIMM 4 GB memory. I don't recommend buying 2x DIMM of 2GB capacity, because if you want to upgrade to full capacity later (and most of you will, that's why one buys a Desktop and not a Craptop), (capacity of the recommended motherboard is 8GBx4 = 32 GB maximum) it will not use up extra DIMM slot.

HD

Seagate® Barracuda™ 7200 rpm 32 MB Cache 500 GB ~6,500 PKR. Buy the smallest/cheapest capacity/price available because most of us pre own portable hard drives anyway, use them for backup.

Optical Drive

Yeah, it was something too, something dinosaurs used! NOT recommended. Just wastage of money! We use USB ports to install any of the current OS, obviously. but of you don't have the ability to install the OS from USB port, or are afraid to make changes to your BIOS, please buy yourself a Super Drive.

WIFI

TP Link® WN722N ~1,000 PKR, it is a must as most of us have WIFI routers these days, so to get internet to your desktop, you will have to use this or a ~2,500 PKR 50+ meter LAN cable. The choice is yours! This isn't even a hard one!
This all adds up to 40,000 PKR without Graphics Card, Keyboard, Mouse, Speakers and a Monitor which most of us pre own and do not change for ~8-10 years.
If you are buying everything from start, add ~2,500 PKR for keyboard and mouse, and ~12,000 for 900p monitor (Dell® or HP® only because of warranty issues).

 
For suggestions, send an email to fadoobaba@live.com , tweet @fadoobaba, PM at https://www.facebook.com/ThreeDimensionalDesign or https://grabcad.com/fahad.rafi.butt or comment with your contact details and I will contact you!. Thank you for reading!

Do comment and share!
 

Haswell Powered CPU Build Guide for Medium Gaming and Entry Level CAD; for October 2013 (Pakistan Market Prices and Parts Availability)

 
This build is recommended for regular CAD users, rendering at very high resolutionwill take lot of time on this build. and casual gamers (which most of us are).

CPU

Intel® Core™ i5-4670 Processor (6M Cache, up to 3.50 GHz) ~22,000 PKR, exceptional value for money, average rendering performance, it will stay for 4 years easy! It has 4 cores and no HT technology, but will perform everyday gaming and CAD tasks like charm!

Motherboard

Intel® Desktop Board DB85FL ~11,000 PKR, using 3rd party mother boards is not recommended in Pakistan because of no-warranty issues. Most of the importers buy from Intel and they come with warranty, others simply don't. This board supports 4 6 GB/s SATA, USB and PCI-e 3.0.

GPU

MSI® NVidia™ GeForce GT 640 GDDR3 2 GB ~10,000 PKR, great value for money too, will easily run all existing games (~30 fps), and all to be released games at low-medium settings at a minimum of ~30 fps for at least 2 more years.

PSU + Case + Extra Fan

Corsair® VS 450 400 Watt PSU + Casing ~5,000 PKR (after the price for built-in PSU is subtracted). In Rendering, the CPU goes to full power and beyond (Intel® Turbo Boost) so power consumption increases, same applies to GPU when gaming, you will probably use 300 Watt maximum, but as PSU gets older (after 3-4 years minimum) the output wattage decrease, so to make up for that, initially buy a slightly larger wattage PSU. Also due to large time spent gaming and/or rendering, the system heats up pretty bad, so be SURE to buy and add an extra 90 mm fan.

RAM

Kingston® KVR16N11/8 8 GB DDR 3 1600 MHz, ~8,000PKR  x1, as RAM is expensive these days, was at around half the price last year, so go for 1 DIMM 8 GB memory. I don't recommend buying 2x DIMM of 4GB capacity, because if you want to upgrade to full capacity later (and most of you will, that's why one buys a Desktop and not a Craptop), (capacity of the recommended motherboard is 8GBx4 = 32 GB maximum) it will not use up extra DIMM slot.

HD

Seagate® Barracuda™ 7200 rpm 32 MB Cache 500 GB ~6,500 PKR. I don't recommend buying a hard disk anymore because it will slow your system down, buy a 180 GB SSD instead. Believe me, 180 GB is enough space, most of us pre own Portable HD anyway, so use that for back up. If you want a HD buy the smallest/cheapest capacity/price available.

Optical Drive

Yeah, it was something too, something dinosaurs used! NOT recommended. Just wastage of money! We use USB ports to install any of the current OS, obviously.

WIFI

TP Link® WN722N ~1,000 PKR, it is a must as most of us have WIFI routers these days, so to get internet to your desktop, you will have to use this or a ~2,500 PKR 50+ meter LAN cable. The choice is yours! This isn't even a hard one!
This all adds up to 70,000 PKR without SSD, Keyboard, Mouse, Speakers and a Monitor which most of us pre own and do not change for ~8-10 years.
If you are buying everything from start, add ~2,500 PKR for keyboard and mouse, and ~12,000 for 900p monitor (Dell® or HP® only because of warranty issues).

 
For suggestions, send an email to fadoobaba@live.com , tweet @fadoobaba, PM at https://www.facebook.com/ThreeDimensionalDesign or https://grabcad.com/fahad.rafi.butt or comment with your contact details and I will contact you!. Thank you for reading!

Do comment and share!

Haswell Powered CPU Build Guide for Hi-End Gaming and CAD; for October 2013 (Pakistan Market Prices and Parts Availability)

 
This build is recommended for those who use CAD software daily and render their models as well at a high resolution. And do PC gaming as well.

CPU

Intel® Core™ i7-4770 Processor (8M Cache, up to 3.90 GHz) ~34,000 PKR, exceptional value for money, excellent render performance, it will stay for 5 years easy! Comes with 8 cores! Do I need say more? :)

Motherboard

Intel® Desktop Board DH87MC ~12,000 PKR, using 3rd party mother boards is not recommended in Pakistan because of no-warranty issues. Most of the importers buy from Intel and they come with warranty, others simply don't. This board supports 6 6 GB/s SATA, USB and PCI-e 3.0.

GPU

MSI® NVidia™ GeForce GTX 650 GDDR5 2 GB ~15,000 PKR, great value for money too, will easily run all existing games (50+ fps), and all to be released games at maximum settings at a minimum of ~30 fps for at least 2 more years. And lets face it, AMD is crap! ;)

PSU + Case + Extra Fan

Corsair® VS 500 500 Watt PSU + Casing ~6,000 PKR (after the price for built-in PSU is subtracted). In Rendering, the CPU goes to full power and beyond (Intel® Turbo Boost) so power consumption increases, same applies to GPU when gaming, you will probably use 400 Watt maximum, but as PSU gets older (after 3-4 years minimum) the output wattage decrease, so to make up for that, initially buy a slightly larger wattage PSU. Also due to large time spent gaming and/or rendering, the system heats up pretty bad, so be SURE to buy and add an extra 120 mm fan.

RAM

Kingston® KVR16N11/8 8 GB DDR 3 1600 MHz, ~8,000PKR  x1, as RAM is expensive these days, was at around half the price last year, so go for 1 DIMM 8 GB memory. I don't recommend buying 2x DIMM of 4GB capacity, because if you want to upgrade to full capacity later (and most of you will, that's why one buys a Desktop and not a Craptop), (capacity of the recommended motherboard is 8GBx4 = 32 GB maximum) it will not use up extra DIMM slot.

HD

Seagate® Barracuda™ 7200 rpm 32 MB Cache 500 GB ~6,500 PKR. I don't recommend buying a hard disk anymore because it will slow your system down, buy a 180 GB SSD instead. Believe me, 180 GB is enough space, most of us pre own Portable HD anyway, so use that for back up. If you want a HD buy the smallest/cheapest capacity/price available.

SSD

Kingston® SV300S37A/60G 60 GB ~6,500PKR. This 6GB/s SSD boots Microsoft's® Windows™ 8.1 RTM in 10 seconds ONLY! Get the point I was making earlier? Go for Kingston because warranty issues, again importers do not buy from Intel in case of SSD, but from Corsair and Kingston.

Optical Drive

Yeah, it was something too, something dinosaurs used! NOT recommended. Just wastage of money! We use USB ports to install any of the current OS, obviously.

WIFI

TP Link® WN722N ~1,000 PKR, it is a must as most of us have WIFI routers these days, so to get internet to your desktop, you will have to use this or a ~2,500 PKR 50+ meter LAN cable. The choice is yours! This isn't even a hard one!
This all adds up to 89,000 PKR without Keyboard, Mouse, Speakers and a Monitor which most of us pre own and do not change for ~8-10 years. And with 60 GB SSD and 500 GB HD.
If you are buying everything from start, add ~2,500 PKR for keyboard and mouse, and ~12,000 for 900p monitor (Dell® or HP® only because of warranty issues).

 

For suggestions, send an email to fadoobaba@live.com , tweet @fadoobaba, PM at https://www.facebook.com/ThreeDimensionalDesign or https://grabcad.com/fahad.rafi.butt or comment with your contact details and I will contact you!. Thank you for reading!

Do comment and share!