<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://e6.ijs.si/medusa/wiki/api.php?action=feedcontributions&amp;user=Zigavaupotic&amp;feedformat=atom</id>
		<title>Medusa: Coordinate Free Mehless Method implementation - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://e6.ijs.si/medusa/wiki/api.php?action=feedcontributions&amp;user=Zigavaupotic&amp;feedformat=atom"/>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php/Special:Contributions/Zigavaupotic"/>
		<updated>2026-04-15T19:39:29Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.1</generator>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Customization&amp;diff=3680</id>
		<title>Customization</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Customization&amp;diff=3680"/>
				<updated>2024-07-12T13:31:24Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: /* Custom operators: Hyperviscosity operator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Medusa library support users defining custom basis types, weights, operators and more, as long as they conform to the prescribed interfaces, given in the [http://e6.ijs.si/medusa/docs/html/concepts.html Concepts page].&lt;br /&gt;
&lt;br /&gt;
== Custom stencil selection ==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Custom RBF definition ==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Custom operators: Hyperviscosity operator ==&lt;br /&gt;
Medusa library also allows custom linear operators $ \mathcal{L} $ to be used. This functionality is achieved by adding a child struct that inherits the struct Operator. The virtual functions of struct Operator that need to be defined are &amp;lt;code&amp;gt;apply&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;applyAt0&amp;lt;/code&amp;gt;, the functions require one to also specify the basis to which the operator is applied. For example if one was to define the hyperviscosity operator denoted as $\nabla^{2\alpha}$, we would say that the RBF-FD approximation to the operator applied to function $u$ is,&lt;br /&gt;
$$&lt;br /&gt;
\nabla^{2\alpha} u \approx \sum_{i=0}^n u_i \nabla^{2\alpha} \Psi_i (u),&lt;br /&gt;
$$&lt;br /&gt;
where $\Psi_i (u)$ are cardinal functions and $\alpha$ is the order of hyperviscosity. The evaluated cardinal functions are called weights. The weights are obtained by using a system of RBF coupled with monomial augmentation. Therefore, our operator must have a definition of the function &amp;lt;code&amp;gt;apply&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt; applyAt0 &amp;lt;/code&amp;gt; for monomial and RBF basis. We define the struct, as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
template &amp;lt;int dim, int order&amp;gt;&lt;br /&gt;
struct Hyperviscosity : public mm::Operator&amp;lt;Hyperviscosity &amp;lt;dim, order&amp;gt;&amp;gt; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Customization&amp;diff=3679</id>
		<title>Customization</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Customization&amp;diff=3679"/>
				<updated>2024-07-12T13:25:33Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: /* Custom operators: Hyperviscosity operator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Medusa library support users defining custom basis types, weights, operators and more, as long as they conform to the prescribed interfaces, given in the [http://e6.ijs.si/medusa/docs/html/concepts.html Concepts page].&lt;br /&gt;
&lt;br /&gt;
== Custom stencil selection ==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Custom RBF definition ==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Custom operators: Hyperviscosity operator ==&lt;br /&gt;
Medusa library also allows custom linear operators $ \mathcal{L} $ to be used. This functionality is achieved by adding a child struct that inherits the struct Operator. The virtual functions of struct Operator that need to be defined are ''apply'' and ''applyAt0'', the functions require one to also specify the basis to which the operator is applied. For example if one was to define the hyperviscosity operator denoted as $\nabla^{2\alpha}$, we would say that the RBF-FD approximation is,&lt;br /&gt;
$$&lt;br /&gt;
\nabla^{2\alpha} u \approx \sum_{i=0}^n u_i \nabla^{2\alpha} \Psi_i (u),&lt;br /&gt;
$$&lt;br /&gt;
where $\Psi_i (u)$ are cardinal functions. The evaluated cardinal functions are called weights. The weights are obtained using a system of RBF coupled with monomial augmentation. Therefore, our operator must have a definition of the function ''apply'' for monomial and RBF basis.&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Customization&amp;diff=3678</id>
		<title>Customization</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Customization&amp;diff=3678"/>
				<updated>2024-07-12T12:27:59Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: /* Custom operators: Hyperviscosity operator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Medusa library support users defining custom basis types, weights, operators and more, as long as they conform to the prescribed interfaces, given in the [http://e6.ijs.si/medusa/docs/html/concepts.html Concepts page].&lt;br /&gt;
&lt;br /&gt;
== Custom stencil selection ==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Custom RBF definition ==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Custom operators: Hyperviscosity operator ==&lt;br /&gt;
&lt;br /&gt;
Medusa library also allows custom linear operators $ \mathcal{L} $ to be used. This functionality is achieved by adding a child struct that inherits the struct Operator. The virtual functions of struct Operator that need to be defined are ''apply'' and ''applyAt0'', the functions require one to also specify the basis to which the operator is applied. For example if one was to define the hyperviscosity operator denoted as $\nabla^{2\alpha}$, we would say that the RBF-FD approximation is,&lt;br /&gt;
$$&lt;br /&gt;
\nabla^{2\alpha} u \approx \sum_{i=0}^n u_i \nabla^{2\alpha} \Psi_i (u),&lt;br /&gt;
$$&lt;br /&gt;
where $\Psi_i (u)$ are cardinal functions&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Customization&amp;diff=3677</id>
		<title>Customization</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Customization&amp;diff=3677"/>
				<updated>2024-07-12T12:27:06Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: /* Custom operators: Hyperviscosity operator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Medusa library support users defining custom basis types, weights, operators and more, as long as they conform to the prescribed interfaces, given in the [http://e6.ijs.si/medusa/docs/html/concepts.html Concepts page].&lt;br /&gt;
&lt;br /&gt;
== Custom stencil selection ==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Custom RBF definition ==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Custom operators: Hyperviscosity operator ==&lt;br /&gt;
&lt;br /&gt;
Medusa library also allows custom linear operators $ \mathcal{L} $ to be used. This functionality is achieved by adding a child struct that inherits the struct Operator. The virtual functions of struct Operator that need to be defined are ''apply'' and ''applyAt0'', the functions require one to also specify the basis to which the operator is applied. For example if one was to define the hyperviscosity operator denoted as $\nabla^{2\alpha}$, we would say that the RBF-FD approximation is,&lt;br /&gt;
$$&lt;br /&gt;
\nabla^{2\alpha} u \approx \sum_{i=0}^n u_i \nabla^{2\alpha} \Psi_i (u) + \sum_{j=0}^\ell \nabla^{2\alpha}\beta_{i} u_i,&lt;br /&gt;
$$&lt;br /&gt;
where $\Psi_i (u)$ are cardinal functions and $\beta_i(u_i)$ are the monomial weights&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Customization&amp;diff=3676</id>
		<title>Customization</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Customization&amp;diff=3676"/>
				<updated>2024-07-12T12:26:56Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: /* Custom operators: Hyperviscosity operator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Medusa library support users defining custom basis types, weights, operators and more, as long as they conform to the prescribed interfaces, given in the [http://e6.ijs.si/medusa/docs/html/concepts.html Concepts page].&lt;br /&gt;
&lt;br /&gt;
== Custom stencil selection ==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Custom RBF definition ==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Custom operators: Hyperviscosity operator ==&lt;br /&gt;
&lt;br /&gt;
Medusa library also allows custom linear operators $ \mathcal{L} $ to be used. This functionality is achieved by adding a child struct that inherits the struct Operator. The virtual functions of struct Operator that need to be defined are ''apply'' and ''applyAt0'', the functions require one to also specify the basis to which the operator is applied. For example if one was to define the hyperviscosity operator denoted as $\nabla^{2\alpha}$, we would say that the RBF-FD approximation is,&lt;br /&gt;
$$&lt;br /&gt;
\nabla^{2\alpha} u \approx \sum_{i=0}^n u_i \nabla^{2\alpha} \Psi_i (u) + \sum_{j=0}^\ell \nabla^{2\alpha}\beta_{i} u_i,&lt;br /&gt;
$$&lt;br /&gt;
where $\Psi_i (u)$ are cardinal functions and $\beta$ are the monomial weights&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Customization&amp;diff=3675</id>
		<title>Customization</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Customization&amp;diff=3675"/>
				<updated>2024-07-12T12:26:23Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: /* Custom operators: Biharmonic equation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Medusa library support users defining custom basis types, weights, operators and more, as long as they conform to the prescribed interfaces, given in the [http://e6.ijs.si/medusa/docs/html/concepts.html Concepts page].&lt;br /&gt;
&lt;br /&gt;
== Custom stencil selection ==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Custom RBF definition ==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Custom operators: Hyperviscosity operator ==&lt;br /&gt;
&lt;br /&gt;
Medusa library also allows custom linear operators $ \mathcal{L} $ to be used. This functionality is achieved by adding a child struct that inherits the struct Operator. The virtual functions of struct Operator that need to be defined are ''apply'' and ''applyAt0'', the functions require one to also specify the basis to which the operator is applied. For example if one was to define the hyperviscosity operator denoted as $\nabla^{2\alpha}$, we would say that the RBF-FD approximation is,&lt;br /&gt;
$$&lt;br /&gt;
\nabla^{2\alpha} u \approx \sum_{i=0}^n u_i \nabla^{2\alpha} \Psi_i (u) + \sum_{j=0}^\ell \nabla^{2\alpha}\beta_{i} u_i&lt;br /&gt;
$$&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Hyperviscosity&amp;diff=3672</id>
		<title>Hyperviscosity</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Hyperviscosity&amp;diff=3672"/>
				<updated>2024-03-23T14:24:02Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;One of the most common drawbacks of the RBF-FD method is its stability. Furthermore, the RBF-FD method, due to scattered nodes, sometimes produces system (differential) matrices with spurious eigenvalues. Those are far more common than with for example FVM or FEM method. &lt;br /&gt;
&lt;br /&gt;
For such unstable systems, one usually considers numerical diffusion in the form of hyperviscosity. The hyperviscosity scheme introduces higher-order Laplacian operator (i.e. hyperviscosity operator) to the right hand side of the PDE&lt;br /&gt;
&lt;br /&gt;
$$&lt;br /&gt;
 +\gamma \Delta^\alpha u,&lt;br /&gt;
$$&lt;br /&gt;
&lt;br /&gt;
where $\gamma$ is a hyperviscosity constant and $\alpha$ is the order of hyperviscosity.&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Hyperviscosity&amp;diff=3671</id>
		<title>Hyperviscosity</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Hyperviscosity&amp;diff=3671"/>
				<updated>2024-03-23T14:19:29Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: Created page with &amp;quot;One of the most commonly mentioned drawbacks of the RBF-FD method is its stability. Furthermore, the RBF-FD method, due to scattered nodes, sometimes produces system (differen...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;One of the most commonly mentioned drawbacks of the RBF-FD method is its stability. Furthermore, the RBF-FD method, due to scattered nodes, sometimes produces system (differential) matrices with spurious eigenvalues. Those are far more common than with for example FVM or FEM method. The instabilities arise fastly even with linear PDEs.&lt;br /&gt;
&lt;br /&gt;
With meshless methods (especially RBF-FD) one usually stabilises such schemes by adding a higher-order Laplacian (hyperviscosity) operator on the right-hand side.&lt;br /&gt;
&lt;br /&gt;
$$&lt;br /&gt;
 +\gamma \Delta^\alpha u&lt;br /&gt;
$$&lt;br /&gt;
&lt;br /&gt;
The final scheme is referred to as hyperviscosity scheme&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Medusa&amp;diff=3569</id>
		<title>Medusa</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Medusa&amp;diff=3569"/>
				<updated>2024-01-13T13:18:56Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--__NOTITLE__--&amp;gt;&lt;br /&gt;
'''Welcome to the Medusa wiki. To visit the main website, go to [http://e6.ijs.si/medusa/ http://e6.ijs.si/medusa/].'''&lt;br /&gt;
&lt;br /&gt;
In [http://e6.ijs.si/ParallelAndDistributedSystems/ Parallel and Distributed Systems Laboratory] we are working on a C++ library that is first and foremost focused on tools for solving Partial Differential Equations by meshless methods. The basic idea is to create generic codes for tools that are needed for solving not only PDEs but many other problems, e.g. Moving Least Squares approximation, $k$-d tree, domain generation engines, etc.&lt;br /&gt;
We call this open source meshless project [http://e6.ijs.si/medusa/ Medusa: Coordinate Free Meshless Method implementation (MM)].&lt;br /&gt;
&lt;br /&gt;
Technical details about code and examples  can be found on our [http://e6.ijs.si/medusa/docs/ documentation page] and [https://gitlab.com/e62Lab/medusa Gitlab repository]. [[File:C.png|100px||link=https://gitlab.com/e62Lab/medusa|alt=Alt text|code]] [[File:doxygen.png|100px|link=http://e6.ijs.si/medusa/docs/|alt=Alt text|Documentation page]]&lt;br /&gt;
&lt;br /&gt;
This wiki site is meant for more relaxed discussions about general principles, possible and already implemented applications, preliminary analyses, etc.&lt;br /&gt;
Note, that there are many grammatical mistakes, typos, stupid sentences, etc. This wiki is meant for quick information exchange and therefore we do not invest a lot of energy into styling :).  &lt;br /&gt;
&lt;br /&gt;
== Documentation ==&lt;br /&gt;
* [https://gitlab.com/e62Lab/medusa Code on Gitlab]&lt;br /&gt;
* [[How to build | Installation and building]]&lt;br /&gt;
* [[Including this library in your project | Including this library in your project]]&lt;br /&gt;
* [[Testing | Running tests]]&lt;br /&gt;
* [http://e6.ijs.si/medusa/docs/ Technical documentation]&lt;br /&gt;
* [[Coding style | Coding style]]&lt;br /&gt;
* [[Wiki editing guide | Wiki editing and backup guide]]&lt;br /&gt;
&lt;br /&gt;
== Building blocks ==&lt;br /&gt;
Medusa is modular coordinate-free parallel implementation of a numerical framework designed, but not limited to, for solving PDEs. In this section we present main modules of the library that can be also used as a standalone tools. &lt;br /&gt;
* [[Positioning of computational nodes]] &lt;br /&gt;
* [[Relaxation of the nodal distribution]]&lt;br /&gt;
* [[Refinement of the nodal distribution]]&lt;br /&gt;
* [[k-d tree|''k''-d tree and other spatial search structures]] &lt;br /&gt;
* [[Solving system | Solving linear system - including over and underdetermined systems]]&lt;br /&gt;
* [[Weighted Least Squares (WLS)]]&lt;br /&gt;
* [[Computation of shape functions]]&lt;br /&gt;
* [[Radial basis function-generated finite differences (RBF-FD)]]&lt;br /&gt;
* [[Ghost nodes (theory)]]&lt;br /&gt;
* [[Integrators for time stepping]]&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
In this section we present exact examples. Each of the below solutions can be found also in in the repository under examples. More explanation about the physical background and solution procedure can be found in following sections.&lt;br /&gt;
* [[Philosophy of examples and how to run them]]&lt;br /&gt;
* [[Poisson's equation]]&lt;br /&gt;
* [[Heat equation]]&lt;br /&gt;
* [[Linear elasticity]]&lt;br /&gt;
* [[Complex-valued problems]]&lt;br /&gt;
* [[Coupled domains]]&lt;br /&gt;
* [[Parametric domains | Parametric domains &amp;amp;ndash; Curved surface with variable density]]&lt;br /&gt;
* [[NURBS domains | Domains modeled with non-uniform rational basis splines (NURBS)]]&lt;br /&gt;
* [[Determining the interior of the domain by oversampling the boundary]]&lt;br /&gt;
* [[Computer-aided design - Importing IGES and STEP files]]&lt;br /&gt;
* [[Realistic 3D models|Working with 3D surface mesh models ]]&lt;br /&gt;
* [[customization | Operator customization]]&lt;br /&gt;
* [[Ghost nodes]]&lt;br /&gt;
* [[Electromagnetic scattering]]&lt;br /&gt;
* [[Schrödinger equation]]&lt;br /&gt;
* [[Wave equation]]&lt;br /&gt;
* [[Cahn-Hilliard equation]]&lt;br /&gt;
* [[Fluid mechanics]]&lt;br /&gt;
* [[Solid Mechanics | Solid mechanics]]&lt;br /&gt;
&lt;br /&gt;
== Discussions / Applications ==&lt;br /&gt;
This section is meant for general discussion about the physical background of the examples, the solution procedures, various applications, etc. Note, that code snippets presented in discussion might not reflect the actual state of Medusa.  &lt;br /&gt;
* [[Convection Diffusion equation | Convection Diffusion equation]]&lt;br /&gt;
* [[Adaptivity|H-adaptivity]]&lt;br /&gt;
* [[Hp-adaptivity]]&lt;br /&gt;
* [[Solid Mechanics]]&lt;br /&gt;
** [[Point contact]]&lt;br /&gt;
** [[Hertzian contact]]&lt;br /&gt;
** [[Cantilever beam]]&lt;br /&gt;
** [[Fretting fatigue case]]&lt;br /&gt;
** [[Plasticity]]&lt;br /&gt;
* [[Fluid Mechanics]]&lt;br /&gt;
** [[Lid driven cavity]]&lt;br /&gt;
** [[Burger's equation]]&lt;br /&gt;
** [[de Vahl Davis natural convection test]]&lt;br /&gt;
** [[Natural convection in 3D irregular domain]]&lt;br /&gt;
** [[Natural convection from heated cylinder]]&lt;br /&gt;
** [[Natural convection between concentric cylinders]]&lt;br /&gt;
** [[Non-Newtonian fluid]]&lt;br /&gt;
* [[Computational electromagnetics]]&lt;br /&gt;
** [[Triple dielectric step in 1D]]&lt;br /&gt;
** [[Scattering from an infinite cylinder]]&lt;br /&gt;
** [[Point source near an anisotropic lens]]&lt;br /&gt;
* Other applications&lt;br /&gt;
** [[Attenuation due to liquid water content in the atmosphere|Attenuation of a satellite communication]]&lt;br /&gt;
** [[Heart rate variability detection]]&lt;br /&gt;
** [[Bioheat equation]]&lt;br /&gt;
&lt;br /&gt;
== Performance analyses ==&lt;br /&gt;
* [[Execution on Intel® Xeon Phi™ co-processor]]&lt;br /&gt;
* [[1D MLSM and FDM comparison]]&lt;br /&gt;
* [[:File:tech_report.pdf|Execution overheads due to clumsy types::technical report]] [[File:pdf-file.gif]]&lt;br /&gt;
* [[Solving sparse systems]]&lt;br /&gt;
* [[Eigen paralelization]]&lt;br /&gt;
&lt;br /&gt;
== Last changes ==&lt;br /&gt;
&amp;lt;news unique=1 limit = 5&amp;gt;&lt;br /&gt;
*{{{timeanddate}}} :: {{{title}}} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/news&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
* FAQ  - [[Frequently asked questions]]. &lt;br /&gt;
* [[List of wiki contributors]]&lt;br /&gt;
* List of library contributors: [http://e6.ijs.si/medusa/about#about-contributors See the official website]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
For all related papers including conference contributions, monographs and book chapters check https://e6.ijs.si/ParallelAndDistributedSystems/publications/&lt;br /&gt;
&lt;br /&gt;
{{Box-round|title= Selected papers |&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/98533123.pdf M. Depolli, J. Slak, G. Kosec; Parallel domain discretization algorithm for RBF-FD and other meshless numerical methods for solving PDEs, Computers &amp;amp; Structures, 2022 [DOI: 10.1016/j.compstruc.2022.106773]]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/69777155.pdf J. Slak, G. Kosec; Medusa : A C++ library for solving PDEs using strong form mesh-free methods, ACM transactions on mathematical software, vol. 47, 2021 [DOI: 10.1145/3450966]]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/56730115.pdf U. Duh, G. Kosec, J. Slak; Fast variable density node generation on parametric surfaces with application to mesh-free methods, SIAM journal on scientific computing, vol. 43, 2021 [DOI: 10.1137/20M1325642]]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/52715011.pdf M. Jančič, J. Slak, G. Kosec; Monomial augmentation guidelines for RBF-FD from accuracy versus computational time perspective, Journal of scientific computing, vol. 87, 2021 [DOI: 10.1007/s10915-020-01401-y]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/32782887.pdf J. Slak, G. Kosec; On generation of node distributions for meshless PDE discretizations, SIAM journal on scientific computing, vol. 41, 2019 [DOI: 10.1137/18M1231456]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/32424999.pdf G. Kosec, J. Slak, M. Depolli, R. Trobec, K. Pereira, S. Tomar, T. Jacquemin, S. Bordas, M. Wahab; Weak and strong from meshless methods for linear elastic problem under fretting contact conditions, Tribology international, vol. 138, 2019]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/32230439.pdf J. Slak, G. Kosec; Adaptive radial basis function-generated finite differences method for contact problems, International journal for numerical methods in engineering, vol. 119, 2019 [DOI: 10.1002/nme.6067]]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/32388135.pdf M. Maksić, V. Djurica, A. Souvent, J. Slak, M. Depolli, G. Kosec; Cooling of overhead power lines due to the natural convection, International journal of electrical power &amp;amp; energy systems, 2019]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/31107623.pdf J. Slak, G. Kosec; Refined meshless local strong form solution of Cauchy-Navier equation on an irregular domain, Engineering analysis with boundary elements, vol. 100, 2019]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/29639719.pdf M. Depolli, G. Kosec; Assessment of differential evolution for multi-objective optimization in a natural convection problem solved by a local meshless method, Engineering optimization, 2017, vol. 49, no. 4, pp. 675-692]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/29512743.pdf G. Kosec; A local numerical solution of a fluid-flow problem on an irregular domain, Advances in engineering software, vol. 120, 2018 [DOI: 10.1016/j.advengsoft.2016.05.010]]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/27912487.pdf G. Kosec, R. Trobec; Simulation of semiconductor devices with a local numerical approach, Engineering analysis with boundary elements, 2015 [DOI: 10.1016/j.enganabound.2014.07.013]]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/3218939.pdf G. Kosec, B. Šarler; Simulation of macrosegregation with mesosegregates in binary metallic casts by a meshless method, Engineering analysis with boundary elements]&lt;br /&gt;
&lt;br /&gt;
[http://comms.ijs.si/~gkosec/data/papers/27339815.pdf G. Kosec, M. Depolli, A. Rashkovska, R. Trobec; Super linear speedup in a local parallel meshless solution of thermo-fluid problem, Computers &amp;amp; Structures, vol. 133, 2014]&lt;br /&gt;
&lt;br /&gt;
[http://comms.ijs.si/~gkosec/data/papers/26785063.pdf G. Kosec, P. Zinterhof; Local strong form meshless method on multiple Graphics Processing Units, Computer modeling in engineering &amp;amp; sciences, vol. 91, 2013]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/2599419.pdf G. Kosec, B. Šarler; Solution of a low Prandtl number natural convection benchmark by a local meshless method, International journal of numerical methods for heat &amp;amp; fluid flow]&lt;br /&gt;
&lt;br /&gt;
[http://comms.ijs.si/~gkosec/data/papers/EABE2499.pdf R. Trobec, G. Kosec, M. Šterk, B. Šarler; Comparison of local weak and strong form meshless methods for 2-D diffusion equation, Engineering analysis with boundary elements, vol. 36, 2012]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/1905659.pdf G. Kosec, M. Založnik, B. Šarler, H. Combeau; A meshless approach towards solution of macrosegregation phenomena, Computers, materials &amp;amp; continua : CMC, vol. 22, 2011 ]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/992507.pdf G. Kosec, B. Šarler; Solution of thermo-fluid problems by collocation with local pressure correction, International journal of numerical methods for heat &amp;amp; fluid flow, vol.18, 2008]&lt;br /&gt;
&lt;br /&gt;
R. Trobec, G. Kosec; Parallel scientific computing : theory, algorithms, and applications of mesh based and meshless methods, 2015&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Related pages==&lt;br /&gt;
* http://e6.ijs.si/ParallelAndDistributedSystems/products/medusa/&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Medusa&amp;diff=3568</id>
		<title>Medusa</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Medusa&amp;diff=3568"/>
				<updated>2024-01-13T13:18:35Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--__NOTITLE__--&amp;gt;&lt;br /&gt;
'''Welcome to the Medusa wiki. To visit the main website, go to [http://e6.ijs.si/medusa/ http://e6.ijs.si/medusa/].'''&lt;br /&gt;
&lt;br /&gt;
In [http://e6.ijs.si/ParallelAndDistributedSystems/ Parallel and Distributed Systems Laboratory] we are working on a C++ library that is first and foremost focused on tools for solving Partial Differential Equations by meshless methods. The basic idea is to create generic codes for tools that are needed for solving not only PDEs but many other problems, e.g. Moving Least Squares approximation, $k$-d tree, domain generation engines, etc.&lt;br /&gt;
We call this open source meshless project [http://e6.ijs.si/medusa/ Medusa: Coordinate Free Meshless Method implementation (MM)].&lt;br /&gt;
&lt;br /&gt;
Technical details about code and examples  can be found on our [http://e6.ijs.si/medusa/docs/ documentation page] and [https://gitlab.com/e62Lab/medusa Gitlab repository]. [[File:C.png|100px||link=https://gitlab.com/e62Lab/medusa|alt=Alt text|code]] [[File:doxygen.png|100px|link=http://e6.ijs.si/medusa/docs/|alt=Alt text|Documentation page]]&lt;br /&gt;
&lt;br /&gt;
This wiki site is meant for more relaxed discussions about general principles, possible and already implemented applications, preliminary analyses, etc.&lt;br /&gt;
Note, that there are many grammatical mistakes, typos, stupid sentences, etc. This wiki is meant for quick information exchange and therefore we do not invest a lot of energy into styling :).  &lt;br /&gt;
&lt;br /&gt;
== Documentation ==&lt;br /&gt;
* [https://gitlab.com/e62Lab/medusa Code on Gitlab]&lt;br /&gt;
* [[How to build | Installation and building]]&lt;br /&gt;
* [[Including this library in your project | Including this library in your project]]&lt;br /&gt;
* [[Testing | Running tests]]&lt;br /&gt;
* [http://e6.ijs.si/medusa/docs/ Technical documentation]&lt;br /&gt;
* [[Coding style | Coding style]]&lt;br /&gt;
* [[Wiki editing guide | Wiki editing and backup guide]]&lt;br /&gt;
&lt;br /&gt;
== Building blocks ==&lt;br /&gt;
Medusa is modular coordinate-free parallel implementation of a numerical framework designed, but not limited to, for solving PDEs. In this section we present main modules of the library that can be also used as a standalone tools. &lt;br /&gt;
* [[Positioning of computational nodes]] &lt;br /&gt;
* [[Relaxation of the nodal distribution]]&lt;br /&gt;
* [[Refinement of the nodal distribution]]&lt;br /&gt;
* [[k-d tree|''k''-d tree and other spatial search structures]] &lt;br /&gt;
* [[Solving system | Solving linear system - including over and underdetermined systems]]&lt;br /&gt;
* [[Weighted Least Squares (WLS)]]&lt;br /&gt;
* [[Computation of shape functions]]&lt;br /&gt;
* [[Radial basis function-generated finite differences (RBF-FD)]]&lt;br /&gt;
* [[Ghost nodes (theory)]]&lt;br /&gt;
* [[Integrators for time stepping]]&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
In this section we present exact examples. Each of the below solutions can be found also in in the repository under examples. More explanation about the physical background and solution procedure can be found in following sections.&lt;br /&gt;
* [[Philosophy of examples and how to run them]]&lt;br /&gt;
* [[Poisson's equation]]&lt;br /&gt;
* [[Heat equation]]&lt;br /&gt;
* [[Linear elasticity]]&lt;br /&gt;
* [[Complex-valued problems]]&lt;br /&gt;
* [[Coupled domains]]&lt;br /&gt;
* [[Parametric domains | Parametric domains &amp;amp;ndash; Curved surface with variable density]]&lt;br /&gt;
* [[NURBS domains | Domains modeled with non-uniform rational basis splines (NURBS)]]&lt;br /&gt;
* [[Determining the interior of the domain by oversampling the boundary]]&lt;br /&gt;
* [[Computer-aided design - Importing IGES and STEP files]]&lt;br /&gt;
* [[Realistic 3D models|Working with 3D surface mesh models ]]&lt;br /&gt;
* [[customization | Operator customization]]&lt;br /&gt;
* [[Ghost nodes]]&lt;br /&gt;
* [[Electromagnetic scattering]]&lt;br /&gt;
* [[Schrödinger equation]]&lt;br /&gt;
* [[Wave equation]]&lt;br /&gt;
* [[Cahn-Hilliard equation]]&lt;br /&gt;
* [[Fluid mechanics]]&lt;br /&gt;
* [[Solid Mechanics | Solid mechanics]]&lt;br /&gt;
&lt;br /&gt;
== Discussions / Applications ==&lt;br /&gt;
This section is meant for general discussion about the physical background of the examples, the solution procedures, various applications, etc. Note, that code snippets presented in discussion might not reflect the actual state of Medusa.  &lt;br /&gt;
* [[Convection Diffusion equation | Convection Diffusion equation]]&lt;br /&gt;
* [[Adaptivity|H-adaptivity]]&lt;br /&gt;
* [[Hp-adaptivity]]&lt;br /&gt;
* [[Solid Mechanics]]&lt;br /&gt;
** [[Point contact]]&lt;br /&gt;
** [[Hertzian contact]]&lt;br /&gt;
** [[Cantilever beam]]&lt;br /&gt;
** [[Fretting fatigue case]]&lt;br /&gt;
** [[Plasticity]]&lt;br /&gt;
* [[Fluid Mechanics]]&lt;br /&gt;
** [[Lid driven cavity]]&lt;br /&gt;
** [[Burger's Equation]]&lt;br /&gt;
** [[de Vahl Davis natural convection test]]&lt;br /&gt;
** [[Natural convection in 3D irregular domain]]&lt;br /&gt;
** [[Natural convection from heated cylinder]]&lt;br /&gt;
** [[Natural convection between concentric cylinders]]&lt;br /&gt;
** [[Non-Newtonian fluid]]&lt;br /&gt;
* [[Computational electromagnetics]]&lt;br /&gt;
** [[Triple dielectric step in 1D]]&lt;br /&gt;
** [[Scattering from an infinite cylinder]]&lt;br /&gt;
** [[Point source near an anisotropic lens]]&lt;br /&gt;
* Other applications&lt;br /&gt;
** [[Attenuation due to liquid water content in the atmosphere|Attenuation of a satellite communication]]&lt;br /&gt;
** [[Heart rate variability detection]]&lt;br /&gt;
** [[Bioheat equation]]&lt;br /&gt;
&lt;br /&gt;
== Performance analyses ==&lt;br /&gt;
* [[Execution on Intel® Xeon Phi™ co-processor]]&lt;br /&gt;
* [[1D MLSM and FDM comparison]]&lt;br /&gt;
* [[:File:tech_report.pdf|Execution overheads due to clumsy types::technical report]] [[File:pdf-file.gif]]&lt;br /&gt;
* [[Solving sparse systems]]&lt;br /&gt;
* [[Eigen paralelization]]&lt;br /&gt;
&lt;br /&gt;
== Last changes ==&lt;br /&gt;
&amp;lt;news unique=1 limit = 5&amp;gt;&lt;br /&gt;
*{{{timeanddate}}} :: {{{title}}} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/news&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
* FAQ  - [[Frequently asked questions]]. &lt;br /&gt;
* [[List of wiki contributors]]&lt;br /&gt;
* List of library contributors: [http://e6.ijs.si/medusa/about#about-contributors See the official website]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
For all related papers including conference contributions, monographs and book chapters check https://e6.ijs.si/ParallelAndDistributedSystems/publications/&lt;br /&gt;
&lt;br /&gt;
{{Box-round|title= Selected papers |&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/98533123.pdf M. Depolli, J. Slak, G. Kosec; Parallel domain discretization algorithm for RBF-FD and other meshless numerical methods for solving PDEs, Computers &amp;amp; Structures, 2022 [DOI: 10.1016/j.compstruc.2022.106773]]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/69777155.pdf J. Slak, G. Kosec; Medusa : A C++ library for solving PDEs using strong form mesh-free methods, ACM transactions on mathematical software, vol. 47, 2021 [DOI: 10.1145/3450966]]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/56730115.pdf U. Duh, G. Kosec, J. Slak; Fast variable density node generation on parametric surfaces with application to mesh-free methods, SIAM journal on scientific computing, vol. 43, 2021 [DOI: 10.1137/20M1325642]]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/52715011.pdf M. Jančič, J. Slak, G. Kosec; Monomial augmentation guidelines for RBF-FD from accuracy versus computational time perspective, Journal of scientific computing, vol. 87, 2021 [DOI: 10.1007/s10915-020-01401-y]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/32782887.pdf J. Slak, G. Kosec; On generation of node distributions for meshless PDE discretizations, SIAM journal on scientific computing, vol. 41, 2019 [DOI: 10.1137/18M1231456]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/32424999.pdf G. Kosec, J. Slak, M. Depolli, R. Trobec, K. Pereira, S. Tomar, T. Jacquemin, S. Bordas, M. Wahab; Weak and strong from meshless methods for linear elastic problem under fretting contact conditions, Tribology international, vol. 138, 2019]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/32230439.pdf J. Slak, G. Kosec; Adaptive radial basis function-generated finite differences method for contact problems, International journal for numerical methods in engineering, vol. 119, 2019 [DOI: 10.1002/nme.6067]]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/32388135.pdf M. Maksić, V. Djurica, A. Souvent, J. Slak, M. Depolli, G. Kosec; Cooling of overhead power lines due to the natural convection, International journal of electrical power &amp;amp; energy systems, 2019]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/31107623.pdf J. Slak, G. Kosec; Refined meshless local strong form solution of Cauchy-Navier equation on an irregular domain, Engineering analysis with boundary elements, vol. 100, 2019]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/29639719.pdf M. Depolli, G. Kosec; Assessment of differential evolution for multi-objective optimization in a natural convection problem solved by a local meshless method, Engineering optimization, 2017, vol. 49, no. 4, pp. 675-692]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/29512743.pdf G. Kosec; A local numerical solution of a fluid-flow problem on an irregular domain, Advances in engineering software, vol. 120, 2018 [DOI: 10.1016/j.advengsoft.2016.05.010]]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/27912487.pdf G. Kosec, R. Trobec; Simulation of semiconductor devices with a local numerical approach, Engineering analysis with boundary elements, 2015 [DOI: 10.1016/j.enganabound.2014.07.013]]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/3218939.pdf G. Kosec, B. Šarler; Simulation of macrosegregation with mesosegregates in binary metallic casts by a meshless method, Engineering analysis with boundary elements]&lt;br /&gt;
&lt;br /&gt;
[http://comms.ijs.si/~gkosec/data/papers/27339815.pdf G. Kosec, M. Depolli, A. Rashkovska, R. Trobec; Super linear speedup in a local parallel meshless solution of thermo-fluid problem, Computers &amp;amp; Structures, vol. 133, 2014]&lt;br /&gt;
&lt;br /&gt;
[http://comms.ijs.si/~gkosec/data/papers/26785063.pdf G. Kosec, P. Zinterhof; Local strong form meshless method on multiple Graphics Processing Units, Computer modeling in engineering &amp;amp; sciences, vol. 91, 2013]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/2599419.pdf G. Kosec, B. Šarler; Solution of a low Prandtl number natural convection benchmark by a local meshless method, International journal of numerical methods for heat &amp;amp; fluid flow]&lt;br /&gt;
&lt;br /&gt;
[http://comms.ijs.si/~gkosec/data/papers/EABE2499.pdf R. Trobec, G. Kosec, M. Šterk, B. Šarler; Comparison of local weak and strong form meshless methods for 2-D diffusion equation, Engineering analysis with boundary elements, vol. 36, 2012]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/1905659.pdf G. Kosec, M. Založnik, B. Šarler, H. Combeau; A meshless approach towards solution of macrosegregation phenomena, Computers, materials &amp;amp; continua : CMC, vol. 22, 2011 ]&lt;br /&gt;
&lt;br /&gt;
[https://e6.ijs.si/ParallelAndDistributedSystems/publications/992507.pdf G. Kosec, B. Šarler; Solution of thermo-fluid problems by collocation with local pressure correction, International journal of numerical methods for heat &amp;amp; fluid flow, vol.18, 2008]&lt;br /&gt;
&lt;br /&gt;
R. Trobec, G. Kosec; Parallel scientific computing : theory, algorithms, and applications of mesh based and meshless methods, 2015&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Related pages==&lt;br /&gt;
* http://e6.ijs.si/ParallelAndDistributedSystems/products/medusa/&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Burgers%27_equation&amp;diff=3567</id>
		<title>Burgers' equation</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Burgers%27_equation&amp;diff=3567"/>
				<updated>2024-01-13T12:32:10Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Let us consider the Burger's equation, which describes the dynamics of viscous fluid without the effects of pressure. Despite being unrealistic it is the simplest description of advective flow with diffusive effects of viscosity. It has the following form&lt;br /&gt;
\begin{equation}&lt;br /&gt;
\frac{\partial \b{u}}{\partial t} + (\b{u}\cdot\nabla)\b{u} = \nu \nabla^2 \b{u}&lt;br /&gt;
\end{equation}&lt;br /&gt;
&lt;br /&gt;
where $\b{u}$ is a velocity field. For time stepping the advection term must be linearized. There are several tactics of linearization, but we choose the simplest one, which is using the current velocity as an approximant of the velociy in the next time step. Using the implicit Euler method we arrive at the equation&lt;br /&gt;
&lt;br /&gt;
\begin{equation}&lt;br /&gt;
\b{u}^{n+1}_i + [\b{u}^{n}_i\cdot\nabla_i\b{u}^{n+1} - \nu\nabla^2_i \b{u}^{n+1}]\Delta t  = \b{u}^{n}_i&lt;br /&gt;
\end{equation}&lt;br /&gt;
&lt;br /&gt;
where the subscript $i$ is the index of the domain node, superscripts $n$ and $n+1$ denote the current and the next time step respectively, $\Delta t$ is the length of the time step. The notation $\nabla_i$ means the gradient operator at node $i$, not the component of the gradient. Same holds for $\nabla^2_i$. Using the Medusa library, this equation can be solved for $\b{u}^{n+1}_i$.&lt;br /&gt;
&lt;br /&gt;
=Solution in 1D=&lt;br /&gt;
Let's look at an example in 1D with Dirichlet boundary conditions. We are solving the equivalent of equation (2) but with only one spatial variable&lt;br /&gt;
$$u^{n+1}_i + [u^{n}_i\frac{\partial u^{n+1}}{\partial x} - \nu\frac{\partial^2 u^{n+1}}{\partial x^2}]\Delta t = u^{n}_i$$&lt;br /&gt;
$$u_i = 0 \text{ on } \partial \Omega$$&lt;br /&gt;
&lt;br /&gt;
This will be rewritten into a linear system of equations with Medusa and then solved with Eigen. Let's look at the code(find the full version in our repository)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot; line&amp;gt;&lt;br /&gt;
// Build 1D domain&lt;br /&gt;
BoxShape&amp;lt;Vec1d&amp;gt; domain((-l), (l));&lt;br /&gt;
auto discretization = domain.discretizeWithStep(dx);&lt;br /&gt;
int domain_size = discretization.size();&lt;br /&gt;
// Find support nodes&lt;br /&gt;
FindClosest find_support(5);&lt;br /&gt;
discretization.findSupport(find_support);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First we construct our 1D domain with lenght 2l, discretize it with a given step dx and find the closest 5 nodes of each node which are called stencil nodes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot; line&amp;gt;&lt;br /&gt;
Polyharmonic&amp;lt;double, 3&amp;gt; p;&lt;br /&gt;
Monomials&amp;lt;Vec1d&amp;gt; mon(4);&lt;br /&gt;
RBFFD&amp;lt;Polyharmonic&amp;lt;double, 3&amp;gt;, Vec1d, ScaleToClosest&amp;gt;&lt;br /&gt;
        approx(p, mon);&lt;br /&gt;
auto storage = discretization.computeShapes(approx); &lt;br /&gt;
VectorXd E1 = VectorXd::Zero(domain_size);  // vector for containing the current state&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use Polyharmonic Radial Basis Functions(RBFs) of order 3 augmented with monomials up to 3th order for our approximation engine. We use it in conjunction with stencil nodes to compute the stencil weights(also called shape functions) which are used in approximations of differential operators on our domain. Next we set the initial condition to $$u(x, 0) = \frac{2\nu ake^{-\nu k^2t}\sin(kx)}{b + ae^{-\nu k^2t}\cos(kx)}$$ where $a, b, k$ are constants. We chose this function because it has an analytical solution which we will compare our solution to. It is derived using the Cole-Hopf transformation of a solution of the diffusion equation with the initial profile $f(x) = b + a\cos(kx)$ for $b&amp;gt;a$.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot; line&amp;gt;&lt;br /&gt;
    //Set initial condition &lt;br /&gt;
    for (int i : discretization.all()){ &lt;br /&gt;
        E1(i) = 2*visc*a*k*std::exp(-visc*pow(k,2)*t_0)*std::sin(k*discretization.pos(i,0))/(b+a*std::exp(- &lt;br /&gt;
        visc*pow(k,2)*t_0)*std::cos(k*discretization.pos(i,0)));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Inside our time-stepping loop, we instantiate the matrix $M$ and the vector $rhs$ representing the linear system. We then construct the differential operators for implicit solving.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot; line&amp;gt;&lt;br /&gt;
for (tt = 1; tt &amp;lt;= t_steps; ++tt) {&lt;br /&gt;
    SparseMatrix&amp;lt;double&amp;gt; M(domain_size, domain_size); // construct matrix of apropreate size&lt;br /&gt;
    VectorXd rhs = VectorXd::Zero(domain_size);  // set empty vector for rhs&lt;br /&gt;
    M.reserve(Range&amp;lt;int&amp;gt;(domain_size, n));&lt;br /&gt;
    auto op = storage.implicitOperators(M, rhs);  // compute the implicit operators        &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now comes the crucial part - setting the equation. In essence, we rewrite the equation (2) in Medusa's terms. Terms with the prefix op. are matrices that represent the appropriate differential operators(op.value is simply the identity matrix).&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Burgers%27_equation&amp;diff=3564</id>
		<title>Burgers' equation</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Burgers%27_equation&amp;diff=3564"/>
				<updated>2023-12-27T12:34:28Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Burgers equation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$$\frac{\partial u}{\partial t} + u(\nabla \cdot u) = \nu \nabla^2 u$$&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Burgers%27_equation&amp;diff=3563</id>
		<title>Burgers' equation</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Burgers%27_equation&amp;diff=3563"/>
				<updated>2023-12-27T12:34:17Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Burgers equation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$$\frac{\partial u}{\partial t} + u(\nabla \cdot u) = \ni \nabla^2 u$$&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Fluid_Mechanics&amp;diff=3562</id>
		<title>Fluid Mechanics</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Fluid_Mechanics&amp;diff=3562"/>
				<updated>2023-12-27T12:32:07Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
Computational fluid dynamics (CFD) is a field of a great interest among researchers in many fields of science, e.g. studying mathematical fundaments of numerical methods, developing novel physical models, improving computer implementations, and many others. Pushing the limits of all involved fields of science helps community to deepen the understanding of several natural and technological phenomena. Weather forecast, ocean dynamics, water transport, casting, various energetic studies, etc., are just few examples where fluid dynamics plays a crucial role. The core problem of the CFD is solving the Navier-Stokes Equation or its variants, e.g. Darcy or Brinkman equation for flow in porous media. Here, we discuss basic algorithms for solving CFD problems. Check reference list on the [[Medusa|main page]] for more details about related work.&lt;br /&gt;
&lt;br /&gt;
Long story short, we want to solve&lt;br /&gt;
\begin{equation}&lt;br /&gt;
\frac{\partial \b{v}}{\partial t}+\nabla \cdot ( \rho \b{vv}) = -\nabla p+ \nabla(\mu \nabla\b{v})+\b{f}&lt;br /&gt;
\label{NavierStokes}&lt;br /&gt;
\end{equation}&lt;br /&gt;
also known as a Navier-Stokes equation. &lt;br /&gt;
&lt;br /&gt;
Note that the $\b{v}\b{v}$ stands for the tensor or dyadic product \[ \b{v}\b{v} = \b{v}\otimes\b{v} = \b{v}\b{v}^\T = \left[ \begin{matrix}&lt;br /&gt;
   {{v}_{1}}{{v}_{1}} &amp;amp; \cdots &amp;amp; {{v}_{1}}{{v}_{n}}  \\&lt;br /&gt;
   \vdots &amp;amp; \ddots &amp;amp; \vdots  \\&lt;br /&gt;
   {{v}_{n}}{{v}_{1}} &amp;amp; \cdots &amp;amp; {{v}_{n}}{{v}_{n}}  \\&lt;br /&gt;
\end{matrix} \right]\]&lt;br /&gt;
&lt;br /&gt;
Combining equation \ref{NavierStokes} and mass contiunity equation&lt;br /&gt;
\begin{equation}&lt;br /&gt;
  \frac{\partial \rho }{\partial t} + \nabla  \cdot (\rho {\bf{u}}) = 0.&lt;br /&gt;
\end{equation}&lt;br /&gt;
&lt;br /&gt;
simplifies advection term into (see [https://en.wikipedia.org/wiki/Derivation_of_the_Navier%E2%80%93Stokes_equations] for derivation)&lt;br /&gt;
&lt;br /&gt;
\[\frac{\partial \left( \rho \b{v} \right)}{\partial t}+\nabla \cdot \left( \rho \b{vv} \right)=\frac{\partial \left( \rho \b{v} \right)}{\partial t}+(\rho \b{v}\cdot \nabla )\cdot \b{v}. \]&lt;br /&gt;
&lt;br /&gt;
An example of advection term in 2D would therefore be&lt;br /&gt;
\[\left( \b{v}\cdot \nabla  \right)\b{v}=\left( \left( \begin{matrix}&lt;br /&gt;
   u  \\&lt;br /&gt;
   v  \\&lt;br /&gt;
\end{matrix} \right) \cdot \left( \begin{matrix}&lt;br /&gt;
   \frac{\partial }{\partial x}  \\&lt;br /&gt;
   \frac{\partial }{\partial y}  \\&lt;br /&gt;
\end{matrix} \right) \right)\left( \begin{matrix}&lt;br /&gt;
   u  \\&lt;br /&gt;
   v  \\&lt;br /&gt;
\end{matrix} \right)=\left( \begin{matrix}&lt;br /&gt;
   u\frac{\partial u}{\partial x}+v\frac{\partial u}{\partial y}  \\&lt;br /&gt;
   u\frac{\partial v}{\partial x}+v\frac{\partial v}{\partial y}  \\&lt;br /&gt;
\end{matrix} \right)\]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In many cases we are interested in the incompressible fluids (Ma&amp;lt;0.3), reducing the continuity equation to&lt;br /&gt;
\begin{equation}&lt;br /&gt;
\nabla \cdot \b{v}=0&lt;br /&gt;
\label{contuinity}&lt;br /&gt;
\end{equation}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The goal of CFD is to solve system \ref{NavierStokes} and \ref{contuinity}. It is obvious that a special treatment will be needed to couple both equations. In the following discussion we cover some basic approaches, how this can be accomplished.&lt;br /&gt;
&lt;br /&gt;
= Solutions algorithms =&lt;br /&gt;
== Artificial compressibility method ==&lt;br /&gt;
The simplest, completely explicit approach, is an artificial compressibility method (ACM), where a compressibility term is included in the mass continuity&lt;br /&gt;
\[\frac{\partial \b{v}}{\partial t}+(\b{v}\cdot\nabla )\b{v}=-\frac{1}{\rho }\nabla p+\nu {{\nabla }^{2}}\b{v}+\b{f}\]&lt;br /&gt;
\[\frac{ 1 }{ \rho } \frac{\partial \rho }{\partial t}+\nabla \cdot \b{v}=0\]&lt;br /&gt;
\[\frac{ 1 }{ \rho } \frac{\partial \rho }{\partial p}\frac{\partial p}{\partial t}+\nabla \cdot \b{v}=0\]&lt;br /&gt;
Now, the above system can be solved directly.&lt;br /&gt;
&lt;br /&gt;
The addition of the time derivative of the pressure term physically means that waves of finite speed (the propagation of which depends on the magnitude of the ACM)&lt;br /&gt;
are introduced into the flow field as a mean to distribute the pressure within the domain. In a true&lt;br /&gt;
incompressible flow, the pressure field is affected instantaneously throughout the whole domain. In ACM there is a time delay between the flow disturbance and its effect on the&lt;br /&gt;
pressure field. Upon rearranging the equation yields&lt;br /&gt;
\[\frac{\partial p}{\partial t}+\rho {{C}^{2}}\nabla \cdot \b{v}=0\]&lt;br /&gt;
where the continuity equation is perturbed by the quantity $\frac{\partial p}{\partial t}$ denominated herein&lt;br /&gt;
as the AC parameter/artificial sound speed recognized by&lt;br /&gt;
$C$ [m/s] - speed of sound&lt;br /&gt;
\[\frac{1}{C^2}=\frac{\partial \rho }{\partial p}\]&lt;br /&gt;
Or in other words&lt;br /&gt;
\[C^2=\left( \frac{\partial p}{\partial \rho}\right)_S\]&lt;br /&gt;
where $\rho$ is the density of the material. It follows, by replacing partial derivatives, that the isentropic compressibility can be expressed as:&lt;br /&gt;
\[\beta =\frac{1}{\rho {{C}^{2}}}\]&lt;br /&gt;
The evaluation of the local ACM parameter in incompressible flows is inspired by the&lt;br /&gt;
speed of sound computations in compressible flows (for instance, from the perfect gas law).&lt;br /&gt;
However, in the incompressible flow situation, employing such a relation is difficult, but an artificial&lt;br /&gt;
relation can be developed from the convective and diffusive velocities.&lt;br /&gt;
Reverting to the justification of continuity modification, it can be immediately seen that the&lt;br /&gt;
artificial sound speed must be sufficiently large to have a significant regularizing effect and at&lt;br /&gt;
the same time must be as small as possible to minimizing perturbations on the incompressibility&lt;br /&gt;
equation.  Therefore, $C$ influences the convergence rate and stability of the solution method. In other words,&lt;br /&gt;
assists in reducing large disparity in the eigenvalues, leading to a well-conditioned system. &lt;br /&gt;
The $C$ can be '''estimated''' with&lt;br /&gt;
&lt;br /&gt;
\[ C = \beta \max \left( \left|\b{v}\right|_2, \left|\b{v}_{ref}\right|_2 \right),\]&lt;br /&gt;
where $\b{v}_{ref}$ stands for a reference velocity. &lt;br /&gt;
Values for $\beta$ in the range of 1–10 are recommended for better convergence to the steady state at which the&lt;br /&gt;
mass conservation is enforced. In addition, Equation ensures that $C$ does not reach zero at stagnation points&lt;br /&gt;
that cause instabilities in pseudo-time, effecting convergence&lt;br /&gt;
&lt;br /&gt;
Note, that for more complex simulation an internal iteration loops is required before marching in time. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;ACM&amp;quot;&amp;gt;&lt;br /&gt;
[[File:ACM BlockDiagram.png|600px]]&lt;br /&gt;
&amp;lt;caption&amp;gt;Scheme of the ACM algorithm &amp;lt;/caption&amp;gt;&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Explicit/Implicit pressure calculation ==&lt;br /&gt;
&lt;br /&gt;
Applying divergence on \ref{NavierStokes} yields&lt;br /&gt;
\[\nabla \cdot \frac{\partial \b{v}}{\partial t}+\nabla \cdot (\b{v}\cdot \nabla )\b{v}=-\frac{1}{\rho }{{\nabla }^{2}}p+\nabla \cdot \nu {{\nabla }^{2}}\b{v}+\nabla \cdot \b{f}\]&lt;br /&gt;
&lt;br /&gt;
And since $\nabla \cdot \b{v}=0$ and we can change order in $\nabla \cdot \nabla^2$ and $ \nabla^2 \cdot \nabla$ equation simplifies to&lt;br /&gt;
\[\frac{1}{\rho }{{\nabla }^{2}}p=\nabla \cdot \b{f}-\nabla \cdot (\b{v}\cdot \nabla )\b{v}\]&lt;br /&gt;
Now, we need boundary conditions that can be obtained by multiplying the equation  with a boundary normal vector&lt;br /&gt;
\[\b{\hat{n}}\cdot \left( \frac{\partial \b{v}}{\partial t}+(\b{v}\cdot \nabla )\b{v} \right)=\b{\hat{n}}\cdot \left( -\frac{1}{\rho }\nabla p+\nu {{\nabla }^{2}}\b{v}+\b{f} \right)\cdot \b{\hat{n}}\]&lt;br /&gt;
\[\frac{\partial p}{\partial \b{\hat{n}}}=\left( \nu {{\nabla }^{2}}\b{v}+\b{f}-\frac{\partial \b{v}}{\partial t}-(\b{v}\cdot\nabla ) \b{v} \right)\cdot \b{\hat{n}}\]&lt;br /&gt;
&lt;br /&gt;
Note that using tangential boundary vector gives equivalent BCs&lt;br /&gt;
\[\frac{\partial p}{\partial \b{\hat{t}}}=\left( \nu {{\nabla }^{2}}\b{v}+\b{f}-\frac{\partial \b{v}}{\partial t}-(\b{v}\cdot\nabla ) \b{v} \right)\cdot \b{\hat{t}}\]&lt;br /&gt;
For no-slip boundaries BCs simplify to&lt;br /&gt;
\[\frac{\partial p}{\partial \b{\hat{n}}}=\left( \nu {{\nabla }^{2}}\b{v}+\b{f} \right)\cdot \b{\hat{n}}\]&lt;br /&gt;
Otherwise an appropriate expression regarding the velocity can be written, i.e. write full  and taken in account velocity BCs. For example, Neumann velocity $\frac{\partial u}{\partial x}=0$ in 2D&lt;br /&gt;
\[\frac{\partial p}{\partial x}=\left( \nu {{\nabla }^{2}}u + {{f}_{x}}-\frac{\partial u}{\partial t}+v\frac{\partial u}{\partial y} \right)\]&lt;br /&gt;
Note that you allready know everything about the velocity and thus you can compute all the terms explicitly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So the procedure is:&lt;br /&gt;
&lt;br /&gt;
* Compute Navier Stokes either explicitly or implicitly&lt;br /&gt;
* Solve pressure equations with  computed velocities&lt;br /&gt;
* March in time&lt;br /&gt;
&lt;br /&gt;
Basic boundary conditions&lt;br /&gt;
Wall:   $\b{v}=0$, \[\frac{\partial p}{\partial \hat{n}}=\left( \nabla \cdot \left( \nu \nabla \b{v} \right)+\b{f} \right)\cdot \hat{n}\]&lt;br /&gt;
Inlet:  $\b{v}=\b{a}$, \[\frac{\partial p}{\partial \hat{n}}=\left( \nabla \cdot \left( \nu \nabla \b{v} \right)+\b{f}-\nabla \cdot (\rho \b{v}\b{v})-\rho \frac{\partial \b{v}}{\partial t} \right)\cdot \hat{n}\]&lt;br /&gt;
&lt;br /&gt;
Above system can be linearized (advection term) and solved either explicitly or implicitly.&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
&lt;br /&gt;
W. D. Henshaw, A fourth-order accurate method for the incompressible Navier–Stokes equations on overlapping grids, J. Comput. Phys. 113, 13 (1994)&lt;br /&gt;
&lt;br /&gt;
J. C. Strikwerda, Finite difference methods for the Stokes and Navier–Stokes equations, SIAM J. Sci. Stat.&lt;br /&gt;
Comput. 5(1), 56 (1984)&lt;br /&gt;
&lt;br /&gt;
== Explicit Pressure correction ==&lt;br /&gt;
Another possibility is to solve pressure correction equation. Again Consider the momentum equation and mass continuity and discretize it explicitly&lt;br /&gt;
\[\frac{{{\b{v}}_{2}}-{{\b{v}}_{1}}}{\Delta t}=-\frac{1}{\rho }\nabla {{p}_{1}}-({{\b{v}}_{1}}\nabla )\cdot {{\b{v}}_{1}}+\nu {{\nabla }^{2}}{{\b{v}}_{1}}+\b{f}\]&lt;br /&gt;
Computed velocity obviously does not satisfy the mass contunity and therefore let’s call it intermediate velocity. Intermediate velocity is calculated from guessed pressure and old velocity values.&lt;br /&gt;
\[{{\b{v}}^{inter}}=\b{v}_1 + \Delta t\left( -\frac{1}{\rho }\nabla {{p}_{1}}-({{\b{v}}_{1}}\nabla )\cdot {{\b{v}}_{1}}+\nu {{\nabla }^{2}}{{\b{v}}_{1}}+\b{f} \right)\]&lt;br /&gt;
A correction term is added that drives velocity to divergence free field&lt;br /&gt;
\[\nabla \cdot ({{\b{v}}^{inter}}+{{\b{v}}^{corr}})=0 \qquad \to \qquad \nabla \cdot {{\b{v}}^{inter}}=-\nabla \cdot {{\b{v}}^{corr}}\]&lt;br /&gt;
&lt;br /&gt;
Velocity correction is affected only by effect of pressure correction. This fact is obvious due to all terms except gradient of pressure on the right side of equation  are constant.&lt;br /&gt;
\[{{\b{v}}^{corr}}=-\frac{\Delta t}{\rho }\nabla {{p}^{corr}} \]&lt;br /&gt;
&lt;br /&gt;
Note that corrected velocity also satisfies boundary conditions&lt;br /&gt;
\[\b{v}^{iter}+\b{v}^{corr}=\b{v}^{BC}\]&lt;br /&gt;
Applying divergence  and  we get '''pressure correction poisson equation'''.&lt;br /&gt;
\[\,{{\nabla }^{2}}{{p}^{corr}}\,=\frac{\rho }{\Delta t}\nabla \cdot {{\mathbf{v}}^{iter}}\,\]&lt;br /&gt;
&lt;br /&gt;
Boundary conditions can be obtained by mulitplying the equation with a unit normal vector $\b{\hat{n}}$&lt;br /&gt;
\[\frac{\Delta t}{\rho }\frac{\partial {p}^{corr}}{\partial \b{\hat{n}}} = \b{\hat{n}} \cdot \left(\b{v}^{iter} - \b{v}^{BC} \right) \]&lt;br /&gt;
The most straightforward approach, for dirichlet BCs, is to take into account velocity boundary condition in computation of intermediate velocity, and clearly in such cases, pressure boundary condition simplifies to &lt;br /&gt;
\[\frac{\partial p^{corr}}{\partial \b{\hat{n}}} = 0 \]&lt;br /&gt;
As ${{\b{v}}^{\operatorname{int}er}}={{\b{v}}^{BC}}$ . Another option is to explicitely compute intermediate velocity also on boundaries and then correct it through pressure correction.&lt;br /&gt;
&lt;br /&gt;
The pressure poisson equation is, at given boundary conditions, defined only up to a constant. One solution is to select a node and set it to a constant, e.g. p(0, 0) = 0, however much more stable approach is to enforce solution with additional condition, also referred to as a regularization&lt;br /&gt;
	\[\int_{\Omega }^{{}}{pd}\Omega =0\]&lt;br /&gt;
\[\,{{\nabla }^{2}}{{p}^{corr}}\,-\alpha =\frac{\rho }{\Delta t}\nabla \cdot {{\b{v}}^{iter}}\,\]&lt;br /&gt;
Where $\alpha $ stands for Lagrange multiplier. Or in discrete form&lt;br /&gt;
	\[\sum\limits_{i}{p\left( {{x}_{i}} \right)=0}\]&lt;br /&gt;
	\[\b{Mp}-\alpha \b{1}=\frac{\rho }{\Delta t}\nabla \cdot {{\b{v}}^{iter}}\]&lt;br /&gt;
&lt;br /&gt;
where $\b{M}$ holds Laplace shape functions, i.e. the discrete version of Laplace differential operator. &lt;br /&gt;
&lt;br /&gt;
Solution of a system&lt;br /&gt;
&lt;br /&gt;
	\[\left[ \begin{matrix}&lt;br /&gt;
   {{M}_{11}} &amp;amp; .. &amp;amp; {{M}_{1n}} &amp;amp; 1  \\&lt;br /&gt;
   .. &amp;amp; .. &amp;amp; .. &amp;amp; 1  \\&lt;br /&gt;
   {{M}_{n1}} &amp;amp; ... &amp;amp; {{M}_{nn}} &amp;amp; 1  \\&lt;br /&gt;
   1 &amp;amp; 1 &amp;amp; 1 &amp;amp; 0  \\&lt;br /&gt;
\end{matrix} \right]\left[ \begin{matrix}&lt;br /&gt;
   {{p}_{1}}  \\&lt;br /&gt;
   ...  \\&lt;br /&gt;
   {{p}_{n}}  \\&lt;br /&gt;
   \alpha   \\&lt;br /&gt;
\end{matrix} \right]=\frac{\rho }{\Delta t}\left[ \begin{matrix}&lt;br /&gt;
   \nabla \cdot \b{v}_{_{1}}^{\text{iter}}  \\&lt;br /&gt;
   ...  \\&lt;br /&gt;
   \nabla \cdot \b{v}_{n}^{\text{iter}}  \\&lt;br /&gt;
   0  \\&lt;br /&gt;
\end{matrix} \right]\]&lt;br /&gt;
Gives us a solution of pressure correction.&lt;br /&gt;
&lt;br /&gt;
== CBS Algorithm ==&lt;br /&gt;
With explicit temporal discretization problem is formulated as&lt;br /&gt;
\[\b{\hat{v}}={{\b{v}}_{0}}+\Delta t\left( -\nabla {{p}_{0}}+\frac{1}{Re}{{\nabla }^{2}}{{\b{v}}_{0}}-\nabla \cdot ({{\b{v}}_{0}}{{\b{v}}_{0}}) \right)\]&lt;br /&gt;
\[p={{p}_{0}}-\xi \Delta {{t}_{F}}\nabla \b{\hat{v}}+\xi \Delta {{t}_{F}}\Delta t{{\nabla }^{2}}{{\overset{\scriptscriptstyle\frown}{P}}_{0}},\]&lt;br /&gt;
where $\b{\hat{v}}$, $\Delta t$, $\xi$ and $\Delta t_F$ stand for intermediate velocity, time step, relaxation parameter, and artificial time step, respectively, and index 0 stands for previous time / iteration step. First, the intermediate velocity is computed from previous time step. Second, the velocity is driven towards solenoidal field by correcting the pressure. Note that no special boundary conditions for pressure are used, i.e., the pressure on boundaries is computed with the same approach as in the interior of the domain. In general, the internal iteration with an artificial time step is required until the divergence of the velocity field is not below required criteria. However, if one is interested only in a steady-state solution, the internal iteration can be skipped and $\Delta t$ equals $\Delta {{t}_{F}}$. Without internal stepping the transient of the solution is distorted by artificial compressibility effect. This approach is also known as ACM with Characteristics-based discretization of continuity equation, where the relaxation parameter relates to the artificial speed of sound [35].&lt;br /&gt;
&lt;br /&gt;
The relaxation parameter should be set between 1-10, lower number more stable solution.&lt;br /&gt;
&lt;br /&gt;
And also dimensional form&lt;br /&gt;
&lt;br /&gt;
\[p={{p}_{0}}-{{C}^{2}}\Delta {{t}_{F}}\rho \nabla \b{\hat{v}}+{{C}^{2}}\Delta {{t}_{F}}\Delta t{{\nabla }^{2}}{{p}_{0}},\]&lt;br /&gt;
&lt;br /&gt;
Where C is speed of sound [m/s]&lt;br /&gt;
&lt;br /&gt;
== The Stream Function - Vorticity Approach ==&lt;br /&gt;
&lt;br /&gt;
In two dimensions, the Navier–Stokes equations can be expressed using the&lt;br /&gt;
stream function $\psi$ and the vorticity $\omega$ in place of the primitive variables $u$, $v$, and&lt;br /&gt;
$p$. This involves the elimination of the pressure $p$, thus yielding one dependent&lt;br /&gt;
variable less. In three dimensions, however, this formulation leads to six unknowns&lt;br /&gt;
rather than four (in primitive variables), which makes this approach less attractive&lt;br /&gt;
for that case.&lt;br /&gt;
&lt;br /&gt;
In the following, we briefly derive the resulting two-dimensional equations for&lt;br /&gt;
$\psi$ and $\omega$. We begin by considering the momentum equations:&lt;br /&gt;
\begin{align}&lt;br /&gt;
\frac{\partial u}{\partial t} + u \frac{\partial u}{\partial x} + v \frac{\partial u}{\partial y}&amp;amp; = -\frac{1}{\rho}\frac{\partial p}{\partial x} + \nu \left(\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2}\right) + g_x \\&lt;br /&gt;
\frac{\partial v}{\partial t} + u \frac{\partial v}{\partial x} + v \frac{\partial v}{\partial y}&amp;amp; = -\frac{1}{\rho}\frac{\partial p}{\partial y} + \nu \left(\frac{\partial^2 v}{\partial x^2} + \frac{\partial^2 v}{\partial y^2}\right) + g_y&lt;br /&gt;
\end{align}&lt;br /&gt;
from which we can eliminate the pressure by differentiating the first equation by $y$ and the second by $x$, subtracting the second from the first and then substituting the definition for the vorticity $\omega = \partial u / \partial y - \partial v / \partial x$. In this manner we obtain the equation:&lt;br /&gt;
\[\frac{\partial \omega}{\partial t} + \frac{\partial u}{\partial x} \omega + u \frac{\partial \omega}{\partial x} + \frac{\partial v}{\partial y}\omega + v \frac{\partial \omega}{\partial y} = \nu \left(\frac{\partial^2 \omega}{\partial x^2} + \frac{\partial^2 \omega}{\partial y^2}\right) + \left(\frac{\partial g_x}{\partial y} - \frac{\partial g_y}{\partial x}\right)\]&lt;br /&gt;
&lt;br /&gt;
We can get rid of the terms containing $\partial u / \partial x$ and $\partial v / \partial y$ by using the continuity equation \eqref{contuinity}. Finally using the definition for the stream function $\partial \psi / \partial y = u$ and $\partial \psi / \partial x = -v$ we can transform the above equation to what is known as the ''vorticity transport equation'':&lt;br /&gt;
\begin{equation}&lt;br /&gt;
\frac{\partial \omega}{\partial t} + \frac{\partial \psi}{\partial y}\frac{\partial \omega}{\partial x} - \frac{\partial \psi}{\partial x}\frac{\partial \omega}{\partial y} = \nu \Delta \omega + \left(\frac{\partial g_x}{\partial y} - \frac{\partial g_y}{\partial x}\right)&lt;br /&gt;
\label{vorticity_transport}&lt;br /&gt;
\end{equation}&lt;br /&gt;
&lt;br /&gt;
Another equation is obtained by inserting the definition of the stream function into that of the vorticity:&lt;br /&gt;
\[\omega = \frac{\partial u}{\partial y} - \frac{\partial v}{\partial x} = \frac{\partial}{\partial y}\left(\frac{\partial \psi}{\partial y}\right) + \frac{\partial }{\partial x}\left(\frac{\partial \psi}{\partial x}\right) = \Delta \psi\]&lt;br /&gt;
leading to the ''Poisson equation for the stream function''&lt;br /&gt;
\begin{equation}&lt;br /&gt;
\Delta \psi = \omega&lt;br /&gt;
\label{poisson_stream}&lt;br /&gt;
\end{equation}&lt;br /&gt;
&lt;br /&gt;
The two equations (\ref{vorticity_transport}) and (\ref{poisson_stream}) form a nonlinear coupled system of equations in which pressure has been eliminated and in which the continuity equation has been satisfied automatically.&lt;br /&gt;
&lt;br /&gt;
= Numerical examples =&lt;br /&gt;
* [[Lid driven cavity]]&lt;br /&gt;
* [[Burger's equation]]&lt;br /&gt;
* [[de Vahl Davis natural convection test]]&lt;br /&gt;
* [[Natural convection in 3D irregular domain]]&lt;br /&gt;
* [[Natural convection from heated cylinder]]&lt;br /&gt;
* [[Natural convection between concentric cylinders]]&lt;br /&gt;
* [[Non-Newtonian fluid]]&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Burgers%27_equation&amp;diff=3560</id>
		<title>Burgers' equation</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Burgers%27_equation&amp;diff=3560"/>
				<updated>2023-12-27T12:31:16Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: Zigavaupotic moved page Burgers equation to Burger's equation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Burgers equation&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Burgers_equation&amp;diff=3561</id>
		<title>Burgers equation</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Burgers_equation&amp;diff=3561"/>
				<updated>2023-12-27T12:31:16Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: Zigavaupotic moved page Burgers equation to Burger's equation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Burger's equation]]&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Fluid_Mechanics&amp;diff=3559</id>
		<title>Fluid Mechanics</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Fluid_Mechanics&amp;diff=3559"/>
				<updated>2023-12-27T12:30:28Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
Computational fluid dynamics (CFD) is a field of a great interest among researchers in many fields of science, e.g. studying mathematical fundaments of numerical methods, developing novel physical models, improving computer implementations, and many others. Pushing the limits of all involved fields of science helps community to deepen the understanding of several natural and technological phenomena. Weather forecast, ocean dynamics, water transport, casting, various energetic studies, etc., are just few examples where fluid dynamics plays a crucial role. The core problem of the CFD is solving the Navier-Stokes Equation or its variants, e.g. Darcy or Brinkman equation for flow in porous media. Here, we discuss basic algorithms for solving CFD problems. Check reference list on the [[Medusa|main page]] for more details about related work.&lt;br /&gt;
&lt;br /&gt;
Long story short, we want to solve&lt;br /&gt;
\begin{equation}&lt;br /&gt;
\frac{\partial \b{v}}{\partial t}+\nabla \cdot ( \rho \b{vv}) = -\nabla p+ \nabla(\mu \nabla\b{v})+\b{f}&lt;br /&gt;
\label{NavierStokes}&lt;br /&gt;
\end{equation}&lt;br /&gt;
also known as a Navier-Stokes equation. &lt;br /&gt;
&lt;br /&gt;
Note that the $\b{v}\b{v}$ stands for the tensor or dyadic product \[ \b{v}\b{v} = \b{v}\otimes\b{v} = \b{v}\b{v}^\T = \left[ \begin{matrix}&lt;br /&gt;
   {{v}_{1}}{{v}_{1}} &amp;amp; \cdots &amp;amp; {{v}_{1}}{{v}_{n}}  \\&lt;br /&gt;
   \vdots &amp;amp; \ddots &amp;amp; \vdots  \\&lt;br /&gt;
   {{v}_{n}}{{v}_{1}} &amp;amp; \cdots &amp;amp; {{v}_{n}}{{v}_{n}}  \\&lt;br /&gt;
\end{matrix} \right]\]&lt;br /&gt;
&lt;br /&gt;
Combining equation \ref{NavierStokes} and mass contiunity equation&lt;br /&gt;
\begin{equation}&lt;br /&gt;
  \frac{\partial \rho }{\partial t} + \nabla  \cdot (\rho {\bf{u}}) = 0.&lt;br /&gt;
\end{equation}&lt;br /&gt;
&lt;br /&gt;
simplifies advection term into (see [https://en.wikipedia.org/wiki/Derivation_of_the_Navier%E2%80%93Stokes_equations] for derivation)&lt;br /&gt;
&lt;br /&gt;
\[\frac{\partial \left( \rho \b{v} \right)}{\partial t}+\nabla \cdot \left( \rho \b{vv} \right)=\frac{\partial \left( \rho \b{v} \right)}{\partial t}+(\rho \b{v}\cdot \nabla )\cdot \b{v}. \]&lt;br /&gt;
&lt;br /&gt;
An example of advection term in 2D would therefore be&lt;br /&gt;
\[\left( \b{v}\cdot \nabla  \right)\b{v}=\left( \left( \begin{matrix}&lt;br /&gt;
   u  \\&lt;br /&gt;
   v  \\&lt;br /&gt;
\end{matrix} \right) \cdot \left( \begin{matrix}&lt;br /&gt;
   \frac{\partial }{\partial x}  \\&lt;br /&gt;
   \frac{\partial }{\partial y}  \\&lt;br /&gt;
\end{matrix} \right) \right)\left( \begin{matrix}&lt;br /&gt;
   u  \\&lt;br /&gt;
   v  \\&lt;br /&gt;
\end{matrix} \right)=\left( \begin{matrix}&lt;br /&gt;
   u\frac{\partial u}{\partial x}+v\frac{\partial u}{\partial y}  \\&lt;br /&gt;
   u\frac{\partial v}{\partial x}+v\frac{\partial v}{\partial y}  \\&lt;br /&gt;
\end{matrix} \right)\]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In many cases we are interested in the incompressible fluids (Ma&amp;lt;0.3), reducing the continuity equation to&lt;br /&gt;
\begin{equation}&lt;br /&gt;
\nabla \cdot \b{v}=0&lt;br /&gt;
\label{contuinity}&lt;br /&gt;
\end{equation}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The goal of CFD is to solve system \ref{NavierStokes} and \ref{contuinity}. It is obvious that a special treatment will be needed to couple both equations. In the following discussion we cover some basic approaches, how this can be accomplished.&lt;br /&gt;
&lt;br /&gt;
= Solutions algorithms =&lt;br /&gt;
== Artificial compressibility method ==&lt;br /&gt;
The simplest, completely explicit approach, is an artificial compressibility method (ACM), where a compressibility term is included in the mass continuity&lt;br /&gt;
\[\frac{\partial \b{v}}{\partial t}+(\b{v}\cdot\nabla )\b{v}=-\frac{1}{\rho }\nabla p+\nu {{\nabla }^{2}}\b{v}+\b{f}\]&lt;br /&gt;
\[\frac{ 1 }{ \rho } \frac{\partial \rho }{\partial t}+\nabla \cdot \b{v}=0\]&lt;br /&gt;
\[\frac{ 1 }{ \rho } \frac{\partial \rho }{\partial p}\frac{\partial p}{\partial t}+\nabla \cdot \b{v}=0\]&lt;br /&gt;
Now, the above system can be solved directly.&lt;br /&gt;
&lt;br /&gt;
The addition of the time derivative of the pressure term physically means that waves of finite speed (the propagation of which depends on the magnitude of the ACM)&lt;br /&gt;
are introduced into the flow field as a mean to distribute the pressure within the domain. In a true&lt;br /&gt;
incompressible flow, the pressure field is affected instantaneously throughout the whole domain. In ACM there is a time delay between the flow disturbance and its effect on the&lt;br /&gt;
pressure field. Upon rearranging the equation yields&lt;br /&gt;
\[\frac{\partial p}{\partial t}+\rho {{C}^{2}}\nabla \cdot \b{v}=0\]&lt;br /&gt;
where the continuity equation is perturbed by the quantity $\frac{\partial p}{\partial t}$ denominated herein&lt;br /&gt;
as the AC parameter/artificial sound speed recognized by&lt;br /&gt;
$C$ [m/s] - speed of sound&lt;br /&gt;
\[\frac{1}{C^2}=\frac{\partial \rho }{\partial p}\]&lt;br /&gt;
Or in other words&lt;br /&gt;
\[C^2=\left( \frac{\partial p}{\partial \rho}\right)_S\]&lt;br /&gt;
where $\rho$ is the density of the material. It follows, by replacing partial derivatives, that the isentropic compressibility can be expressed as:&lt;br /&gt;
\[\beta =\frac{1}{\rho {{C}^{2}}}\]&lt;br /&gt;
The evaluation of the local ACM parameter in incompressible flows is inspired by the&lt;br /&gt;
speed of sound computations in compressible flows (for instance, from the perfect gas law).&lt;br /&gt;
However, in the incompressible flow situation, employing such a relation is difficult, but an artificial&lt;br /&gt;
relation can be developed from the convective and diffusive velocities.&lt;br /&gt;
Reverting to the justification of continuity modification, it can be immediately seen that the&lt;br /&gt;
artificial sound speed must be sufficiently large to have a significant regularizing effect and at&lt;br /&gt;
the same time must be as small as possible to minimizing perturbations on the incompressibility&lt;br /&gt;
equation.  Therefore, $C$ influences the convergence rate and stability of the solution method. In other words,&lt;br /&gt;
assists in reducing large disparity in the eigenvalues, leading to a well-conditioned system. &lt;br /&gt;
The $C$ can be '''estimated''' with&lt;br /&gt;
&lt;br /&gt;
\[ C = \beta \max \left( \left|\b{v}\right|_2, \left|\b{v}_{ref}\right|_2 \right),\]&lt;br /&gt;
where $\b{v}_{ref}$ stands for a reference velocity. &lt;br /&gt;
Values for $\beta$ in the range of 1–10 are recommended for better convergence to the steady state at which the&lt;br /&gt;
mass conservation is enforced. In addition, Equation ensures that $C$ does not reach zero at stagnation points&lt;br /&gt;
that cause instabilities in pseudo-time, effecting convergence&lt;br /&gt;
&lt;br /&gt;
Note, that for more complex simulation an internal iteration loops is required before marching in time. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;ACM&amp;quot;&amp;gt;&lt;br /&gt;
[[File:ACM BlockDiagram.png|600px]]&lt;br /&gt;
&amp;lt;caption&amp;gt;Scheme of the ACM algorithm &amp;lt;/caption&amp;gt;&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Explicit/Implicit pressure calculation ==&lt;br /&gt;
&lt;br /&gt;
Applying divergence on \ref{NavierStokes} yields&lt;br /&gt;
\[\nabla \cdot \frac{\partial \b{v}}{\partial t}+\nabla \cdot (\b{v}\cdot \nabla )\b{v}=-\frac{1}{\rho }{{\nabla }^{2}}p+\nabla \cdot \nu {{\nabla }^{2}}\b{v}+\nabla \cdot \b{f}\]&lt;br /&gt;
&lt;br /&gt;
And since $\nabla \cdot \b{v}=0$ and we can change order in $\nabla \cdot \nabla^2$ and $ \nabla^2 \cdot \nabla$ equation simplifies to&lt;br /&gt;
\[\frac{1}{\rho }{{\nabla }^{2}}p=\nabla \cdot \b{f}-\nabla \cdot (\b{v}\cdot \nabla )\b{v}\]&lt;br /&gt;
Now, we need boundary conditions that can be obtained by multiplying the equation  with a boundary normal vector&lt;br /&gt;
\[\b{\hat{n}}\cdot \left( \frac{\partial \b{v}}{\partial t}+(\b{v}\cdot \nabla )\b{v} \right)=\b{\hat{n}}\cdot \left( -\frac{1}{\rho }\nabla p+\nu {{\nabla }^{2}}\b{v}+\b{f} \right)\cdot \b{\hat{n}}\]&lt;br /&gt;
\[\frac{\partial p}{\partial \b{\hat{n}}}=\left( \nu {{\nabla }^{2}}\b{v}+\b{f}-\frac{\partial \b{v}}{\partial t}-(\b{v}\cdot\nabla ) \b{v} \right)\cdot \b{\hat{n}}\]&lt;br /&gt;
&lt;br /&gt;
Note that using tangential boundary vector gives equivalent BCs&lt;br /&gt;
\[\frac{\partial p}{\partial \b{\hat{t}}}=\left( \nu {{\nabla }^{2}}\b{v}+\b{f}-\frac{\partial \b{v}}{\partial t}-(\b{v}\cdot\nabla ) \b{v} \right)\cdot \b{\hat{t}}\]&lt;br /&gt;
For no-slip boundaries BCs simplify to&lt;br /&gt;
\[\frac{\partial p}{\partial \b{\hat{n}}}=\left( \nu {{\nabla }^{2}}\b{v}+\b{f} \right)\cdot \b{\hat{n}}\]&lt;br /&gt;
Otherwise an appropriate expression regarding the velocity can be written, i.e. write full  and taken in account velocity BCs. For example, Neumann velocity $\frac{\partial u}{\partial x}=0$ in 2D&lt;br /&gt;
\[\frac{\partial p}{\partial x}=\left( \nu {{\nabla }^{2}}u + {{f}_{x}}-\frac{\partial u}{\partial t}+v\frac{\partial u}{\partial y} \right)\]&lt;br /&gt;
Note that you allready know everything about the velocity and thus you can compute all the terms explicitly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So the procedure is:&lt;br /&gt;
&lt;br /&gt;
* Compute Navier Stokes either explicitly or implicitly&lt;br /&gt;
* Solve pressure equations with  computed velocities&lt;br /&gt;
* March in time&lt;br /&gt;
&lt;br /&gt;
Basic boundary conditions&lt;br /&gt;
Wall:   $\b{v}=0$, \[\frac{\partial p}{\partial \hat{n}}=\left( \nabla \cdot \left( \nu \nabla \b{v} \right)+\b{f} \right)\cdot \hat{n}\]&lt;br /&gt;
Inlet:  $\b{v}=\b{a}$, \[\frac{\partial p}{\partial \hat{n}}=\left( \nabla \cdot \left( \nu \nabla \b{v} \right)+\b{f}-\nabla \cdot (\rho \b{v}\b{v})-\rho \frac{\partial \b{v}}{\partial t} \right)\cdot \hat{n}\]&lt;br /&gt;
&lt;br /&gt;
Above system can be linearized (advection term) and solved either explicitly or implicitly.&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
&lt;br /&gt;
W. D. Henshaw, A fourth-order accurate method for the incompressible Navier–Stokes equations on overlapping grids, J. Comput. Phys. 113, 13 (1994)&lt;br /&gt;
&lt;br /&gt;
J. C. Strikwerda, Finite difference methods for the Stokes and Navier–Stokes equations, SIAM J. Sci. Stat.&lt;br /&gt;
Comput. 5(1), 56 (1984)&lt;br /&gt;
&lt;br /&gt;
== Explicit Pressure correction ==&lt;br /&gt;
Another possibility is to solve pressure correction equation. Again Consider the momentum equation and mass continuity and discretize it explicitly&lt;br /&gt;
\[\frac{{{\b{v}}_{2}}-{{\b{v}}_{1}}}{\Delta t}=-\frac{1}{\rho }\nabla {{p}_{1}}-({{\b{v}}_{1}}\nabla )\cdot {{\b{v}}_{1}}+\nu {{\nabla }^{2}}{{\b{v}}_{1}}+\b{f}\]&lt;br /&gt;
Computed velocity obviously does not satisfy the mass contunity and therefore let’s call it intermediate velocity. Intermediate velocity is calculated from guessed pressure and old velocity values.&lt;br /&gt;
\[{{\b{v}}^{inter}}=\b{v}_1 + \Delta t\left( -\frac{1}{\rho }\nabla {{p}_{1}}-({{\b{v}}_{1}}\nabla )\cdot {{\b{v}}_{1}}+\nu {{\nabla }^{2}}{{\b{v}}_{1}}+\b{f} \right)\]&lt;br /&gt;
A correction term is added that drives velocity to divergence free field&lt;br /&gt;
\[\nabla \cdot ({{\b{v}}^{inter}}+{{\b{v}}^{corr}})=0 \qquad \to \qquad \nabla \cdot {{\b{v}}^{inter}}=-\nabla \cdot {{\b{v}}^{corr}}\]&lt;br /&gt;
&lt;br /&gt;
Velocity correction is affected only by effect of pressure correction. This fact is obvious due to all terms except gradient of pressure on the right side of equation  are constant.&lt;br /&gt;
\[{{\b{v}}^{corr}}=-\frac{\Delta t}{\rho }\nabla {{p}^{corr}} \]&lt;br /&gt;
&lt;br /&gt;
Note that corrected velocity also satisfies boundary conditions&lt;br /&gt;
\[\b{v}^{iter}+\b{v}^{corr}=\b{v}^{BC}\]&lt;br /&gt;
Applying divergence  and  we get '''pressure correction poisson equation'''.&lt;br /&gt;
\[\,{{\nabla }^{2}}{{p}^{corr}}\,=\frac{\rho }{\Delta t}\nabla \cdot {{\mathbf{v}}^{iter}}\,\]&lt;br /&gt;
&lt;br /&gt;
Boundary conditions can be obtained by mulitplying the equation with a unit normal vector $\b{\hat{n}}$&lt;br /&gt;
\[\frac{\Delta t}{\rho }\frac{\partial {p}^{corr}}{\partial \b{\hat{n}}} = \b{\hat{n}} \cdot \left(\b{v}^{iter} - \b{v}^{BC} \right) \]&lt;br /&gt;
The most straightforward approach, for dirichlet BCs, is to take into account velocity boundary condition in computation of intermediate velocity, and clearly in such cases, pressure boundary condition simplifies to &lt;br /&gt;
\[\frac{\partial p^{corr}}{\partial \b{\hat{n}}} = 0 \]&lt;br /&gt;
As ${{\b{v}}^{\operatorname{int}er}}={{\b{v}}^{BC}}$ . Another option is to explicitely compute intermediate velocity also on boundaries and then correct it through pressure correction.&lt;br /&gt;
&lt;br /&gt;
The pressure poisson equation is, at given boundary conditions, defined only up to a constant. One solution is to select a node and set it to a constant, e.g. p(0, 0) = 0, however much more stable approach is to enforce solution with additional condition, also referred to as a regularization&lt;br /&gt;
	\[\int_{\Omega }^{{}}{pd}\Omega =0\]&lt;br /&gt;
\[\,{{\nabla }^{2}}{{p}^{corr}}\,-\alpha =\frac{\rho }{\Delta t}\nabla \cdot {{\b{v}}^{iter}}\,\]&lt;br /&gt;
Where $\alpha $ stands for Lagrange multiplier. Or in discrete form&lt;br /&gt;
	\[\sum\limits_{i}{p\left( {{x}_{i}} \right)=0}\]&lt;br /&gt;
	\[\b{Mp}-\alpha \b{1}=\frac{\rho }{\Delta t}\nabla \cdot {{\b{v}}^{iter}}\]&lt;br /&gt;
&lt;br /&gt;
where $\b{M}$ holds Laplace shape functions, i.e. the discrete version of Laplace differential operator. &lt;br /&gt;
&lt;br /&gt;
Solution of a system&lt;br /&gt;
&lt;br /&gt;
	\[\left[ \begin{matrix}&lt;br /&gt;
   {{M}_{11}} &amp;amp; .. &amp;amp; {{M}_{1n}} &amp;amp; 1  \\&lt;br /&gt;
   .. &amp;amp; .. &amp;amp; .. &amp;amp; 1  \\&lt;br /&gt;
   {{M}_{n1}} &amp;amp; ... &amp;amp; {{M}_{nn}} &amp;amp; 1  \\&lt;br /&gt;
   1 &amp;amp; 1 &amp;amp; 1 &amp;amp; 0  \\&lt;br /&gt;
\end{matrix} \right]\left[ \begin{matrix}&lt;br /&gt;
   {{p}_{1}}  \\&lt;br /&gt;
   ...  \\&lt;br /&gt;
   {{p}_{n}}  \\&lt;br /&gt;
   \alpha   \\&lt;br /&gt;
\end{matrix} \right]=\frac{\rho }{\Delta t}\left[ \begin{matrix}&lt;br /&gt;
   \nabla \cdot \b{v}_{_{1}}^{\text{iter}}  \\&lt;br /&gt;
   ...  \\&lt;br /&gt;
   \nabla \cdot \b{v}_{n}^{\text{iter}}  \\&lt;br /&gt;
   0  \\&lt;br /&gt;
\end{matrix} \right]\]&lt;br /&gt;
Gives us a solution of pressure correction.&lt;br /&gt;
&lt;br /&gt;
== CBS Algorithm ==&lt;br /&gt;
With explicit temporal discretization problem is formulated as&lt;br /&gt;
\[\b{\hat{v}}={{\b{v}}_{0}}+\Delta t\left( -\nabla {{p}_{0}}+\frac{1}{Re}{{\nabla }^{2}}{{\b{v}}_{0}}-\nabla \cdot ({{\b{v}}_{0}}{{\b{v}}_{0}}) \right)\]&lt;br /&gt;
\[p={{p}_{0}}-\xi \Delta {{t}_{F}}\nabla \b{\hat{v}}+\xi \Delta {{t}_{F}}\Delta t{{\nabla }^{2}}{{\overset{\scriptscriptstyle\frown}{P}}_{0}},\]&lt;br /&gt;
where $\b{\hat{v}}$, $\Delta t$, $\xi$ and $\Delta t_F$ stand for intermediate velocity, time step, relaxation parameter, and artificial time step, respectively, and index 0 stands for previous time / iteration step. First, the intermediate velocity is computed from previous time step. Second, the velocity is driven towards solenoidal field by correcting the pressure. Note that no special boundary conditions for pressure are used, i.e., the pressure on boundaries is computed with the same approach as in the interior of the domain. In general, the internal iteration with an artificial time step is required until the divergence of the velocity field is not below required criteria. However, if one is interested only in a steady-state solution, the internal iteration can be skipped and $\Delta t$ equals $\Delta {{t}_{F}}$. Without internal stepping the transient of the solution is distorted by artificial compressibility effect. This approach is also known as ACM with Characteristics-based discretization of continuity equation, where the relaxation parameter relates to the artificial speed of sound [35].&lt;br /&gt;
&lt;br /&gt;
The relaxation parameter should be set between 1-10, lower number more stable solution.&lt;br /&gt;
&lt;br /&gt;
And also dimensional form&lt;br /&gt;
&lt;br /&gt;
\[p={{p}_{0}}-{{C}^{2}}\Delta {{t}_{F}}\rho \nabla \b{\hat{v}}+{{C}^{2}}\Delta {{t}_{F}}\Delta t{{\nabla }^{2}}{{p}_{0}},\]&lt;br /&gt;
&lt;br /&gt;
Where C is speed of sound [m/s]&lt;br /&gt;
&lt;br /&gt;
== The Stream Function - Vorticity Approach ==&lt;br /&gt;
&lt;br /&gt;
In two dimensions, the Navier–Stokes equations can be expressed using the&lt;br /&gt;
stream function $\psi$ and the vorticity $\omega$ in place of the primitive variables $u$, $v$, and&lt;br /&gt;
$p$. This involves the elimination of the pressure $p$, thus yielding one dependent&lt;br /&gt;
variable less. In three dimensions, however, this formulation leads to six unknowns&lt;br /&gt;
rather than four (in primitive variables), which makes this approach less attractive&lt;br /&gt;
for that case.&lt;br /&gt;
&lt;br /&gt;
In the following, we briefly derive the resulting two-dimensional equations for&lt;br /&gt;
$\psi$ and $\omega$. We begin by considering the momentum equations:&lt;br /&gt;
\begin{align}&lt;br /&gt;
\frac{\partial u}{\partial t} + u \frac{\partial u}{\partial x} + v \frac{\partial u}{\partial y}&amp;amp; = -\frac{1}{\rho}\frac{\partial p}{\partial x} + \nu \left(\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2}\right) + g_x \\&lt;br /&gt;
\frac{\partial v}{\partial t} + u \frac{\partial v}{\partial x} + v \frac{\partial v}{\partial y}&amp;amp; = -\frac{1}{\rho}\frac{\partial p}{\partial y} + \nu \left(\frac{\partial^2 v}{\partial x^2} + \frac{\partial^2 v}{\partial y^2}\right) + g_y&lt;br /&gt;
\end{align}&lt;br /&gt;
from which we can eliminate the pressure by differentiating the first equation by $y$ and the second by $x$, subtracting the second from the first and then substituting the definition for the vorticity $\omega = \partial u / \partial y - \partial v / \partial x$. In this manner we obtain the equation:&lt;br /&gt;
\[\frac{\partial \omega}{\partial t} + \frac{\partial u}{\partial x} \omega + u \frac{\partial \omega}{\partial x} + \frac{\partial v}{\partial y}\omega + v \frac{\partial \omega}{\partial y} = \nu \left(\frac{\partial^2 \omega}{\partial x^2} + \frac{\partial^2 \omega}{\partial y^2}\right) + \left(\frac{\partial g_x}{\partial y} - \frac{\partial g_y}{\partial x}\right)\]&lt;br /&gt;
&lt;br /&gt;
We can get rid of the terms containing $\partial u / \partial x$ and $\partial v / \partial y$ by using the continuity equation \eqref{contuinity}. Finally using the definition for the stream function $\partial \psi / \partial y = u$ and $\partial \psi / \partial x = -v$ we can transform the above equation to what is known as the ''vorticity transport equation'':&lt;br /&gt;
\begin{equation}&lt;br /&gt;
\frac{\partial \omega}{\partial t} + \frac{\partial \psi}{\partial y}\frac{\partial \omega}{\partial x} - \frac{\partial \psi}{\partial x}\frac{\partial \omega}{\partial y} = \nu \Delta \omega + \left(\frac{\partial g_x}{\partial y} - \frac{\partial g_y}{\partial x}\right)&lt;br /&gt;
\label{vorticity_transport}&lt;br /&gt;
\end{equation}&lt;br /&gt;
&lt;br /&gt;
Another equation is obtained by inserting the definition of the stream function into that of the vorticity:&lt;br /&gt;
\[\omega = \frac{\partial u}{\partial y} - \frac{\partial v}{\partial x} = \frac{\partial}{\partial y}\left(\frac{\partial \psi}{\partial y}\right) + \frac{\partial }{\partial x}\left(\frac{\partial \psi}{\partial x}\right) = \Delta \psi\]&lt;br /&gt;
leading to the ''Poisson equation for the stream function''&lt;br /&gt;
\begin{equation}&lt;br /&gt;
\Delta \psi = \omega&lt;br /&gt;
\label{poisson_stream}&lt;br /&gt;
\end{equation}&lt;br /&gt;
&lt;br /&gt;
The two equations (\ref{vorticity_transport}) and (\ref{poisson_stream}) form a nonlinear coupled system of equations in which pressure has been eliminated and in which the continuity equation has been satisfied automatically.&lt;br /&gt;
&lt;br /&gt;
= Numerical examples =&lt;br /&gt;
* [[Lid driven cavity]]&lt;br /&gt;
* [[Burgers equation]]&lt;br /&gt;
* [[de Vahl Davis natural convection test]]&lt;br /&gt;
* [[Natural convection in 3D irregular domain]]&lt;br /&gt;
* [[Natural convection from heated cylinder]]&lt;br /&gt;
* [[Natural convection between concentric cylinders]]&lt;br /&gt;
* [[Non-Newtonian fluid]]&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Burgers%27_equation&amp;diff=3558</id>
		<title>Burgers' equation</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Burgers%27_equation&amp;diff=3558"/>
				<updated>2023-12-27T12:27:49Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: Created page with &amp;quot;Burgers equation&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Burgers equation&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Solving_system&amp;diff=3557</id>
		<title>Solving system</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Solving_system&amp;diff=3557"/>
				<updated>2023-12-27T12:07:21Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: /* ordinary least squares */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Basics of solving square linear systems =&lt;br /&gt;
