3 #include "../include/Draw.h" 8 for(
int d=0;d<3;d++) Dr->
Edge[d] =
pEdge(d);
12 Dr->
xa = -60.;Dr->ya = -00.;Dr->za = -38.;
13 Dr->
xf = 160.;Dr->yf = -25.;Dr->zf = 0.;
14 Dr->
xi = -.4;Dr->yi = -.4;Dr->zi = 0.;
15 for(
int n=0;n<
pNNano();n++){
27 void ParticleRealTime(){
29 Dr->
OpenImage(
"RadDistrNanoR1_0H0_4h32_0.tif");
31 glRasterPos3d(-.35,-.4,-.32);
33 glDrawPixels(Dr->
ImWidth,Dr->ImHeight,GL_RGBA,GL_UNSIGNED_BYTE,Dr->
pixel);
36 void reshape(
int w,
int h){
42 void MouseMove(
int x,
int y){
45 void mouse(
int button,
int state,
int x,
int y){
46 Dr->
Dmouse(button,state,x,y);
48 void special(
int k,
int x,
int y){
60 Dr->tDiap=glutGet(GLUT_ELAPSED_TIME);
62 double fps = Dr->
Diap*1000.0/(Dr->tDiap-Dr->tDiapBase);
65 if (Dr->tDiap - Dr->tDiapBase > 1000) {
66 fprintf(stderr,
"Frame per second %lf\r",fps);
67 Dr->tDiapBase = Dr->tDiap;
70 if(Dr->tDiap - Dr->tDiapBase > 1000/Speed){
82 CurrTime = time(NULL);
83 Ratio += Dr->
Step/(1000.*(CurrTime-InitTime));
86 for(
int p=0;p<
pNPart();p++){
94 glutTimerFunc(1000, Timer, 1);
98 if(!VAR_IF_TYPE(
SysShape,SYS_ELECTRO)){
101 glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
102 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
103 glEnable(GL_DEPTH_TEST);
105 glEnable(GL_LIGHTING);
108 double InvNBin = 1./(double)NBin;
115 for(
int sx=0;sx<NBin-1;sx++){
116 for(
int sy=0;sy<NBin-1;sy++){
117 v1.
x[0] = sx*
pEdge(0)*InvNBin;
118 v2.
x[0] = (sx+1)*
pEdge(0)*InvNBin;
119 v3.
x[0] = (sx+1)*
pEdge(0)*InvNBin;
120 v4.
x[0] = (sx)*
pEdge(0)*InvNBin;
121 v1.
x[1] = sy*
pEdge(1)*InvNBin;
122 v2.
x[1] = (sy)*
pEdge(1)*InvNBin;
123 v3.
x[1] = (sy+1)*
pEdge(1)*InvNBin;
124 v4.
x[1] = (sy+1)*
pEdge(1)*InvNBin;
129 for(
int d=0;d<3;d++){
130 v1.
x[d] *= InvScaleUn;
131 v2.
x[d] *= InvScaleUn;
132 v3.
x[d] *= InvScaleUn;
133 v4.
x[d] *= InvScaleUn;
135 glColor4fv(ColorType[Typ]);
136 glLightfv(GL_LIGHT0, GL_AMBIENT,ColorType[Typ]);
137 glLightfv(GL_LIGHT1, GL_DIFFUSE,ColorType[Typ]);
138 glLightfv(GL_LIGHT1, GL_POSITION,ColorType[Typ]);
143 glNormal3f(vN.
x[0],vN.
x[1],vN.
x[2]);
144 glVertex3d(v1.
x[0],v1.
x[1],v1.
x[2]);
146 glNormal3f(vN.
x[0],vN.
x[1],vN.
x[2]);
147 glVertex3d(v2.x[0],v2.x[1],v2.x[2]);
149 glNormal3f(vN.
x[0],vN.
x[1],vN.
x[2]);
150 glVertex3d(v3.x[0],v3.x[1],v3.x[2]);
152 glNormal3f(vN.
x[0],vN.
x[1],vN.
x[2]);
153 glVertex3d(v4.x[0],v4.x[1],v4.x[2]);
158 glDisable(GL_DEPTH_TEST);
159 glDisable(GL_LIGHT1);
160 glDisable(GL_LIGHTING);
173 glEnable(GL_LIGHTING);
181 for(
int sx=0;sx<
nEdge[0]-1;sx++){
182 for(
int sy=0;sy<nEdge[1]-1;sy++){
183 int pRight[3] = {sx*nEdge[1]+sy,(sx+1)*nEdge[1]+sy,(sx+1)*nEdge[1]+sy+1};
184 for(
int d=0;d<3;d++){
185 v1.
x[d] =
pPos(pRight[0],d)*InvScaleUn;
186 v2.
x[d] =
pPos(pRight[1],d)*InvScaleUn;
187 v3.
x[d] =
pPos(pRight[2],d)*InvScaleUn;
190 glColor4fv(ColorType[Typ]);
191 glLightfv(GL_LIGHT0, GL_AMBIENT,ColorType[Typ]);
192 glLightfv(GL_LIGHT1, GL_DIFFUSE,ColorType[Typ]);
195 vN.
x[0] = v1.
x[1]*v2.
x[2] - v1.
x[2]*v2.
x[1];
196 vN.
x[1] = v1.
x[2]*v2.
x[0] - v1.
x[0]*v2.
x[2];
197 vN.
x[2] = v1.
x[0]*v2.
x[1] - v1.
x[1]*v2.
x[0];
201 glBegin(GL_TRIANGLES);
202 glNormal3f(vN.
x[0],vN.
x[1],vN.
x[2]);
203 glVertex3d(v1.
x[0],v1.
x[1],v1.
x[2]);
204 glVertex3d(v2.
x[0],v2.
x[1],v2.
x[2]);
205 glVertex3d(v3.
x[0],v3.
x[1],v3.
x[2]);
209 for(
int d=0;d<3;d++){
210 v1.
x[d] =
pPos(pLeft[0],d)*InvScaleUn;
211 v2.
x[d] =
pPos(pLeft[1],d)*InvScaleUn;
212 v3.
x[d] =
pPos(pLeft[2],d)*InvScaleUn;
214 vN.
x[0] = v1.
x[1]*v2.
x[2] - v1.
x[2]*v2.
x[1];
215 vN.
x[1] = v1.
x[2]*v2.
x[0] - v1.
x[0]*v2.
x[2];
216 vN.
x[2] = v1.
x[0]*v2.
x[1] - v1.
x[1]*v2.
x[0];
221 glBegin(GL_TRIANGLES);
222 glNormal3f(vN.
x[0],vN.
x[1],vN.
x[2]);
223 glVertex3d(v1.
x[0],v1.
x[1],v1.
x[2]);
224 glVertex3d(v2.
x[0],v2.
x[1],v2.
x[2]);
225 glVertex3d(v3.
x[0],v3.
x[1],v3.
x[2]);
235 double Diameter = .01;
239 glDisable(GL_LIGHTING);
242 for(
int p=0,link=0;p<
pNPart();p++){
245 glColor4f(Red*ColorType[Typ][0],ColorType[Typ][1],ColorType[Typ][2],1.);
252 glTranslatef((GLfloat)(
pPos(p,0)*InvScaleUn),
253 (GLfloat)(
pPos(p,1)*InvScaleUn),
254 (GLfloat)(
pPos(p,2)*InvScaleUn));
257 glColor4fv(ColorType[Typ]);
259 else glutSolidSphere(Diameter,20,20);
263 if(VAR_IF_TYPE(
SysShape,SYS_LEAVES)){
265 glColor4f(.7,.7,.0,1.);
267 glVertex3f(0.,.5,.6);
268 glVertex3f(1.,.5,.6);
271 glVertex3f(0.,.5,.4);
272 glVertex3f(1.,.5,.4);
275 glVertex3f((GLfloat)(
pPos(0,0)*InvScaleUn),
276 (GLfloat)(
pPos(0,1)*InvScaleUn),
277 (GLfloat)(
pPos(0,2)*InvScaleUn));
278 glVertex3f((GLfloat)(
pPos(
NEdge-1,0)*InvScaleUn),
283 glVertex3f((GLfloat)(
Pm[
NEdge].Pos[0]*InvScaleUn),
284 (GLfloat)(
Pm[
NEdge].Pos[1]*InvScaleUn),
285 (GLfloat)(
Pm[
NEdge].Pos[2]*InvScaleUn));
286 glVertex3f((GLfloat)(
Pm[2*
NEdge-1].Pos[0]*InvScaleUn),
287 (GLfloat)(
Pm[2*
NEdge-1].Pos[1]*InvScaleUn),
288 (GLfloat)(
Pm[2*
NEdge-1].Pos[2]*InvScaleUn));
293 for(
int p=0;p<
NShow-1;p++){
295 if(
Pl[p].Idx ==
NEdge-2)
continue;
297 glColor4f(1.,.0,.0,1.);
300 glVertex3f((GLfloat)(
Pl[p].Pos[0]*InvScaleUn),
301 (GLfloat)(
Pl[p].Pos[1]*InvScaleUn),
302 (GLfloat)(
Pl[p].Pos[2]*InvScaleUn));
303 glVertex3f((GLfloat)(
Pl[p+1].Pos[0]*InvScaleUn),
304 (GLfloat)(
Pl[p+1].Pos[1]*InvScaleUn),
305 (GLfloat)(
Pl[p+1].Pos[2]*InvScaleUn));
322 glDisable(GL_LIGHTING);
323 for(
int l=0;l<
Ln[p].
NLink;l++){
325 double Pos[3] = {
pPos(link,0),
pPos(link,1),
pPos(link,2)};
328 for(
int d=0;d<3;d++){
330 if(fabs(Bf) > 0. & !PeriodicImage[d]) IfContinue = 0;
332 Mid[d] = .5*(
pPos(p,d)+Pos[d])*InvScaleUn;
337 glColor4fv(ColorType[
pType(p)]);
338 glVertex3d((
pPos(p,0)*InvScaleUn),
339 (
pPos(p,1)*InvScaleUn),
340 (
pPos(p,2)*InvScaleUn));
341 glVertex3d(Mid[0],Mid[1],Mid[2]);
342 glColor4fv(ColorType[
pType(link)]);
343 glVertex3d(Mid[0],Mid[1],Mid[2]);
344 glVertex3d(((Pos[0])*InvScaleUn),
345 ((Pos[1])*InvScaleUn),
346 ((Pos[2])*InvScaleUn));
352 glDisable(GL_LIGHTING);
353 for(
int n=0;n<
pNNano();n++){
354 if(
Nano[n].Shape == 0)
continue;
357 double Angle = Zed.
Angle(&Ax,&Zed);
364 glColor4f( 1.,.1,.1,1.);
365 if(VAR_IF_TYPE(
Nano[n].Shape,SHAPE_SPH)){
366 glutSolidSphere(
Nano[n].Rad,20,20);
368 else if(VAR_IF_TYPE(
Nano[n].Shape,SHAPE_CYL)){
376 glutAddMenuEntry(
"SottoPrima",3);
379 glutAddMenuEntry(
"Move",1);
380 glutAddMenuEntry(
"Stop",2);
381 glutAddSubMenu(
"Altro",submenu);
382 glutAttachMenu(GLUT_RIGHT_BUTTON);
385 double StepDiameter = 0.01;
395 sprintf(Dr->
info,
"Bonding visualisation");
402 sprintf(Dr->
info,
"Increasing radius");
404 sprintf(Dr->
info,
"Increasing height");
406 sprintf(Dr->
info,
"Increasing angle");
408 sprintf(Dr->
info,
"D^4 term");
410 sprintf(Dr->
info,
"D^2 term");
412 sprintf(Dr->
info,
"Elastic term");
414 sprintf(Dr->
info,
"Moving center ->x");
416 sprintf(Dr->
info,
"Moving center ->z");
422 for(
int n=0;n<
pNNano();n++)
423 Nano[n].Rad += StepDiameter;
427 for(
int n=0;n<
pNNano();n++)
428 Nano[n].Height += StepDiameter;
432 for(
int n=0;n<
pNNano();n++)
433 Nano[n].Hamaker += 5.;
451 Nano[0].
Pos[0] += StepDiameter;
455 for(
int n=0;n<
pNNano();n++)
456 Nano[n].Pos[2] += StepDiameter;
459 for(
int n=0;n<
pNNano();n++)
467 for(
int n=0;n<
pNNano();n++)
468 Nano[n].Rad -= StepDiameter;
472 for(
int n=0;n<
pNNano();n++)
473 Nano[n].Height -= StepDiameter;
495 Nano[0].
Pos[0] -= StepDiameter;
499 for(
int n=0;n<
pNNano();n++)
500 Nano[n].Pos[2] -= StepDiameter;
503 for(
int n=0;n<
pNNano();n++)
545 InitTime = time(NULL);
546 glutIdleFunc(DynamicsMotion);
551 sprintf(Dr->
info,
"initial configuration");
558 sprintf(Dr->
info,
"reload configuration");
594 VAR_REM_TYPE(
SysType,VAR_SYS_TXVL);
595 VAR_ADD_TYPE(
SysType,VAR_SYS_XVT);
602 sprintf(
Block[0].Name,
"GAS");
604 sprintf(FileName,
"Trajectory%09d.dat",
pStep());
621 sprintf(Dr->
info,
"Interpolating via Spline3 %d",
NShow);
625 sprintf(Dr->
info,
"Interpolating via Spline4 %d",
NShow);
629 sprintf(Dr->
info,
"Interpolating via Parabola2 %d",
NShow);
633 sprintf(Dr->
info,
"Interpolating via Cubic %d",
NShow);
637 sprintf(Dr->
info,
"Interpolating via Forth %d",
NShow);
641 sprintf(Dr->
info,
"Interpolating via BSpline %d",
NShow);
645 sprintf(Dr->
info,
"Interpolating via %dth grade poly %d",
pNPart()-1,
NShow);
int InterSpline3(PART *PmIn, PART *PmOut, int NIn, int NOut)
third order spline
double InvScaleUn
Rescale the three orthogonal directions.
int pNLink()
Maximum number of bonds.
void keyboard(unsigned char key, int x, int y)
Additional key bindings.
void DMouseMove(int x, int y)
How the scene rotate (Camera view should be implemented)
void DrawNano()
Draws cylinder or spheres.
int NLink
How many links per particle.
int NInsertion
Count accepted moves.
int InterSpline4(PART *PmIn, PART *PmOut, int NIn, int NOut)
forth order spline
void Dreshape(int w, int h)
Principal reshape function.
double pVel(int p, int d)
Return the velocity.
BLOCK * Block
Information for every block.
LINKS * Ln
Array of linking between the particles.
void AddRigid()
Add all rigid bodies as a boundary condition.
Draw provides the basic configuration of the openGL libraries used in every derived program...
void DrawCarpet()
Two dimensional surface.
NANO * Nano
Extra particle.
double Normalize()
Normlizes a Vettore.
double Hamaker
Strength of the interaction.
bool Write(char *OutFile)
Writes a "system-file" or a "x y z" file".
double Lap
Prefactor of the Laplacian.
Geometrical operations on vectors.
int Diap
Number of frames.
void PullBead()
Move a particle.
void DFigure(void)
Definition of the scene on which the objects will be drawn.
void DrawScene()
Draw the scene.
int SetNBlock(int Val)
Set NBlock.
double pInvEdge(int d)
Inverted xyzr edges of the simulation box.
double Height
Height of the cylinder.
void DrBondLine(int p)
Alternative drawing of the particle position.
int pType(int p)
Return the type.
double El[3]
Elastic force.
void Dynamics()
Sum up all the forces and update the positions.
void DrawSoil()
Two dimensional soil.
double Pos[3]
xyz Position of the particle
int IfInterp
If interpolates with the splines.
void Dspecial(int k, int x, int y)
Boh.
void FillMatrix()
Fill the entries of the interaction matrix.
int Picture()
Write a tiff file of the data in pixel.
double * x
Where the data are stored.
int IfFillMatrix
If the matrix has to be changed.
int NRemoval
Count accepted moves.
void keyboardDraw(unsigned char key)
Combines the key with the functions.
int ImWidth
Width and height of the image.
int InitIdx
Initial particle position.
void CreateInitial()
Create an initial configuration and an appropriate force field.
int CalcMode
Calculation mode.
void DTimer(int v)
Not working.
void Info()
System's info.
double pNanoPos(int n, int d)
Return back folded nano position.
GLuint Point
Refers to the list of the point.
double pEdge(int d)
xyzr edges of the simulation box
int pNPCh()
Number of particle per chain.
GLuint * Cylinder
List referring the cylinder.
int DefCylinder(double Rad, double Height)
Cylinder.
int InterBSpline(PART *PmIn, PART *PmOut, int NIn, int NOut)
BSpline.
void PushBead()
Move a particle.
void InitConstant()
Initializes all the view constants.
int * Link
with whom is bonded
int NEdge
Number of particles per edge.
int OpenImage(const char *FileName)
Open a image to be store in pixel.
KFORCES Kf
Prefactor of the forces.
int NUpdate
How many timesteps before redrawing.
int InterParab2(PART *PmIn, PART *PmOut, int NIn, int NOut)
Discontinous parabolas.
int SysShape
Shape of system.
int SysType
Contains the definition of the system.
int IfPoint
Decides to draw points or spheres.
int InterPoly(PART *PmIn, PART *PmOut, int NIn, int nOut)
NIn-polynomian.
int pNNano()
Number of nanoparticles.
GLuint Particles
Refers to the list of the total position of the particles which will be generated in another program...
int nEdge[3]
Number of particle per edge.
int InterForth(PART *PmIn, PART *PmOut, int NIn, int NOut)
Discontinous forth degree.
int NPCh
particles per chain
Matrice computes the algebric operations on matrices.
int IfSphere
Visualize spheres or points.
int SysFormat
Contains the definition of the file format.
int Step
Current step for the picture's name.
void DrawParticles()
Alternative drawing of the particle position.
int IfMovie
Produce the images for the video.
int Graphics(int argc, char **argv)
Initialize the scene.
int EndIdx
End particle position.
GLfloat xf
Orientation of the light.
double pPos(int p, int d)
Return back folded position.
int pNChain()
Number of chain.
double Angle(Vettore *u, Vettore *v)
Computes the angle between two Vetttore.
GLfloat xi
Position of the info string.
int Interp()
Show interpolating lines.
int InterCubica(PART *PmIn, PART *PmOut, int NIn, int NOut)
Discontinous cubic.
void Window(int argc, char **argv)
Initial definition of the window.
void SelectBead(int p)
Select a particle.
int ReadConfDinamica(char *File)
Read the config file.
void DynamicsView()
Idle function to run the dynamics.
PART * Pm
Particle information of all particle.
double SLap
Prefactor of the square laplacian.
GLubyte * pixel
Principal image (always allocated)
void Dmouse(int button, int state, int x, int y)
To launch the menu.
int Bead2Move
Bead to move.
int pStep()
Number of steps.
int pNPart()
Number of particle.
int BeadType
Boundary condition for a single particle.
void Solve()
Solve a system of four oder differential equation.
int NSpline
Total number of points for drawing a spline.