<br />
<b>Warning</b>:  session_id(): Cannot change session id when session is active in <b>/var/www/html/wiki/includes/Setup.php</b> on line <b>775</b><br />
<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://e6.ijs.si/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MihaR</id>
		<title>Medusa: Coordinate Free Mehless Method implementation - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://e6.ijs.si/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MihaR"/>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Special:Contributions/MihaR"/>
		<updated>2026-05-13T23:50:54Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.1</generator>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Philosophy_of_examples_and_how_to_run_them&amp;diff=3186</id>
		<title>Philosophy of examples and how to run them</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Philosophy_of_examples_and_how_to_run_them&amp;diff=3186"/>
				<updated>2022-03-02T12:36:23Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Renamed the example file due to changes in the code.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Go back to [[Medusa#Examples|Examples]].&lt;br /&gt;
&lt;br /&gt;
The idea of our examples is to present the functionality of the library in an accessible and incremental manner. &lt;br /&gt;
The examples present different solutions to problems ranging in difficulty from the simple [[Poisson's equation]] to more specific examples, such as [[Fluid mechanics]].&lt;br /&gt;
Each examples consists of a name, e.g. &amp;lt;code&amp;gt;poisson_dirichlet_2D&amp;lt;/code&amp;gt; and its corresponding&lt;br /&gt;
* source code, e.g. &amp;lt;code&amp;gt;poisson_dirichlet_2D.cpp&amp;lt;/code&amp;gt;&lt;br /&gt;
* plot script, e.g. &amp;lt;code&amp;gt;poisson_dirichlet_2D.m&amp;lt;/code&amp;gt;&lt;br /&gt;
Additional appropriately named input files might be present for more complicated examples and similarly named output files might be produced. &lt;br /&gt;
The examples and their plot scripts are intended to work out of the box,  so the reader can simply run the examples on their machine.&lt;br /&gt;
The procedure for running examples is simple and the same for all examples. The accompanying plot scripts can be run with Matlab or octave and &lt;br /&gt;
they produce the figures the reader sees in the Examples category of this wiki.&lt;br /&gt;
&lt;br /&gt;
Let us now illustrate the process of running an example &amp;lt;code&amp;gt;poisson_dirichlet_2D&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
First the example needs to be built (compiled). The building is done in the same &amp;lt;code&amp;gt;build/&amp;lt;/code&amp;gt; directory&lt;br /&gt;
where medusa was build. To build and run the example, simply execute&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
make poisson_dirichlet_2D_run  # builds and runs your example          &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
to compile and run your example. On first compilation, the whole library might compile as well, if not compiled previously, so it might take longer than usual.&lt;br /&gt;
Compiled binary used to run the example is placed next to the example source file. If only &amp;lt;code&amp;gt;make poisson_dirichlet_2D&amp;lt;/code&amp;gt; (without _run) the&lt;br /&gt;
example is built, but not run.&lt;br /&gt;
&lt;br /&gt;
To build all examples, you can just run &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
make examples  # or &amp;quot;make examples_run&amp;quot; to also run them&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run the built example again, go back to the initial folder where the source code for your example was, and run&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./poisson_dirichlet_2D&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The output will be saved in the same folder as the binary and the source file.&lt;br /&gt;
&lt;br /&gt;
After, just run the corresponding plot script &amp;lt;code&amp;gt;example_name.m&amp;lt;/code&amp;gt; and you should see a figure, usually showing the solution.&lt;br /&gt;
&lt;br /&gt;
'''Standalone compilation'''&lt;br /&gt;
&lt;br /&gt;
The examples can then be compiled manually using e.g. &amp;lt;code&amp;gt;g++&amp;lt;/code&amp;gt;, provided that&lt;br /&gt;
appropriate include and library paths are set and the &amp;lt;code&amp;gt;medusa_standalone&amp;lt;/code&amp;gt; library is specified&lt;br /&gt;
for linking.&lt;br /&gt;
&lt;br /&gt;
Example command to be run from &amp;lt;code&amp;gt;poisson_equation&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g++ -o poisson_dirichlet_2D poisson_dirichlet_2D.cpp -I ../../include -Wall -O3 -L ../../bin -lmedusa_standalone&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The compiled example can be run simply as&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./poisson_dirichlet_2D&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
and plotted using the accompanying plot script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some more feature specific examples are found in the [http://e6.ijs.si/docs/ technical documentation] and in the unit tests.&lt;br /&gt;
&lt;br /&gt;
Go back to [[Medusa#Examples|Examples]].&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=How_to_build&amp;diff=3171</id>
		<title>How to build</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=How_to_build&amp;diff=3171"/>
				<updated>2021-08-17T10:47:44Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Updated run script flags&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 master --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;
&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;
==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>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Fluid_mechanics&amp;diff=3170</id>
		<title>Fluid mechanics</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Fluid_mechanics&amp;diff=3170"/>
				<updated>2021-05-13T09:34:14Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Redirected page to Fluid Mechanics&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Fluid Mechanics]]&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Medusa&amp;diff=3110</id>
		<title>Medusa</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Medusa&amp;diff=3110"/>
				<updated>2020-10-21T11:33:32Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: /* Examples */  Added link to non-Newtonian example&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;
== 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 spline's (NURBS)]]&lt;br /&gt;
* [[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;
* [[Non-Newtonian_fluid_example | Non-Newtonian fluid]]&lt;br /&gt;
* [[Meshless Lattice Boltzmann method]]&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 [[Solving linear systems | linear systems]], [[Solving overdetermined systems | overdetermined]] and [[Solving underdetermined systems | underdetermined]]&lt;br /&gt;
* [[Weighted Least Squares (WLS)]]&lt;br /&gt;
* [[Computation of shape functions]]&lt;br /&gt;
* [[Meshless Local Strong Form Method (MLSM)]]&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;
* [[RBF Interpolation]]&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;
* Basic PDE solutions&lt;br /&gt;
** [[Convection Diffusion equation | Convection Diffusion equation]]&lt;br /&gt;
**[[Wave equation application]] &lt;br /&gt;
* [[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;
* [[Fluid Mechanics]]&lt;br /&gt;
** [[Lid driven cavity]]&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;
* Slak J., Kosec G. Adaptive radial basis function-generated finite differences method for contact problems. International journal for numerical methods in engineering, ISSN 0029-5981 [http://www-e6.ijs.si/ParallelAndDistributedSystems/pdf/32230439.pdf manuscript]&lt;br /&gt;
* Slak J., Kosec G.; Refined meshless local strong form solution of Cauchy-Navier equation on an irregular domain. Engineering analysis with boundary elements. 2018;11 ; [http://comms.ijs.si/~gkosec/data/papers/31107623.pdf manuscript]&lt;br /&gt;
* Depolli, M., Kosec, G., 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 ;[http://comms.ijs.si/~gkosec/data/papers/29639719.pdf manuscript]&lt;br /&gt;
* Kosec G., A local numerical solution of a fluid-flow problem on an irregular domain. Advances in engineering software. 2016;7 ; [29512743] ; [http://comms.ijs.si/~gkosec/data/papers/29512743.pdf manuscript]&lt;br /&gt;
* Kosec G., Trobec R., Simulation of semiconductor devices with a local numerical approach. Engineering analysis with boundary elements. 2015;69-75; [27912487] ; [http://comms.ijs.si/~gkosec/data/papers/27912487.pdf manuscript]&lt;br /&gt;
* Kosec G., Šarler B., Simulation of macrosegregation with mesosegregates in binary metallic casts by a meshless method. Engineering analysis with boundary elements. 2014;36-44; [http://comms.ijs.si/~gkosec/data/papers/3218939.pdf manuscript]&lt;br /&gt;
* Kosec G., Depolli M., Rashkovska A., Trobec R., Super linear speedup in a local parallel meshless solution of thermo-fluid problem. Computers &amp;amp; Structures. 2014;133:30-38; [http://comms.ijs.si/~gkosec/data/papers/27339815.pdf manuscript]&lt;br /&gt;
* Kosec G., Zinterhof P., Local strong form meshless method on multiple Graphics Processing Units. Computer modeling in engineering &amp;amp; sciences. 2013;91:377-396; [http://comms.ijs.si/~gkosec/data/papers/26785063.pdf manuscript]&lt;br /&gt;
* Kosec G., Šarler B., H-adaptive local radial basis function collocation meshless method. Computers, materials &amp;amp; continua. 2011;26:227-253; [http://comms.ijs.si/~gkosec/data/papers/KosecSarlerBurgers.pdf manuscript]&lt;br /&gt;
* Trobec R., Kosec G., Šterk M., Šarler B., Comparison of local weak and strong form meshless methods for 2-D diffusion equation. Engineering analysis with boundary elements. 2012;36:310-321; [http://comms.ijs.si/~gkosec/data/papers/EABE2499.pdf manuscript]&lt;br /&gt;
* Kosec G, Zaloznik M, Sarler B, Combeau H. A Meshless Approach Towards Solution of Macrosegregation Phenomena. CMC: Computers, Materials, &amp;amp; Continua. 2011;580:1-27 [http://comms.ijs.si/~gkosec/data/papers/KosecZaloznikSarlerCombeauSegregation.pdf manuscript]&lt;br /&gt;
* Kosec G, Sarler B. Solution of thermo-fluid problems by collocation with local pressure correction. International Journal of Numerical Methods for Heat &amp;amp; Fluid Flow. 2008;18:868-82 [http://comms.ijs.si/~gkosec/data/papers/KosecSarlerNS2008.pdf manuscript]&lt;br /&gt;
*  Trobec R., Kosec G., Parallel Scientific Computing, ISBN: 978-3-319-17072-5 (Print) 978-3-319-17073-2.&lt;br /&gt;
*  Slak, J., Kosec, G.. Detection of heart rate variability from a wearable differential ECG device., MIPRO 2016, 39th International Convention, 2016, Opatija, Croatia, ISSN 1847-3938, pp 450-455.&lt;br /&gt;
*  Kolman, M., Kosec, G. Correlation between attenuation of 20 GHz satellite communication link and liquid water content in the atmosphere. MIPRO 2016, 39th International Convention, 2016, Opatija, Croatia, ISSN 1847-3938. pp. 308-313.&lt;br /&gt;
&lt;br /&gt;
==Related pages==&lt;br /&gt;
* http://e6.ijs.si/ParallelAndDistributedSystems/#!NumericalMethods&lt;br /&gt;
* http://e6.ijs.si/ParallelAndDistributedSystems/#!utils&lt;br /&gt;
* http://e6.ijs.si/ParallelAndDistributedSystems/#!NUMA&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Non-Newtonian_fluid&amp;diff=3109</id>
		<title>Non-Newtonian fluid</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Non-Newtonian_fluid&amp;diff=3109"/>
				<updated>2020-10-21T11:29:38Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Improved grammar&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Click here to return back to [[Fluid Mechanics]]&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
Other fluid mechanics examples have assumed that the fluids in question are Newtonian, but that is not always the case when dealing with real world applications. Many significant fluids exhibit non-Newtonian behaviour with examples including blood, foodstuffs, polymer melts... Newtonian fluids have a linear relationship between viscous stress and shear rate but that is no longer true for non-Newtonian fluids.&lt;br /&gt;
&lt;br /&gt;
Some fluids exhibit increasing or decreasing viscosity with increasing shear rate which is the simplest form of non-Newtonian behaviour that we will tackle in the following sections. Some act as solids at small stress but begin flowing when sufficiently disturbed, while others behaviour depends on the duration of movement and applied stress.&lt;br /&gt;
&lt;br /&gt;
=Model formulation=&lt;br /&gt;
Viscous forces are a result of velocity differentials within the fluid and are therefore connected with the velocity gradient. We are interested in the symmetric part that excludes the rotational contributions. Shear rate tensor $\dot{u}$ for incompressible fluids can be expressed as &lt;br /&gt;
$$&lt;br /&gt;
\dot{u}=\frac{1}{2}\left(\boldsymbol{\nabla} \boldsymbol{v}+(\boldsymbol{\nabla} \boldsymbol{v})^{\top}\right),&lt;br /&gt;
$$&lt;br /&gt;
where $\boldsymbol{v}$ denotes the fluid velocity. We introduce viscosity $\mu$ through a generalized Newton's law of viscosity with viscous stress tensor $\tau$ expressed as&lt;br /&gt;
$$&lt;br /&gt;
\tau = \mu \dot{u}.&lt;br /&gt;
$$&lt;br /&gt;
In general $\mu$ is an arbitrary tensor but usually reduces to a scalar value due to isotropic properties of fluids. Non-Newtonian fluids are fluids where viscosity is a function of shear stress and duration of stress. There are many, often quantitative, models of varying complexities used to describe the viscosity of various non-Newtonian fluids.&lt;br /&gt;
&lt;br /&gt;
We limit ourselves to Ostwald-de Waele power law model&lt;br /&gt;
$$&lt;br /&gt;
\mu = \mu_0 \left\| \dot{u} \right\| ^{n-1} = \mu_0 \left( 2 \dot{u}{:}\dot{u} \right) ^\frac{n-1}{2},&lt;br /&gt;
$$&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:devahl_scheme&amp;quot;&amp;gt;&lt;br /&gt;
[[File:image.png|thumb|&amp;lt;caption&amp;gt;Scheme of the de Vahl Davis benchmark test.&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is one of the simplest non-Newtonian viscosity models. We introduced two parameters used to fit the model to the experimental data for the fluid in question. Viscosity constant $\mu_0$ used as a scaling factor and non-Newtonian power index $n$ that describes the behaviour. Model with $n &amp;lt; 1$ describes shear-thinning (pseudoplastic), $n = 1$ Newtonian and $n &amp;gt; 1$ shear thickening (dilatant) fluids.&lt;br /&gt;
&lt;br /&gt;
We will focus on shear thinning fluids as their behaviour of reduced viscosity at higher velocity gradients leads towards interesting behaviour with decreasing $n$.&lt;br /&gt;
&lt;br /&gt;
=de Vahl Davis example=&lt;br /&gt;
We take a closer look at the behaviour of non-Newtonian fluid in a natural convection driven flow within a square cavity. The convection is driven by differentially heated east and west walls with the north and south walls thermally insulated as is schematically shown in &amp;lt;xr id=&amp;quot;fig:devahl_scheme&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This is a common benchmark with existing solutions that we can compare our meshless implementation against. Convergence and comparison with the benchmark article is shown in &amp;lt;xr id=&amp;quot;fig:nonNewtonianConvergence&amp;quot;/&amp;gt; where we plot how the average Nusselt number changes with increasing node density. Nusselt number is a dimensionless number that expresses the ratio between the convective and conductive heat transfer. We use the average value on the western wall and define it as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:nonNewtonianConvergence&amp;quot;&amp;gt;&lt;br /&gt;
[[File:nonNewtonianConvergence.png|thumb|left|700px|&lt;br /&gt;
&amp;lt;caption&amp;gt;Convergence&amp;lt;/caption&amp;gt; of the average Nusselt number value with the increasing node count and comparison with reference values from the reference&amp;lt;ref name=&amp;quot;Turan2011&amp;quot;&amp;gt;O. Turan, A. Sachdeva, N. Chakraborty in R. J. Poole, Laminar natural convection of power-law Fluids in a square enclosure with differentially heated side walls subjected to constant temperatures, Journal of Non-Newtonian Fluid Mechanics 166, 1049 (2011).&amp;lt;/ref&amp;gt;. Convergence is calculated at Ra$=10^4$ and Pr$=10$.]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$$&lt;br /&gt;
\mathrm{Nu}=\frac{\Omega_W}{T_{H}-T_{C}}\left|\frac{\partial T}{\partial p_x}\right|_{p_x=0},&lt;br /&gt;
$$&lt;br /&gt;
where $T$ denotes the temperature, $p_x$ the $x$ coordinate and $\Omega_W$ the cavity width. Nusselt number is a convenient tool that can be used to reduce the dynamics of a complex multidimensional system into a single scalar value. &lt;br /&gt;
&lt;br /&gt;
We define the problem in terms of Rayleigh and Prandtl dimensionless numbers that need to be slightly modified to remain relevant in a non-Newtonian case but their specifics are not really relevant for this review. Dimensionless number definitions used in these calculations match reference&amp;lt;ref name=&amp;quot;Turan2011&amp;quot;&amp;gt;O. Turan, A. Sachdeva, N. Chakraborty in R. J. Poole, Laminar natural convection of power-law Fluids in a square enclosure with differentially heated side walls subjected to constant temperatures, Journal of Non-Newtonian Fluid Mechanics 166, 1049 (2011).&amp;lt;/ref&amp;gt; and can be viewed there.&lt;br /&gt;
&lt;br /&gt;
Parameters that lead to an oscillatory behaviour in the de Vahl Davis cavity can be found in literature&amp;lt;ref name=&amp;quot;Kosec2011&amp;quot;&amp;gt;G. Kosec in 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 23, 22 (2013).&amp;lt;/ref&amp;gt;. The referenced article found oscillatory behaviour in Newtonian fluids at Ra=$5 \cdot 10^4$ and Pr=$0.01$, but we want to use a slightly lower Ra value to find the transition as the dynamics become wilder with a smaller $n$. We chose Ra=$2 \cdot 10^4$ and Pr=$0.01$ as the parameters to be used for all subsequently displayed calculations.&lt;br /&gt;
&lt;br /&gt;
The following figures display or mention dimensionless time that is defined with the same definition as described in the reference&amp;lt;ref name=&amp;quot;Kosec2011&amp;quot;&amp;gt;G. Kosec in 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 23, 22 (2013).&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:nusseltEvolutionNN&amp;quot;&amp;gt;&lt;br /&gt;
[[File:nusseltEvolutionNN.png|thumb|left|700px|&lt;br /&gt;
&amp;lt;caption&amp;gt;Evolution of the average Nusselt number in a differentially heated square cavity for different values of the non-Newtonian power index $n$.&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We reuse the Nusselt number to analyse the differences in behaviour for different non-Newtonian power indices $n$ shown in &amp;lt;xr id=&amp;quot;fig:nusseltEvolutionNN&amp;quot;/&amp;gt;. The Newtonian case with $n=1$ settles into a stationary case which is expected, as we chose parameters below the previously identified oscillatory solution. The time evolutions of the average Nusselt number become oscillatory as we increase the strenght of non-Newtonian behaviour, while the solutions become less and less regular as we reduce the power index $n$, which can be seen in pictures of velocity and temperature distributions shown in &amp;lt;xr id=&amp;quot;fig:squareCavityDisplay&amp;quot;/&amp;gt;. Detailed animation of behaviour in the most extreme $n=0.7$ case is shown in &amp;lt;xr id=&amp;quot;fig:animation&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Exact implementation of the non-Newtonian fluid modeled with Ostwald-de Waele power law can be found in the [[Non-Newtonian_fluid_example|example]]. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:squareCavityDisplay&amp;quot;&amp;gt;&lt;br /&gt;
[[File:squareCavity_t10_Ra20000Pr001.png|frame|center|&lt;br /&gt;
&amp;lt;caption&amp;gt;Velocity and temperature fields within the cavity at $t=10$ for different values of the non-Newtonian power index $n$.&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:animation&amp;quot;&amp;gt;&lt;br /&gt;
[[File:squareCavityAnimationNN_n07.mp4|thumb|center|upright=2|&lt;br /&gt;
&amp;lt;caption&amp;gt;Animation of velocity and temperature fields within the cavity between $t=10$ and $t=11$ for $n=0.7$.&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Non-Newtonian_fluid&amp;diff=3106</id>
		<title>Non-Newtonian fluid</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Non-Newtonian_fluid&amp;diff=3106"/>
				<updated>2020-10-12T18:32:54Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Link to example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Click here to return back to [[Fluid Mechanics]]&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
Other fluid mechanics examples have assumed that the fluids in question are Newtonian, but that is not always the case when dealing with real world applications. Many significant fluids exhibit non-Newtonian behaviour with examples including blood, foodstuffs, polymer melts... Newtonian fluids have a linear relationship between viscous stress and shear rate but that is no longer true for non-Newtonian fluids.&lt;br /&gt;
&lt;br /&gt;
Some fluids exhibit increasing or decreasing viscosity with increasing shear rate which is the simplest form of non-Newtonian behaviour that we will tackle in the following sections. Some act as solids at small stress but begin flowing when sufficiently disturbed, while others behaviour depends on the duration of movement and applied stress.&lt;br /&gt;
&lt;br /&gt;
=Model formulation=&lt;br /&gt;
Viscous forces are a result of velocity differentials within the fluid and are therefore connected with the velocity gradient. We are interested in the symmetric part that excludes the rotational contributions. Shear rate tensor $\dot{u}$ for incompressible fluids can be expressed as &lt;br /&gt;
$$&lt;br /&gt;
\dot{u}=\frac{1}{2}\left(\boldsymbol{\nabla} \boldsymbol{v}+(\boldsymbol{\nabla} \boldsymbol{v})^{\top}\right),&lt;br /&gt;
$$&lt;br /&gt;
where $\boldsymbol{v}$ denotes the fluid velocity. We introduce viscosity $\mu$ through a generalized Newton's law of viscosity with viscous stress tensor $\tau$ expressed as&lt;br /&gt;
$$&lt;br /&gt;
\tau = \mu \dot{u}.&lt;br /&gt;
$$&lt;br /&gt;
In general $\mu$ is an arbitrary tensor but usually reduces to a scalar value due to isotropic properties of fluids. Non-Newtonian fluids are fluids where viscosity is a function of shear stress and duration of stress. There are many, often quantitative, models of varying complexities used to describe the viscosity of various non-Newtonian fluids.&lt;br /&gt;
&lt;br /&gt;
We limit ourselves to Ostwald-de Waele power law model&lt;br /&gt;
$$&lt;br /&gt;
\mu = \mu_0 \left\| \dot{u} \right\| ^{n-1} = \mu_0 \left( 2 \dot{u}{:}\dot{u} \right) ^\frac{n-1}{2},&lt;br /&gt;
$$&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:devahl_scheme&amp;quot;&amp;gt;&lt;br /&gt;
[[File:image.png|thumb|&amp;lt;caption&amp;gt;Scheme of the de Vahl Davis benchmark test.&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is one of the simplest non-Newtonian viscosity models. We introduced two parameters used to fit the model to the experimental data for the fluid in question. Viscosity constant $\mu_0$ used as a scaling factor and non-Newtonian power index $n$ that describes the behaviour. Model with $n &amp;lt; 1$ describes shear-thinning (pseudoplastic), $n = 1$ Newtonian and $n &amp;gt; 1$ shear thickening (dilatant) fluids.&lt;br /&gt;
&lt;br /&gt;
We will focus on shear thinning fluids as their behaviour of reduced viscosity at higher velocity gradients leads towards interesting behaviour with decreasing $n$.&lt;br /&gt;
&lt;br /&gt;
=de Vahl Davis example=&lt;br /&gt;
We take a closer look at the behaviour of non-Newtonian fluid in a natural convection driven flow within a square cavity. The convection is driven by differentially heated east and west walls with the north and south walls thermally insulated as is schematically shown in &amp;lt;xr id=&amp;quot;fig:devahl_scheme&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This is a common benchmark with existing solutions that we can benchmark our meshless implementation against. Convergence and comparison with benchmark article is shown in &amp;lt;xr id=&amp;quot;fig:nonNewtonianConvergence&amp;quot;/&amp;gt; where we plot the changes of average Nusselt number with increasing node density. Nusselt number is a dimensionless number that expresses the ratio between convective and conductive heat transfer. We use the average value on the western wall and define it as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:nonNewtonianConvergence&amp;quot;&amp;gt;&lt;br /&gt;
[[File:nonNewtonianConvergence.png|thumb|left|700px|&lt;br /&gt;
&amp;lt;caption&amp;gt;Convergence&amp;lt;/caption&amp;gt; of average Nusselt number value with increasing node count and comparison with reference values from reference&amp;lt;ref name=&amp;quot;Turan2011&amp;quot;&amp;gt;O. Turan, A. Sachdeva, N. Chakraborty in R. J. Poole, Laminar natural convection of power-law Fluids in a square enclosure with differentially heated side walls subjected to constant temperatures, Journal of Non-Newtonian Fluid Mechanics 166, 1049 (2011).&amp;lt;/ref&amp;gt;. Convergence is calculated at Ra$=10^4$ and Pr$=10$.]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$$&lt;br /&gt;
\mathrm{Nu}=\frac{\Omega_W}{T_{H}-T_{C}}\left|\frac{\partial T}{\partial p_x}\right|_{p_x=0},&lt;br /&gt;
$$&lt;br /&gt;
where $T$ denotest the demperature, $p_x$ $x$ coordinate and $\Omega_W$ cavity width. Nusselt number is a convenient tool that can be used to reduce the dynamics of a complex multidimensional system into a single scalar value. &lt;br /&gt;
&lt;br /&gt;
We define the problem in terms of Rayleigh and Prandtl dimensionless numbers that need to be slightly modified to remain relevant in non-Newtonian case but specifics are not really relevant for this review. Dimensionless number definitions used in these calculations match reference&amp;lt;ref name=&amp;quot;Turan2011&amp;quot;&amp;gt;O. Turan, A. Sachdeva, N. Chakraborty in R. J. Poole, Laminar natural convection of power-law Fluids in a square enclosure with differentially heated side walls subjected to constant temperatures, Journal of Non-Newtonian Fluid Mechanics 166, 1049 (2011).&amp;lt;/ref&amp;gt; and can be viewed there.&lt;br /&gt;
&lt;br /&gt;
Parameters that lead to oscillatory behaviour in de Vahl Davis cavity can be found in literature&amp;lt;ref name=&amp;quot;Kosec2011&amp;quot;&amp;gt;G. Kosec in 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 23, 22 (2013).&amp;lt;/ref&amp;gt;. Referenced article found oscillatory behaviour in Newtonian fluids at Ra=$5 \cdot 10^4$ and Pr=$0.01$ but we want to start slightly lower to find the transition as the dynamics become wilder with smaller $n$. We chose Ra=$2 \cdot 10^4$ and Pr=$0.01$ as the parameters to be used for all subsequently displayed calculations.&lt;br /&gt;
&lt;br /&gt;
The following figures display or mention dimensionless time that is defined with the same definition as described in reference&amp;lt;ref name=&amp;quot;Kosec2011&amp;quot;&amp;gt;G. Kosec in 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 23, 22 (2013).&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:nusseltEvolutionNN&amp;quot;&amp;gt;&lt;br /&gt;
[[File:nusseltEvolutionNN.png|thumb|left|700px|&lt;br /&gt;
&amp;lt;caption&amp;gt;Evolution of average Nusselt number in a differentially heated square cavity for different values of non-Newtonian power index $n$.&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We reuse the Nusselt number to analyse the differences in behaviour for different non-Newtonian power indices $n$ shown in &amp;lt;xr id=&amp;quot;fig:nusseltEvolutionNN&amp;quot;/&amp;gt;. The Newtonian case with $n=1$ settles into a stationary case which is expected, as we chose parameters below the previously identified oscillatory solution. Evolutions of Nusselt number become oscillatory as we increase the strenght of non-Newtonian behaviour while the solutions become less and less regular as we reduce the power index $n$ which can be seen in pictures of velocity and temperature distributions shown in &amp;lt;xr id=&amp;quot;fig:squareCavityDisplay&amp;quot;/&amp;gt;. Detailed animation of behaviour in the most extreme $n=0.7$ case is shown in &amp;lt;xr id=&amp;quot;fig:animation&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Exact implementation of non-Newtonian fluid modeled with Ostwald-de Waele power law can be found in [[Non-Newtonian_fluid_example|example]]. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:squareCavityDisplay&amp;quot;&amp;gt;&lt;br /&gt;
[[File:squareCavity_t10_Ra20000Pr001.png|frame|center|&lt;br /&gt;
&amp;lt;caption&amp;gt;Velocity and temperature fields within the cavity at $t=10$ for different values of non-Newtonian power index $n$.&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:animation&amp;quot;&amp;gt;&lt;br /&gt;
[[File:squareCavityAnimationNN_n07.mp4|thumb|center|upright=2|&lt;br /&gt;
&amp;lt;caption&amp;gt;Animation of velocity and temperature fields within the cavity between $t=10$ and $t=11$ for $n=0.7$.&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Non-Newtonian_fluid&amp;diff=3105</id>
		<title>Non-Newtonian fluid</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Non-Newtonian_fluid&amp;diff=3105"/>
				<updated>2020-10-12T18:13:54Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Added &amp;lt;caption&amp;gt; tags to figure captions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Click here to return back to [[Fluid Mechanics]]&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
Other fluid mechanics examples have assumed that the fluids in question are Newtonian, but that is not always the case when dealing with real world applications. Many significant fluids exhibit non-Newtonian behaviour with examples including blood, foodstuffs, polymer melts... Newtonian fluids have a linear relationship between viscous stress and shear rate but that is no longer true for non-Newtonian fluids.&lt;br /&gt;
&lt;br /&gt;
Some fluids exhibit increasing or decreasing viscosity with increasing shear rate which is the simplest form of non-Newtonian behaviour that we will tackle in the following sections. Some act as solids at small stress but begin flowing when sufficiently disturbed, while others behaviour depends on the duration of movement and applied stress.&lt;br /&gt;
&lt;br /&gt;
=Model formulation=&lt;br /&gt;
Viscous forces are a result of velocity differentials within the fluid and are therefore connected with the velocity gradient. We are interested in the symmetric part that excludes the rotational contributions. Shear rate tensor $\dot{u}$ for incompressible fluids can be expressed as &lt;br /&gt;
$$&lt;br /&gt;
\dot{u}=\frac{1}{2}\left(\boldsymbol{\nabla} \boldsymbol{v}+(\boldsymbol{\nabla} \boldsymbol{v})^{\top}\right),&lt;br /&gt;
$$&lt;br /&gt;
where $\boldsymbol{v}$ denotes the fluid velocity. We introduce viscosity $\mu$ through a generalized Newton's law of viscosity with viscous stress tensor $\tau$ expressed as&lt;br /&gt;
$$&lt;br /&gt;
\tau = \mu \dot{u}.&lt;br /&gt;
$$&lt;br /&gt;
In general $\mu$ is an arbitrary tensor but usually reduces to a scalar value due to isotropic properties of fluids. Non-Newtonian fluids are fluids where viscosity is a function of shear stress and duration of stress. There are many, often quantitative, models of varying complexities used to describe the viscosity of various non-Newtonian fluids.&lt;br /&gt;
&lt;br /&gt;
We limit ourselves to Ostwald-de Waele power law model&lt;br /&gt;
$$&lt;br /&gt;
\mu = \mu_0 \left\| \dot{u} \right\| ^{n-1} = \mu_0 \left( 2 \dot{u}{:}\dot{u} \right) ^\frac{n-1}{2},&lt;br /&gt;
$$&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:devahl_scheme&amp;quot;&amp;gt;&lt;br /&gt;
[[File:image.png|thumb|&amp;lt;caption&amp;gt;Scheme of the de Vahl Davis benchmark test.&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is one of the simplest non-Newtonian viscosity models. We introduced two parameters used to fit the model to the experimental data for the fluid in question. Viscosity constant $\mu_0$ used as a scaling factor and non-Newtonian power index $n$ that describes the behaviour. Model with $n &amp;lt; 1$ describes shear-thinning (pseudoplastic), $n = 1$ Newtonian and $n &amp;gt; 1$ shear thickening (dilatant) fluids.&lt;br /&gt;
&lt;br /&gt;
We will focus on shear thinning fluids as their behaviour of reduced viscosity at higher velocity gradients leads towards interesting behaviour with decreasing $n$.&lt;br /&gt;
&lt;br /&gt;
=de Vahl Davis example=&lt;br /&gt;
We take a closer look at the behaviour of non-Newtonian fluid in a natural convection driven flow within a square cavity. The convection is driven by differentially heated east and west walls with the north and south walls thermally insulated as is schematically shown in &amp;lt;xr id=&amp;quot;fig:devahl_scheme&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This is a common benchmark with existing solutions that we can benchmark our meshless implementation against. Convergence and comparison with benchmark article is shown in &amp;lt;xr id=&amp;quot;fig:nonNewtonianConvergence&amp;quot;/&amp;gt; where we plot the changes of average Nusselt number with increasing node density. Nusselt number is a dimensionless number that expresses the ratio between convective and conductive heat transfer. We use the average value on the western wall and define it as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:nonNewtonianConvergence&amp;quot;&amp;gt;&lt;br /&gt;
[[File:nonNewtonianConvergence.png|thumb|left|700px|&lt;br /&gt;
&amp;lt;caption&amp;gt;Convergence&amp;lt;/caption&amp;gt; of average Nusselt number value with increasing node count and comparison with reference values from reference&amp;lt;ref name=&amp;quot;Turan2011&amp;quot;&amp;gt;O. Turan, A. Sachdeva, N. Chakraborty in R. J. Poole, Laminar natural convection of power-law Fluids in a square enclosure with differentially heated side walls subjected to constant temperatures, Journal of Non-Newtonian Fluid Mechanics 166, 1049 (2011).&amp;lt;/ref&amp;gt;. Convergence is calculated at Ra$=10^4$ and Pr$=10$.]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$$&lt;br /&gt;
\mathrm{Nu}=\frac{\Omega_W}{T_{H}-T_{C}}\left|\frac{\partial T}{\partial p_x}\right|_{p_x=0},&lt;br /&gt;
$$&lt;br /&gt;
where $T$ denotest the demperature, $p_x$ $x$ coordinate and $\Omega_W$ cavity width. Nusselt number is a convenient tool that can be used to reduce the dynamics of a complex multidimensional system into a single scalar value. &lt;br /&gt;
&lt;br /&gt;
We define the problem in terms of Rayleigh and Prandtl dimensionless numbers that need to be slightly modified to remain relevant in non-Newtonian case but specifics are not really relevant for this review. Dimensionless number definitions used in these calculations match reference&amp;lt;ref name=&amp;quot;Turan2011&amp;quot;&amp;gt;O. Turan, A. Sachdeva, N. Chakraborty in R. J. Poole, Laminar natural convection of power-law Fluids in a square enclosure with differentially heated side walls subjected to constant temperatures, Journal of Non-Newtonian Fluid Mechanics 166, 1049 (2011).&amp;lt;/ref&amp;gt; and can be viewed there.&lt;br /&gt;
&lt;br /&gt;
Parameters that lead to oscillatory behaviour in de Vahl Davis cavity can be found in literature&amp;lt;ref name=&amp;quot;Kosec2011&amp;quot;&amp;gt;G. Kosec in 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 23, 22 (2013).&amp;lt;/ref&amp;gt;. Referenced article found oscillatory behaviour in Newtonian fluids at Ra=$5 \cdot 10^4$ and Pr=$0.01$ but we want to start slightly lower to find the transition as the dynamics become wilder with smaller $n$. We chose Ra=$2 \cdot 10^4$ and Pr=$0.01$ as the parameters to be used for all subsequently displayed calculations.&lt;br /&gt;
&lt;br /&gt;
The following figures display or mention dimensionless time that is defined with the same definition as described in reference&amp;lt;ref name=&amp;quot;Kosec2011&amp;quot;&amp;gt;G. Kosec in 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 23, 22 (2013).&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:nusseltEvolutionNN&amp;quot;&amp;gt;&lt;br /&gt;
[[File:nusseltEvolutionNN.png|thumb|left|700px|&lt;br /&gt;
&amp;lt;caption&amp;gt;Evolution of average Nusselt number in a differentially heated square cavity for different values of non-Newtonian power index $n$.&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We reuse the Nusselt number to analyse the differences in behaviour for different non-Newtonian power indices $n$ shown in &amp;lt;xr id=&amp;quot;fig:nusseltEvolutionNN&amp;quot;/&amp;gt;. The Newtonian case with $n=1$ settles into a stationary case which is expected, as we chose parameters below the previously identified oscillatory solution. Evolutions of Nusselt number become oscillatory as we increase the strenght of non-Newtonian behaviour while the solutions become less and less regular as we reduce the power index $n$ which can be seen in pictures of velocity and temperature distributions shown in &amp;lt;xr id=&amp;quot;fig:squareCavityDisplay&amp;quot;/&amp;gt;. Detailed animation of behaviour in the most extreme $n=0.7$ case is shown in &amp;lt;xr id=&amp;quot;fig:animation&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Exact implementation of non-Newtonian fluid modeled with Ostwald-de Waele power law can be found in example. &lt;br /&gt;
TODO: link to example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:squareCavityDisplay&amp;quot;&amp;gt;&lt;br /&gt;
[[File:squareCavity_t10_Ra20000Pr001.png|frame|center|&lt;br /&gt;
&amp;lt;caption&amp;gt;Velocity and temperature fields within the cavity at $t=10$ for different values of non-Newtonian power index $n$.&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:animation&amp;quot;&amp;gt;&lt;br /&gt;
[[File:squareCavityAnimationNN_n07.mp4|thumb|center|upright=2|&lt;br /&gt;
&amp;lt;caption&amp;gt;Animation of velocity and temperature fields within the cavity between $t=10$ and $t=11$ for $n=0.7$.&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=3104</id>
		<title>Cahn-Hilliard equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=3104"/>
				<updated>2020-10-12T18:08:24Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Go back to [[Medusa#Examples|Examples]].&lt;br /&gt;
&lt;br /&gt;
In this example we will show how to solve the [https://en.wikipedia.org/wiki/Cahn%E2%80%93Hilliard_equation Cahn-Hilliard] equation in Medusa. The solution provides an implementation of periodic boundary conditions and shows how to combine implicit and explicit operators. This example uses a custom biharmonic operator, so we recommend firstly reading the tutorial on [[Customization]].&lt;br /&gt;
&lt;br /&gt;
== Cahn-Hilliard equation ==&lt;br /&gt;
The Cahn-Hilliard equation describes the separation of binary fluid into pure domains. We define concentration, a scalar field $c(x, y) \in [-1, 1]$ to describe the fluid, with values $c \pm 1$ representing pure phases. In this case the equation can be written as&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\frac{\partial c}{\partial t} = D \nabla^2 (c^3 - c - \gamma \nabla^2 c),&lt;br /&gt;
\]&lt;br /&gt;
where $D$ is the diffusion constant and $\sqrt{\gamma}$ is the characteristic transition length between domains.&lt;br /&gt;
&lt;br /&gt;
We want to avoid any boundary effects and solve the equation for infinite fluid which can be approximated by using periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Periodic boundary conditions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:periodicBands&amp;quot;&amp;gt;&lt;br /&gt;
[[File:PeriodicBands.png|thumb|upright=2|&amp;lt;caption&amp;gt;Periodic band display.&lt;br /&gt;
&lt;br /&gt;
Left subplot shows an example of filled domain with $border = 10$ and $dx = 0.2$. Interior nodes and their periodic counterparts share colors to illustrate periodicity.&lt;br /&gt;
&lt;br /&gt;
Right subplot shows the neighbourhood of bottom left corner node $(-border, -border)$, with its support nodes highlighted in red. This example uses same fill parameters as the left figure and a support size of 100. &lt;br /&gt;
&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The simplest method of implementing a periodic boundary is adding a band of periodic nodes that mirror values from nodes that lie close to the opposite boundary. We have to create periodic nodes based on locations of interior nodes and construct a mapping that will allow us to update their values based on their interior counterparts. Width of the periodic band should be chosen with support size in mind. Periodic band should be wide enough to include all nodes required to calculate interior values. An example that can help us determine the required width of the periodic band is shown on the right subplot of &amp;lt;xr id=&amp;quot;fig:periodicBands&amp;quot;/&amp;gt; and shows that we need a periodic band width of $6 dx$ for a support size of 100.&lt;br /&gt;
&lt;br /&gt;
We start by creating a square domain centered on 0 and uniformly filling it with nodes. $border$ parameter determines the square size while $dx$, the typical distance between nodes, determines the node density.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
mm::BoxShape&amp;lt;vec_t&amp;gt; box(-border, border);&lt;br /&gt;
mm::DomainDiscretization&amp;lt;vec_t&amp;gt; domain = box.discretizeBoundaryWithStep(dx);&lt;br /&gt;
mm::GeneralFill&amp;lt;vec_t&amp;gt; fill;&lt;br /&gt;
fill.seed(randomSeed);&lt;br /&gt;
domain.fill(fill, dx);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Afterwards we remove boundary nodes at positive $border$ and move others into interior. This creates a $[-border, border) \times [-border, border)$ interior that can be made periodic.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Eigen::Matrix2d borders;  // col1: - border, col2: + border, rows for dimensions&lt;br /&gt;
borders &amp;lt;&amp;lt; domain.shape().bbox().first, domain.shape().bbox().second;&lt;br /&gt;
for (auto idx : domain.boundary()) {&lt;br /&gt;
    const auto&amp;amp; pos = domain.pos(idx);&lt;br /&gt;
    if (pos[0] != borders(0, 1) &amp;amp;&amp;amp; pos[1] != borders(1, 1)) {&lt;br /&gt;
        domain.changeToInterior(idx, pos, 1);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
domain.removeBoundaryNodes();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we are ready to find all nodes that lie sufficiently close to the border and create their periodic counterparts. In general rectangle case we would need to check all dimesions and create periodic nodes in all subsets of dimensions where that node lies close to the border. In this 2D case that simplifies to checking whether node lies close to the border in $x$, $y$ or both, which would mean a periodic corner. We could simplify our code and ignore the small periodic corners but that would lead to slightly worse results.&lt;br /&gt;
&lt;br /&gt;
Periodic boundary nodes are created with type -2 so that we can still differentiate between them and any legitimate boundary nodes we would have in case of mixing periodic and normal boundary conditions. Boundary normal can be chosen arbitrarily, periodic nodes are only used as value holders.&lt;br /&gt;
&lt;br /&gt;
During this process we also store periodic node indices in $periodicNodes$ and indices of the original nodes in $interiorMapping$.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
mm::Range&amp;lt;int&amp;gt; periodicNodes;&lt;br /&gt;
mm::Range&amp;lt;int&amp;gt; interiorMapping;&lt;br /&gt;
mm::Vec2d normal(0, 0);  // not used in this case and can be chosen arbitrarily&lt;br /&gt;
for (auto idx : domain.interior()) {&lt;br /&gt;
    const auto&amp;amp; pos = domain.pos(idx);&lt;br /&gt;
    // col1: distance to - border, col2: distance to + border, rows represent dimensions&lt;br /&gt;
    auto borderDistance = borders.colwise() - pos;&lt;br /&gt;
    const auto&amp;amp; isPeriodic = borderDistance.array().abs() &amp;lt; periodicBandWidth * dx;&lt;br /&gt;
    for (int i0 = 0; i0 &amp;lt; 2; i0++) {&lt;br /&gt;
        // check for periodicity in 1st dimension (x)&lt;br /&gt;
        if (isPeriodic(0, i0)) {&lt;br /&gt;
            auto periodicPos = pos;&lt;br /&gt;
            periodicPos(0) = borders(0, (i0 + 1) % 2) - borderDistance(0, i0);&lt;br /&gt;
            periodicNodes.push_back(domain.addBoundaryNode(periodicPos, -2, normal));&lt;br /&gt;
            interiorMapping.push_back(idx);&lt;br /&gt;
        }&lt;br /&gt;
        for (int i1 = 0; i1 &amp;lt; 2; i1++) {&lt;br /&gt;
            // check for periodicity in 2nd dimension (y)&lt;br /&gt;
            if (i0 == 0 &amp;amp;&amp;amp; isPeriodic(1, i1)) {&lt;br /&gt;
                auto periodicPos = pos;&lt;br /&gt;
                periodicPos(1) = borders(1, (i1 + 1) % 2) - borderDistance(1, i1);&lt;br /&gt;
                periodicNodes.push_back(domain.addBoundaryNode(periodicPos, -2, normal));&lt;br /&gt;
                interiorMapping.push_back(idx);&lt;br /&gt;
            }&lt;br /&gt;
            // check for periodicity in both dimensions (corners)&lt;br /&gt;
            if (isPeriodic(0, i0) &amp;amp;&amp;amp; isPeriodic(1, i1)) {&lt;br /&gt;
                auto periodicPos = pos;&lt;br /&gt;
                periodicPos(0) = borders(0, (i0 + 1) % 2) - borderDistance(0, i0);&lt;br /&gt;
                periodicPos(1) = borders(1, (i1 + 1) % 2) - borderDistance(1, i1);&lt;br /&gt;
                periodicNodes.push_back(domain.addBoundaryNode(periodicPos, -2, normal));&lt;br /&gt;
                interiorMapping.push_back(idx);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:timeEvolution&amp;quot;&amp;gt;&lt;br /&gt;
[[File:TimeEvolution.mp4|thumb|upright=2|&amp;lt;caption&amp;gt;Time evolution of the concentration. Initially mixed fluid separates into domains that grow with time.&lt;br /&gt;
&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
We need to handle two uncommon terms to solve the equation. Biharmonic ($\nabla^4$) operator can be implemented with custom operators as shown in [[Customization]] example. Nonlinear ($\nabla^2 c^3$) term proves to be more problematic, as it can not be solved implicitly. We either need to solve the entire equation with explicit time stepping or include the nonlinear term in the right hand side of our system of equations.&lt;br /&gt;
&lt;br /&gt;
Initial concentration is random. &lt;br /&gt;
&lt;br /&gt;
=== Explicit solution ===&lt;br /&gt;
Explicit solution is simpler to implement and faster when we want to solve the equation for very small time steps.&lt;br /&gt;
&lt;br /&gt;
We use Euler method for time stepping and copy interior node values to their periodic counterparts at every step.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
double t = 0;&lt;br /&gt;
Eigen::VectorXd bracket;&lt;br /&gt;
while (t &amp;lt;= tEnd) {&lt;br /&gt;
    bracket = concentration.array() * concentration.array() * concentration.array() - concentration.array();&lt;br /&gt;
    for (int i : allNodes) {&lt;br /&gt;
        bracket[i] -= L * expOp.lap(concentration, i);&lt;br /&gt;
    }&lt;br /&gt;
    for (int i : interiorNodes) {&lt;br /&gt;
        concentration[i] = concentration[i] + dt * D * expOp.lap(bracket, i);&lt;br /&gt;
    }&lt;br /&gt;
    t += dt;&lt;br /&gt;
&lt;br /&gt;
    for (int i = 0; i &amp;lt; periodicSize; i++) {&lt;br /&gt;
        concentration[periodicNodes[i]] = concentration[interiorMapping[i]];&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:timeEvolutionStatic&amp;quot;&amp;gt;&lt;br /&gt;
[[File:cahnHilliardTimeEvolution.png|thumb|upright=1.5|&amp;lt;caption&amp;gt;Time evolution of the concentration. Initially mixed fluid separates into domains that grow with time.&lt;br /&gt;
&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mixed solution ===&lt;br /&gt;
Mixed solution allows for much longer (several orders) time steps as we solve the majority of our equation implicitly. Explicit computation of the nonlinear term will always lead to inaccuracies, especially for long $dt$.&lt;br /&gt;
&lt;br /&gt;
We set the equation on interior and identities on boundary. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
for (int i : interiorNodes) {&lt;br /&gt;
    impOp.value(i) + D * dt * impOp.lap(i) + D * dt * L * impOp.apply&amp;lt;Biharmonic&amp;lt;dim&amp;gt;&amp;gt;(i) = rhs[i];&lt;br /&gt;
}&lt;br /&gt;
for (int i = 0; i &amp;lt; periodicSize; i++) {&lt;br /&gt;
    impOp.value(periodicNodes[i]) = rhs[interiorMapping[i]];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Eigen::SparseLU&amp;lt;decltype(M)&amp;gt; solver;&lt;br /&gt;
solver.compute(M);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have to explicitly compute nonlinear $\nabla^2 c^3$ term at every step and add it to the rhs. Once we solve the system for new concentration we have to copy interior node values to their periodic counterparts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/// Time stepping.&lt;br /&gt;
double t = 0;&lt;br /&gt;
Eigen::VectorXd cubedConcentration;&lt;br /&gt;
while (t &amp;lt;= tEnd) {&lt;br /&gt;
    /// Prepare rhs.&lt;br /&gt;
    cubedConcentration = concentration.array() * concentration.array() * concentration.array();&lt;br /&gt;
    for (int i : allNodes) {&lt;br /&gt;
        concentration[i] = D * dt * expOp.lap(cubedConcentration, i) + concentration[i];&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    concentration = solver.solve(concentration);&lt;br /&gt;
    t += dt;&lt;br /&gt;
&lt;br /&gt;
    /// Copy values from interior nodes to their periodic representations.&lt;br /&gt;
    for (int i = 0; i &amp;lt; periodicSize; i++) {&lt;br /&gt;
        concentration[periodicNodes[i]] = concentration[interiorMapping[i]];&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The complete example is avalible on [https://gitlab.com/e62Lab/medusa/blob/dev/examples/cahnHilliard_equation git].&lt;br /&gt;
&lt;br /&gt;
Go back to [[Medusa#Examples|Examples]].&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=File:CahnHilliardTimeEvolution.png&amp;diff=3103</id>
		<title>File:CahnHilliardTimeEvolution.png</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=File:CahnHilliardTimeEvolution.png&amp;diff=3103"/>
				<updated>2020-10-12T18:01:40Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Example visualization of concentration evolution for Cahn-Hilliard equation.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Example visualization of concentration evolution for Cahn-Hilliard equation.&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Non-Newtonian_fluid&amp;diff=3102</id>
		<title>Non-Newtonian fluid</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Non-Newtonian_fluid&amp;diff=3102"/>
				<updated>2020-10-08T19:42:27Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Animation display fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Click here to return back to [[Fluid Mechanics]]&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
Other fluid mechanics examples have assumed that the fluids in question are Newtonian, but that is not always the case when dealing with real world applications. Many significant fluids exhibit non-Newtonian behaviour with examples including blood, foodstuffs, polymer melts... Newtonian fluids have a linear relationship between viscous stress and shear rate but that is no longer true for non-Newtonian fluids.&lt;br /&gt;
&lt;br /&gt;
Some fluids exhibit increasing or decreasing viscosity with increasing shear rate which is the simplest form of non-Newtonian behaviour that we will tackle in the following sections. Some act as solids at small stress but begin flowing when sufficiently disturbed, while others behaviour depends on the duration of movement and applied stress.&lt;br /&gt;
&lt;br /&gt;
=Model formulation=&lt;br /&gt;
Viscous forces are a result of velocity differentials within the fluid and are therefore connected with the velocity gradient. We are interested in the symmetric part that excludes the rotational contributions. Shear rate tensor $\dot{u}$ for incompressible fluids can be expressed as &lt;br /&gt;
$$&lt;br /&gt;
\dot{u}=\frac{1}{2}\left(\boldsymbol{\nabla} \boldsymbol{v}+(\boldsymbol{\nabla} \boldsymbol{v})^{\top}\right),&lt;br /&gt;
$$&lt;br /&gt;
where $\boldsymbol{v}$ denotes the fluid velocity. We introduce viscosity $\mu$ through a generalized Newton's law of viscosity with viscous stress tensor $\tau$ expressed as&lt;br /&gt;
$$&lt;br /&gt;
\tau = \mu \dot{u}.&lt;br /&gt;
$$&lt;br /&gt;
In general $\mu$ is an arbitrary tensor but usually reduces to a scalar value due to isotropic properties of fluids. Non-Newtonian fluids are fluids where viscosity is a function of shear stress and duration of stress. There are many, often quantitative, models of varying complexities used to describe the viscosity of various non-Newtonian fluids.&lt;br /&gt;
&lt;br /&gt;
We limit ourselves to Ostwald-de Waele power law model&lt;br /&gt;
$$&lt;br /&gt;
\mu = \mu_0 \left\| \dot{u} \right\| ^{n-1} = \mu_0 \left( 2 \dot{u}{:}\dot{u} \right) ^\frac{n-1}{2},&lt;br /&gt;
$$&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:devahl_scheme&amp;quot;&amp;gt;&lt;br /&gt;
[[File:image.png|thumb|Scheme of the de Vahl Davis benchmark test.]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is one of the simplest non-Newtonian viscosity models. We introduced two parameters used to fit the model to the experimental data for the fluid in question. Viscosity constant $\mu_0$ used as a scaling factor and non-Newtonian power index $n$ that describes the behaviour. Model with $n &amp;lt; 1$ describes shear-thinning (pseudoplastic), $n = 1$ Newtonian and $n &amp;gt; 1$ shear thickening (dilatant) fluids.&lt;br /&gt;
&lt;br /&gt;
We will focus on shear thinning fluids as their behaviour of reduced viscosity at higher velocity gradients leads towards interesting behaviour with decreasing $n$.&lt;br /&gt;
&lt;br /&gt;
=de Vahl Davis example=&lt;br /&gt;
We take a closer look at the behaviour of non-Newtonian fluid in a natural convection driven flow within a square cavity. The convection is driven by differentially heated east and west walls with the north and south walls thermally insulated as is schematically shown in &amp;lt;xr id=&amp;quot;fig:devahl_scheme&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This is a common benchmark with existing solutions that we can benchmark our meshless implementation against. Convergence and comparison with benchmark article is shown in &amp;lt;xr id=&amp;quot;fig:nonNewtonianConvergence&amp;quot;/&amp;gt; where we plot the changes of average Nusselt number with increasing node density. Nusselt number is a dimensionless number that expresses the ratio between convective and conductive heat transfer. We use the average value on the western wall and define it as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:nonNewtonianConvergence&amp;quot;&amp;gt;&lt;br /&gt;
[[File:nonNewtonianConvergence.png|thumb|left|700px|&lt;br /&gt;
Convergence of average Nusselt number value with increasing node count and comparison with reference values from reference&amp;lt;ref name=&amp;quot;Turan2011&amp;quot;&amp;gt;O. Turan, A. Sachdeva, N. Chakraborty in R. J. Poole, Laminar natural convection of power-law Fluids in a square enclosure with differentially heated side walls subjected to constant temperatures, Journal of Non-Newtonian Fluid Mechanics 166, 1049 (2011).&amp;lt;/ref&amp;gt;. Convergence is calculated at Ra$=10^4$ and Pr$=10$.]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$$&lt;br /&gt;
\mathrm{Nu}=\frac{\Omega_W}{T_{H}-T_{C}}\left|\frac{\partial T}{\partial p_x}\right|_{p_x=0},&lt;br /&gt;
$$&lt;br /&gt;
where $T$ denotest the demperature, $p_x$ $x$ coordinate and $\Omega_W$ cavity width. Nusselt number is a convenient tool that can be used to reduce the dynamics of a complex multidimensional system into a single scalar value. &lt;br /&gt;
&lt;br /&gt;
We define the problem in terms of Rayleigh and Prandtl dimensionless numbers that need to be slightly modified to remain relevant in non-Newtonian case but specifics are not really relevant for this review. Dimensionless number definitions used in these calculations match reference&amp;lt;ref name=&amp;quot;Turan2011&amp;quot;&amp;gt;O. Turan, A. Sachdeva, N. Chakraborty in R. J. Poole, Laminar natural convection of power-law Fluids in a square enclosure with differentially heated side walls subjected to constant temperatures, Journal of Non-Newtonian Fluid Mechanics 166, 1049 (2011).&amp;lt;/ref&amp;gt; and can be viewed there.&lt;br /&gt;
&lt;br /&gt;
Parameters that lead to oscillatory behaviour in de Vahl Davis cavity can be found in literature&amp;lt;ref name=&amp;quot;Kosec2011&amp;quot;&amp;gt;G. Kosec in 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 23, 22 (2013).&amp;lt;/ref&amp;gt;. Referenced article found oscillatory behaviour in Newtonian fluids at Ra=$5 \cdot 10^4$ and Pr=$0.01$ but we want to start slightly lower to find the transition as the dynamics become wilder with smaller $n$. We chose Ra=$2 \cdot 10^4$ and Pr=$0.01$ as the parameters to be used for all subsequently displayed calculations.&lt;br /&gt;
&lt;br /&gt;
The following figures display or mention dimensionless time that is defined with the same definition as described in reference&amp;lt;ref name=&amp;quot;Kosec2011&amp;quot;&amp;gt;G. Kosec in 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 23, 22 (2013).&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:nusseltEvolutionNN&amp;quot;&amp;gt;&lt;br /&gt;
[[File:nusseltEvolutionNN.png|thumb|left|700px|&lt;br /&gt;
Evolution of average Nusselt number in a differentially heated square cavity for different values of non-Newtonian power index $n$.]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We reuse the Nusselt number to analyse the differences in behaviour for different non-Newtonian power indices $n$ shown in &amp;lt;xr id=&amp;quot;fig:nusseltEvolutionNN&amp;quot;/&amp;gt;. The Newtonian case with $n=1$ settles into a stationary case which is expected, as we chose parameters below the previously identified oscillatory solution. Evolutions of Nusselt number become oscillatory as we increase the strenght of non-Newtonian behaviour while the solutions become less and less regular as we reduce the power index $n$ which can be seen in pictures of velocity and temperature distributions shown in &amp;lt;xr id=&amp;quot;fig:squareCavityDisplay&amp;quot;/&amp;gt;. Detailed animation of behaviour in the most extreme $n=0.7$ case is shown in &amp;lt;xr id=&amp;quot;fig:animation&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Exact implementation of non-Newtonian fluid modeled with Ostwald-de Waele power law can be found in example. &lt;br /&gt;
TODO: link to example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:squareCavityDisplay&amp;quot;&amp;gt;&lt;br /&gt;
[[File:squareCavity_t10_Ra20000Pr001.png|frame|center|&lt;br /&gt;
Velocity and temperature fields within the cavity at $t=10$ for different values of non-Newtonian power index $n$.]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:animation&amp;quot;&amp;gt;&lt;br /&gt;
[[File:squareCavityAnimationNN_n07.mp4|thumb|center|upright=2|&lt;br /&gt;
Animation of velocity and temperature fields within the cavity between $t=10$ and $t=11$ for $n=0.7$.]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Non-Newtonian_fluid&amp;diff=3101</id>
		<title>Non-Newtonian fluid</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Non-Newtonian_fluid&amp;diff=3101"/>
				<updated>2020-10-08T19:37:35Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Initial version&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Click here to return back to [[Fluid Mechanics]]&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
Other fluid mechanics examples have assumed that the fluids in question are Newtonian, but that is not always the case when dealing with real world applications. Many significant fluids exhibit non-Newtonian behaviour with examples including blood, foodstuffs, polymer melts... Newtonian fluids have a linear relationship between viscous stress and shear rate but that is no longer true for non-Newtonian fluids.&lt;br /&gt;
&lt;br /&gt;
Some fluids exhibit increasing or decreasing viscosity with increasing shear rate which is the simplest form of non-Newtonian behaviour that we will tackle in the following sections. Some act as solids at small stress but begin flowing when sufficiently disturbed, while others behaviour depends on the duration of movement and applied stress.&lt;br /&gt;
&lt;br /&gt;
=Model formulation=&lt;br /&gt;
Viscous forces are a result of velocity differentials within the fluid and are therefore connected with the velocity gradient. We are interested in the symmetric part that excludes the rotational contributions. Shear rate tensor $\dot{u}$ for incompressible fluids can be expressed as &lt;br /&gt;
$$&lt;br /&gt;
\dot{u}=\frac{1}{2}\left(\boldsymbol{\nabla} \boldsymbol{v}+(\boldsymbol{\nabla} \boldsymbol{v})^{\top}\right),&lt;br /&gt;
$$&lt;br /&gt;
where $\boldsymbol{v}$ denotes the fluid velocity. We introduce viscosity $\mu$ through a generalized Newton's law of viscosity with viscous stress tensor $\tau$ expressed as&lt;br /&gt;
$$&lt;br /&gt;
\tau = \mu \dot{u}.&lt;br /&gt;
$$&lt;br /&gt;
In general $\mu$ is an arbitrary tensor but usually reduces to a scalar value due to isotropic properties of fluids. Non-Newtonian fluids are fluids where viscosity is a function of shear stress and duration of stress. There are many, often quantitative, models of varying complexities used to describe the viscosity of various non-Newtonian fluids.&lt;br /&gt;
&lt;br /&gt;
We limit ourselves to Ostwald-de Waele power law model&lt;br /&gt;
$$&lt;br /&gt;
\mu = \mu_0 \left\| \dot{u} \right\| ^{n-1} = \mu_0 \left( 2 \dot{u}{:}\dot{u} \right) ^\frac{n-1}{2},&lt;br /&gt;
$$&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:devahl_scheme&amp;quot;&amp;gt;&lt;br /&gt;
[[File:image.png|thumb|Scheme of the de Vahl Davis benchmark test.]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is one of the simplest non-Newtonian viscosity models. We introduced two parameters used to fit the model to the experimental data for the fluid in question. Viscosity constant $\mu_0$ used as a scaling factor and non-Newtonian power index $n$ that describes the behaviour. Model with $n &amp;lt; 1$ describes shear-thinning (pseudoplastic), $n = 1$ Newtonian and $n &amp;gt; 1$ shear thickening (dilatant) fluids.&lt;br /&gt;
&lt;br /&gt;
We will focus on shear thinning fluids as their behaviour of reduced viscosity at higher velocity gradients leads towards interesting behaviour with decreasing $n$.&lt;br /&gt;
&lt;br /&gt;
=de Vahl Davis example=&lt;br /&gt;
We take a closer look at the behaviour of non-Newtonian fluid in a natural convection driven flow within a square cavity. The convection is driven by differentially heated east and west walls with the north and south walls thermally insulated as is schematically shown in &amp;lt;xr id=&amp;quot;fig:devahl_scheme&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This is a common benchmark with existing solutions that we can benchmark our meshless implementation against. Convergence and comparison with benchmark article is shown in &amp;lt;xr id=&amp;quot;fig:nonNewtonianConvergence&amp;quot;/&amp;gt; where we plot the changes of average Nusselt number with increasing node density. Nusselt number is a dimensionless number that expresses the ratio between convective and conductive heat transfer. We use the average value on the western wall and define it as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:nonNewtonianConvergence&amp;quot;&amp;gt;&lt;br /&gt;
[[File:nonNewtonianConvergence.png|thumb|left|700px|&lt;br /&gt;
Convergence of average Nusselt number value with increasing node count and comparison with reference values from reference&amp;lt;ref name=&amp;quot;Turan2011&amp;quot;&amp;gt;O. Turan, A. Sachdeva, N. Chakraborty in R. J. Poole, Laminar natural convection of power-law Fluids in a square enclosure with differentially heated side walls subjected to constant temperatures, Journal of Non-Newtonian Fluid Mechanics 166, 1049 (2011).&amp;lt;/ref&amp;gt;. Convergence is calculated at Ra$=10^4$ and Pr$=10$.]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$$&lt;br /&gt;
\mathrm{Nu}=\frac{\Omega_W}{T_{H}-T_{C}}\left|\frac{\partial T}{\partial p_x}\right|_{p_x=0},&lt;br /&gt;
$$&lt;br /&gt;
where $T$ denotest the demperature, $p_x$ $x$ coordinate and $\Omega_W$ cavity width. Nusselt number is a convenient tool that can be used to reduce the dynamics of a complex multidimensional system into a single scalar value. &lt;br /&gt;
&lt;br /&gt;
We define the problem in terms of Rayleigh and Prandtl dimensionless numbers that need to be slightly modified to remain relevant in non-Newtonian case but specifics are not really relevant for this review. Dimensionless number definitions used in these calculations match reference&amp;lt;ref name=&amp;quot;Turan2011&amp;quot;&amp;gt;O. Turan, A. Sachdeva, N. Chakraborty in R. J. Poole, Laminar natural convection of power-law Fluids in a square enclosure with differentially heated side walls subjected to constant temperatures, Journal of Non-Newtonian Fluid Mechanics 166, 1049 (2011).&amp;lt;/ref&amp;gt; and can be viewed there.&lt;br /&gt;
&lt;br /&gt;
Parameters that lead to oscillatory behaviour in de Vahl Davis cavity can be found in literature&amp;lt;ref name=&amp;quot;Kosec2011&amp;quot;&amp;gt;G. Kosec in 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 23, 22 (2013).&amp;lt;/ref&amp;gt;. Referenced article found oscillatory behaviour in Newtonian fluids at Ra=$5 \cdot 10^4$ and Pr=$0.01$ but we want to start slightly lower to find the transition as the dynamics become wilder with smaller $n$. We chose Ra=$2 \cdot 10^4$ and Pr=$0.01$ as the parameters to be used for all subsequently displayed calculations.&lt;br /&gt;
&lt;br /&gt;
The following figures display or mention dimensionless time that is defined with the same definition as described in reference&amp;lt;ref name=&amp;quot;Kosec2011&amp;quot;&amp;gt;G. Kosec in 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 23, 22 (2013).&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:nusseltEvolutionNN&amp;quot;&amp;gt;&lt;br /&gt;
[[File:nusseltEvolutionNN.png|thumb|left|700px|&lt;br /&gt;
Evolution of average Nusselt number in a differentially heated square cavity for different values of non-Newtonian power index $n$.]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We reuse the Nusselt number to analyse the differences in behaviour for different non-Newtonian power indices $n$ shown in &amp;lt;xr id=&amp;quot;fig:nusseltEvolutionNN&amp;quot;/&amp;gt;. The Newtonian case with $n=1$ settles into a stationary case which is expected, as we chose parameters below the previously identified oscillatory solution. Evolutions of Nusselt number become oscillatory as we increase the strenght of non-Newtonian behaviour while the solutions become less and less regular as we reduce the power index $n$ which can be seen in pictures of velocity and temperature distributions shown in &amp;lt;xr id=&amp;quot;fig:squareCavityDisplay&amp;quot;/&amp;gt;. Detailed animation of behaviour in the most extreme $n=0.7$ case is shown in &amp;lt;xr id=&amp;quot;fig:animation&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Exact implementation of non-Newtonian fluid modeled with Ostwald-de Waele power law can be found in example. &lt;br /&gt;
TODO: link to example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:squareCavityDisplay&amp;quot;&amp;gt;&lt;br /&gt;
[[File:squareCavity_t10_Ra20000Pr001.png|frame|center|&lt;br /&gt;
Velocity and temperature fields within the cavity at $t=10$ for different values of non-Newtonian power index $n$.]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:animation&amp;quot;&amp;gt;&lt;br /&gt;
[[File:squareCavityAnimationNN_n07.mp4|frame|center|&lt;br /&gt;
Animation of velocity and temperature fields within the cavity between $t=10$ and $t=11$ for $n=0.7$.]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=File:SquareCavityAnimationNN_n07.mp4&amp;diff=3100</id>
		<title>File:SquareCavityAnimationNN n07.mp4</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=File:SquareCavityAnimationNN_n07.mp4&amp;diff=3100"/>
				<updated>2020-10-08T19:34:35Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Animation of velocity and temperature fields within the cavity between $t=10$ and $t=11$ for $n=0.7$.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Animation of velocity and temperature fields within the cavity between $t=10$ and $t=11$ for $n=0.7$.&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=File:SquareCavity_t10_Ra20000Pr001.png&amp;diff=3099</id>
		<title>File:SquareCavity t10 Ra20000Pr001.png</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=File:SquareCavity_t10_Ra20000Pr001.png&amp;diff=3099"/>
				<updated>2020-10-08T18:43:24Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Velocity magnitude and temperature within the cavity for different values of non-Newtonian power index $n$.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Velocity magnitude and temperature within the cavity for different values of non-Newtonian power index $n$.&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=File:NusseltEvolutionNN.png&amp;diff=3098</id>
		<title>File:NusseltEvolutionNN.png</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=File:NusseltEvolutionNN.png&amp;diff=3098"/>
				<updated>2020-10-08T18:41:20Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Evolution of average Nusselt number in a differentially heated square cavity for different values of non-Newtonian power index $n$.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Evolution of average Nusselt number in a differentially heated square cavity for different values of non-Newtonian power index $n$.&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=File:NonNewtonianConvergence.png&amp;diff=3097</id>
		<title>File:NonNewtonianConvergence.png</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=File:NonNewtonianConvergence.png&amp;diff=3097"/>
				<updated>2020-10-08T17:39:46Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: MihaR uploaded a new version of File:NonNewtonianConvergence.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Convergence of average Nusselt number value with increasing node count and comparison with reference values from O. Turan, A. Sachdeva, N. Chakraborty in R. J. Poole, Laminar natural convection of power-law �uids in a square enclosure with di�erentially heated side walls subjected to constant temperatures, Journal of Non-Newtonian Fluid Mechanics 166, 1049 (2011).&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=File:NonNewtonianConvergence.png&amp;diff=3096</id>
		<title>File:NonNewtonianConvergence.png</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=File:NonNewtonianConvergence.png&amp;diff=3096"/>
				<updated>2020-10-08T17:03:57Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Convergence of average Nusselt number value with increasing node count and comparison with reference values from O. Turan, A. Sachdeva, N. Chakraborty in R. J. Poole, Laminar natural convection of power-law �uids in a square enclosure with di�erent...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Convergence of average Nusselt number value with increasing node count and comparison with reference values from O. Turan, A. Sachdeva, N. Chakraborty in R. J. Poole, Laminar natural convection of power-law �uids in a square enclosure with di�erentially heated side walls subjected to constant temperatures, Journal of Non-Newtonian Fluid Mechanics 166, 1049 (2011).&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=File:NonNewtonianConvergence.pdf&amp;diff=3095</id>
		<title>File:NonNewtonianConvergence.pdf</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=File:NonNewtonianConvergence.pdf&amp;diff=3095"/>
				<updated>2020-10-08T16:53:03Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=De_Vahl_Davis_natural_convection_test&amp;diff=3094</id>
		<title>De Vahl Davis natural convection test</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=De_Vahl_Davis_natural_convection_test&amp;diff=3094"/>
				<updated>2020-10-07T11:16:25Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Dead link fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Click here to return back to [[Fluid Mechanics]]&lt;br /&gt;
&lt;br /&gt;
=Intro=&lt;br /&gt;
The classical de Vahl Davis benchmark test is defined for the natural convection of the air ($\Pr =0.71$) in the square closed cavity (${{\text{A}}_{\text{R}}}=1$). The only physical free parameter of the test remains the thermal Rayleigh number. In the original paper [1] de Vahl Davis tested the problem up to the Rayleigh number ${{10}^{6}}$, however in the latter publications, the results of more intense simulations were presented with the Rayleigh number up to ${{10}^{8}}$. Lage and Bejan [2] showed that the laminar domain of the closed cavity natural convection problem is roughly below $\text{Gr1}{{\text{0}}^{9}}$. It was reported [3, 4] that the natural convection becomes unsteady for $\text{Ra}=2\cdot {{10}^5}$. Here we present a MLSM solution of the case.&lt;br /&gt;
&lt;br /&gt;
\begin{equation}&lt;br /&gt;
\text{Ra}\text{=}\,\frac{\left| \mathbf{g} \right|{{\beta }_{T}}\left( {{T}_{H}}-{{T}_{C}} \right){{\Omega }_{H}}^{3}{{\rho }^{2}}{{c}_{p}}}{\lambda \mu }&lt;br /&gt;
\end{equation}&lt;br /&gt;
\begin{equation}&lt;br /&gt;
\text{Pr}=\frac{\mu {{c}_{p}}}{\lambda }&lt;br /&gt;
\end{equation}&lt;br /&gt;
&lt;br /&gt;
[1] de Vahl Davis G. Natural convection of air in a square cavity: a bench mark numerical solution. Int J Numer Meth Fl. 1983;3:249-64. &lt;br /&gt;
&lt;br /&gt;
[2] Lage JL, Bejan A. The Ra-Pr domain of laminar natural convection in an enclosure heated from the side. Numer Heat Transfer. 1991;A19:21-41. &lt;br /&gt;
&lt;br /&gt;
[3] Janssen RJA, Henkes RAWM. Accuracy of finite-volume disretizations for the bifurcating natural-convection flow in a square cavity. Numer Heat Transfer. 1993;B24:191-207. &lt;br /&gt;
&lt;br /&gt;
[4] Nobile E. Simulation of time-dependent flow in cavities with the additive-correction multigrid method, part II: Apllications. Numer Heat Transfer. 1996;B30:341-50.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:devahl_scheme&amp;quot;&amp;gt;&lt;br /&gt;
[[File:image.png]].&lt;br /&gt;
&amp;lt;caption&amp;gt;Scheme of the de Vahl Davis benchmark test &amp;lt;/caption&amp;gt;&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Code=&lt;br /&gt;
Full examples can be found under the examples in the [https://gitlab.com/e62Lab/medusa code repository].&lt;br /&gt;
&lt;br /&gt;
==Explicit ACM method with CBS looks==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot; line&amp;gt;&lt;br /&gt;
    v2[boundary] = vec_t{0.0, 0.0};&lt;br /&gt;
    T2[left] = O.T_cold;&lt;br /&gt;
    T2[right] = O.T_hot;&lt;br /&gt;
    //Time stepping&lt;br /&gt;
    for (int step = 0; step &amp;lt;= O.t_steps; ++step) {&lt;br /&gt;
        for (int i_count = 1; i_count &amp;lt; _MAX_ITER_; ++i_count) {&lt;br /&gt;
            // Navier Stokes&lt;br /&gt;
            for (auto c : interior) {&lt;br /&gt;
                v2[c] = v1[c] + O.dt * (-1 / O.rho * op.grad(P1, c)&lt;br /&gt;
                                        + O.mu / O.rho * op.lap(v1, c)&lt;br /&gt;
                                        - op.grad(v1, c) * v1[c]&lt;br /&gt;
                                        + O.g * (1 - O.beta * (T1[c] - O.T_ref)));&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            //Speed of sound&lt;br /&gt;
            Range&amp;lt;scal_t&amp;gt; norm = v2.map([](const vec_t&amp;amp; p) { return p.norm(); });&lt;br /&gt;
            scal_t C = O.dl * std::max(*std::max_element(norm.begin(), norm.end()), O.v_ref);&lt;br /&gt;
            // Mass continuity&lt;br /&gt;
            Range&amp;lt;scal_t&amp;gt; div_v;&lt;br /&gt;
            for (auto c:all) {&lt;br /&gt;
                div_v[c] = op.div(v2, c);&lt;br /&gt;
                P2[c] = P1[c] - C * C * O.dt * O.rho * div_v[c] +&lt;br /&gt;
                        O.dl2 * C * C * O.dt * O.dt * op.lap(P1, c);&lt;br /&gt;
            }&lt;br /&gt;
            P1.swap(P2);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        //heat transport&lt;br /&gt;
        for (auto c : interior) {&lt;br /&gt;
            T2[c] = T1[c] + O.dt * O.lam / O.rho / O.c_p * op.lap(T1, c) -&lt;br /&gt;
                    O.dt * v1[c].transpose() * op.grad(T1, c);&lt;br /&gt;
        }&lt;br /&gt;
        for (auto c : top) T2[c] = op.neumann(T2, c, vec_t{0, -1}, 0.0);&lt;br /&gt;
        for (auto c : bottom) T2[c] = op.neumann(T2, c, vec_t{0, 1}, 0.0);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Explicit pressure correction ==&lt;br /&gt;
The solution of heat equation is the same as in above example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot; line&amp;gt;&lt;br /&gt;
    for (int step = 0; step &amp;lt;= O.t_steps; ++step) {&lt;br /&gt;
        // Explicit Navier-Stokes computed on whole domain, including boundaries&lt;br /&gt;
        // without pressure&lt;br /&gt;
        for (int c:all) {&lt;br /&gt;
            v_2[c] = v_1[c] + O.dt (&lt;br /&gt;
                                   O.mu / O.rho * op.lap(v_1, c)&lt;br /&gt;
                                    - op.grad(v_1, c) * v_1[c]&lt;br /&gt;
                                    + O.g * (1 - O.beta * (T_1[c] - O.T_ref)));&lt;br /&gt;
        }&lt;br /&gt;
        // Pressure correction&lt;br /&gt;
        VecXd rhs_pressure(N + 1, 0); //Note N+1, +1 stands for regularization equation&lt;br /&gt;
        rhs_pressure(N) = 0; // = 0 part of the regularization equation&lt;br /&gt;
        for (int i:interior) rhs_pressure(c) = O.rho / O.dt * op.div(v_2, c);&lt;br /&gt;
        for (int i: boundary) rhs_pressure(c) = O.rho / O.dt * v_2[c].dot(domain.normal(c));&lt;br /&gt;
        VecXd solution = solver_p.solve(rhs_pressure);&lt;br /&gt;
        alpha = solution[N];&lt;br /&gt;
        VecXd P_c = solution.head(N);&lt;br /&gt;
        for ( int i = interior) v_2[c] -=  O.dt / O.rho * op.grad(P_c, c);&lt;br /&gt;
        v_2[boundary] = 0; // force boundary conditions&lt;br /&gt;
        //heat transport&lt;br /&gt;
        for (auto c : interior) {&lt;br /&gt;
            T2[c] = T1[c] + O.dt * O.lam / O.rho / O.c_p * op.lap(T1, c) -&lt;br /&gt;
                    O.dt * v1[c].transpose() * op.grad(T1, c);&lt;br /&gt;
        }&lt;br /&gt;
        for (auto c : top) T2[c] = op.neumann(T2, c, vec_t{0, -1}, 0.0);&lt;br /&gt;
        for (auto c : bottom) T2[c] = op.neumann(T2, c, vec_t{0, 1}, 0.0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implicit ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot; line&amp;gt;&lt;br /&gt;
for (int step = 0; step &amp;lt;= O.t_steps_i; ++step) {&lt;br /&gt;
        time_1 = std::chrono::high_resolution_clock::now();&lt;br /&gt;
        // NAVIER STOKES&lt;br /&gt;
        M_velocity = mat_t(2 * N, 2 * N);&lt;br /&gt;
        // system&lt;br /&gt;
        M_velocity.reserve(Range&amp;lt;int&amp;gt;(2 * N, O.n));&lt;br /&gt;
        for (int i : interior) {&lt;br /&gt;
            op.valuevec(M_velocity, i, 1 / O.dt_i);&lt;br /&gt;
            op.lapvec(M_velocity, i, -O.mu / O.rho);&lt;br /&gt;
            op.gradvec(M_velocity, i, v_1[i]);&lt;br /&gt;
        }&lt;br /&gt;
        for (int i : boundary) op.valuevec(M_velocity, i, 1); //sets velocity to 0&lt;br /&gt;
&lt;br /&gt;
        M_velocity.makeCompressed();&lt;br /&gt;
        solver_v.compute(M_velocity);&lt;br /&gt;
        // solution&lt;br /&gt;
        Range &amp;lt;vec_t&amp;gt; rhs_vec(domain.size(), 0);&lt;br /&gt;
        for (int i : interior) {&lt;br /&gt;
            rhs_vec[i] = -1 / O.rho * op.grad(P, i) +&lt;br /&gt;
                         v_1[i] / O.dt_i&lt;br /&gt;
                         + O.g * (1 - O.beta * (T[i] - O.T_ref));&lt;br /&gt;
        }&lt;br /&gt;
        // for (int i:top) rhs_vec[i] = vec_t{0,1};&lt;br /&gt;
&lt;br /&gt;
        v_2 = reshape&amp;lt;2&amp;gt;(solver_v.solveWithGuess(reshape(rhs_vec), reshape(v_1)));&lt;br /&gt;
        // END OF NAVIER STOKES&lt;br /&gt;
&lt;br /&gt;
        // PRESSURE CORRECTION&lt;br /&gt;
        VecXd rhs_pressure(N + 1, 0); //Note N+1, +1 stands for regularization equation&lt;br /&gt;
        rhs_pressure(N) = 0; // = 0 part of the regularization equation&lt;br /&gt;
        double alpha;&lt;br /&gt;
        for (int i : interior) rhs_pressure(i) = O.rho / O.dt_i * op.div(v_2, i);&lt;br /&gt;
        for (int i : boundary) rhs_pressure(i) = O.rho / O.dt * v_2[i].dot(domain.normal(i));&lt;br /&gt;
&lt;br /&gt;
        VecXd solution = solver_p.solve(rhs_pressure);&lt;br /&gt;
        alpha = solution[N];&lt;br /&gt;
        VecXd P_c = solution.head(N);&lt;br /&gt;
        // apply velocity correction&lt;br /&gt;
        for (int i : interior) {&lt;br /&gt;
            v_2[i] -= O.dl * O.dt_i / O.rho * op.grad(P_c, i);&lt;br /&gt;
        }&lt;br /&gt;
        P += O.dl * P_c;&lt;br /&gt;
        // enforce velocity BC&lt;br /&gt;
        // v_2[boundary] = 0;&lt;br /&gt;
        // END OF PRESSURE CORRECTION&lt;br /&gt;
&lt;br /&gt;
        // HEAT TRANSPORT&lt;br /&gt;
        M_temperature = mat_t(N, N);&lt;br /&gt;
        Range&amp;lt;int&amp;gt; per_row(N, O.n);&lt;br /&gt;
        M_temperature.reserve(per_row);&lt;br /&gt;
        // outer boundary dirichlet BC&lt;br /&gt;
        for (int i : top) op.neumann_implicit(M_temperature, i, domain.normal(i), 1);&lt;br /&gt;
        for (int i : bottom) op.neumann_implicit(M_temperature, i, domain.normal(i), 1);&lt;br /&gt;
        for (int i : left) op.value(M_temperature, i, 1.0);&lt;br /&gt;
        for (int i : right) op.value(M_temperature, i, 1.0);&lt;br /&gt;
        // heat transport in air&lt;br /&gt;
        for (int i : interior) {&lt;br /&gt;
            op.value(M_temperature, i, 1.0);                          // time dependency&lt;br /&gt;
            op.lap(M_temperature, i, -O.dt_i * O.lam / O.rho / O.c_p);  //laplace in interior&lt;br /&gt;
            op.grad(M_temperature, i, O.dt * v_2[i]);&lt;br /&gt;
        }&lt;br /&gt;
        M_temperature.makeCompressed();&lt;br /&gt;
        solver_T.compute(M_temperature);&lt;br /&gt;
&lt;br /&gt;
        VectorXd rhs = VectorXd::Zero(N);&lt;br /&gt;
        for (int i : interior) rhs(i) = T(i);&lt;br /&gt;
        for (int i : top) rhs(i) = 0;&lt;br /&gt;
        for (int i : bottom) rhs(i) = 0;&lt;br /&gt;
        for (int i : left) rhs(i) = O.T_hot;&lt;br /&gt;
        for (int i : right) rhs(i) = O.T_cold;&lt;br /&gt;
        T = solver_T.solveWithGuess(rhs, T);&lt;br /&gt;
        // END OF HEAT TRANSPORT&lt;br /&gt;
        v_1.swap(v_2);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
== Comparison of MLSM solution with reference data  ==&lt;br /&gt;
Following video shows evolution of temperature and velocity magnitude for the $Ra=10^8$ case. &lt;br /&gt;
&lt;br /&gt;
[[File:DeVahlDavisRa1e8.mp4|640px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In below galley you can find temperature contour plots, velocity magnitude contour plots, v_max and average hot side Nusselt number convergence behavior. The reference values are from:&lt;br /&gt;
*[a] de Vahl Davis G. Natural convection of air in a square cavity: a bench mark numerical solution. Int J Numer Meth Fl. 1983;3:249-64. &lt;br /&gt;
*[b]  Sadat H, Couturier S. Performance and accuracy of a meshless method for laminar natural convection. Numer Heat Transfer. 2000;B37:455-67. &lt;br /&gt;
*[c] Wan DC, Patnaik BSV, Wei GW. A new benchmark quality solution for the buoyancy-driven cavity by discrete singular convolution. Numer Heat Transfer. 2001;B40:199-228. &lt;br /&gt;
*[d] Šarler B. A radial basis function collocation approach in computational fluid dynamics. CMES-Comp Model Eng. 2005;7:185-93. &lt;br /&gt;
*[e] Kosec G, Šarler B. Solution of thermo-fluid problems by collocation with local pressure correction. Int J Numer Method H. 2008;18:868-82. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
File:DVD_cont_T_Ra3.png&lt;br /&gt;
File:DVD_cont_T_Ra4.png&lt;br /&gt;
File:DVD_cont_T_Ra5.png&lt;br /&gt;
File:DVD_cont_T_Ra6.png&lt;br /&gt;
File:DVD_cont_T_Ra7.png&lt;br /&gt;
File:DVD_cont_T_Ra8.png&lt;br /&gt;
File:DVD_cont_v_Ra3.png&lt;br /&gt;
File:DVD_cont_v_Ra4.png&lt;br /&gt;
File:DVD_cont_v_Ra5.png&lt;br /&gt;
File:DVD_cont_v_Ra6.png&lt;br /&gt;
File:DVD_cont_v_Ra7.png&lt;br /&gt;
File:DVD_cont_v_Ra8.png&lt;br /&gt;
File:DVD_Nu_convRa3.png&lt;br /&gt;
File:DVD_Nu_convRa4.png&lt;br /&gt;
File:DVD_Nu_convRa5.png&lt;br /&gt;
File:DVD_Nu_convRa6.png&lt;br /&gt;
File:DVD_Nu_convRa7.png&lt;br /&gt;
File:DVD_Nu_convRa8.png&lt;br /&gt;
File:DVD_vMax_convRa3.png&lt;br /&gt;
File:DVD_vMax_convRa4.png&lt;br /&gt;
File:DVD_vMax_convRa5.png&lt;br /&gt;
File:DVD_vMax_convRa6.png&lt;br /&gt;
File:DVD_vMax_convRa7.png&lt;br /&gt;
File:DVD_vMax_convRa8.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Medusa&amp;diff=2915</id>
		<title>Medusa</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Medusa&amp;diff=2915"/>
				<updated>2020-03-23T20:40:33Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: /* Discussions / Applications */&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, examples, and  can be found on our [http://e6.ijs.si/medusa/docs/ documentation page] and [https://gitlab.com/e62Lab/medusa the code]. [[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;
== 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;
* [[Customization | Customization example: Biharmonic equation]]&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;
* [[Meshless Lattice Boltzmann method]]&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;
* [[k-d tree|''k''-d tree]] and other spatial search structures&lt;br /&gt;
* Solving [[Solving linear systems | linear systems]], [[Solving overdetermined systems | overdetermined]] and [[Solving underdetermined systems | underdetermined]]&lt;br /&gt;
* [[Weighted Least Squares (WLS)]]&lt;br /&gt;
* [[Computation of shape functions]]&lt;br /&gt;
* [[Meshless Local Strong Form Method (MLSM)]]&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;
== 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;
* Basic PDE solutions&lt;br /&gt;
** [[Convection Diffusion equation | Convection Diffusion equation]]&lt;br /&gt;
**[[Wave equation application]] &lt;br /&gt;
* [[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;
* [[Fluid Mechanics]]&lt;br /&gt;
** [[Lid driven cavity]]&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;
* 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;
* Slak J., Kosec G. Adaptive radial basis function-generated finite differences method for contact problems. International journal for numerical methods in engineering, ISSN 0029-5981 [http://www-e6.ijs.si/ParallelAndDistributedSystems/pdf/32230439.pdf manuscript]&lt;br /&gt;
* Slak J., Kosec G.; Refined meshless local strong form solution of Cauchy-Navier equation on an irregular domain. Engineering analysis with boundary elements. 2018;11 ; [http://comms.ijs.si/~gkosec/data/papers/31107623.pdf manuscript]&lt;br /&gt;
* Depolli, M., Kosec, G., 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 ;[http://comms.ijs.si/~gkosec/data/papers/29639719.pdf manuscript]&lt;br /&gt;
* Kosec G., A local numerical solution of a fluid-flow problem on an irregular domain. Advances in engineering software. 2016;7 ; [29512743] ; [http://comms.ijs.si/~gkosec/data/papers/29512743.pdf manuscript]&lt;br /&gt;
* Kosec G., Trobec R., Simulation of semiconductor devices with a local numerical approach. Engineering analysis with boundary elements. 2015;69-75; [27912487] ; [http://comms.ijs.si/~gkosec/data/papers/27912487.pdf manuscript]&lt;br /&gt;
* Kosec G., Šarler B., Simulation of macrosegregation with mesosegregates in binary metallic casts by a meshless method. Engineering analysis with boundary elements. 2014;36-44; [http://comms.ijs.si/~gkosec/data/papers/3218939.pdf manuscript]&lt;br /&gt;
* Kosec G., Depolli M., Rashkovska A., Trobec R., Super linear speedup in a local parallel meshless solution of thermo-fluid problem. Computers &amp;amp; Structures. 2014;133:30-38; [http://comms.ijs.si/~gkosec/data/papers/27339815.pdf manuscript]&lt;br /&gt;
* Kosec G., Zinterhof P., Local strong form meshless method on multiple Graphics Processing Units. Computer modeling in engineering &amp;amp; sciences. 2013;91:377-396; [http://comms.ijs.si/~gkosec/data/papers/26785063.pdf manuscript]&lt;br /&gt;
* Kosec G., Šarler B., H-adaptive local radial basis function collocation meshless method. Computers, materials &amp;amp; continua. 2011;26:227-253; [http://comms.ijs.si/~gkosec/data/papers/KosecSarlerBurgers.pdf manuscript]&lt;br /&gt;
* Trobec R., Kosec G., Šterk M., Šarler B., Comparison of local weak and strong form meshless methods for 2-D diffusion equation. Engineering analysis with boundary elements. 2012;36:310-321; [http://comms.ijs.si/~gkosec/data/papers/EABE2499.pdf manuscript]&lt;br /&gt;
* Kosec G, Zaloznik M, Sarler B, Combeau H. A Meshless Approach Towards Solution of Macrosegregation Phenomena. CMC: Computers, Materials, &amp;amp; Continua. 2011;580:1-27 [http://comms.ijs.si/~gkosec/data/papers/KosecZaloznikSarlerCombeauSegregation.pdf manuscript]&lt;br /&gt;
* Kosec G, Sarler B. Solution of thermo-fluid problems by collocation with local pressure correction. International Journal of Numerical Methods for Heat &amp;amp; Fluid Flow. 2008;18:868-82 [http://comms.ijs.si/~gkosec/data/papers/KosecSarlerNS2008.pdf manuscript]&lt;br /&gt;
*  Trobec R., Kosec G., Parallel Scientific Computing, ISBN: 978-3-319-17072-5 (Print) 978-3-319-17073-2.&lt;br /&gt;
*  Slak, J., Kosec, G.. Detection of heart rate variability from a wearable differential ECG device., MIPRO 2016, 39th International Convention, 2016, Opatija, Croatia, ISSN 1847-3938, pp 450-455.&lt;br /&gt;
*  Kolman, M., Kosec, G. Correlation between attenuation of 20 GHz satellite communication link and liquid water content in the atmosphere. MIPRO 2016, 39th International Convention, 2016, Opatija, Croatia, ISSN 1847-3938. pp. 308-313.&lt;br /&gt;
&lt;br /&gt;
==Related pages==&lt;br /&gt;
* http://e6.ijs.si/ParallelAndDistributedSystems/#!NumericalMethods&lt;br /&gt;
* http://e6.ijs.si/ParallelAndDistributedSystems/#!utils&lt;br /&gt;
* http://e6.ijs.si/ParallelAndDistributedSystems/#!NUMA&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Bioheat_equation&amp;diff=2914</id>
		<title>Bioheat equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Bioheat_equation&amp;diff=2914"/>
				<updated>2020-03-23T20:27:37Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;figure id=&amp;quot;fig:brainBioheat&amp;quot;&amp;gt;&lt;br /&gt;
[[File:BrainBioheat.png|thumb|upright=2|&amp;lt;caption&amp;gt; &lt;br /&gt;
&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Pennes' bioheat equation is a standard model for temperature distrubution in living tissues, that enhances diffusion equation with a linear term describing blood flow and a constant metabolic heat source.&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\rho c \frac{\partial T}{\partial t} = \nabla(\lambda \nabla T) + W_b (T_a -T) + Q_m&lt;br /&gt;
\]&lt;br /&gt;
&lt;br /&gt;
This example implements the stationary form of bioheat equation&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\nabla(\lambda \nabla T) + W_b (T_a -T) + Q_m = 0&lt;br /&gt;
\]&lt;br /&gt;
with Robin boundary conditions&lt;br /&gt;
\[&lt;br /&gt;
\lambda \frac{\partial T}{\partial \hat{n}} = h_s(T - T_{ext})&lt;br /&gt;
\]&lt;br /&gt;
on a human brain model&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Cvetkovic2016&amp;quot;&amp;gt;&lt;br /&gt;
Mario Cvetković, Dragan Poljak, Akimasa Hirata, The electromagnetic-thermal dosimetry for the homogeneous human brain model, Engineering Analysis with Boundary Elements, Volume 63, 2016, Pages 61-73, ISSN 0955 7997, https://doi.org/10.1016/j.enganabound.2015.11.002.&amp;lt;/ref&amp;gt;. Simulation nodes are based on FEM elements used in the referenced article with constants set to the default values from table 2 of the article.&lt;br /&gt;
&lt;br /&gt;
Obtained solution is displayed on &amp;lt;xr id=&amp;quot;fig:brainBioheat&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Bioheat_equation&amp;diff=2913</id>
		<title>Bioheat equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Bioheat_equation&amp;diff=2913"/>
				<updated>2020-03-23T20:25:33Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;figure id=&amp;quot;fig:brainBioheat&amp;quot;&amp;gt;&lt;br /&gt;
[[File:BrainBioheat.png|thumb|upright=2|&amp;lt;caption&amp;gt; &lt;br /&gt;
&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Pennes' bioheat equation is a standard model for temperature distrubution in living tissues that enhances diffusion equation with a linear term describing blood flow and constant metabolic heat sources.&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\rho c \frac{\partial T}{\partial t} = \nabla(\lambda \nabla T) + W_b (T_a -T) + Q_m&lt;br /&gt;
\]&lt;br /&gt;
&lt;br /&gt;
This example implements the stationary form of bioheat equation&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\nabla(\lambda \nabla T) + W_b (T_a -T) + Q_m = 0&lt;br /&gt;
\]&lt;br /&gt;
with Robin boundary conditions&lt;br /&gt;
\[&lt;br /&gt;
\lambda \frac{\partial T}{\partial \hat{n}} = h_s(T - T_{ext})&lt;br /&gt;
\]&lt;br /&gt;
on a human brain model&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Cvetkovic2016&amp;quot;&amp;gt;&lt;br /&gt;
Mario Cvetković, Dragan Poljak, Akimasa Hirata, The electromagnetic-thermal dosimetry for the homogeneous human brain model, Engineering Analysis with Boundary Elements, Volume 63, 2016, Pages 61-73, ISSN 0955 7997, https://doi.org/10.1016/j.enganabound.2015.11.002.&amp;lt;/ref&amp;gt;. Simulation nodes are based on the FEM elements used in the referenced article with constants set to the default values from table 2 of the article.&lt;br /&gt;
&lt;br /&gt;
Obtained solution is displayed on &amp;lt;xr id=&amp;quot;fig:brainBioheat&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=File:BrainBioheat.png&amp;diff=2912</id>
		<title>File:BrainBioheat.png</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=File:BrainBioheat.png&amp;diff=2912"/>
				<updated>2020-03-23T20:24:51Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Bioheat_equation&amp;diff=2911</id>
		<title>Bioheat equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Bioheat_equation&amp;diff=2911"/>
				<updated>2020-03-23T20:24:25Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Created page with &amp;quot;The Pennes' bioheat equation is a standard model for temperature distrubution in living tissues that enhances diffusion equation with a linear term describing blood flow and c...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Pennes' bioheat equation is a standard model for temperature distrubution in living tissues that enhances diffusion equation with a linear term describing blood flow and constant metabolic heat sources.&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\rho c \frac{\partial T}{\partial t} = \nabla(\lambda \nabla T) + W_b (T_a -T) + Q_m&lt;br /&gt;
\]&lt;br /&gt;
&lt;br /&gt;
This example implements the stationary form of bioheat equation&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\nabla(\lambda \nabla T) + W_b (T_a -T) + Q_m = 0&lt;br /&gt;
\]&lt;br /&gt;
with Robin boundary conditions&lt;br /&gt;
\[&lt;br /&gt;
\lambda \frac{\partial T}{\partial \hat{n}} = h_s(T - T_{ext})&lt;br /&gt;
\]&lt;br /&gt;
on a human brain model&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Cvetkovic2016&amp;quot;&amp;gt;&lt;br /&gt;
Mario Cvetković, Dragan Poljak, Akimasa Hirata, The electromagnetic-thermal dosimetry for the homogeneous human brain model, Engineering Analysis with Boundary Elements, Volume 63, 2016, Pages 61-73, ISSN 0955 7997, https://doi.org/10.1016/j.enganabound.2015.11.002.&amp;lt;/ref&amp;gt;. Simulation nodes are based on the FEM elements used in the referenced article with constants set to the default values from table 2 of the article.&lt;br /&gt;
&lt;br /&gt;
Obtained solution is displayed on &amp;lt;xr id=&amp;quot;fig:brainBioheat&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:brainBioheat&amp;quot;&amp;gt;&lt;br /&gt;
[[File:BrainBioheat.png|thumb|upright=2|&amp;lt;caption&amp;gt; &lt;br /&gt;
&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=File:TimeEvolution.mp4&amp;diff=2909</id>
		<title>File:TimeEvolution.mp4</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=File:TimeEvolution.mp4&amp;diff=2909"/>
				<updated>2020-02-13T11:40:39Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: MihaR uploaded a new version of File:TimeEvolution.mp4&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Medusa&amp;diff=2908</id>
		<title>Medusa</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Medusa&amp;diff=2908"/>
				<updated>2020-02-13T11:14:45Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: /* Examples */&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, examples, and  can be found on our [http://e6.ijs.si/medusa/docs/ documentation page] and [https://gitlab.com/e62Lab/medusa the code]. [[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;
== 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;
* [[Customization | Customization example: Biharmonic equation]]&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;
* [[Meshless Lattice Boltzmann method]]&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;
* [[k-d tree|''k''-d tree]] and other spatial search structures&lt;br /&gt;
* Solving [[Solving linear systems | linear systems]], [[Solving overdetermined systems | overdetermined]] and [[Solving underdetermined systems | underdetermined]]&lt;br /&gt;
* [[Weighted Least Squares (WLS)]]&lt;br /&gt;
* [[Computation of shape functions]]&lt;br /&gt;
* [[Meshless Local Strong Form Method (MLSM)]]&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;
== 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;
* Basic PDE solutions&lt;br /&gt;
** [[Convection Diffusion equation | Convection Diffusion equation]]&lt;br /&gt;
**[[Wave equation application]] &lt;br /&gt;
* [[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;
* [[Fluid Mechanics]]&lt;br /&gt;
** [[Lid driven cavity]]&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;
* 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;
&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;
* Slak J., Kosec G. Adaptive radial basis function-generated finite differences method for contact problems. International journal for numerical methods in engineering, ISSN 0029-5981 [http://www-e6.ijs.si/ParallelAndDistributedSystems/pdf/32230439.pdf manuscript]&lt;br /&gt;
* Slak J., Kosec G.; Refined meshless local strong form solution of Cauchy-Navier equation on an irregular domain. Engineering analysis with boundary elements. 2018;11 ; [http://comms.ijs.si/~gkosec/data/papers/31107623.pdf manuscript]&lt;br /&gt;
* Depolli, M., Kosec, G., 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 ;[http://comms.ijs.si/~gkosec/data/papers/29639719.pdf manuscript]&lt;br /&gt;
* Kosec G., A local numerical solution of a fluid-flow problem on an irregular domain. Advances in engineering software. 2016;7 ; [29512743] ; [http://comms.ijs.si/~gkosec/data/papers/29512743.pdf manuscript]&lt;br /&gt;
* Kosec G., Trobec R., Simulation of semiconductor devices with a local numerical approach. Engineering analysis with boundary elements. 2015;69-75; [27912487] ; [http://comms.ijs.si/~gkosec/data/papers/27912487.pdf manuscript]&lt;br /&gt;
* Kosec G., Šarler B., Simulation of macrosegregation with mesosegregates in binary metallic casts by a meshless method. Engineering analysis with boundary elements. 2014;36-44; [http://comms.ijs.si/~gkosec/data/papers/3218939.pdf manuscript]&lt;br /&gt;
* Kosec G., Depolli M., Rashkovska A., Trobec R., Super linear speedup in a local parallel meshless solution of thermo-fluid problem. Computers &amp;amp; Structures. 2014;133:30-38; [http://comms.ijs.si/~gkosec/data/papers/27339815.pdf manuscript]&lt;br /&gt;
* Kosec G., Zinterhof P., Local strong form meshless method on multiple Graphics Processing Units. Computer modeling in engineering &amp;amp; sciences. 2013;91:377-396; [http://comms.ijs.si/~gkosec/data/papers/26785063.pdf manuscript]&lt;br /&gt;
* Kosec G., Šarler B., H-adaptive local radial basis function collocation meshless method. Computers, materials &amp;amp; continua. 2011;26:227-253; [http://comms.ijs.si/~gkosec/data/papers/KosecSarlerBurgers.pdf manuscript]&lt;br /&gt;
* Trobec R., Kosec G., Šterk M., Šarler B., Comparison of local weak and strong form meshless methods for 2-D diffusion equation. Engineering analysis with boundary elements. 2012;36:310-321; [http://comms.ijs.si/~gkosec/data/papers/EABE2499.pdf manuscript]&lt;br /&gt;
* Kosec G, Zaloznik M, Sarler B, Combeau H. A Meshless Approach Towards Solution of Macrosegregation Phenomena. CMC: Computers, Materials, &amp;amp; Continua. 2011;580:1-27 [http://comms.ijs.si/~gkosec/data/papers/KosecZaloznikSarlerCombeauSegregation.pdf manuscript]&lt;br /&gt;
* Kosec G, Sarler B. Solution of thermo-fluid problems by collocation with local pressure correction. International Journal of Numerical Methods for Heat &amp;amp; Fluid Flow. 2008;18:868-82 [http://comms.ijs.si/~gkosec/data/papers/KosecSarlerNS2008.pdf manuscript]&lt;br /&gt;
*  Trobec R., Kosec G., Parallel Scientific Computing, ISBN: 978-3-319-17072-5 (Print) 978-3-319-17073-2.&lt;br /&gt;
*  Slak, J., Kosec, G.. Detection of heart rate variability from a wearable differential ECG device., MIPRO 2016, 39th International Convention, 2016, Opatija, Croatia, ISSN 1847-3938, pp 450-455.&lt;br /&gt;
*  Kolman, M., Kosec, G. Correlation between attenuation of 20 GHz satellite communication link and liquid water content in the atmosphere. MIPRO 2016, 39th International Convention, 2016, Opatija, Croatia, ISSN 1847-3938. pp. 308-313.&lt;br /&gt;
&lt;br /&gt;
==Related pages==&lt;br /&gt;
* http://e6.ijs.si/ParallelAndDistributedSystems/#!NumericalMethods&lt;br /&gt;
* http://e6.ijs.si/ParallelAndDistributedSystems/#!utils&lt;br /&gt;
* http://e6.ijs.si/ParallelAndDistributedSystems/#!NUMA&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2907</id>
		<title>Cahn-Hilliard equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2907"/>
				<updated>2020-02-11T14:10:53Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Go back to [[Medusa#Examples|Examples]].&lt;br /&gt;
&lt;br /&gt;
In this example we will show how to solve the [https://en.wikipedia.org/wiki/Cahn%E2%80%93Hilliard_equation Cahn-Hilliard] equation in Medusa. The solution provides an implementation of periodic boundary conditions and shows how to combine implicit and explicit operators. This example uses a custom biharmonic operator, so we recommend firstly reading the tutorial on [[Customization]].&lt;br /&gt;
&lt;br /&gt;
== Cahn-Hilliard equation ==&lt;br /&gt;
The Cahn-Hilliard equation describes the separation of binary fluid into pure domains. We define concentration, a scalar field $c(x, y) \in [-1, 1]$ to describe the fluid, with values $c \pm 1$ representing pure phases. In this case the equation can be written as&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\frac{\partial c}{\partial t} = D \nabla^2 (c^3 - c - \gamma \nabla^2 c),&lt;br /&gt;
\]&lt;br /&gt;
where $D$ is the diffusion constant and $\sqrt{\gamma}$ is the characteristic transition length between domains.&lt;br /&gt;
&lt;br /&gt;
We want to avoid any boundary effects and solve the equation for infinite fluid which can be approximated by using periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Periodic boundary conditions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:periodicBands&amp;quot;&amp;gt;&lt;br /&gt;
[[File:PeriodicBands.png|thumb|upright=2|&amp;lt;caption&amp;gt;Periodic band display.&lt;br /&gt;
&lt;br /&gt;
Left subplot shows an example of filled domain with $border = 10$ and $dx = 0.2$. Interior nodes and their periodic counterparts share colors to illustrate periodicity.&lt;br /&gt;
&lt;br /&gt;
Right subplot shows the neighbourhood of bottom left corner node $(-border, -border)$, with its support nodes highlighted in red. This example uses same fill parameters as the left figure and a support size of 100. &lt;br /&gt;
&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The simplest method of implementing a periodic boundary is adding a band of periodic nodes that mirror values from nodes that lie close to the opposite boundary. We have to create periodic nodes based on locations of interior nodes and construct a mapping that will allow us to update their values based on their interior counterparts. Width of the periodic band should be chosen with support size in mind. Periodic band should be wide enough to include all nodes required to calculate interior values. An example that can help us determine the required width of the periodic band is shown on the right subplot of &amp;lt;xr id=&amp;quot;fig:periodicBands&amp;quot;/&amp;gt; and shows that we need a periodic band width of $6 dx$ for a support size of 100.&lt;br /&gt;
&lt;br /&gt;
We start by creating a square domain centered on 0 and uniformly filling it with nodes. $border$ parameter determines the square size while $dx$, the typical distance between nodes, determines the node density.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
mm::BoxShape&amp;lt;vec_t&amp;gt; box(-border, border);&lt;br /&gt;
mm::DomainDiscretization&amp;lt;vec_t&amp;gt; domain = box.discretizeBoundaryWithStep(dx);&lt;br /&gt;
mm::GeneralFill&amp;lt;vec_t&amp;gt; fill;&lt;br /&gt;
fill.seed(randomSeed);&lt;br /&gt;
domain.fill(fill, dx);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Afterwards we remove boundary nodes at positive $border$ and move others into interior. This creates a $[-border, border) \times [-border, border)$ interior that can be made periodic.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Eigen::Matrix2d borders;  // col1: - border, col2: + border, rows for dimensions&lt;br /&gt;
borders &amp;lt;&amp;lt; domain.shape().bbox().first, domain.shape().bbox().second;&lt;br /&gt;
for (auto idx : domain.boundary()) {&lt;br /&gt;
    const auto&amp;amp; pos = domain.pos(idx);&lt;br /&gt;
    if (pos[0] != borders(0, 1) &amp;amp;&amp;amp; pos[1] != borders(1, 1)) {&lt;br /&gt;
        domain.changeToInterior(idx, pos, 1);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
domain.removeBoundaryNodes();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we are ready to find all nodes that lie sufficiently close to the border and create their periodic counterparts. In general rectangle case we would need to check all dimesions and create periodic nodes in all subsets of dimensions where that node lies close to the border. In this 2D case that simplifies to checking whether node lies close to the border in $x$, $y$ or both, which would mean a periodic corner. We could simplify our code and ignore the small periodic corners but that would lead to slightly worse results.&lt;br /&gt;
&lt;br /&gt;
Periodic boundary nodes are created with type -2 so that we can still differentiate between them and any legitimate boundary nodes we would have in case of mixing periodic and normal boundary conditions. Boundary normal can be chosen arbitrarily, periodic nodes are only used as value holders.&lt;br /&gt;
&lt;br /&gt;
During this process we also store periodic node indices in $periodicNodes$ and indices of the original nodes in $interiorMapping$.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
mm::Range&amp;lt;int&amp;gt; periodicNodes;&lt;br /&gt;
mm::Range&amp;lt;int&amp;gt; interiorMapping;&lt;br /&gt;
mm::Vec2d normal(0, 0);  // not used in this case and can be chosen arbitrarily&lt;br /&gt;
for (auto idx : domain.interior()) {&lt;br /&gt;
    const auto&amp;amp; pos = domain.pos(idx);&lt;br /&gt;
    // col1: distance to - border, col2: distance to + border, rows represent dimensions&lt;br /&gt;
    auto borderDistance = borders.colwise() - pos;&lt;br /&gt;
    const auto&amp;amp; isPeriodic = borderDistance.array().abs() &amp;lt; periodicBandWidth * dx;&lt;br /&gt;
    for (int i0 = 0; i0 &amp;lt; 2; i0++) {&lt;br /&gt;
        // check for periodicity in 1st dimension (x)&lt;br /&gt;
        if (isPeriodic(0, i0)) {&lt;br /&gt;
            auto periodicPos = pos;&lt;br /&gt;
            periodicPos(0) = borders(0, (i0 + 1) % 2) - borderDistance(0, i0);&lt;br /&gt;
            periodicNodes.push_back(domain.addBoundaryNode(periodicPos, -2, normal));&lt;br /&gt;
            interiorMapping.push_back(idx);&lt;br /&gt;
        }&lt;br /&gt;
        for (int i1 = 0; i1 &amp;lt; 2; i1++) {&lt;br /&gt;
            // check for periodicity in 2nd dimension (y)&lt;br /&gt;
            if (i0 == 0 &amp;amp;&amp;amp; isPeriodic(1, i1)) {&lt;br /&gt;
                auto periodicPos = pos;&lt;br /&gt;
                periodicPos(1) = borders(1, (i1 + 1) % 2) - borderDistance(1, i1);&lt;br /&gt;
                periodicNodes.push_back(domain.addBoundaryNode(periodicPos, -2, normal));&lt;br /&gt;
                interiorMapping.push_back(idx);&lt;br /&gt;
            }&lt;br /&gt;
            // check for periodicity in both dimensions (corners)&lt;br /&gt;
            if (isPeriodic(0, i0) &amp;amp;&amp;amp; isPeriodic(1, i1)) {&lt;br /&gt;
                auto periodicPos = pos;&lt;br /&gt;
                periodicPos(0) = borders(0, (i0 + 1) % 2) - borderDistance(0, i0);&lt;br /&gt;
                periodicPos(1) = borders(1, (i1 + 1) % 2) - borderDistance(1, i1);&lt;br /&gt;
                periodicNodes.push_back(domain.addBoundaryNode(periodicPos, -2, normal));&lt;br /&gt;
                interiorMapping.push_back(idx);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:timeEvolution&amp;quot;&amp;gt;&lt;br /&gt;
[[File:TimeEvolution.mp4|thumb|upright=2|&amp;lt;caption&amp;gt;Time evolution of the concentration. Initially mixed fluid separates into domains that grow with time.&lt;br /&gt;
&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
We need to handle two uncommon terms to solve the equation. Biharmonic ($\nabla^4$) operator can be implemented with custom operators as shown in [[Customization]] example. Nonlinear ($\nabla^2 c^3$) term proves to be more problematic, as it can not be solved implicitly. We either need to solve the entire equation with explicit time stepping or include the nonlinear term in the right hand side of our system of equations.&lt;br /&gt;
&lt;br /&gt;
Initial concentration is random. &lt;br /&gt;
&lt;br /&gt;
=== Explicit solution ===&lt;br /&gt;
Explicit solution is simpler to implement and faster when we want to solve the equation for very small time steps.&lt;br /&gt;
&lt;br /&gt;
We use Euler method for time stepping and copy interior node values to their periodic counterparts at every step.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
double t = 0;&lt;br /&gt;
Eigen::VectorXd bracket;&lt;br /&gt;
while (t &amp;lt;= tEnd) {&lt;br /&gt;
    bracket = concentration.array() * concentration.array() * concentration.array() - concentration.array();&lt;br /&gt;
    for (int i : allNodes) {&lt;br /&gt;
        bracket[i] -= L * expOp.lap(concentration, i);&lt;br /&gt;
    }&lt;br /&gt;
    for (int i : interiorNodes) {&lt;br /&gt;
        concentration[i] = concentration[i] + dt * D * expOp.lap(bracket, i);&lt;br /&gt;
    }&lt;br /&gt;
    t += dt;&lt;br /&gt;
&lt;br /&gt;
    for (int i = 0; i &amp;lt; periodicSize; i++) {&lt;br /&gt;
        concentration[periodicNodes[i]] = concentration[interiorMapping[i]];&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mixed solution ===&lt;br /&gt;
Mixed solution allows for much longer (several orders) time steps as we solve the majority of our equation implicitly. Explicit computation of the nonlinear term will always lead to inaccuracies, especially for long $dt$.&lt;br /&gt;
&lt;br /&gt;
We set the equation on interior and identities on boundary. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
for (int i : interiorNodes) {&lt;br /&gt;
    impOp.value(i) + D * dt * impOp.lap(i) + D * dt * L * impOp.apply&amp;lt;Biharmonic&amp;lt;dim&amp;gt;&amp;gt;(i) = rhs[i];&lt;br /&gt;
}&lt;br /&gt;
for (int i = 0; i &amp;lt; periodicSize; i++) {&lt;br /&gt;
    impOp.value(periodicNodes[i]) = rhs[interiorMapping[i]];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Eigen::SparseLU&amp;lt;decltype(M)&amp;gt; solver;&lt;br /&gt;
solver.compute(M);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have to explicitly compute nonlinear $\nabla^2 c^3$ term at every step and add it to the rhs. Once we solve the system for new concentration we have to copy interior node values to their periodic counterparts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/// Time stepping.&lt;br /&gt;
double t = 0;&lt;br /&gt;
Eigen::VectorXd cubedConcentration;&lt;br /&gt;
while (t &amp;lt;= tEnd) {&lt;br /&gt;
    /// Prepare rhs.&lt;br /&gt;
    cubedConcentration = concentration.array() * concentration.array() * concentration.array();&lt;br /&gt;
    for (int i : allNodes) {&lt;br /&gt;
        concentration[i] = D * dt * expOp.lap(cubedConcentration, i) + concentration[i];&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    concentration = solver.solve(concentration);&lt;br /&gt;
    t += dt;&lt;br /&gt;
&lt;br /&gt;
    /// Copy values from interior nodes to their periodic representations.&lt;br /&gt;
    for (int i = 0; i &amp;lt; periodicSize; i++) {&lt;br /&gt;
        concentration[periodicNodes[i]] = concentration[interiorMapping[i]];&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The complete example is avalible on [https://gitlab.com/e62Lab/medusa/blob/dev/examples/cahnHilliard_equation git].&lt;br /&gt;
&lt;br /&gt;
Go back to [[Medusa#Examples|Examples]].&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=File:TimeEvolution.mp4&amp;diff=2906</id>
		<title>File:TimeEvolution.mp4</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=File:TimeEvolution.mp4&amp;diff=2906"/>
				<updated>2020-02-11T14:10:21Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: MihaR uploaded a new version of File:TimeEvolution.mp4&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=File:TimeEvolution.mp4&amp;diff=2905</id>
		<title>File:TimeEvolution.mp4</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=File:TimeEvolution.mp4&amp;diff=2905"/>
				<updated>2020-02-11T13:42:26Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2904</id>
		<title>Cahn-Hilliard equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2904"/>
				<updated>2020-02-11T13:38:02Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Go back to [[Medusa#Examples|Examples]].&lt;br /&gt;
&lt;br /&gt;
In this example we will show how to solve the [https://en.wikipedia.org/wiki/Cahn%E2%80%93Hilliard_equation Cahn-Hilliard] equation in Medusa. The solution provides an implementation of periodic boundary conditions and shows how to combine implicit and explicit operators. This example uses a custom biharmonic operator, so we recommend firstly reading the tutorial on [[Customization]].&lt;br /&gt;
&lt;br /&gt;
== Cahn-Hilliard equation ==&lt;br /&gt;
The Cahn-Hilliard equation describes the separation of binary fluid into pure domains. We define concentration, a scalar field $c(x, y) \in [-1, 1]$ to describe the fluid, with values $c \pm 1$ representing pure phases. In this case the equation can be written as&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\frac{\partial c}{\partial t} = D \nabla^2 (c^3 - c - \gamma \nabla^2 c),&lt;br /&gt;
\]&lt;br /&gt;
where $D$ is the diffusion constant and $\sqrt{\gamma}$ is the characteristic transition length between domains.&lt;br /&gt;
&lt;br /&gt;
We want to avoid any boundary effects and solve the equation for infinite fluid which can be approximated by using periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Periodic boundary conditions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:periodicBands&amp;quot;&amp;gt;&lt;br /&gt;
[[File:PeriodicBands.png|thumb|upright=2|&amp;lt;caption&amp;gt;Periodic band display.&lt;br /&gt;
&lt;br /&gt;
Left subplot shows an example of filled domain with $border = 10$ and $dx = 0.2$. Interior nodes and their periodic counterparts share colors to illustrate periodicity.&lt;br /&gt;
&lt;br /&gt;
Right subplot shows the neighbourhood of bottom left corner node $(-border, -border)$, with its support nodes highlighted in red. This example uses same fill parameters as the left figure and a support size of 100. &lt;br /&gt;
&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The simplest method of implementing a periodic boundary is adding a band of periodic nodes that mirror values from nodes that lie close to the opposite boundary. We have to create periodic nodes based on locations of interior nodes and construct a mapping that will allow us to update their values based on their interior counterparts. Width of the periodic band should be chosen with support size in mind. Periodic band should be wide enough to include all nodes required to calculate interior values. An example that can help us determine the required width of the periodic band is shown on the right subplot of &amp;lt;xr id=&amp;quot;fig:periodicBands&amp;quot;/&amp;gt; and shows that we need a periodic band width of $6 dx$ for a support size of 100.&lt;br /&gt;
&lt;br /&gt;
We start by creating a square domain centered on 0 and uniformly filling it with nodes. $border$ parameter determines the square size while $dx$, the typical distance between nodes, determines the node density.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
mm::BoxShape&amp;lt;vec_t&amp;gt; box(-border, border);&lt;br /&gt;
mm::DomainDiscretization&amp;lt;vec_t&amp;gt; domain = box.discretizeBoundaryWithStep(dx);&lt;br /&gt;
mm::GeneralFill&amp;lt;vec_t&amp;gt; fill;&lt;br /&gt;
fill.seed(randomSeed);&lt;br /&gt;
domain.fill(fill, dx);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Afterwards we remove boundary nodes at positive $border$ and move others into interior. This creates a $[-border, border) \times [-border, border)$ interior that can be made periodic.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Eigen::Matrix2d borders;  // col1: - border, col2: + border, rows for dimensions&lt;br /&gt;
borders &amp;lt;&amp;lt; domain.shape().bbox().first, domain.shape().bbox().second;&lt;br /&gt;
for (auto idx : domain.boundary()) {&lt;br /&gt;
    const auto&amp;amp; pos = domain.pos(idx);&lt;br /&gt;
    if (pos[0] != borders(0, 1) &amp;amp;&amp;amp; pos[1] != borders(1, 1)) {&lt;br /&gt;
        domain.changeToInterior(idx, pos, 1);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
domain.removeBoundaryNodes();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we are ready to find all nodes that lie sufficiently close to the border and create their periodic counterparts. In general rectangle case we would need to check all dimesions and create periodic nodes in all subsets of dimensions where that node lies close to the border. In this 2D case that simplifies to checking whether node lies close to the border in $x$, $y$ or both, which would mean a periodic corner. We could simplify our code and ignore the small periodic corners but that would lead to slightly worse results.&lt;br /&gt;
&lt;br /&gt;
Periodic boundary nodes are created with type -2 so that we can still differentiate between them and any legitimate boundary nodes we would have in case of mixing periodic and normal boundary conditions. Boundary normal can be chosen arbitrarily, periodic nodes are only used as value holders.&lt;br /&gt;
&lt;br /&gt;
During this process we also store periodic node indices in $periodicNodes$ and indices of the original nodes in $interiorMapping$.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
mm::Range&amp;lt;int&amp;gt; periodicNodes;&lt;br /&gt;
mm::Range&amp;lt;int&amp;gt; interiorMapping;&lt;br /&gt;
mm::Vec2d normal(0, 0);  // not used in this case and can be chosen arbitrarily&lt;br /&gt;
for (auto idx : domain.interior()) {&lt;br /&gt;
    const auto&amp;amp; pos = domain.pos(idx);&lt;br /&gt;
    // col1: distance to - border, col2: distance to + border, rows represent dimensions&lt;br /&gt;
    auto borderDistance = borders.colwise() - pos;&lt;br /&gt;
    const auto&amp;amp; isPeriodic = borderDistance.array().abs() &amp;lt; periodicBandWidth * dx;&lt;br /&gt;
    for (int i0 = 0; i0 &amp;lt; 2; i0++) {&lt;br /&gt;
        // check for periodicity in 1st dimension (x)&lt;br /&gt;
        if (isPeriodic(0, i0)) {&lt;br /&gt;
            auto periodicPos = pos;&lt;br /&gt;
            periodicPos(0) = borders(0, (i0 + 1) % 2) - borderDistance(0, i0);&lt;br /&gt;
            periodicNodes.push_back(domain.addBoundaryNode(periodicPos, -2, normal));&lt;br /&gt;
            interiorMapping.push_back(idx);&lt;br /&gt;
        }&lt;br /&gt;
        for (int i1 = 0; i1 &amp;lt; 2; i1++) {&lt;br /&gt;
            // check for periodicity in 2nd dimension (y)&lt;br /&gt;
            if (i0 == 0 &amp;amp;&amp;amp; isPeriodic(1, i1)) {&lt;br /&gt;
                auto periodicPos = pos;&lt;br /&gt;
                periodicPos(1) = borders(1, (i1 + 1) % 2) - borderDistance(1, i1);&lt;br /&gt;
                periodicNodes.push_back(domain.addBoundaryNode(periodicPos, -2, normal));&lt;br /&gt;
                interiorMapping.push_back(idx);&lt;br /&gt;
            }&lt;br /&gt;
            // check for periodicity in both dimensions (corners)&lt;br /&gt;
            if (isPeriodic(0, i0) &amp;amp;&amp;amp; isPeriodic(1, i1)) {&lt;br /&gt;
                auto periodicPos = pos;&lt;br /&gt;
                periodicPos(0) = borders(0, (i0 + 1) % 2) - borderDistance(0, i0);&lt;br /&gt;
                periodicPos(1) = borders(1, (i1 + 1) % 2) - borderDistance(1, i1);&lt;br /&gt;
                periodicNodes.push_back(domain.addBoundaryNode(periodicPos, -2, normal));&lt;br /&gt;
                interiorMapping.push_back(idx);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:timeEvolution&amp;quot;&amp;gt;&lt;br /&gt;
[[File:TimeEvolution.mp4|thumb|upright=2|&amp;lt;caption&amp;gt;Time evolution of the concentration. Initially mixed fluid separates into domains that grow with time.&lt;br /&gt;
&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
We need to handle two uncommon terms to solve the equation. Biharmonic ($\nabla^4$) operator can be implemented with custom operators as shown in [[Customization]] example. Nonlinear ($\nabla^2 c^3$) term proves to be more problematic, as it can not be solved implicitly. We either need to solve the entire equation with explicit time stepping or include the nonlinear term in the right hand side of our system of equations.&lt;br /&gt;
&lt;br /&gt;
Initial concentration is random. &lt;br /&gt;
&lt;br /&gt;
=== Explicit solution ===&lt;br /&gt;
Explicit solution is simpler to implement and faster when we want to solve the equation for very small time steps.&lt;br /&gt;
&lt;br /&gt;
We use Euler method for time stepping and copy interior node values to their periodic counterparts at every step.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
double t = 0;&lt;br /&gt;
Eigen::VectorXd bracket;&lt;br /&gt;
while (t &amp;lt;= tEnd) {&lt;br /&gt;
    bracket = concentration.array() * concentration.array() * concentration.array() - concentration.array();&lt;br /&gt;
    for (int i : allNodes) {&lt;br /&gt;
        bracket[i] -= L * expOp.lap(concentration, i);&lt;br /&gt;
    }&lt;br /&gt;
    for (int i : interiorNodes) {&lt;br /&gt;
        concentration[i] = concentration[i] + dt * D * expOp.lap(bracket, i);&lt;br /&gt;
    }&lt;br /&gt;
    t += dt;&lt;br /&gt;
&lt;br /&gt;
    for (int i = 0; i &amp;lt; periodicSize; i++) {&lt;br /&gt;
        concentration[periodicNodes[i]] = concentration[interiorMapping[i]];&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mixed solution ===&lt;br /&gt;
Mixed solution allows for much longer (several orders) time steps as we solve the majority of our equation implicitly. Explicit computation of the nonlinear term will always lead to inaccuracies, especially for long $dt$.&lt;br /&gt;
&lt;br /&gt;
We set the equation on interior and identities on boundary. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
for (int i : interiorNodes) {&lt;br /&gt;
    impOp.value(i) + D * dt * impOp.lap(i) + D * dt * L * impOp.apply&amp;lt;Biharmonic&amp;lt;dim&amp;gt;&amp;gt;(i) = rhs[i];&lt;br /&gt;
}&lt;br /&gt;
for (int i = 0; i &amp;lt; periodicSize; i++) {&lt;br /&gt;
    impOp.value(periodicNodes[i]) = rhs[interiorMapping[i]];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Eigen::SparseLU&amp;lt;decltype(M)&amp;gt; solver;&lt;br /&gt;
solver.compute(M);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have to explicitly compute nonlinear $\nabla^2 c^3$ term at every step and add it to the rhs. Once we solve the system for new concentration we have to copy interior node values to their periodic counterparts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/// Time stepping.&lt;br /&gt;
double t = 0;&lt;br /&gt;
Eigen::VectorXd cubedConcentration;&lt;br /&gt;
while (t &amp;lt;= tEnd) {&lt;br /&gt;
    /// Prepare rhs.&lt;br /&gt;
    cubedConcentration = concentration.array() * concentration.array() * concentration.array();&lt;br /&gt;
    for (int i : allNodes) {&lt;br /&gt;
        concentration[i] = D * dt * expOp.lap(cubedConcentration, i) + concentration[i];&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    concentration = solver.solve(concentration);&lt;br /&gt;
    t += dt;&lt;br /&gt;
&lt;br /&gt;
    /// Copy values from interior nodes to their periodic representations.&lt;br /&gt;
    for (int i = 0; i &amp;lt; periodicSize; i++) {&lt;br /&gt;
        concentration[periodicNodes[i]] = concentration[interiorMapping[i]];&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Go back to [[Medusa#Examples|Examples]].&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2903</id>
		<title>Cahn-Hilliard equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2903"/>
				<updated>2020-02-11T00:51:42Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Go back to [[Medusa#Examples|Examples]].&lt;br /&gt;
&lt;br /&gt;
In this example we will show how to solve the [https://en.wikipedia.org/wiki/Cahn%E2%80%93Hilliard_equation Cahn-Hilliard] equation in Medusa. The solution provides an implementation of periodic boundary conditions and shows how to combine implicit and explicit operators. This example uses a custom biharmonic operator, so we recommend firstly reading the tutorial on [[Customization]].&lt;br /&gt;
&lt;br /&gt;
== Cahn-Hilliard equation ==&lt;br /&gt;
The Cahn-Hilliard equation describes the separation of binary fluid into pure domains. We define concentration, a scalar field $c(x, y) \in [-1, 1]$ to describe the fluid, with values $c \pm 1$ representing pure phases. In this case the equation can be written as&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\frac{\partial c}{\partial t} = D \nabla^2 (c^3 - c - \gamma \nabla^2 c),&lt;br /&gt;
\]&lt;br /&gt;
where $D$ is the diffusion constant and $\sqrt{\gamma}$ is the characteristic transition length between domains.&lt;br /&gt;
&lt;br /&gt;
We want to avoid any boundary effects and solve the equation for infinite fluid which can be approximated by using periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Periodic boundary conditions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;figure id=&amp;quot;fig:periodicBands&amp;quot;&amp;gt;&lt;br /&gt;
[[File:PeriodicBands.png|thumb|upright=2|&amp;lt;caption&amp;gt;Periodic band display.&lt;br /&gt;
&lt;br /&gt;
Left subplot shows an example of filled domain with $border = 10$ and $dx = 0.2$. Interior nodes and their periodic counterparts share colors to illustrate periodicity.&lt;br /&gt;
&lt;br /&gt;
Right subplot shows the neighbourhood of bottom left corner node $(-border, -border)$, with its support nodes highlighted in red. This example uses same fill parameters as the left figure and a support size of 100. &lt;br /&gt;
&amp;lt;/caption&amp;gt;]]&lt;br /&gt;
&amp;lt;/figure&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The simplest method of implementing a periodic boundary is adding a band of periodic nodes that mirror values from nodes that lie close to the opposite boundary. We have to create periodic nodes based on locations of interior nodes and construct a mapping that will allow us to update their values based on their interior counterparts. Width of the periodic band should be chosen with support size in mind. Periodic band should be wide enough to include all nodes required to calculate interior values. An example that can help us determine the required width of the periodic band is shown on the right subplot of &amp;lt;xr id=&amp;quot;fig:periodicBands&amp;quot;/&amp;gt; and shows that we need a periodic band width of $6 dx$ for a support size of 100.&lt;br /&gt;
&lt;br /&gt;
We start by creating a square domain centered on 0 and uniformly filling it with nodes. $border$ parameter determines the square size while $dx$, the typical distance between nodes, determines the node density.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
mm::BoxShape&amp;lt;vec_t&amp;gt; box(-border, border);&lt;br /&gt;
mm::DomainDiscretization&amp;lt;vec_t&amp;gt; domain = box.discretizeBoundaryWithStep(dx);&lt;br /&gt;
mm::GeneralFill&amp;lt;vec_t&amp;gt; fill;&lt;br /&gt;
fill.seed(randomSeed);&lt;br /&gt;
domain.fill(fill, dx);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
We need to handle two uncommon terms to solve the equation. Biharmonic ($\nabla^4$) operator can be implemented with custom operators as shown in [[Customization]] example. Nonlinear ($\nabla^2 c^3$) term proves to be more problematic, as it can not be solved implicitly. We either need to solve the entire equation with explicit time stepping or include the nonlinear term in the right hand side of our system of equations.&lt;br /&gt;
&lt;br /&gt;
=== Explicit solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mixed solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Go back to [[Medusa#Examples|Examples]].&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=File:PeriodicBands.png&amp;diff=2902</id>
		<title>File:PeriodicBands.png</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=File:PeriodicBands.png&amp;diff=2902"/>
				<updated>2020-02-11T00:18:36Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2901</id>
		<title>Cahn-Hilliard equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2901"/>
				<updated>2020-02-11T00:17:48Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Go back to [[Medusa#Examples|Examples]].&lt;br /&gt;
&lt;br /&gt;
In this example we will show how to solve the [https://en.wikipedia.org/wiki/Cahn%E2%80%93Hilliard_equation Cahn-Hilliard] equation in Medusa. The solution provides an implementation of periodic boundary conditions and shows how to combine implicit and explicit operators. This example uses a custom biharmonic operator, so we recommend firstly reading the tutorial on [[Customization]].&lt;br /&gt;
&lt;br /&gt;
== Cahn-Hilliard equation ==&lt;br /&gt;
The Cahn-Hilliard equation describes the separation of binary fluid into pure domains. We define concentration, a scalar field $c(x, y) \in [-1, 1]$ to describe the fluid, with values $c \pm 1$ representing pure phases. In this case the equation can be written as&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\frac{\partial c}{\partial t} = D \nabla^2 (c^3 - c - \gamma \nabla^2 c),&lt;br /&gt;
\]&lt;br /&gt;
where $D$ is the diffusion constant and $\sqrt{\gamma}$ is the characteristic transition length between domains.&lt;br /&gt;
&lt;br /&gt;
We want to avoid any boundary effects and solve the equation for infinite fluid which can be approximated by using periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Periodic boundary conditions ==&lt;br /&gt;
The simplest method of implementing a periodic boundary is adding a band of periodic nodes that mirror values from nodes that lie close to the opposite boundary. We have to create periodic nodes based on locations of interior nodes and construct a mapping that will allow us to update their values based on their interior counterparts. Width of the periodic band should be chosen with support size in mind. Periodic band should be wide enough to include all nodes required to calculate interior values.&lt;br /&gt;
&lt;br /&gt;
[[File:periodicBands.png|center|300px]]&lt;br /&gt;
TODO: node visualization with same colors for periodic nodes, support in corner visualization&lt;br /&gt;
&lt;br /&gt;
We start by creating a square domain centered on 0 and uniformly filling it with nodes. $border$ parameter determines the square size while $dx$, the typical distance between nodes, determines the node density.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
mm::BoxShape&amp;lt;vec_t&amp;gt; box(-border, border);&lt;br /&gt;
mm::DomainDiscretization&amp;lt;vec_t&amp;gt; domain = box.discretizeBoundaryWithStep(dx);&lt;br /&gt;
mm::GeneralFill&amp;lt;vec_t&amp;gt; fill;&lt;br /&gt;
fill.seed(randomSeed);&lt;br /&gt;
domain.fill(fill, dx);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
We need to handle two uncommon terms to solve the equation. Biharmonic ($\nabla^4$) operator can be implemented with custom operators as shown in [[Customization]] example. Nonlinear ($\nabla^2 c^3$) term proves to be more problematic, as it can not be solved implicitly. We either need to solve the entire equation with explicit time stepping or include the nonlinear term in the right hand side of our system of equations.&lt;br /&gt;
&lt;br /&gt;
=== Explicit solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mixed solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Go back to [[Medusa#Examples|Examples]].&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2900</id>
		<title>Cahn-Hilliard equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2900"/>
				<updated>2020-02-07T15:40:23Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Go back to [[Medusa#Examples|Examples]].&lt;br /&gt;
&lt;br /&gt;
In this example we will show how to solve the [https://en.wikipedia.org/wiki/Cahn%E2%80%93Hilliard_equation Cahn-Hilliard] equation in Medusa. The solution provides an implementation of periodic boundary conditions and shows how to combine implicit and explicit operators. This example uses a custom biharmonic operator, so we recommend firstly reading the tutorial on [[Customization]].&lt;br /&gt;
&lt;br /&gt;
== Cahn-Hilliard equation ==&lt;br /&gt;
The Cahn-Hilliard equation describes the separation of binary fluid into pure domains. We define concentration, a scalar field $c(x, y) \in [-1, 1]$ to describe the fluid, with values $c \pm 1$ representing pure phases. In this case the equation can be written as&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\frac{\partial c}{\partial t} = D \nabla^2 (c^3 - c - \gamma \nabla^2 c),&lt;br /&gt;
\]&lt;br /&gt;
where $D$ is the diffusion constant and $\sqrt{\gamma}$ is the characteristic transition length between domains.&lt;br /&gt;
&lt;br /&gt;
We want to avoid any boundary effects and solve the equation for infinite fluid which can be approximated by using periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Periodic boundary conditions ==&lt;br /&gt;
The simplest method of implementing a periodic boundary is adding a band of periodic nodes that mirror values from nodes that lie close to the opposite boundary. We have to create periodic nodes based on locations of interior nodes and construct a mapping that will allow us to update their values based on their interior counterparts. Width of the periodic band should be chosen with support size in mind. Periodic band should be wide enough to include all nodes required to calculate interior values.&lt;br /&gt;
&lt;br /&gt;
TODO: node visualization with same colors for periodic nodes, support in corner visualization&lt;br /&gt;
&lt;br /&gt;
We start by creating a square domain centered on 0 and uniformly filling it with nodes. $border$ parameter determines the square size while $dx$, the typical distance between nodes, determines the node density.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
mm::BoxShape&amp;lt;vec_t&amp;gt; box(-border, border);&lt;br /&gt;
mm::DomainDiscretization&amp;lt;vec_t&amp;gt; domain = box.discretizeBoundaryWithStep(dx);&lt;br /&gt;
mm::GeneralFill&amp;lt;vec_t&amp;gt; fill;&lt;br /&gt;
fill.seed(randomSeed);&lt;br /&gt;
domain.fill(fill, dx);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
We need to handle two uncommon terms to solve the equation. Biharmonic ($\nabla^4$) operator can be implemented with custom operators as shown in [[Customization]] example. Nonlinear ($\nabla^2 c^3$) term proves to be more problematic, as it can not be solved implicitly. We either need to solve the entire equation with explicit time stepping or include the nonlinear term in the right hand side of our system of equations.&lt;br /&gt;
&lt;br /&gt;
=== Explicit solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mixed solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Go back to [[Medusa#Examples|Examples]].&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2899</id>
		<title>Cahn-Hilliard equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2899"/>
				<updated>2020-02-07T13:52:21Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Go back to [[Medusa#Examples|Examples]].&lt;br /&gt;
&lt;br /&gt;
In this example we will show how to solve the [https://en.wikipedia.org/wiki/Cahn%E2%80%93Hilliard_equation Cahn-Hilliard] equation in Medusa. The solution provides an implementation of periodic boundary conditions and shows how to combine implicit and explicit operators. This example uses a custom biharmonic operator, so we recommend firstly reading the tutorial on [[Customization]].&lt;br /&gt;
&lt;br /&gt;
== Cahn-Hilliard equation ==&lt;br /&gt;
The Cahn-Hilliard equation describes the separation of binary fluid into pure domains. We define concentration, a scalar field $c(x, y) \in [-1, 1]$ to describe the fluid, with values $c \pm 1$ representing pure phases. In this case the equation can be written as&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\frac{\partial c}{\partial t} = D \nabla^2 (c^3 - c - \gamma \nabla^2 c),&lt;br /&gt;
\]&lt;br /&gt;
where $D$ is the diffusion constant and $\sqrt{\gamma}$ is the characteristic transition length between domains.&lt;br /&gt;
&lt;br /&gt;
We want to avoid any boundary effects and solve the equation for infinite fluid which can be approximated by using periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Periodic boundary conditions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/// Create the square domain and fill it with nodes.&lt;br /&gt;
typedef mm::Vec&amp;lt;double, dim&amp;gt; vec_t;&lt;br /&gt;
mm::BoxShape&amp;lt;vec_t&amp;gt; box(-border, border);&lt;br /&gt;
mm::DomainDiscretization&amp;lt;vec_t&amp;gt; domain = box.discretizeBoundaryWithStep(dx);&lt;br /&gt;
mm::GeneralFill&amp;lt;vec_t&amp;gt; fill;&lt;br /&gt;
fill.seed(randomSeed);&lt;br /&gt;
domain.fill(fill, dx);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
We need to handle two uncommon terms to solve the equation. Biharmonic ($\nabla^4$) operator can be implemented with custom operators as shown in [[Customization]] example. Nonlinear ($\nabla^2 c^3$) term proves to be more problematic, as it can not be solved implicitly. We either need to solve the entire equation with explicit time stepping or include the nonlinear term in the right hand side of our system of equations.&lt;br /&gt;
&lt;br /&gt;
=== Explicit solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mixed solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Go back to [[Medusa#Examples|Examples]].&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2898</id>
		<title>Cahn-Hilliard equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2898"/>
				<updated>2020-02-07T02:09:07Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Go back to [[Medusa#Examples|Examples]].&lt;br /&gt;
&lt;br /&gt;
In this example we will show how to solve the [https://en.wikipedia.org/wiki/Cahn%E2%80%93Hilliard_equation Cahn-Hilliard] equation in Medusa. The solution provides an implementation of periodic boundary conditions and shows how to combine implicit and explicit operators. This example uses a custom biharmonic operator, so we recommend firstly reading the tutorial on [[Customization]].&lt;br /&gt;
&lt;br /&gt;
== Cahn-Hilliard equation ==&lt;br /&gt;
The Cahn-Hilliard equation describes the separation of binary fluid into pure domains. We define concentration, a scalar field $c(x, y) \in [-1, 1]$ to describe the fluid, with values $c \pm 1$ representing pure phases. In this case the equation can be written as&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\frac{\partial c}{\partial t} = D \nabla^2 (c^3 - c - \gamma \nabla^2 c),&lt;br /&gt;
\]&lt;br /&gt;
where $D$ is the diffusion constant and $\sqrt{\gamma}$ is the characteristic transition length between domains.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Go back to [[Medusa#Examples|Examples]].&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2896</id>
		<title>Cahn-Hilliard equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2896"/>
				<updated>2020-02-07T02:07:55Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: MihaR moved page CahnHilliard equation to Cahn-Hilliard equation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Go back to [[Medusa#Examples|Examples]].&lt;br /&gt;
&lt;br /&gt;
In this example we will show how to solve the [https://en.wikipedia.org/wiki/Cahn%E2%80%93Hilliard_equation Cahn-Hilliard] equation in Medusa. The solution provides an implementation of periodic boundary conditions and shows how to combine implicit and explicit operators. This example uses a custom biharmonic operator, so we recommend firstly reading tutorial on [[Customization]].&lt;br /&gt;
&lt;br /&gt;
== Cahn-Hilliard equation ==&lt;br /&gt;
The Cahn-Hilliard equation describes the separation of binary fluid into pure domains. We define concentration, a scalar field $c(x, y) \in [-1, 1]$ to describe the fluid, with values $c \pm 1$ representing pure phases. In this case the equation can be written as&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\frac{\partial c}{\partial t} = D \nabla^2 (c^3 - c - \gamma \nabla^2 c),&lt;br /&gt;
\]&lt;br /&gt;
where $D$ is the diffusion constant and $\sqrt{\gamma}$ is the characteristic transition length between domains.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Go back to [[Medusa#Examples|Examples]].&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=CahnHilliard_equation&amp;diff=2897</id>
		<title>CahnHilliard equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=CahnHilliard_equation&amp;diff=2897"/>
				<updated>2020-02-07T02:07:55Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: MihaR moved page CahnHilliard equation to Cahn-Hilliard equation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Cahn-Hilliard equation]]&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	<entry>
		<id>https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2895</id>
		<title>Cahn-Hilliard equation</title>
		<link rel="alternate" type="text/html" href="https://e6.ijs.si/medusa/wiki/index.php?title=Cahn-Hilliard_equation&amp;diff=2895"/>
				<updated>2020-02-07T02:05:51Z</updated>
		
		<summary type="html">&lt;p&gt;MihaR: Created page with &amp;quot;Go back to Examples.  In this example we will show how to solve the [https://en.wikipedia.org/wiki/Cahn%E2%80%93Hilliard_equation Cahn-Hilliard] equation i...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Go back to [[Medusa#Examples|Examples]].&lt;br /&gt;
&lt;br /&gt;
In this example we will show how to solve the [https://en.wikipedia.org/wiki/Cahn%E2%80%93Hilliard_equation Cahn-Hilliard] equation in Medusa. The solution provides an implementation of periodic boundary conditions and shows how to combine implicit and explicit operators. This example uses a custom biharmonic operator, so we recommend firstly reading tutorial on [[Customization]].&lt;br /&gt;
&lt;br /&gt;
== Cahn-Hilliard equation ==&lt;br /&gt;
The Cahn-Hilliard equation describes the separation of binary fluid into pure domains. We define concentration, a scalar field $c(x, y) \in [-1, 1]$ to describe the fluid, with values $c \pm 1$ representing pure phases. In this case the equation can be written as&lt;br /&gt;
&lt;br /&gt;
\[&lt;br /&gt;
\frac{\partial c}{\partial t} = D \nabla^2 (c^3 - c - \gamma \nabla^2 c),&lt;br /&gt;
\]&lt;br /&gt;
where $D$ is the diffusion constant and $\sqrt{\gamma}$ is the characteristic transition length between domains.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Go back to [[Medusa#Examples|Examples]].&lt;/div&gt;</summary>
		<author><name>MihaR</name></author>	</entry>

	</feed>