Commit 75aeeff0 authored by Radek Fučík's avatar Radek Fučík
Browse files

initial commit

	modified:   README.md
	new file:   core.h
	new file:   core.hpp
	new file:   d1q3.h
	new file:   d2q5.h
	new file:   d2q9.h
	new file:   d3q27.h
	new file:   d3q7.h
	new file:   defs.h
	new file:   defs.hpp
	new file:   export_latex
	new file:   export_latex.cpp
	new file:   export_latex_compare
	new file:   export_latex_compare.cpp
	new file:   lbm.h
	new file:   lbmat
	new file:   lbmat.cpp
	new file:   script_backsubst_searcher.py
	new file:   script_backsubst_searcher_all.sh
	new file:   simplify
	new file:   simplify.cpp
	new file:   tpde.h
	new file:   tpde.hpp
parent 035d8cd1
Loading
Loading
Loading
Loading

Makefile

0 → 100644
+27 −0
Original line number Diff line number Diff line
defaults: lbmat simplify export_latex export_latex_compare

CXXFLAGS=-O2 -I. -std=c++11
LIBS=-lm -lginac 

DEPS = *.h *.hpp

lbmat: $(DEPS) lbmat.cpp
	$(CXX) $(CXXFLAGS) lbmat.cpp -o lbmat  $(LIBS) 

simplify: $(DEPS) simplify.cpp
	$(CXX) $(CXXFLAGS) simplify.cpp -o simplify  $(LIBS)

export_latex: $(DEPS) export_latex.cpp
	$(CXX) $(CXXFLAGS) export_latex.cpp -o export_latex  $(LIBS)

export_latex_compare: $(DEPS) export_latex_compare.cpp
	$(CXX) $(CXXFLAGS) export_latex_compare.cpp -o export_latex_compare  $(LIBS)

clean:
	@rm -rf export_latex
	@rm -rf export_latex_compare
	@rm -rf lbmat
	@rm -rf simplify
	@rm -rf *.o
	@rm -rf *.d
+41 −1
Original line number Diff line number Diff line
# lbmat
```
 .----------------.  .----------------.  .----------------.  .----------------.  .----------------. 
| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
| |   _____      | || |   ______     | || | ____    ____ | || |      __      | || |  _________   | |
| |  |_   _|     | || |  |_   _ \    | || ||_   \  /   _|| || |     /  \     | || | |  _   _  |  | |
| |    | |       | || |    | |_) |   | || |  |   \/   |  | || |    / /\ \    | || | |_/ | | \_|  | |
| |    | |   _   | || |    |  __'.   | || |  | |\  /| |  | || |   / ____ \   | || |     | |      | |
| |   _| |__/ |  | || |   _| |__) |  | || | _| |_\/_| |_ | || | _/ /    \ \_ | || |    _| |_     | |
| |  |________|  | || |  |_______/   | || ||_____||_____|| || ||____|  |____|| || |   |_____|    | |
| |              | || |              | || |              | || |              | || |              | |
| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |
 '----------------'  '----------------'  '----------------'  '----------------'  '----------------' 
```

# Lattice Boltzmann Method Analysis Tool

 https://mmg-gitlab.fjfi.cvut.cz/gitlab/lbm/lbmat

 Developped by:
* Radek Fučík (fucik@fjfi.cvut.cz) FNSPE CTU in Prague, Czech Republic
* Robert Straka (straka@metal.agh.edu.pl) AGH Krakow, Poland
* Jakub Klinkovský (klinkovsky@mmg.fjfi.cvut.cz) FNSPE CTU in Prague, Czech Republic
* Pavel Eichler (eichlpa1@fjfi.cvut.cz) FNSPE CTU in Prague, Czech Republic
* Tomáš Oberhuber (oberhuber.tomas@fjfi.cvut.cz) FNSPE CTU in Prague, Czech Republic

 Read and cite: <br/>
* Radek Fučík, Pavel Eichler, Jakub Klinkovský, Robert Straka and Tomáš Oberhuber: <i>Lattice Boltzmann Method Analysis Tool (LBMAT)</i> in review in Elsevier Computers & Mathematics with Applications

* Radek Fučík and Robert Straka: <i>Equivalent finite difference and partial differential equations for the lattice Boltzmann method</i>, Elsevier Computers & Mathematics with Applications, vol. 90, 2021, 96-103 
 https://doi.org/10.1016/j.camwa.2021.03.014

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 https://www.gnu.org/licenses/

core.h

0 → 100644
+58 −0
Original line number Diff line number Diff line
// Lattice Boltzmann Method Analysis Tool
// https://mmg-gitlab.fjfi.cvut.cz/gitlab/lbm/lbmat

#pragma once

#include "defs.h"
#include "lbm.h"
#include "tpde.h"

template< typename LBM_TYPE >
struct CORE : BASE
{
	using LBM=LBM_TYPE;
	LBM lbm;

