{"id":18964259,"url":"https://github.com/lorransutter/cvfem","last_synced_at":"2025-04-19T12:50:14.500Z","repository":{"id":114624216,"uuid":"263463243","full_name":"LorranSutter/CVFEM","owner":"LorranSutter","description":"Control finite volume element method - problem solving","archived":false,"fork":false,"pushed_at":"2022-05-20T01:03:24.000Z","size":70,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T08:02:45.428Z","etag":null,"topics":["convection-diffusion","convex-hull","finite-volume-methods","matplotlib","python","steady-state"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LorranSutter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-05-12T22:09:58.000Z","updated_at":"2025-03-28T07:11:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"bf108f41-ebbb-4957-9d02-42c9a51743f4","html_url":"https://github.com/LorranSutter/CVFEM","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LorranSutter%2FCVFEM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LorranSutter%2FCVFEM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LorranSutter%2FCVFEM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LorranSutter%2FCVFEM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LorranSutter","download_url":"https://codeload.github.com/LorranSutter/CVFEM/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249201117,"owners_count":21229004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convection-diffusion","convex-hull","finite-volume-methods","matplotlib","python","steady-state"],"created_at":"2024-11-08T14:23:28.302Z","updated_at":"2025-04-16T05:31:51.518Z","avatar_url":"https://github.com/LorranSutter.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n    Control Volume Finite Element Method\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    Project presented as part of the Final Term Paper in Exact Sciences of the \u003ca href='http://www.ufjf.br/ufjf/'\u003eUniversidade Federal de Juiz de Fora\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"#pencil2-what-is-cvfem\"\u003eCVFEM\u003c/a\u003e\u0026nbsp;\u0026nbsp;|\u0026nbsp;\u0026nbsp;\n    \u003ca href=\"#pushpin-problem-presentation\"\u003eProblem presentation\u003c/a\u003e\u0026nbsp;\u0026nbsp;|\u0026nbsp;\u0026nbsp;\n    \u003ca href=\"#pencil-dependencies\"\u003eDependencies\u003c/a\u003e\u0026nbsp;\u0026nbsp;|\u0026nbsp;\u0026nbsp;\n    \u003ca href=\"#runner-how-to-run\"\u003eHow to run\u003c/a\u003e\u0026nbsp;\u0026nbsp;|\u0026nbsp;\u0026nbsp;\n    \u003ca href=\"#computer-technologies\"\u003eTechnologies\u003c/a\u003e\u0026nbsp;\u0026nbsp;|\u0026nbsp;\u0026nbsp;\n    \u003ca href=\"#book-references\"\u003eReferences\u003c/a\u003e\u0026nbsp;\u0026nbsp;\n\u003c/p\u003e\n\n## :pencil2: What is CVFEM?\n\nControl Volume Finite Element Method is a combination of two well known numerical methods: Finite Element Method (FEM) and Finite Volume Method (FVM). These methods aims to represent and evaluate partial differential equations (PDE) in the form of algebric equations.\n\nThe problems that these methods solve are usually two or three dimensional physical problems, such as heat transfer, fluid dynamics and magnetic flux, which are represented by complex and difficult to solve PDE. Therefore, numerical methods are generally used to discretize the domain in numerous elements and solving the equations for each of them.\n\nCVFEM uses unstructured meshes, starting with a conservation equation in integral form. The solution domain is divided in an finite number of control volumes (CV) and the conservation equation is applied to each CV.\n\n## :pushpin: Problem presentation\n\nIn this problem, CVFEM was used to obtain the discrete form of the conservation equation for a scalar quantity. Each integral represents, respectively, conservation of linear momentum, source, diffusion and advection:\n\n\u003cdiv align=\"center\"\u003e\n\n$$\\frac{d}{dt}\\int_{V}\\phi dV \\ - \\ \\int_{V}Q dV \\ - \\ \\int_{A}\\kappa\\nabla\\phi\\cdot\\boldsymbol{n}dA \\ + \\ B\\int_{A}\\(\\boldsymbol{v}\\cdot \\boldsymbol{n}\\)\\phi dA \\ = \\ 0$$\n\n\u003c/div\u003e\n\nThis process is employed in the discretization of this equation generating a linear system of algebric equations. Thus, it is possible to obtain the following equation:\n\n\u003cdiv align=\"center\"\u003e\n\n$$a_{i}\\phi_{i} \\ = \\ \\sum_{j=1}^{n_i}a_{i,j}\\phi_{S_{i,j}} \\ + \\ b_i$$\n\n\u003c/div\u003e\n\nWhere $a_i$ and $a_{ij}$ are the coefficients of the linear system of equations for the variable $\\phi$, and $b_i$ represents all source, transient and boundary terms contributions.\n\nThe figure bellow illustrates the relationship of a node $i$ with its adjacent nodes in the support matrix $S_{ij}$ and its CV:\n\n\u003cdiv align=\"center\"\u003e\n\n\u003cimg src='https://res.cloudinary.com/lorransutter/image/upload/v1589420190/ControlVolume.svg' height=200\u003e\n\n\u003c/div\u003e\n\nThe case studied is a steady state advection-diffusion problem withoud sources. The domain geometry is a quarter of a circular crown, and considering a field of velocities and diffusivity varying radially and not including sources, the problem can be solved analytically for comparison criteria:\n\n\u003cdiv align=\"center\"\u003e\n\n\u003cimg src='https://res.cloudinary.com/lorransutter/image/upload/v1589497575/EquationAndDomain.svg'/\u003e\n\n\u003c/div\u003e\n\nFinally, follow the numerical solution compared to analytical solution:\n\n\u003cdiv align=\"center\"\u003e\n\n![Solution](https://res.cloudinary.com/lorransutter/image/upload/v1589497916/CVFEM_solution.svg)\n\n\u003c/div\u003e\n\n## :pencil: Dependencies\n\nBesides, of course, [Python](https://www.python.org/), you will need [NumPy](https://numpy.org/) library for numerical operations and [Matplotlib](https://matplotlib.org/) library for plotting.\n\nAlso, if you want to generate your own mesh you may use the free mesh generator [Gmsh](https://gmsh.info/).\n\n## :runner: How to run\n\nAfter install \u003ca href=\"#pencil-dependencies\"\u003edependencies\u003c/a\u003e, open your terminal in the folder you want to clone the project:\n\n```sh\n# Clone this repo\ngit clone https://github.com/LorranSutter/CVFEM.git\n\n# Go to the project folder\ncd CVFEM\n```\n\nThe following command read a .msh file generate by Gmsh to be read by the solver code:\n\n```sh\npython3 readGmsh.py mesh.msh\n```\n\nThen, run the solver code having the output of the previous code as an input:\n\n```sh\npython3 cvfem.py outputMesh.dat\n```\n\n## :computer: Technologies\n\n- [Python](https://www.python.org/) - interpreted, high-level, general-purpose programming language\n- [NumPy](https://numpy.org/) - general-purpose array-processing package\n- [Matplotlib](https://matplotlib.org/) - plotting library for the Python\n- [Gmsh](https://gmsh.info/) - three-dimensional finite element mesh generator\n\n## :book: References\n\n- Voller, Vaughan R, *Basic control volume finite element methods for fluids and solids*\n- Versteeg, Henk Kaarle and Malalasekera, Weeratunge, *An introduction to computational fluid dynamics: The Finite Volume Method*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Florransutter%2Fcvfem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Florransutter%2Fcvfem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Florransutter%2Fcvfem/lists"}