<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Harman Gill on Medium]]></title>
        <description><![CDATA[Stories by Harman Gill on Medium]]></description>
        <link>https://medium.com/@harmanxgill?source=rss-4fbabd16ab16------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qwHjxNB4C2O8a7jnzWm-Fg.jpeg</url>
            <title>Stories by Harman Gill on Medium</title>
            <link>https://medium.com/@harmanxgill?source=rss-4fbabd16ab16------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 13:31:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harmanxgill/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Painting with Pixels: A Beginner’s Guide to the Finite Element Method]]></title>
            <link>https://medium.com/@harmanxgill/painting-with-pixels-a-beginners-guide-to-the-finite-element-method-c4287c41f12f?source=rss-4fbabd16ab16------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4287c41f12f</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[computational-science]]></category>
            <category><![CDATA[finite-element-method]]></category>
            <category><![CDATA[engineering-simulation]]></category>
            <category><![CDATA[numerical-methods]]></category>
            <dc:creator><![CDATA[Harman Gill]]></dc:creator>
            <pubDate>Sat, 09 Aug 2025 02:54:57 GMT</pubDate>
            <atom:updated>2025-08-09T06:01:01.105Z</atom:updated>
            <content:encoded><![CDATA[<h4>If you’ve ever zoomed into a photo and seen it turn into a blocky mess, you already understand the basic problem that <strong>adaptive mesh refinement</strong> tries to solve.</h4><p>Numerical simulations, whether for weather, bridges, or black holes; often start as blurry paintings. The computer splits the world into chunks (called <em>elements</em>) and pretends the physics inside each chunk is simple. That works… until something interesting happens in a tiny corner of the domain. Then your simulation is like a painting with gorgeous detail in the sky but a blurry smudge where the hero’s face should be.</p><p>Adaptive mesh refinement is the “reading glasses” we give our simulations; letting them focus only where more detail is worth the cost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MlxNl4I1rrOwYHSTr2HrxQ.png" /><figcaption>Painting with Pixels</figcaption></figure><h3>The “Why” Before the “How”</h3><p>Imagine trying to paint a giant mural using just a paint roller. Great for the background sky, terrible for the fine details in the eyes. The <strong>finite element method (FEM)</strong> is like using a set of paint tools: big brushes for the big areas, tiny brushes for the fine lines.</p><p>In FEM:</p><ol><li><strong>We chop the problem into pieces</strong> (<em>mesh elements</em>).</li><li><strong>We solve a simpler version</strong> of the equations inside each piece.</li><li><strong>We stitch the pieces back together</strong> to get an approximation of the full solution.</li></ol><p>If we stick with a single mesh size everywhere, we either:</p><ul><li>waste time painting fine detail where it’s not needed, or</li><li>miss the important small-scale features entirely.</li></ul><p>Adaptive refinement solves this trade-off by letting the mesh <strong>zoom in only where the action is</strong>.</p><h3>The Big Idea Behind FEM</h3><p>The world is full of partial differential equations (PDEs); equations that describe how things like heat, waves, or stress change in space and time. For example, the steady-state heat equation in a domain Ω looks like:</p><blockquote>−∇ ⋅ ( k ∇ u ) = f</blockquote><p>Here:</p><ul><li><em>u</em> is the temperature,</li><li><em>k </em>is the thermal conductivity,</li><li><em>f </em>is a heat source.</li></ul><p>The problem? This equation is often too complex to solve exactly for real-world shapes. FEM’s trick is to <strong>replace the infinite problem with a finite one</strong>.</p><p>We do this by:</p><ul><li>picking “test functions” <em>v</em>,</li><li>multiplying the equation by <em>v</em>,</li><li>integrating over the domain,</li><li>and cleverly choosing <em>v </em>so the problem becomes a solvable system of equations.</li></ul><p>That’s called the <strong>weak formulation </strong>and it turns scary PDEs into something our linear algebra libraries can handle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1xjDG279z5PAaJs2JvuLdw.png" /><figcaption><strong>PDE to Weak Form</strong></figcaption></figure><h3>Where Adaptivity Comes In</h3><p>Not all parts of the domain are equally “interesting.” In some areas, the solution is smooth and boring; one big element is fine. In others, it’s changing rapidly; we need small elements to capture the detail.</p><p>Adaptive FEM works like this:</p><ol><li>Solve the PDE on a coarse mesh.</li><li>Estimate the error in each element.</li><li>Refine the mesh only where the error is big.</li><li>Repeat until the accuracy is good enough.</li></ol><p>This is a huge time saver; you might get the same accuracy as a uniform fine mesh but with <strong>10× fewer elements</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SWaVjOv3rNoam1esWXQHMQ.png" /><figcaption><strong>Coarse Mesh vs Refined Mesh</strong></figcaption></figure><h3>My Little Solver</h3><p>For this project, I built a <strong>2D adaptive finite element solver</strong> in Python. The workflow looks like this:</p><ol><li>Start with a triangular mesh of the domain.</li><li>Assemble the stiffness matrix <em>A </em>and load vector <em>b </em>from the weak form.</li><li>Solve <em>Au=b</em> for <em>u</em>.</li><li>Estimate local errors using the gradient jumps across elements.</li></ol><p>Repeat until your simulation looks sharp where it needs to be, without wasting time elsewhere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WjgfRx1_83K_UkkSQ79FRQ.gif" /><figcaption><strong>Adaptive Refinement Process</strong></figcaption></figure><h3>Why You Should Care (Even If You’re Not an Engineer)</h3><p>Adaptive FEM isn’t just for engineers designing bridges; it’s used in:</p><ul><li><strong>Astrophysics</strong> (simulating black hole mergers without wasting compute time on empty space). PS: Article on this project of mine coming soon</li><li><strong>Climate science</strong> (focusing resolution where storms form)</li><li><strong>Medicine</strong> (modeling blood flow in complex arteries)</li><li><strong>Graphics &amp; Games</strong> (real-time physics without killing the frame rate)</li></ul><h3>Closing Thought</h3><p>FEM by itself is like drawing with a single-size pen; neat, precise, but maybe not the most efficient. Adaptive FEM is the sketch artist who changes pen sizes on the fly, adding detail only where it’s worth it.</p><p>In the end, good simulations aren’t about solving every part of the domain equally well; they’re about putting your computational effort where it matters most.</p><p>Code and visualizations here: <a href="https://github.com/harmanxgill/refine2d-fem">https://github.com/harmanxgill/refine2d-fem</a> feel free to fork and experiment!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4287c41f12f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>