Commit be2e3215 authored by foggia's avatar foggia

testing average in parallel

parent 807a2f80
......@@ -42,6 +42,7 @@
#include "FiniteDifference/eq.hpp"
#include "Solvers/petsc_solver.hpp"
#include "Solvers/petsc_solver.hpp"
#include "FiniteDifference/operators.hpp"
struct lid_nn
{
......@@ -111,14 +112,6 @@ const bool lid_nn::boundary[] = {NON_PERIODIC,NON_PERIODIC};
//! \cond [def equation] \endcond
// Constant Field
struct eta
{
typedef void const_field;
static float val() {return 1.0;}
};
// Convenient constants
constexpr unsigned int v[] = {0,1};
constexpr unsigned int P = 2;
......@@ -126,31 +119,6 @@ constexpr unsigned int ic = 2;
constexpr int x = 0;
constexpr int y = 1;
// Create field that we have v_x, v_y, P
typedef Field<v[x],lid_nn> v_x; // Definition 1 v_x
typedef Field<v[y],lid_nn> v_y; // Definition 2 v_y
typedef Field<P,lid_nn> Prs; // Definition 3 Prs
// Eq1 V_x
typedef mul<eta,Lap<v_x,lid_nn>,lid_nn> eta_lap_vx; // Step 1
typedef D<x,Prs,lid_nn> p_x; // Step 2
typedef minus<p_x,lid_nn> m_p_x; // Step 3
typedef sum<eta_lap_vx,m_p_x,lid_nn> vx_eq; // Step 4
// Eq2 V_y
typedef mul<eta,Lap<v_y,lid_nn>,lid_nn> eta_lap_vy;
typedef D<y,Prs,lid_nn> p_y;
typedef minus<p_y,lid_nn> m_p_y;
typedef sum<eta_lap_vy,m_p_y,lid_nn> vy_eq;
// Eq3 Incompressibility
typedef D<x,v_x,lid_nn,FORWARD> dx_vx; // Step 5
typedef D<y,v_y,lid_nn,FORWARD> dy_vy; // Step 6
typedef sum<dx_vx,dy_vy,lid_nn> ic_eq; // Step 7
//! \cond [def equation] \endcond
/*!
......@@ -187,15 +155,6 @@ typedef sum<dx_vx,dy_vy,lid_nn> ic_eq; // Step 7
//! \cond [bond def eq] \endcond
// Equation for boundary conditions
// Directional Avg
typedef Avg<x,v_y,lid_nn> avg_vy;
typedef Avg<y,v_x,lid_nn> avg_vx;
typedef Avg<x,v_y,lid_nn,FORWARD> avg_vy_f;
typedef Avg<y,v_x,lid_nn,FORWARD> avg_vx_f;
// Usefull constants (as MACRO)
#define EQ_1 0
#define EQ_2 1
......@@ -232,6 +191,40 @@ int main(int argc, char* argv[])
// Initialize
openfpm_init(&argc,&argv);
// Names for the positions in cell
std::initializer_list<char> cc = {0,0};
std::initializer_list<char> ll = {0,-1};
std::initializer_list<char> bl = {-1,-1};
std::initializer_list<char> bb = {-1,0};
//! \cond [def equation] \endcond
// Create field that we have v_x, v_y, P
Field<v[x],lid_nn> v_x{ll}; // Definition 1 v_x
Field<v[y],lid_nn> v_y{bb}; // Definition 2 v_y
Field<P,lid_nn> Prs{cc}; // Definition 3 Prs
coeff<double,lid_nn> eta{1.0,bl}; // Coefficient
// Create the derivatives and Laplacians that are needed
Laplacian<lid_nn,CENTRAL> lap;
Der<x,lid_nn,CENTRAL> dx;
Der<y,lid_nn,CENTRAL> dy;
Der<x,lid_nn,FORWARD> dx_f;
Der<y,lid_nn,FORWARD> dy_f;
// Equations
auto vx_eq = eta*lap(v_x) - dx(Prs); // Eq1 V_x
auto vy_eq = eta*lap(v_y) - dy(Prs); // Eq2 V_y
auto ic_eq = dx_f(v_x) + dy_f(v_y); // Eq3 Incom
Avg<x,decltype(v_y)> avg_vy{v_y};
Avg<y,decltype(v_x)> avg_vx{v_x};
Avg<x,decltype(v_y),FORWARD> avg_vy_f{v_y};
Avg<y,decltype(v_x),FORWARD> avg_vx_f{v_x};
//! \cond [def equation] \endcond
// velocity in the grid is the property 0, pressure is the property 1
constexpr int velocity = 0;
constexpr int pressure = 1;
......@@ -324,27 +317,27 @@ int main(int argc, char* argv[])
//! \cond [impose eq dom] \endcond
fd.impose(ic_eq(),0.0, EQ_3, {0,0},{sz[0]-2,sz[1]-2},true);
fd.impose(Prs(), 0.0, EQ_3, {0,0},{0,0});
fd.impose<EQ_3>(ic_eq,0.0,{0,0},{sz[0]-2,sz[1]-2},cc,true);
fd.impose<EQ_3>(Prs,0.0,{0,0},{0,0},cc);
// Here we impose the Eq1 and Eq2
fd.impose(vx_eq(),0.0, EQ_1, {1,0},{sz[0]-2,sz[1]-2});
fd.impose(vy_eq(),0.0, EQ_2, {0,1},{sz[0]-2,sz[1]-2});
fd.impose<EQ_1>(vx_eq,0.0,{1,0},{sz[0]-2,sz[1]-2},ll);
fd.impose<EQ_2>(vy_eq,0.0,{0,1},{sz[0]-2,sz[1]-2},bb);
// v_x and v_y
// Imposing B1
fd.impose(v_x(),0.0, EQ_1, {0,0},{0,sz[1]-2});
fd.impose(avg_vy_f(),0.0, EQ_2 , {-1,0},{-1,sz[1]-1});
fd.impose<EQ_1>(v_x,0.0,{0,0},{0,sz[1]-2},ll);
fd.impose<EQ_2>(avg_vy_f,0.0,{-1,0},{-1,sz[1]-1},bb);
// Imposing B2
fd.impose(v_x(),0.0, EQ_1, {sz[0]-1,0},{sz[0]-1,sz[1]-2});
fd.impose(avg_vy(),1.0, EQ_2, {sz[0]-1,0},{sz[0]-1,sz[1]-1});
fd.impose<EQ_1>(v_x,0.0,{sz[0]-1,0},{sz[0]-1,sz[1]-2},ll);
fd.impose<EQ_2>(avg_vy,1.0,{sz[0]-1,0},{sz[0]-1,sz[1]-1},bb);
// Imposing B3
fd.impose(avg_vx_f(),0.0, EQ_1, {0,-1},{sz[0]-1,-1});
fd.impose(v_y(), 0.0, EQ_2, {0,0},{sz[0]-2,0});
fd.impose<EQ_1>(avg_vx_f,0.0,{0,-1},{sz[0]-1,-1},ll);
fd.impose<EQ_2>(v_y,0.0,{0,0},{sz[0]-2,0},bb);
// Imposing B4
fd.impose(avg_vx(),0.0, EQ_1, {0,sz[1]-1},{sz[0]-1,sz[1]-1});
fd.impose(v_y(), 0.0, EQ_2, {0,sz[1]-1},{sz[0]-2,sz[1]-1});
fd.impose<EQ_1>(avg_vx,0.0,{0,sz[1]-1},{sz[0]-1,sz[1]-1},ll);
fd.impose<EQ_2>(v_y,0.0,{0,sz[1]-1},{sz[0]-2,sz[1]-1},bb);
// When we pad the grid, there are points of the grid that are not
// touched by the previous condition. Mathematically this lead
......@@ -353,14 +346,14 @@ int main(int argc, char* argv[])
//
// Padding pressure
fd.impose(Prs(), 0.0, EQ_3, {-1,-1},{sz[0]-1,-1});
fd.impose(Prs(), 0.0, EQ_3, {-1,sz[1]-1},{sz[0]-1,sz[1]-1});
fd.impose(Prs(), 0.0, EQ_3, {-1,0},{-1,sz[1]-2});
fd.impose(Prs(), 0.0, EQ_3, {sz[0]-1,0},{sz[0]-1,sz[1]-2});
fd.impose<EQ_3>(Prs,0.0,{-1,-1},{sz[0]-1,-1},cc);
fd.impose<EQ_3>(Prs,0.0,{-1,sz[1]-1},{sz[0]-1,sz[1]-1},cc);
fd.impose<EQ_3>(Prs,0.0,{-1,0},{-1,sz[1]-2},cc);
fd.impose<EQ_3>(Prs,0.0,{sz[0]-1,0},{sz[0]-1,sz[1]-2},cc);
// Impose v_x Padding Impose v_y padding
fd.impose(v_x(), 0.0, EQ_1, {-1,-1},{-1,sz[1]-1});
fd.impose(v_y(), 0.0, EQ_2, {-1,-1},{sz[0]-1,-1});
fd.impose<EQ_1>(v_x,0.0,{-1,-1},{-1,sz[1]-1},cc);
fd.impose<EQ_2>(v_y,0.0,{-1,-1},{sz[0]-1,-1},cc);
//! \cond [impose eq dom] \endcond
......
Subproject commit 761522af3952e282fc05ebefa7702bc9cf64e2a5
Subproject commit 3017eaf926c3b502f87873e26275c508277f5f2e
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment