-
Notifications
You must be signed in to change notification settings - Fork 3
/
4-DamBreak3D.cpp
129 lines (105 loc) · 3.85 KB
/
4-DamBreak3D.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/***********************************************************************************
* PersianSPH - A C++ library to simulate Mechanical Systems (solids, fluids *
* and soils) using Smoothed Particle Hydrodynamics method *
* Copyright (C) 2013 Maziar Gholami Korzani and Sergio Galindo-Torres *
* *
* This file is part of PersianSPH *
* *
* This 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. *
* *
* You should have received a copy of the GNU General Public License along with *
* PersianSPH; if not, see <http://www.gnu.org/licenses/> *
************************************************************************************/
#include "Domain.h"
int main(int argc, char **argv) try
{
SPH::Domain dom;
dom.Dimension = 3;
dom.Nproc = 8;
dom.Scheme = 0;
dom.Viscosity_Eq_Set(Morris);
dom.Kernel_Set(Qubic_Spline);
dom.Gradient_Approach_Set(Squared_density);
double xb,yb,zb,dx,Cs,h,Rho,H,L,TL,TH,t,res,Mu,g,TW,W;
H = 0.5;
L = H;
TH = 1.25*H;
TL = 1.5*H;
W = H/2.0;
TW = H;
res = 40.0;
g = 9.81;
Rho = 998.21;
Mu = 1.002e-3;
dx = H/res;
h = dx*1.2;
Cs = 10.0 * sqrt(g*H);
t = (0.2*h/Cs);
dom.InitialDist = dx;
dom.Gravity = 0.0, -g ,0.0 ;
dom.AddBoxLength(1 ,Vec3_t ( -3.0*dx , -3.0*dx , -3.0*dx ), 7.0*dx + TL + dx/10.0 , 3.0*dx + TH + dx/10.0, 6.0*dx + TW + dx/10.0 , dx/2.0 ,Rho, h, 1 , 0 , false, false );
for (size_t a=0; a<dom.Particles.Size(); a++)
{
xb=dom.Particles[a]->x(0);
yb=dom.Particles[a]->x(1);
zb=dom.Particles[a]->x(2);
dom.Particles[a]->Cs = Cs;
dom.Particles[a]->PresEq = 1;
dom.Particles[a]->Mu = Mu;
dom.Particles[a]->MuRef = Mu;
dom.Particles[a]->Material= 1;
dom.Particles[a]->Shepard = true;
if (xb<0.0)
{
dom.Particles[a]->ID = 2;
dom.Particles[a]->IsFree = false;
dom.Particles[a]->NoSlip = true;
}
if (yb<0.0)
{
dom.Particles[a]->ID = 2;
dom.Particles[a]->IsFree = false;
dom.Particles[a]->NoSlip = true;
}
if (zb<0.0)
{
dom.Particles[a]->ID = 2;
dom.Particles[a]->IsFree = false;
dom.Particles[a]->NoSlip = true;
}
if (xb>TL)
{
dom.Particles[a]->ID = 2;
dom.Particles[a]->IsFree = false;
dom.Particles[a]->NoSlip = true;
}
if (zb>TW)
{
dom.Particles[a]->ID = 2;
dom.Particles[a]->IsFree = false;
dom.Particles[a]->NoSlip = true;
}
if (yb>H && dom.Particles[a]->ID==1)
dom.Particles[a]->ID=11;
if (xb>L && dom.Particles[a]->ID==1)
dom.Particles[a]->ID=11;
if (zb>W && dom.Particles[a]->ID==1)
dom.Particles[a]->ID=11;
if (dom.Particles[a]->ID==1)
{
dom.Particles[a]->Density = Rho*pow((1+7.0*g*(H-yb)/(Cs*Cs)),(1.0/7.0));
dom.Particles[a]->Densityb = Rho*pow((1+7.0*g*(H-yb)/(Cs*Cs)),(1.0/7.0));
}
}
dom.DelParticles(11);
dom.Solve(/*tf*/50.0,/*dt*/t,/*dtOut*/0.05,"test06",999);
return 0;
}
MECHSYS_CATCH