forked from TJFord/iblb2d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclassFluidConcept.cpp
107 lines (97 loc) · 2.48 KB
/
classFluidConcept.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
class LB
{
int lx,ly;//bounding box
int *IJidx;//semi direct address index
int *nbList;//neighbor list
int nf; // total fluid nodes
double *f;//density distribution
int *coor;
Units *pUnits;
double omega; // relaxation = 1/tau;
static const int d;//dimension
static const int q;//discrete velocity component
static const double cs2; // square of sound speed
static const int c[9][2]; //velocity vector
static const double w[9];// weight factor
int nbc;//number of boundary conditions
Dynamics *pBC;
collType collisionFun;
int nv,no,nb;//number of velocity, open boundaries;
velData *pVel;
bbData *pBB;
openData *pOpen;
public:
//creator
LB();
~LB();
LB& operator=(const LB& rhs);
void readInput(const std::string filename); //only read nn, nlist, etc.
// manipulator
void init();//initialize density with 0 velocity
void stream();
void collide();
void streamSwap();
void collideSwap();
void applyBC();
//void applyForce(int id, double fx, double fy);
void bgk(int id, void* selfData);
double computeEquilibrium(int idx, double rho,double ux, double uy,double uSqr);
// accessor
void computeMacros(int id, double *rho, double * ux, double *uy);
void output(const std::string out);
void printInfor();
};
class Solid
{
double *x;
double *v;
double *a;
double *x0;
double *force;
double xc[3];//center position for periodic BC
int nn, nb, na;
public:
virtual void readInput(const std::string filename)=0;
virtual void computeForce()=0;
virtual void init()=0;
virtual void nondimension(const Units&);
virtual void updateHalf()=0;
virtual void update()=0;
}
class IBM
{
Fluid *pFluid;
Solid *pSolid;
public:
void interpret(pFluid, pSolid, *velocity){
for i in pSolid.node
x1 = x(i)-1:x(i)+1;
y1 = y(i)-1:y(i)+1;
computeMacros(IJidx(x1,y1),rho, ux,uy);
pSolid->ux[i] += ux*weight;
pSolid->uy[i] += uy*weight;
}
void spread(pFluid, pSolid){
for i in pSolid.node
x1 = x(i)-1:x(i)+1;
y1 = y(i)-1:y(i)+1;
pFluid->force_x[IJidx(x1,y1)] += pSolid->force[x]*weight;
pFluid->force_y[IJidx(x1,y1)] += pSolid->force[y]*weight;
}
void ph1();
void ph2();
void ph3();
}
main()
{
int ts;
IBM ibm;
ibm.pFluid->readInput();
ibm.pSolid->readInput();
for (int i=0;i<ts;i++)
{
ibm.interpret()
if (i%tsave == 0)
saveResults();
}
}