-
Notifications
You must be signed in to change notification settings - Fork 5
/
Compression.cpp
208 lines (171 loc) · 6.88 KB
/
Compression.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/***********************************************************************************
* 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"
#include "InteractionAlt.cpp"
#include "SolverKickDrift.cpp"
#include "SolverVerlet.cpp"
#include "SolverFraser.cpp"
#include "SolverLeapfrog.cpp"
#include "SolverLeapFrog.cpp"
#define TAU 0.005
#define VMAX 10.0
int forcepart_count;
std::ofstream of;
double tout;
void UserAcc(SPH::Domain & domi)
{
double vcompress;
double acc = 7.906e4/(forcepart_count*domi.Particles[0]->Mass);
if (domi.getTime() < TAU )
vcompress = VMAX/TAU * domi.getTime();
else
vcompress = VMAX;
//cout << "time: "<< domi.getTime() << "V compress "<< vcompress <<endl;
#pragma omp parallel for schedule (static) num_threads(domi.Nproc)
#ifdef __GNUC__
for (size_t i=0; i<domi.Particles.Size(); i++)
#else
for (int i=0; i<domi.Particles.Size(); i++)
#endif
{
if (domi.Particles[i]->ID == 3)
{
//domi.Particles[i]->a = Vec3_t(0.0,0.0,0.0);
//domi.Particles[i]->a(2) = -VMAX/TAU;
// domi.Particles[i]->v = Vec3_t(0.0,0.0,-vcompress);
// domi.Particles[i]->va = Vec3_t(0.0,0.0,-vcompress);
// domi.Particles[i]->vb = Vec3_t(0.0,0.0,-vcompress);
domi.Particles[i]->v = Vec3_t(0.0,0.0,-vcompress);
domi.Particles[i]->va = Vec3_t(0.0,0.0,-vcompress);
domi.Particles[i]->vb = Vec3_t(0.0,0.0,-vcompress);
domi.Particles[i]->a = Vec3_t(0.0,0.0,0.0);
// domi.Particles[i]->VXSPH = Vec3_t(0.0,0.0,0.0);
}
if (domi.Particles[i]->ID == 2)
{
domi.Particles[i]->a = Vec3_t(0.0,0.0,0.0);
domi.Particles[i]->v = Vec3_t(0.0,0.0,0.0);
domi.Particles[i]->vb = Vec3_t(0.0,0.0,0.0);
//domi.Particles[i]->VXSPH = Vec3_t(0.0,0.0,0.0);
}
}
double dtout = 1.e-4;
if (domi.getTime()>=tout){
// cout << "Normal integrated force " <<domi.m_scalar_prop<<endl;
// cout << "Normal acc sum " << normal_acc_sum<<endl;
tout += dtout;
of << domi.getTime()<< ", " << domi.max_disp[2]<<", " << domi.contact_force_sum << ", " << ", " <<domi.ext_forces_work<<", " <<domi.plastic_work << ", " <<domi.accum_cont_heat_cond << ", " << domi.contact_friction_work<<endl;
}
}
using std::cout;
using std::endl;
int main(int argc, char **argv) try
{
SPH::Domain dom;
dom.Dimension = 3;
dom.Nproc = 12;
dom.Kernel_Set(Qubic_Spline);
//dom.Kernel_Set(Hyperbolic_Spline);
dom.Scheme = 1; //Mod Verlet
//dom.XSPH = 0.1; //Very important
double dx,h,rho,K,G,Cs,Fy;
double R,L,n;
R = 0.15;
L = 0.56;
n = 30.0; //in length, radius is same distance
rho = 2700.0;
K = 6.7549e10;
G = 2.5902e10;
Fy = 300.e6;
//dx = L / (n-1);
//dx = L/(n-1);
dx = 0.015;
h = dx*1.2; //Very important
Cs = sqrt(K/rho);
double timestep;
timestep = (0.2*h/(Cs));
//timestep = 2.5e-6;
cout<<"t = "<<timestep<<endl;
cout<<"Cs = "<<Cs<<endl;
cout<<"K = "<<K<<endl;
cout<<"G = "<<G<<endl;
cout<<"Fy = "<<Fy<<endl;
dom.GeneralAfter = & UserAcc;
dom.DomMax(0) = L;
dom.DomMin(0) = -L;
dom.Gradient_Approach_Set( 2);
// inline void Domain::AddCylinderLength(int tag, Vec3_t const & V, double Rxy, double Lz,
// double r, double Density, double h, bool Fixed) {
dom.AddCylinderLength(1, Vec3_t(0.,0.,-L/10.0), R, L + 2.*L/10.0, dx/2., rho, h, false);
cout << "Particle count: "<<dom.Particles.Size()<<endl;
forcepart_count = 0;
int bottom_count = 0;
//dom.gradKernelCorr = true;
dom.ts_nb_inc = 5;
for (size_t a=0; a<dom.Particles.Size(); a++)
{
dom.Particles[a]->G = G;
dom.Particles[a]->PresEq = 0;
dom.Particles[a]->Cs = Cs;
dom.Particles[a]->Shepard = false;
dom.Particles[a]->Material = 2;
dom.Particles[a]->Fail = 1;
dom.Particles[a]->Sigmay = Fy;
dom.Particles[a]->Alpha = 1.0;
//dom.Particles[a]->Beta = 1.0;
dom.Particles[a]->TI = 0.3;
dom.Particles[a]->TIInitDist = dx;
double z = dom.Particles[a]->x(2);
//if ( z < -3.0*dx ){
if ( z < 0.0 ){
dom.Particles[a]->ID=2;
// dom.Particles[a]->IsFree=false;
// dom.Particles[a]->NoSlip=true;
bottom_count++;
}
//if ( z > L + 2.*dx ) {//Changed to only last row
if ( z > L ) {//Changed to only last row
dom.Particles[a]->ID=3;
//dom.Particles[a]->XSPH = 0.1;
forcepart_count++;
}
}
cout << "Contact Force Particles: "<<forcepart_count<<endl;
cout << "bottom count "<<bottom_count<<endl;
dom.WriteXDMF("maz");
dom.m_kernel = SPH::iKernel(dom.Dimension,h);
dom.BC.InOutFlow = 0;
of = std::ofstream ("cf.csv", std::ios::out);
of << "Time, disp, cf, ext_f_wk, plastic_wk, heat_cond, friction_wk"<<endl;
tout = 0.;
//dom.Solve_orig_Ext(/*tf*/0.00205,/*dt*/timestep,/*dtOut*/0.001,"test06",999);
//dom.Solve(/*tf*/0.0105,/*dt*/timestep,/*dtOut*/0.0001,"test06",999);
timestep = (0.4*h/(Cs+VMAX));
dom.CFL = 0.4;
//timestep = 2.5e-6;
dom.auto_ts = false;
//dom.SolveDiffUpdateKickDrift(/*tf*/0.105,/*dt*/timestep,/*dtOut*/1.e-4,"test06",10000);
dom.SolveDiffUpdateLeapfrog(/*tf*/0.105,/*dt*/timestep,/*dtOut*/1.e-4,"test06",10000);
//dom.SolveDiffUpdateVerlet(/*tf*/0.105,/*dt*/timestep,/*dtOut*/1.e-4,"test06",10000);
//dom.SolveDiffUpdateFraser(/*tf*/0.105,/*dt*/timestep,/*dtOut*/1.e-4,"test06",10000);
//dom.SolveDiffUpdateFraser(5*timestep,/*dt*/timestep,/*dtOut*/timestep,"test06",10000);
return 0;
}
MECHSYS_CATCH