	const int MAXO=5;	// maximal time order to deal with, increase this if you need more than that
	int ORDER=4;		// Taylor order
	int MFCO=4;		// maximal factors common order for TPDE 
	int verbosity=0;
	// link to lbm
	int Q=0, D=0;
	bool use_symbolic_coefs=false; // use symbolic coefficients for abs_rhs to save memory

	FUN fun;

	int dump_lst_count=0;
	int subs_lst_level=0;

	// virtualize for non-matrix LBMs!!! (such as CuLBM...)
	virtual void assemble_pdes(TPDE *pde);

	bool find_lowest_time_derivative(TPDE &expression, int basindex, int order, int& kt, int& kx, int& ky, int&kz);

	void subs_time_derivatives_up_to_order(TPDE &expr, int basindex, TPDE *ders, int max_order);
	void eliminate_all_spatial_orders_for_given_time_order(int basindex, int time_order, TPDE *ders);
	void eliminate_all_spatial_orders_for_given_time_order(TPDE &target, int basindex, int time_order, TPDE &source);
	void replace_time_derivative(TPDE &target, int bj, int time_order, TPDE &derivative);

	void eliminate_higher_raw_moments(vct& bas, TPDE *pde, TPDE*abs_rhs, int offset);

	// Algorithm 1
	void gauss_eliminate_derivatives_on_diagonal(int bi, vct& bas, TPDE*abs_rhs, int index_offset);
	void gauss_eliminate_derivatives_below_diagonal(int bi, vct& bas, TPDE*abs_rhs, int index_offset);
	void gauss_eliminate_derivatives_above_diagonal(int bi, vct& bas, TPDE*abs_rhs, int index_offset);
	void gauss_eliminate_coefs_on_diagonal(int bi, vct& bas, TPDE*abs_rhs, int index_offset);
	void gauss_eliminate_coefs_below_diagonal(int bi, vct& bas, TPDE*abs_rhs, int index_offset);
	void gauss_eliminate_coefs_above_diagonal(int bi, vct& bas, TPDE*abs_rhs, int index_offset);

	// Algorithm 2
	void compute_NSE();
	void compute_ADE();

	void compute_all();

	CORE();
};

#include "core.hpp"

core.hpp

0 → 100644
+835 −0

File added.

Preview size limit exceeded, changes collapsed.

d1q3.h

0 → 100644
+90 −0
Original line number Diff line number Diff line
#pragma once
#include "lbm.h"

template< typename MM>
struct D1Q3 : LBM<MM>
{
	static constexpr const char* id = "d1q3";
	void setC(matrix &C)
	{
		C = matrix(1, 3);
		int maxima_matrix[1][3] = {
			{0,	1,	-1}
		};
		for (int i=0;i<1;i++)
		for (int j=0;j<3;j++)
			C(i,j) = (ex)(maxima_matrix[i][j]);
	}
	D1Q3() : LBM<MM>(3) {}
};

struct D1Q3_M1
{
	static constexpr const char* id = "M1";
	static void setM(matrix &M, matrix &C)
	{
		const int Q=3,D=1;
		M = matrix(Q, Q);
		for (int j=0;j<Q;j++)
		{
			M(0,j) = (ex)1;
			for (int d=0;d<D;d++) M(d+1,j) = C(d,j);
			M(2,j) = pow(C(0,j), 2);
		}
	}
	static ex get_moments_eq(int q, FUN& fun, ex sym_cs, matrix &C)
	{
		if (q==0) return fun.rho;
		if (q==1) return fun.rho*fun.vel[0];
		if (q==2) return fun.rho*(fun.vel[0]*fun.vel[0] + sym_cs*sym_cs);
		return 0;
	}
};

template< typename MM>
struct D1Q3_SRT : D1Q3<MM>
{
	static constexpr const char* id_col = "srt";
	using LBM<MM>::Q;

	virtual void setA(matrix &A, ex& u, ex&v, ex&w)
	{
		A = matrix(Q, Q);
		for (int i=0;i<Q;i++)
		for (int j=0;j<Q;j++)
			A(i,j) = (i==j) ? (ex)LBM<MM>::sym_o : (ex)0;
	}

};

template< typename MM>
struct D1Q3_MRT1 : D1Q3<MM>
{
	static constexpr const char* id_col = "mrt1";
	virtual void setM(matrix &M, matrix &C)
	{
		D1Q3_M1::setM(M,C);
	}
	virtual void setA(matrix &A, ex& u, ex&v, ex&w)
	{
		matrix S,M;
		LBM<MM>::setS(S);
	        LBM<MM>::setM(M);
	        matrix Mi = inverse(M);
	        A = Mi.mul(S).mul(M);
	}
};

template< typename MM>
struct D1Q3_CLBM1 : D1Q3_MRT1<MM>
{
	static constexpr const char* id_col = "clbm1";
	virtual void setA(matrix &A, ex& u, ex&v, ex&w)
	{
		matrix S,K;
		LBM<MM>::setS(S);
		LBM<MM>::setK(K, u, v, w);
		matrix Ki = inverse(K);
		A = Ki.mul(S).mul(K);
	}
};
Loading