&lt;br /&gt;
Solving a system $Ax = b$, where $A$ is a $n\times n$ matrix of scalars (complex, real, or otherwise) is possible if $A$ is invertible, and the solution is given theoretically by $x = A^{-1}b$.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let $\hat{x}$ be the solution of  $\hat{A} \hat{x} = \hat{b}$, where the matrix $A$ is disturbed as $\hat{A} = A + \Delta{A}$ and the right hand side as $\hat{b} = b + \Delta b$.&lt;br /&gt;
&lt;br /&gt;
The absolute error of $x$ is $\Delta x = \|\hat{x} - x\|$ and the relative errors are defined as $\delta A = \|\Delta A\|/\|A\|$ and $\delta b = \|\Delta b\|/\|b\|$ and $\delta x = \|\Delta x\|/\|x\|$.&lt;br /&gt;
We assume that relative errors in inputs are reasonably small.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If only $b$ is disturbed, the error is given by &lt;br /&gt;
$$\delta x \leq \kappa(A) \delta b,$$ where $\kappa(A) = \|A\|\|A^{-1}\|$ is the ''condition number'' of matrix $A$.&lt;br /&gt;
&lt;br /&gt;
In general, the error is given by&lt;br /&gt;
&lt;br /&gt;
$$\delta x \leq \frac{\kappa(A)}{1 - \kappa(A) \delta A} (\delta A + \delta b).$$&lt;br /&gt;
&lt;br /&gt;
Therefore, if the condition number $\kappa(A)$ is large, the accuracy of the solution of the system can deteriorate.&lt;br /&gt;
&lt;br /&gt;
If $A$ is not invertible, Moore-Penrose pseudoinverse can be used to compute a &amp;quot;solution&amp;quot;: $x = A^+b$.&lt;br /&gt;
&lt;br /&gt;
= Basics of solving underdetermined linear systems = &lt;br /&gt;
= Least norm solution =&lt;br /&gt;
Consider the system $Ax = b$, where $A$ is a $n \times m$ matrix of full rank and $n \leq m$. The number of variables $m$ is larger than the number of equations. This means that all equations can be satisfied &lt;br /&gt;
and some degrees of freedom are left to obtain various properties of the solution. The common problem is to find the least-norm solution: find $x$, such that&lt;br /&gt;
$$\min_x \|x\|_2, \text{ such that } Ax = b.$$&lt;br /&gt;
&lt;br /&gt;
The solution is given by $x = A^\T (AA^\T)^{-1} b$, and it can be obtained by solving the $n \times n$ system $AA^\T y = b$ and computing $x = A^\T y$. &lt;br /&gt;
The solution can also be written as $x = A^+ b$. &lt;br /&gt;
&lt;br /&gt;
To validate the correctness, consider any other $z$, such that $Az=b$. Then, $$&lt;br /&gt;
(z-x)^\T x = (z-x)^\T A^\T (AA^\T)^{-1} b = (A(x-z))^\T (AA^\T)^{-1} b = (b-b)^\T (AA^\T)^{-1} b = 0,&lt;br /&gt;
$$&lt;br /&gt;
and consequently&lt;br /&gt;
$$&lt;br /&gt;
\|z\|^2 = \|z-x+x\|^2 = \|z-x\|^2 + 2(z-x)^\T x + \|x\|^2 = \|z-x\|^2 + \|x\|^2 \geq \|x\|^2,&lt;br /&gt;
$$&lt;br /&gt;
which shows that $x$ has smaller norm than any other solution $z$.&lt;br /&gt;
&lt;br /&gt;
Alternative derivation is to minimize $x^\T x$ with respect to $Ax=b$ using Lagrangian multipliers.&lt;br /&gt;
&lt;br /&gt;
= Weighted case =&lt;br /&gt;
&lt;br /&gt;
Weighted case is similar, except that the minimization problem becomes $$\min_x \|x\|_{2,w}, \text{ such that } Ax = b.$$&lt;br /&gt;
The minimization can be written $\min_x \|Wx\|_{2}, \text{ such that } Ax = b$, or substituting $Wx = y$, we obtain the following&lt;br /&gt;
ordinary least norm problem:&lt;br /&gt;
$$\min_y \|y\|_{2}, \text{ such that } AW^{-1}y = b,$$&lt;br /&gt;
with matrix $AW^{-1}$ and right hand side $b$, and with solution $x = W^{-1} y$.&lt;br /&gt;
&lt;br /&gt;
Thus, the final solution is given as $x = W^{-2} A^\T (A W^{-2} A^\T)^{-1} b$ and can be computed by first solving &lt;br /&gt;
$n \times n$ system $AW^{-2}A^\T y = b$ and computing $x = W^{-2} A^\T y$.&lt;br /&gt;
&lt;br /&gt;
= Numerical solving =&lt;br /&gt;
&lt;br /&gt;
Techniques for numerical solving of (weighted) underdetermined systems are described below. As list of decompositions available in Eigen is available here:&lt;br /&gt;
https://eigen.tuxfamily.org/dox/group__LeastSquares.html&lt;br /&gt;
&lt;br /&gt;
As when solving overdetermined systems if a lot of systems $Ax = b_i$ need to be solved, which only differ in the right hand side, the matrix $A$ can only be decomposed once, with&lt;br /&gt;
subsequent solutions taking $O(n^2)$ time.&lt;br /&gt;
&lt;br /&gt;
== Normal equations ==&lt;br /&gt;
&lt;br /&gt;
We can solve the system directly, by solving the $n \times n$ system $AA^\T y = b$ using Cholesky, and computing $x = A^\T y$.&lt;br /&gt;
&lt;br /&gt;
This decomposition takes $\frac13 n^3 + 2n^2m$ time.&lt;br /&gt;
&lt;br /&gt;
== QR decomposition ==&lt;br /&gt;
&lt;br /&gt;
Writing $A^\T = Q_1R_1$ as when solving overdetermined systems, we can get the solution&lt;br /&gt;
$$x = Q_1R_1 (R_1^\T Q_1^\T Q_1 R_1)^{-1}b = Q_1 R_1 R_1^{-1} R_1^{-\T} b = Q_1 R_1^{-\T} b.$$&lt;br /&gt;
&lt;br /&gt;
The computational costs are the same as in the overdetermined case.&lt;br /&gt;
&lt;br /&gt;
== SVD decomposition ==&lt;br /&gt;
&lt;br /&gt;
The pseudoinverse can be computed using SVD and the solution obtained as $x = A^{+} b$.&lt;br /&gt;
&lt;br /&gt;
The computational costs are the same as in the overdetermined case.&lt;br /&gt;
&lt;br /&gt;
== Decompositions ==&lt;br /&gt;
&lt;br /&gt;
Solving linear systems is not done by computing inverses of $A$ but by suitably decomposing $A$. &lt;br /&gt;
Many decompositions are available, with $LU$ decomposition with partial pivoting being the go-to option.&lt;br /&gt;
with $\frac23 n^3$ cost. Additionally, we have $QR$ and $SVD$ decompositions if more robust decompositions are desired, at a greater cost.&lt;br /&gt;
&lt;br /&gt;
See full the list of Eigen's available decompositions: https://eigen.tuxfamily.org/dox/group__TopicLinearAlgebraDecompositions.html&lt;br /&gt;
&lt;br /&gt;
If many systems $Ax = b_i$ need to be saved with only different right hand sides, the decomposition of $A$ can be computed in $O(n^3)$ and&lt;br /&gt;
stored with subsequent solutions only taking  $O(n^2)$ time.&lt;br /&gt;
&lt;br /&gt;
If the matrix is symmetric and positive definite, Cholesky (called $VV^\T$ or $LL^\T$) decomposition can be used, with $\frac13 n^3$ cost.&lt;br /&gt;
&lt;br /&gt;
= Basics of solving overdetermined linear systems =&lt;br /&gt;
== Ordinary least squares ==&lt;br /&gt;
&lt;br /&gt;
Let $A$ be a matrix of size $n \times m$ and $b$ be a vector of size $n$, with $n \geq m$ and let $A$ have full rank. If $n=m$ the system $Ax=b$ is square, and can be treated as such, however the&lt;br /&gt;
derivation below works as well.&lt;br /&gt;
&lt;br /&gt;
The system $Ax=b$ has $n$ equations for $m$ unknowns $x_1, \ldots, x_m$ and is overdetermined. The solution is most often sought in the least-squares sense, defining the solution $x$ to be the solution of the following minimisation problem&lt;br /&gt;
$$ \min_x \|Ax-b\|_2. $$&lt;br /&gt;
The solution can be obtained using calculus, by looking for stationary points of function $\|Ax-b\|_2^2 = (Ax-b)^\T(Ax-b)$ (which has the same minimum), and getting the system of&lt;br /&gt;
normal equations $$A^\T A x = A^\T b.$$ The solution can be expressed theoretically as&lt;br /&gt;
$x = (A^\T A)^{-1} A^\T b$.&lt;br /&gt;
&lt;br /&gt;
== Weighted least squares ==&lt;br /&gt;
&lt;br /&gt;
The weighted least squares problem has the same setup as the ordinary least squares, but we instead minimise the norm $\|Ax-b\|_{2,w}$, where $\|z\|_{2,w} = \sum_{i=1}^n (w_iz_i)^2$. We assume all weights $w_i$ are positive.&lt;br /&gt;
&lt;br /&gt;
By observing that $\|z\|_{2,w} = \|Wz\|_2$, where $W = \operatorname{diag}(w_1, \ldots, w_n)$, we can reduce the problem to ordinary least squares.&lt;br /&gt;
Writing $\|Ax-b\|_{2,w} = \|W(Ax-b)\|_2 = \|WA x - Wb\|_2$, we obtain an ordinary least squares problem with matrix $WA$ and vector $Wb$, which has the &lt;br /&gt;
normal equations $$A^\T W^2Ax = A^\T W^2b$$ and the solution $x = (A^\T W^2A)^{-1} A^\T W^2b$.&lt;br /&gt;
&lt;br /&gt;
= Numerical solving =&lt;br /&gt;
&lt;br /&gt;
Techniques for numerical solving of (weighted) least squares systems are described below. As list of decompositions available in Eigen is available here:&lt;br /&gt;
https://eigen.tuxfamily.org/dox/group__LeastSquares.html&lt;br /&gt;
&lt;br /&gt;
As when solving linear systems if a lot of systems $Ax = b_i$ need to be solved, which only differ in the right hand side, the matrix $A$ can only be decomposed once, with&lt;br /&gt;
subsequent solutions taking $O(n^2)$ time.&lt;br /&gt;
&lt;br /&gt;
== Normal equations ==&lt;br /&gt;
The normal equations above can be directly used to solve the system. The matrix $A^\T A$ is symmetric and positive definite, and&lt;br /&gt;
normal equations can be solved using Cholesky decomposition. However, this can be &lt;br /&gt;
poorly behaved with respect to round-off errors since the condition number $\kappa(A^\T A)$ is the square&lt;br /&gt;
of $\kappa(A)$.&lt;br /&gt;
&lt;br /&gt;
Complexity of Cholesky decomposition is $\frac{m^3}{3}$ and complexity of matrix multiplication $2m^2n$. To preform the Cholesky decomposition the rank of $A$ must be full.&lt;br /&gt;
&lt;br /&gt;
'''Pros:'''&lt;br /&gt;
* simple to implement&lt;br /&gt;
* low computational complexity&lt;br /&gt;
&lt;br /&gt;
'''Cons:'''&lt;br /&gt;
* numerically unstable&lt;br /&gt;
* full rank requirement&lt;br /&gt;
&lt;br /&gt;
== [https://en.wikipedia.org/wiki/QR_decomposition $QR$ Decomposition] ==&lt;br /&gt;
The square $n\times m$ matrix $A$ is decomposed as &lt;br /&gt;
$$&lt;br /&gt;
A = QR = &lt;br /&gt;
\begin{bmatrix} Q_1 &amp;amp; Q_2 \end{bmatrix} &lt;br /&gt;
\begin{bmatrix} R_1 \\ 0 \end{bmatrix} = Q_1R_1,$$&lt;br /&gt;
where &lt;br /&gt;
$Q$ is a unitary matrix ($Q^{-1}=Q^T$) of size $n\times n$, $R$ trapezoidal and is the same size as $A$ ($n \times m$),&lt;br /&gt;
$Q_1$ is also the same as $A$  ($n \times m$) and $R_1$ is a triangular $m \times m$ matrix.&lt;br /&gt;
A useful property of a unitary matrices is that multiplying with them does not alter the (Euclidean) norm of a vector, i.e.,&lt;br /&gt;
$$ \| Qx \| = \| x \|. $$&lt;br /&gt;
Therefore we can say&lt;br /&gt;
$$&lt;br /&gt;
\| Ax- b \| = \| Q^\T (Ax-b) \| = \| Q^\T Ax  - Q^\T b \|&lt;br /&gt;
 = \| Q^\T QRx  - Q^\T b \| = \| [R_1; 0] x  - [Q_1, Q_2]^\T b \|&lt;br /&gt;
 = \| R_1x  - Q_1^\T b \| + \| Q_2^\T b \|&lt;br /&gt;
$$&lt;br /&gt;
Of the two terms, we have no control over the second, and we can render the first one&lt;br /&gt;
zero by solving&lt;br /&gt;
$$ R_1x  = Q_1^\T b, $$&lt;br /&gt;
which results in a minimum $x = R_1^{-1} Q_1^\T b$.&lt;br /&gt;
&lt;br /&gt;
When computing the $QR$ decomposition, only the ''thin'' decomposition $Q_1$, $R_1$ is needed to solve the least squares problem.&lt;br /&gt;
&lt;br /&gt;
The complexity of $QR$ decomposition is $2nm^2−2m^3/3$.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Pros:&amp;lt;/strong&amp;gt; better stability in comparison to normal equations, &amp;lt;strong&amp;gt; cons: &amp;lt;/strong&amp;gt;higher complexity&lt;br /&gt;
&lt;br /&gt;
== [https://en.wikipedia.org/wiki/Singular_value_decomposition SVD decomposition] ==&lt;br /&gt;
In linear algebra, the [https://en.wikipedia.org/wiki/Singular_value_decomposition singular value decomposition (SVD)]&lt;br /&gt;
is a factorization of a real or complex matrix. &lt;br /&gt;
&lt;br /&gt;
The singular value decomposition of an $n \times m$ real or complex&lt;br /&gt;
matrix $A$ is a factorization of the form $A= U\Sigma V^\T$, where&lt;br /&gt;
$U$ is an $n \times n$ unitary matrix, $\Sigma$ is an $n \times m$&lt;br /&gt;
rectangular diagonal matrix with non-negative real numbers on the diagonal, and&lt;br /&gt;
$V$  is an $m \times m$ unitary matrix. The diagonal entries&lt;br /&gt;
$\Sigma_{ii}$ are known as the singular values of $A$. The $n$ columns of&lt;br /&gt;
$U$ and the $n$ columns of $V$ are called the left-singular vectors and&lt;br /&gt;
right-singular vectors of $A$, respectively.&lt;br /&gt;
&lt;br /&gt;
The singular value decomposition and the eigendecomposition are closely&lt;br /&gt;
related. Namely:&lt;br /&gt;
&lt;br /&gt;
* The left-singular vectors of $A$ are eigen vectors of $A A^\T$.&lt;br /&gt;
* The right-singular vectors of $A$ are eigen vectors of $A^\T A$.&lt;br /&gt;
* The non-zero singular values of $A$ (found on the diagonal entries of $\Sigma$) are the square roots of the non-zero eigenvalues of both $A^\T A$ and $A^\T A$.&lt;br /&gt;
&lt;br /&gt;
with SVD we can write $A$ as \[A= U\Sigma V^\T \] where are $U$ and $V$ again unitary matrices and $\Sigma$&lt;br /&gt;
stands for diagonal matrix of singular values.&lt;br /&gt;
&lt;br /&gt;
SVD can be used to compute the pseudoinverse&lt;br /&gt;
\[ A^{+} = \left( U\Sigma V^\T\right)^{-1} = V \Sigma^{-1}U^\T \]&lt;br /&gt;
where $\Sigma^{-1}$ is trivial, just replace every non-zero diagonal entry by&lt;br /&gt;
its reciprocal and transpose the resulting matrix. &lt;br /&gt;
&lt;br /&gt;
This can be used to solve the least squares problem, ordinary systems or underdetermined systems.&lt;br /&gt;
Note that usually only the ''thin'' variant is needed.&lt;br /&gt;
&lt;br /&gt;
One can also choose a threshold $t$&lt;br /&gt;
below which the singular value is considered as $0$ and truncate all &lt;br /&gt;
singular values, whose magnitude is below $t$. Because we do not invert very small values,&lt;br /&gt;
stability of the solution increases, at the cost of a slightly inexact solution.&lt;br /&gt;
This approach is called &amp;quot;truncated SVD decomposition&amp;quot;, which is a form of regularization of badly conditioned problems.&lt;br /&gt;
Another approach would be [https://en.wikipedia.org/wiki/Tikhonov_regularization Tikhonov regularization].&lt;br /&gt;
&lt;br /&gt;
SVD decomposition complexity \[ 2nm^2+2m^3 = O(n^3) \]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Pros:&amp;lt;/strong&amp;gt; stable, &amp;lt;strong&amp;gt; cons: &amp;lt;/strong&amp;gt;high complexity&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Solving_system&amp;diff=3556</id>
		<title>Solving system</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Solving_system&amp;diff=3556"/>
				<updated>2023-12-27T12:06:59Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Basics of solving square linear systems =&lt;br /&gt;
&lt;br /&gt;
Solving a system $Ax = b$, where $A$ is a $n\times n$ matrix of scalars (complex, real, or otherwise) is possible if $A$ is invertible, and the solution is given theoretically by $x = A^{-1}b$.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let $\hat{x}$ be the solution of  $\hat{A} \hat{x} = \hat{b}$, where the matrix $A$ is disturbed as $\hat{A} = A + \Delta{A}$ and the right hand side as $\hat{b} = b + \Delta b$.&lt;br /&gt;
&lt;br /&gt;
The absolute error of $x$ is $\Delta x = \|\hat{x} - x\|$ and the relative errors are defined as $\delta A = \|\Delta A\|/\|A\|$ and $\delta b = \|\Delta b\|/\|b\|$ and $\delta x = \|\Delta x\|/\|x\|$.&lt;br /&gt;
We assume that relative errors in inputs are reasonably small.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If only $b$ is disturbed, the error is given by &lt;br /&gt;
$$\delta x \leq \kappa(A) \delta b,$$ where $\kappa(A) = \|A\|\|A^{-1}\|$ is the ''condition number'' of matrix $A$.&lt;br /&gt;
&lt;br /&gt;
In general, the error is given by&lt;br /&gt;
&lt;br /&gt;
$$\delta x \leq \frac{\kappa(A)}{1 - \kappa(A) \delta A} (\delta A + \delta b).$$&lt;br /&gt;
&lt;br /&gt;
Therefore, if the condition number $\kappa(A)$ is large, the accuracy of the solution of the system can deteriorate.&lt;br /&gt;
&lt;br /&gt;
If $A$ is not invertible, Moore-Penrose pseudoinverse can be used to compute a &amp;quot;solution&amp;quot;: $x = A^+b$.&lt;br /&gt;
&lt;br /&gt;
= Basics of solving underdetermined linear systems = &lt;br /&gt;
= Least norm solution =&lt;br /&gt;
Consider the system $Ax = b$, where $A$ is a $n \times m$ matrix of full rank and $n \leq m$. The number of variables $m$ is larger than the number of equations. This means that all equations can be satisfied &lt;br /&gt;
and some degrees of freedom are left to obtain various properties of the solution. The common problem is to find the least-norm solution: find $x$, such that&lt;br /&gt;
$$\min_x \|x\|_2, \text{ such that } Ax = b.$$&lt;br /&gt;
&lt;br /&gt;
The solution is given by $x = A^\T (AA^\T)^{-1} b$, and it can be obtained by solving the $n \times n$ system $AA^\T y = b$ and computing $x = A^\T y$. &lt;br /&gt;
The solution can also be written as $x = A^+ b$. &lt;br /&gt;
&lt;br /&gt;
To validate the correctness, consider any other $z$, such that $Az=b$. Then, $$&lt;br /&gt;
(z-x)^\T x = (z-x)^\T A^\T (AA^\T)^{-1} b = (A(x-z))^\T (AA^\T)^{-1} b = (b-b)^\T (AA^\T)^{-1} b = 0,&lt;br /&gt;
$$&lt;br /&gt;
and consequently&lt;br /&gt;
$$&lt;br /&gt;
\|z\|^2 = \|z-x+x\|^2 = \|z-x\|^2 + 2(z-x)^\T x + \|x\|^2 = \|z-x\|^2 + \|x\|^2 \geq \|x\|^2,&lt;br /&gt;
$$&lt;br /&gt;
which shows that $x$ has smaller norm than any other solution $z$.&lt;br /&gt;
&lt;br /&gt;
Alternative derivation is to minimize $x^\T x$ with respect to $Ax=b$ using Lagrangian multipliers.&lt;br /&gt;
&lt;br /&gt;
= Weighted case =&lt;br /&gt;
&lt;br /&gt;
Weighted case is similar, except that the minimization problem becomes $$\min_x \|x\|_{2,w}, \text{ such that } Ax = b.$$&lt;br /&gt;
The minimization can be written $\min_x \|Wx\|_{2}, \text{ such that } Ax = b$, or substituting $Wx = y$, we obtain the following&lt;br /&gt;
ordinary least norm problem:&lt;br /&gt;
$$\min_y \|y\|_{2}, \text{ such that } AW^{-1}y = b,$$&lt;br /&gt;
with matrix $AW^{-1}$ and right hand side $b$, and with solution $x = W^{-1} y$.&lt;br /&gt;
&lt;br /&gt;
Thus, the final solution is given as $x = W^{-2} A^\T (A W^{-2} A^\T)^{-1} b$ and can be computed by first solving &lt;br /&gt;
$n \times n$ system $AW^{-2}A^\T y = b$ and computing $x = W^{-2} A^\T y$.&lt;br /&gt;
&lt;br /&gt;
= Numerical solving =&lt;br /&gt;
&lt;br /&gt;
Techniques for numerical solving of (weighted) underdetermined systems are described below. As list of decompositions available in Eigen is available here:&lt;br /&gt;
https://eigen.tuxfamily.org/dox/group__LeastSquares.html&lt;br /&gt;
&lt;br /&gt;
As when solving overdetermined systems if a lot of systems $Ax = b_i$ need to be solved, which only differ in the right hand side, the matrix $A$ can only be decomposed once, with&lt;br /&gt;
subsequent solutions taking $O(n^2)$ time.&lt;br /&gt;
&lt;br /&gt;
== Normal equations ==&lt;br /&gt;
&lt;br /&gt;
We can solve the system directly, by solving the $n \times n$ system $AA^\T y = b$ using Cholesky, and computing $x = A^\T y$.&lt;br /&gt;
&lt;br /&gt;
This decomposition takes $\frac13 n^3 + 2n^2m$ time.&lt;br /&gt;
&lt;br /&gt;
== QR decomposition ==&lt;br /&gt;
&lt;br /&gt;
Writing $A^\T = Q_1R_1$ as when solving overdetermined systems, we can get the solution&lt;br /&gt;
$$x = Q_1R_1 (R_1^\T Q_1^\T Q_1 R_1)^{-1}b = Q_1 R_1 R_1^{-1} R_1^{-\T} b = Q_1 R_1^{-\T} b.$$&lt;br /&gt;
&lt;br /&gt;
The computational costs are the same as in the overdetermined case.&lt;br /&gt;
&lt;br /&gt;
== SVD decomposition ==&lt;br /&gt;
&lt;br /&gt;
The pseudoinverse can be computed using SVD and the solution obtained as $x = A^{+} b$.&lt;br /&gt;
&lt;br /&gt;
The computational costs are the same as in the overdetermined case.&lt;br /&gt;
&lt;br /&gt;
== Decompositions ==&lt;br /&gt;
&lt;br /&gt;
Solving linear systems is not done by computing inverses of $A$ but by suitably decomposing $A$. &lt;br /&gt;
Many decompositions are available, with $LU$ decomposition with partial pivoting being the go-to option.&lt;br /&gt;
with $\frac23 n^3$ cost. Additionally, we have $QR$ and $SVD$ decompositions if more robust decompositions are desired, at a greater cost.&lt;br /&gt;
&lt;br /&gt;
See full the list of Eigen's available decompositions: https://eigen.tuxfamily.org/dox/group__TopicLinearAlgebraDecompositions.html&lt;br /&gt;
&lt;br /&gt;
If many systems $Ax = b_i$ need to be saved with only different right hand sides, the decomposition of $A$ can be computed in $O(n^3)$ and&lt;br /&gt;
stored with subsequent solutions only taking  $O(n^2)$ time.&lt;br /&gt;
&lt;br /&gt;
If the matrix is symmetric and positive definite, Cholesky (called $VV^\T$ or $LL^\T$) decomposition can be used, with $\frac13 n^3$ cost.&lt;br /&gt;
&lt;br /&gt;
= Basics of solving overdetermined linear systems =&lt;br /&gt;
== ordinary least squares ==&lt;br /&gt;
&lt;br /&gt;
Let $A$ be a matrix of size $n \times m$ and $b$ be a vector of size $n$, with $n \geq m$ and let $A$ have full rank. If $n=m$ the system $Ax=b$ is square, and can be treated as such, however the&lt;br /&gt;
derivation below works as well.&lt;br /&gt;
&lt;br /&gt;
The system $Ax=b$ has $n$ equations for $m$ unknowns $x_1, \ldots, x_m$ and is overdetermined. The solution is most often sought in the least-squares sense, defining the solution $x$ to be the solution of the following minimisation problem&lt;br /&gt;
$$ \min_x \|Ax-b\|_2. $$&lt;br /&gt;
The solution can be obtained using calculus, by looking for stationary points of function $\|Ax-b\|_2^2 = (Ax-b)^\T(Ax-b)$ (which has the same minimum), and getting the system of&lt;br /&gt;
normal equations $$A^\T A x = A^\T b.$$ The solution can be expressed theoretically as&lt;br /&gt;
$x = (A^\T A)^{-1} A^\T b$.&lt;br /&gt;
&lt;br /&gt;
== Weighted least squares ==&lt;br /&gt;
&lt;br /&gt;
The weighted least squares problem has the same setup as the ordinary least squares, but we instead minimise the norm $\|Ax-b\|_{2,w}$, where $\|z\|_{2,w} = \sum_{i=1}^n (w_iz_i)^2$. We assume all weights $w_i$ are positive.&lt;br /&gt;
&lt;br /&gt;
By observing that $\|z\|_{2,w} = \|Wz\|_2$, where $W = \operatorname{diag}(w_1, \ldots, w_n)$, we can reduce the problem to ordinary least squares.&lt;br /&gt;
Writing $\|Ax-b\|_{2,w} = \|W(Ax-b)\|_2 = \|WA x - Wb\|_2$, we obtain an ordinary least squares problem with matrix $WA$ and vector $Wb$, which has the &lt;br /&gt;
normal equations $$A^\T W^2Ax = A^\T W^2b$$ and the solution $x = (A^\T W^2A)^{-1} A^\T W^2b$.&lt;br /&gt;
&lt;br /&gt;
= Numerical solving =&lt;br /&gt;
&lt;br /&gt;
Techniques for numerical solving of (weighted) least squares systems are described below. As list of decompositions available in Eigen is available here:&lt;br /&gt;
https://eigen.tuxfamily.org/dox/group__LeastSquares.html&lt;br /&gt;
&lt;br /&gt;
As when solving linear systems if a lot of systems $Ax = b_i$ need to be solved, which only differ in the right hand side, the matrix $A$ can only be decomposed once, with&lt;br /&gt;
subsequent solutions taking $O(n^2)$ time.&lt;br /&gt;
&lt;br /&gt;
== Normal equations ==&lt;br /&gt;
The normal equations above can be directly used to solve the system. The matrix $A^\T A$ is symmetric and positive definite, and&lt;br /&gt;
normal equations can be solved using Cholesky decomposition. However, this can be &lt;br /&gt;
poorly behaved with respect to round-off errors since the condition number $\kappa(A^\T A)$ is the square&lt;br /&gt;
of $\kappa(A)$.&lt;br /&gt;
&lt;br /&gt;
Complexity of Cholesky decomposition is $\frac{m^3}{3}$ and complexity of matrix multiplication $2m^2n$. To preform the Cholesky decomposition the rank of $A$ must be full.&lt;br /&gt;
&lt;br /&gt;
'''Pros:'''&lt;br /&gt;
* simple to implement&lt;br /&gt;
* low computational complexity&lt;br /&gt;
&lt;br /&gt;
'''Cons:'''&lt;br /&gt;
* numerically unstable&lt;br /&gt;
* full rank requirement&lt;br /&gt;
&lt;br /&gt;
== [https://en.wikipedia.org/wiki/QR_decomposition $QR$ Decomposition] ==&lt;br /&gt;
The square $n\times m$ matrix $A$ is decomposed as &lt;br /&gt;
$$&lt;br /&gt;
A = QR = &lt;br /&gt;
\begin{bmatrix} Q_1 &amp;amp; Q_2 \end{bmatrix} &lt;br /&gt;
\begin{bmatrix} R_1 \\ 0 \end{bmatrix} = Q_1R_1,$$&lt;br /&gt;
where &lt;br /&gt;
$Q$ is a unitary matrix ($Q^{-1}=Q^T$) of size $n\times n$, $R$ trapezoidal and is the same size as $A$ ($n \times m$),&lt;br /&gt;
$Q_1$ is also the same as $A$  ($n \times m$) and $R_1$ is a triangular $m \times m$ matrix.&lt;br /&gt;
A useful property of a unitary matrices is that multiplying with them does not alter the (Euclidean) norm of a vector, i.e.,&lt;br /&gt;
$$ \| Qx \| = \| x \|. $$&lt;br /&gt;
Therefore we can say&lt;br /&gt;
$$&lt;br /&gt;
\| Ax- b \| = \| Q^\T (Ax-b) \| = \| Q^\T Ax  - Q^\T b \|&lt;br /&gt;
 = \| Q^\T QRx  - Q^\T b \| = \| [R_1; 0] x  - [Q_1, Q_2]^\T b \|&lt;br /&gt;
 = \| R_1x  - Q_1^\T b \| + \| Q_2^\T b \|&lt;br /&gt;
$$&lt;br /&gt;
Of the two terms, we have no control over the second, and we can render the first one&lt;br /&gt;
zero by solving&lt;br /&gt;
$$ R_1x  = Q_1^\T b, $$&lt;br /&gt;
which results in a minimum $x = R_1^{-1} Q_1^\T b$.&lt;br /&gt;
&lt;br /&gt;
When computing the $QR$ decomposition, only the ''thin'' decomposition $Q_1$, $R_1$ is needed to solve the least squares problem.&lt;br /&gt;
&lt;br /&gt;
The complexity of $QR$ decomposition is $2nm^2−2m^3/3$.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Pros:&amp;lt;/strong&amp;gt; better stability in comparison to normal equations, &amp;lt;strong&amp;gt; cons: &amp;lt;/strong&amp;gt;higher complexity&lt;br /&gt;
&lt;br /&gt;
== [https://en.wikipedia.org/wiki/Singular_value_decomposition SVD decomposition] ==&lt;br /&gt;
In linear algebra, the [https://en.wikipedia.org/wiki/Singular_value_decomposition singular value decomposition (SVD)]&lt;br /&gt;
is a factorization of a real or complex matrix. &lt;br /&gt;
&lt;br /&gt;
The singular value decomposition of an $n \times m$ real or complex&lt;br /&gt;
matrix $A$ is a factorization of the form $A= U\Sigma V^\T$, where&lt;br /&gt;
$U$ is an $n \times n$ unitary matrix, $\Sigma$ is an $n \times m$&lt;br /&gt;
rectangular diagonal matrix with non-negative real numbers on the diagonal, and&lt;br /&gt;
$V$  is an $m \times m$ unitary matrix. The diagonal entries&lt;br /&gt;
$\Sigma_{ii}$ are known as the singular values of $A$. The $n$ columns of&lt;br /&gt;
$U$ and the $n$ columns of $V$ are called the left-singular vectors and&lt;br /&gt;
right-singular vectors of $A$, respectively.&lt;br /&gt;
&lt;br /&gt;
The singular value decomposition and the eigendecomposition are closely&lt;br /&gt;
related. Namely:&lt;br /&gt;
&lt;br /&gt;
* The left-singular vectors of $A$ are eigen vectors of $A A^\T$.&lt;br /&gt;
* The right-singular vectors of $A$ are eigen vectors of $A^\T A$.&lt;br /&gt;
* The non-zero singular values of $A$ (found on the diagonal entries of $\Sigma$) are the square roots of the non-zero eigenvalues of both $A^\T A$ and $A^\T A$.&lt;br /&gt;
&lt;br /&gt;
with SVD we can write $A$ as \[A= U\Sigma V^\T \] where are $U$ and $V$ again unitary matrices and $\Sigma$&lt;br /&gt;
stands for diagonal matrix of singular values.&lt;br /&gt;
&lt;br /&gt;
SVD can be used to compute the pseudoinverse&lt;br /&gt;
\[ A^{+} = \left( U\Sigma V^\T\right)^{-1} = V \Sigma^{-1}U^\T \]&lt;br /&gt;
where $\Sigma^{-1}$ is trivial, just replace every non-zero diagonal entry by&lt;br /&gt;
its reciprocal and transpose the resulting matrix. &lt;br /&gt;
&lt;br /&gt;
This can be used to solve the least squares problem, ordinary systems or underdetermined systems.&lt;br /&gt;
Note that usually only the ''thin'' variant is needed.&lt;br /&gt;
&lt;br /&gt;
One can also choose a threshold $t$&lt;br /&gt;
below which the singular value is considered as $0$ and truncate all &lt;br /&gt;
singular values, whose magnitude is below $t$. Because we do not invert very small values,&lt;br /&gt;
stability of the solution increases, at the cost of a slightly inexact solution.&lt;br /&gt;
This approach is called &amp;quot;truncated SVD decomposition&amp;quot;, which is a form of regularization of badly conditioned problems.&lt;br /&gt;
Another approach would be [https://en.wikipedia.org/wiki/Tikhonov_regularization Tikhonov regularization].&lt;br /&gt;
&lt;br /&gt;
SVD decomposition complexity \[ 2nm^2+2m^3 = O(n^3) \]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Pros:&amp;lt;/strong&amp;gt; stable, &amp;lt;strong&amp;gt; cons: &amp;lt;/strong&amp;gt;high complexity&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=Ghost_nodes&amp;diff=3554</id>
		<title>Ghost nodes</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=Ghost_nodes&amp;diff=3554"/>
				<updated>2023-11-05T21:05:00Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Go back to [[Medusa#Examples|Examples]].&lt;br /&gt;
&lt;br /&gt;
See the [[Ghost nodes (theory)]] page for what ghost nodes and how they are used. We will use them in this example to reliably solve a 3D mixed Dirichlet and Neumann problem on an irregular domain.&lt;br /&gt;
&lt;br /&gt;
We will solve the problem&lt;br /&gt;
&lt;br /&gt;
$\nabla^2 u = 1 \text{ in } \Omega, \quad \frac{\partial u}{\partial n} = 0 \text{ on } \partial \Omega_{+}, \quad u = 0 \text{ on } \partial \Omega_{-}$&lt;br /&gt;
&lt;br /&gt;
where $\Omega = B(\boldsymbol{0}, 1) - B(\boldsymbol{1}, 1.5)$, $\partial \Omega_{+}$ is the part of the boundary with the nonnegative $x$ coordinate and $\partial \Omega_{-}$ the part of the boundary with negative $x$ coordinate.&lt;br /&gt;
&lt;br /&gt;
The code below constructs ghost nodes and remembers the corresponding ghost node for each boundary node.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Range&amp;lt;int&amp;gt; gh = domain.addGhostNodes(dx, 0, neu);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It is equivalent to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Range&amp;lt;int&amp;gt; gh(domain.size(), -1);  // Maps boundary nodes to their corresponding ghost nodes.&lt;br /&gt;
for (int i : neu) {  // Add ghost nodes for each Neumann boundary node&lt;br /&gt;
    gh[i] = domain.addNode(domain.pos(i) + dx*domain.normal(i), 0);   // add node with type 0&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When assembling the system, we write two equations for each Neumann node. One is the Neumann BC and is written in the row corresponding to the boundary node. &lt;br /&gt;
The other is the fact that the PDE also holds at the boundary node, but we write that equation in the row, corresponding to the ghost node. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
for (int i : interior) {&lt;br /&gt;
    op.lap(i) = 1.0;  // Equation&lt;br /&gt;
}&lt;br /&gt;
for (int i : dir) {&lt;br /&gt;
    op.value(i) = 0.0;  // Dirichlet&lt;br /&gt;
}&lt;br /&gt;
for (int i : neu) {&lt;br /&gt;
    op.neumann(i, domain.normal(i)) = 0.0;  // Neumann&lt;br /&gt;
    // Equation holds also on the boundary, write it in the row corresponding to the ghost node.&lt;br /&gt;
    op.lap(i, gh[i]) = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system is then solved as usual. The solution (without the ghost nodes) is shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:solution_ghost_example.png|600px]]&lt;br /&gt;
&lt;br /&gt;
The code is available as [https://gitlab.com/e62Lab/medusa/blob/dev/examples/ghost_nodes/poisson_mixed_3D_ghost.cpp poisson_mixed_3D_ghost.cpp] in the Medusa examples.&lt;br /&gt;
&lt;br /&gt;
Go back to [[Medusa#Examples|Examples]].&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	<entry>
		<id>http://e6.ijs.si/medusa/wiki/index.php?title=How_to_build&amp;diff=3553</id>
		<title>How to build</title>
		<link rel="alternate" type="text/html" href="http://e6.ijs.si/medusa/wiki/index.php?title=How_to_build&amp;diff=3553"/>
				<updated>2023-07-07T14:19:04Z</updated>
		
		<summary type="html">&lt;p&gt;Zigavaupotic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Installation=&lt;br /&gt;
To make this work from plain Ubuntu installation, run&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install git g++ python3 cmake libhdf5-serial-dev doxygen graphviz&lt;br /&gt;
git clone https://gitlab.com/e62Lab/medusa.git --branch dev --single-branch&lt;br /&gt;
cd medusa&lt;br /&gt;
./run_tests.py -t&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
which installs dependencies, clones the repository, goes into the root folder of&lt;br /&gt;
the repository and runs tests.  This will build and run all tests. If this&lt;br /&gt;
works, you are ready to go! Otherwise install any missing packages and if it&lt;br /&gt;
still fails, raise an issue!&lt;br /&gt;
Note: If you are told the packages cannot be located, try doing a sudo apt-get update.&lt;br /&gt;
&lt;br /&gt;
For instructions on how to use this library in you project, see&lt;br /&gt;
[[Including this library in your project]].&lt;br /&gt;
&lt;br /&gt;
=Building=&lt;br /&gt;
&lt;br /&gt;
List of dependencies:&lt;br /&gt;
&lt;br /&gt;
* Build tools, like &amp;lt;code&amp;gt; cmake &amp;gt;= 2.8.12&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; g++ &amp;gt;= 4.8&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;python3&amp;lt;/code&amp;gt;&lt;br /&gt;
* [https://www.hdfgroup.org/ HDF5 library] for IO &lt;br /&gt;
* &amp;lt;code&amp;gt;doxygen &amp;gt;=  1.8.8 &amp;lt;/code&amp;gt; and Graphviz for generating the documentation&lt;br /&gt;
&lt;br /&gt;
Out of source builds are preferred. Run&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p build&lt;br /&gt;
cd build&lt;br /&gt;
cmake ..&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that you only have to run &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; once, after that only &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; is sufficient.&lt;br /&gt;
&lt;br /&gt;
Binaries are placed into &amp;lt;code&amp;gt;bin/&amp;lt;/code&amp;gt; folder. Tests can be run all at once via &amp;lt;code&amp;gt;make medusa_run_tests&amp;lt;/code&amp;gt; &lt;br /&gt;
or individually via e. g. &amp;lt;code&amp;gt;make operators_run_tests&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Linker errors ==&lt;br /&gt;
&lt;br /&gt;
When trying out different classes, you might come along linker errors such as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
Scanning dependencies of target cantilever_beam&lt;br /&gt;
[100%] Building CXX object examples/linear_elasticity/CMakeFiles/cantilever_beam.dir/cantilever_beam.cpp.o&lt;br /&gt;
[100%] Linking CXX executable ../../../examples/linear_elasticity/cantilever_beam&lt;br /&gt;
/usr/bin/ld: CMakeFiles/cantilever_beam.dir/cantilever_beam.cpp.o: in function `main':&lt;br /&gt;
cantilever_beam.cpp:(.text.startup+0x162): undefined reference to `void mm::FindBalancedSupport::operator()&amp;lt;mm::DomainDiscretization&amp;lt;Eigen::Matrix&amp;lt;double, 2, 1, 0, 2, 1&amp;gt; &amp;gt; &amp;gt;(mm::DomainDiscretization&amp;lt;Eigen::Matrix&amp;lt;double, 2, 1, 0, 2, 1&amp;gt; &amp;gt;&amp;amp;) const'&lt;br /&gt;
collect2: error: ld returned 1 exit status&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is expected and is the result of some optimizations of compilation time. The medusa library can actually be included in two ways: as&lt;br /&gt;
&amp;lt;code&amp;gt;#include &amp;lt;medusa/Medusa_fwd.hpp&amp;gt;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;#include &amp;lt;medusa/Medusa.hpp&amp;gt;&amp;lt;/code&amp;gt;. The first version contains the declarations of all symbols, but not all the definitions. Some of the more commonly used template instantiations are included, but by far not all. Using a template instantiation that is not precompiled will cause your program to compile fine, but will fail to link, due to the missing definitions. In this case you have a few options: include the &amp;lt;i&amp;gt;full&amp;lt;/i&amp;gt; Medusa library (the header without the &amp;lt;code&amp;gt;_fwd&amp;lt;/code&amp;gt;) and it should just work, but you will have to wait a bit longer for it to compile. Include only the missing header (in the case above &amp;lt;code&amp;gt;medusa/bits/domains/FindBalancedSupport.hpp&amp;lt;/code&amp;gt;) and pay for whay you use. Or, add your instantiation among the already precompiled instantiations (located in &amp;lt;code&amp;gt;.cpp&amp;lt;/code&amp;gt; files, such as e.g. [https://gitlab.com/e62Lab/medusa/-/blob/dev/src/domains/DomainDiscretization.cpp this one]).&lt;br /&gt;
&lt;br /&gt;
== Building on macOS ==&lt;br /&gt;
This method was tested on macOS Mojave 10.14.2.&lt;br /&gt;
&lt;br /&gt;
First install Xcode via App Store and then Xcode Command Line Tools with&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
xcode-select --install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, install all dependencies from homebrew&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
brew install cmake hdf5 boost python doxygen graphviz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you can clone and build the project using the following commands&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://gitlab.com/e62Lab/medusa.git&lt;br /&gt;
cd medusa&lt;br /&gt;
mkdir build&lt;br /&gt;
cd build&lt;br /&gt;
cmake ..&lt;br /&gt;
cd ..&lt;br /&gt;
python3 run_tests.py -t&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will also run all tests. If it works, you are ready to go! Otherwise install any missing packages and if it still fails, raise an issue!&lt;br /&gt;
&lt;br /&gt;
==HDF5==&lt;br /&gt;
In order to use HDF5 IO you need the [https://www.hdfgroup.org/ HDF5 library].&lt;br /&gt;
You can install it easily using the command &amp;lt;code&amp;gt;sudo apt-get install libhdf5-dev&amp;lt;/code&amp;gt;&lt;br /&gt;
or &amp;lt;code&amp;gt;sudo pacman -S hdf5&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Ubuntu places (at least on older versions) hdf5 headers and libraries in a weird folder &lt;br /&gt;
&amp;lt;code&amp;gt;/usr/{lib, include}/x86_64-linux-gnu/hdf5/serial/&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
If you get an error like &amp;lt;code&amp;gt;HDF5 sample failed to compile.  See errors above.&amp;lt;/code&amp;gt; during &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; execution&lt;br /&gt;
then the sample hdf test file located in &amp;lt;code&amp;gt;test/test_hdf_compile.cpp&amp;lt;/code&amp;gt; failed to compile. Perhaps it is good to make this file compile first, &lt;br /&gt;
before tackling the whole project. &lt;br /&gt;
&lt;br /&gt;
If you get an error similar to &amp;lt;code&amp;gt;fatal error: hdf5.h: No such file or directory&amp;lt;/code&amp;gt;,&lt;br /&gt;
then your compiler cannot see the HDF5 header files. Some distributions, notably (older) Ubuntu, place them into nonstandard folders&lt;br /&gt;
&amp;lt;code&amp;gt;/usr/include/hdf5/serial/&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;/usr/include/x86_64-linux-gnu/hdf5/serial/&amp;lt;/code&amp;gt;.&lt;br /&gt;
Check these two folders or check your distributions hdf package for the locations of these files.&lt;br /&gt;
After you have determined the location, add that directory to the include directories,&lt;br /&gt;
using -I flag or in &amp;lt;code&amp;gt;CMakeLists.txt&amp;lt;/code&amp;gt; by using&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
include_directories(/usr/include/hdf5/serial/)  # or your appropriate directory&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you wish to fix this problem permanently, you can create soft links to the headers in your &amp;lt;code&amp;gt;/usr/include&amp;lt;/code&amp;gt; directory, &lt;br /&gt;
by typing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo ln -s /usr/include/hdf5/serial/* /usr/include&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After this, there should be no compile time errors. If there are, please raise an issue.&lt;br /&gt;
&lt;br /&gt;
If you get error similar to &amp;lt;code&amp;gt;-lhdf5 not found&amp;lt;/code&amp;gt; and you have hdf5 installed, &lt;br /&gt;
you might have to link the libraries into a discoverable place, like &amp;lt;code&amp;gt;/usr/lib/&amp;lt;/code&amp;gt; &lt;br /&gt;
or add the above directory to the linker path. Similarly to above, check the &amp;lt;code&amp;gt;/usr/lib/x86_64-linux-gnu/hdf5/serial/&amp;lt;/code&amp;gt;&lt;br /&gt;
directory and look for file &amp;lt;code&amp;gt;libhdf5.a&amp;lt;/code&amp;gt;. When found,&lt;br /&gt;
specify the location using -L flag or &amp;lt;code&amp;gt;CMakeLists.txt&amp;lt;/code&amp;gt; by using&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
link_directories(/usr/lib/x86_64-linux-gnu/hdf5/serial/)  # or your appropriate directory&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
or fix the problem permanently by soft-linking&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo ln -s /usr/lib/x86_64-linux-gnu/hdf5/serial/* /usr/lib&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== OpenMP ==&lt;br /&gt;
Sometimes, OpenMP cmake errors might occure. This happens mainly due to limited multi-thread support. One can fix such issues, by adding the following code into their CMakeLists.txt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
find_package(OpenMP)&lt;br /&gt;
if (OPENMP_FOUND)&lt;br /&gt;
    set (CMAKE_C_FLAGS &amp;quot;${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}&amp;quot;)&lt;br /&gt;
    set (CMAKE_CXX_FLAGS &amp;quot;${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}&amp;quot;)&lt;br /&gt;
    set (CMAKE_EXE_LINKER_FLAGS &amp;quot;${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}&amp;quot;)&lt;br /&gt;
endif()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Linear Algebra==&lt;br /&gt;
We use [http://eigen.tuxfamily.org/ Eigen] as our matrix library. See&lt;br /&gt;
[http://eigen.tuxfamily.org/dox-devel/group__QuickRefPage.html here] for use&lt;br /&gt;
reference and documentation. For a quick transition from Matlab see&lt;br /&gt;
[http://eigen.tuxfamily.org/dox/AsciiQuickReference.txt here].&lt;br /&gt;
&lt;br /&gt;
== Using Intel Math Kernel Library (MKL) ==&lt;br /&gt;
Install [https://software.intel.com/en-us/mkl Intel MKL] and take not of installation directories.&lt;br /&gt;
&lt;br /&gt;
Proper include and link directories need to be set to use the Intel MKL. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
include_directories(SYSTEM /opt/intel/compilers_and_libraries/linux/mkl/include)    # change these to your installation path&lt;br /&gt;
link_directories(SYSTEM /opt/intel/compilers_and_libraries/linux/mkl/lib/intel64)&lt;br /&gt;
link_directories(SYSTEM /opt/intel/compilers_and_libraries/linux/lib/intel64)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Eigen has great support for MKL. You can see more detailed instructions [https://eigen.tuxfamily.org/dox/TopicUsingIntelMKL.html on their website].&lt;br /&gt;
To use MKL for math operations, define &amp;lt;code&amp;gt;EIGEN_USE_MKL_VML&amp;lt;/code&amp;gt; when compiling. You must also link&lt;br /&gt;
the appropriate libraries and define &amp;lt;code&amp;gt;MKL_LP64&amp;lt;/code&amp;gt; for use on a 64bit system.&lt;br /&gt;
With parallelism enabled, the configuration looks as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
target_compile_options(my_target PRIVATE &amp;quot;-fopenmp&amp;quot;)&lt;br /&gt;
target_compile_definitions(my_target PUBLIC EIGEN_USE_MKL_VML MKL_LP64)&lt;br /&gt;
target_link_libraries(my_target medusa mkl_intel_lp64 mkl_intel_thread mkl_core pthread iomp5)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have Intel Parallel Studio installed this also enables you to use the Pardiso paralle direct sparse solver through its [https://eigen.tuxfamily.org/dox/group__PardisoSupport__Module.html Eigen interface].&lt;br /&gt;
&lt;br /&gt;
== Using Intel C/C++ Compiler ==&lt;br /&gt;
&lt;br /&gt;
In order to use Intel's compiler when compiling Medusa, you have several standard optionas for &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt;.&lt;br /&gt;
Make sure compilers and installed and in your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; by running &amp;lt;code&amp;gt;which icc&amp;lt;/code&amp;gt;, which &lt;br /&gt;
should return something like &amp;lt;code&amp;gt;/opt/intel/bin/icc&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can define the compiler when *first* calling cmake like so&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cmake .. -DCMAKE_C_COMPILER=$(which icc) -DCMAKE_CXX_COMPILER=$(which icpc) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If this is not your first call, remove the &amp;lt;code&amp;gt;build&amp;lt;/code&amp;gt; directory and start anew.&lt;br /&gt;
&lt;br /&gt;
You can also set the &amp;lt;code&amp;gt;CXX&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CC&amp;lt;/code&amp;gt; bash variables. Before calling&lt;br /&gt;
&amp;lt;code&amp;gt; cmake &amp;lt;/code&amp;gt; for the first time you have to export the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
export CXX=&amp;quot;icpc&amp;quot;&lt;br /&gt;
export CC=&amp;quot;icc&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
You can also compile it directly for Intel® Xeon Phi™ Coprocessor. You do this by adding &amp;lt;code&amp;gt;-Dmmic=ON&amp;lt;/code&amp;gt;&lt;br /&gt;
flag to the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cmake .. -Dmmic=ON -DCMAKE_C_COMPILER=$(which icc) -DCMAKE_CXX_COMPILER=$(which icpc) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; All features that depend on system third-party libraries are not available on MIC (Many Integrated Core).&lt;br /&gt;
This includes:&lt;br /&gt;
&lt;br /&gt;
* HDF class in &amp;lt;code&amp;gt;io.hpp&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zigavaupotic</name></author>	</entry>

	</feed>