26 #include "../include/VarData.h" 29 void VarData::OpenComprWrite(
char *FName,filtering_ostream ZipFile){
30 ofstream OpenZipFile(FName, ios_base::binary);
32 ZipFile.push(bzip2_compressor());
33 ZipFile.push(OpenZipFile);
35 void VarData::OpenComprRead(
char *FName,filtering_istream ZipFile){
36 ifstream OpenZipFile(FName, ios_base::binary);
38 ZipFile.push(bzip2_compressor());
39 ZipFile.push(OpenZipFile);
41 void VarData::CloseCompr(filtering_istream ZipFile){
44 void VarData::CloseCompr(filtering_ostream ZipFile){
63 FILE *FileToWrite = fopen(OutFile,
"w");
64 SigErr(FileToWrite==NULL,
"The output file %s could not be opened\n",OutFile);
65 fprintf(FileToWrite,
"# ");
66 if( VAR_IF_TYPE(
SysType,VAR_EDGE) ){
67 fprintf(FileToWrite,
"l( %.2g %.2g %.2g) ",
70 fprintf(FileToWrite,
"c[%d] ",Gen->
NChain);
71 fprintf(FileToWrite,
"s[%d] ",Gen->
Step);
72 fprintf(FileToWrite,
"n[%d] ",Gen->
NPart);
73 fprintf(FileToWrite,
"L[%d] ",Gen->
NLink);
74 fprintf(FileToWrite,
"v[%d] ",
NEdge);
76 fprintf(FileToWrite,
"D(%lf) ",Gen->
Deltat);
77 fprintf(FileToWrite,
"i(%.2f %.2f %.2f) ",Gen->
rho,Gen->
chiN,Gen->
kappaN);
78 fprintf(FileToWrite,
"\n");
80 for(
int p=0;p<Gen->
NPart;p++){
81 fprintf(FileToWrite,
"{ t[%d %d %d] ",
82 Pm[p].Idx,
Pm[p].CId,
Pm[p].Typ);
83 fprintf(FileToWrite,
"x(%lf %lf %lf) ",
84 Pm[p].Pos[0],
Pm[p].Pos[1],
Pm[p].Pos[2]);
85 fprintf(FileToWrite,
"v(%lf %lf %lf) ",
86 Pm[p].Vel[0],
Pm[p].Vel[1],
Pm[p].Vel[2]);
90 fprintf(FileToWrite,
"l[%d] ",
Ln[p].Link[i]);
92 fprintf(FileToWrite,
"}\n");
107 fprintf(FileToWrite,
"# v=%.2f %.2f %.2f %.2f %.2f %.2f ",
MInt->
Coeff(0,0),
MInt->
Coeff(0,1),
MInt->
Coeff(0,2),
MInt->
Coeff(1,1),
MInt->
Coeff(1,2),
MInt->
Coeff(2,2));
108 fprintf(FileToWrite,
"w=%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n",
MInt->
Coeff(0,0,0),
MInt->
Coeff(0,0,1),
MInt->
Coeff(0,0,2),
MInt->
Coeff(0,1,1),
MInt->
Coeff(0,1,2),
MInt->
Coeff(0,2,2),
MInt->
Coeff(1,1,1),
MInt->
Coeff(1,1,2),
MInt->
Coeff(1,2,2),
MInt->
Coeff(2,2,2));
115 if(VAR_IF_TYPE(iShape,SHAPE_SPH)) sprintf(Shape,
"sph");
116 else if(VAR_IF_TYPE(iShape,SHAPE_TIP)) sprintf(Shape,
"tip");
117 else if(VAR_IF_TYPE(iShape,SHAPE_CYL)) sprintf(Shape,
"cyl");
118 else if(VAR_IF_TYPE(iShape,SHAPE_PILL)) sprintf(Shape,
"pill");
119 else if(VAR_IF_TYPE(iShape,SHAPE_TILT)) sprintf(Shape,
"tilt");
120 else if(VAR_IF_TYPE(iShape,SHAPE_WALL)) sprintf(Shape,
"wall");
121 else if(VAR_IF_TYPE(iShape,SHAPE_PORE)) sprintf(Shape,
"pore");
122 else if(VAR_IF_TYPE(iShape,SHAPE_EXT)) sprintf(Shape,
"ext");
123 else if(VAR_IF_TYPE(iShape,SHAPE_JANUS)) sprintf(Shape,
"janus");
124 else if(VAR_IF_TYPE(iShape,SHAPE_STALK)) sprintf(Shape,
"stalk");
125 else if(VAR_IF_TYPE(iShape,SHAPE_TORUS)) sprintf(Shape,
"torus");
126 else if(VAR_IF_TYPE(iShape,SHAPE_HARM)) sprintf(Shape,
"harm");
127 else if(VAR_IF_TYPE(iShape,SHAPE_UMBR)) sprintf(Shape,
"umbr");
128 else if(VAR_IF_TYPE(iShape,SHAPE_BOUND)) sprintf(Shape,
"bound");
133 if(VAR_IF_TYPE(
Nano[n].Shape,SHAPE_CLUSTER)){
134 sprintf(Shape,
"Architecture%d.dat",n);
135 sprintf(String,
"# Pep x(%.2f %.2f %.2f) a(%.2f %.2f %.2f) g(%.2f %.2f %.2f) i[%d] d[%d %d] fn{%s}",
Nano[n].Pos[0],
Nano[n].Pos[1],
Nano[n].Pos[2],
Nano[n].Axis[0],
Nano[n].Axis[1],
Nano[n].Axis[2],
Nano[n].Rad,
Nano[n].Height,
Nano[n].Hamaker,n,
Nano[n].NCircle,
Nano[n].NHeight,Shape);
137 else if(VAR_IF_TYPE(
Nano[n].Shape,SHAPE_CLINKS)){
138 sprintf(Shape,
"CrossLinks.dat");
139 sprintf(String,
"# Ext i[%d] fn{%s}",0,Shape);
142 sprintf(String,
"# Rigid x(%.2f %.2f %.2f) a(%.2f %.2f %.2f) c(%.2f %.2f %.2f %.4f) s{%s}",
Nano[n].Pos[0],
Nano[n].Pos[1],
Nano[n].Pos[2],
Nano[n].Axis[0],
Nano[n].Axis[1],
Nano[n].Axis[2],
Nano[n].Rad,
Nano[n].Hamaker,
Nano[n].Height,
Nano[n].OffSet,Shape);
145 if(Gen->NNano == 0)
return 1;
146 for(
int n=0;n<Gen->NNano;n++){
150 fprintf(FileToWrite,
"%s\n",String);
155 if(
NSoft == 0)
return 1;
156 for(
int n=0;n<
NSoft;n++){
159 if(
Soft[n].Topology == VAR_PLANAR) sprintf(Shape,
"planar");
160 if(
Soft[n].Topology == VAR_VESICLE) sprintf(Shape,
"vesicle");
161 if(
Soft[n].Topology == VAR_COATING) sprintf(Shape,
"coating");
162 if(
Soft[n].Topology == VAR_DISTRIBUTED) sprintf(Shape,
"distributed");
163 sprintf(Line,
"# Soft x(%.2f %.2f %.2f) c(%.2f %.2f) s{%s} n{%s}\n",
Soft[n].Pos[0],
Soft[n].Pos[1],
Soft[n].Pos[2],
Soft[n].Size[0],
Soft[n].Size[1],Shape,
Soft[n].Name);
169 FILE *FileToWrite = NULL;
171 FileToWrite = fopen(OutFile,
"w");
172 SigErr(FileToWrite==NULL,
"The output file %s could not be opened\n",OutFile);
173 fprintf(FileToWrite,
"# L=%lf %lf %lf t=%lf blocks=%d\n",Gen->
Edge[0],Gen->
Edge[1],Gen->
Edge[2],
pTime(),Gen->
NBlock);
177 if(
Block[b].NChain == 0)
continue;
178 fprintf(FileToWrite,
"# n=%d N=%d name=%s\n",
Block[b].NChain,
Block[b].NPCh,
Block[b].Name);
180 for(
int p=0;p<
Block[b].
NPCh;p++,pCurr++){
189 fprintf(FileToWrite,
"%lf %lf %lf ",
191 fprintf(FileToWrite,
"%lf %lf %lf ",
192 Pm[pCurr].Vel[0],
Pm[pCurr].Vel[1],
Pm[pCurr].Vel[2]);
193 fprintf(FileToWrite,
" %d ",
195 fprintf(FileToWrite,
"\n");
204 FILE *FileToWrite = NULL;
205 if( (FileToWrite = fopen(OutFile,
"w")) == 0){
206 printf(
"The output file %s could not be opened\n",OutFile);
209 for(
int p=0;p<Gen->
NPart;p++){
210 fprintf(FileToWrite,
"%lf %lf %lf\n",
211 Pm[p].Pos[0],
Pm[p].Pos[1],
Pm[p].Pos[2]);
220 double InvValues = 1./(double)Values;
221 int link[4] = {0,0,0,0};
222 for(
int vv=0;vv<Values-1;vv++){
223 for(
int v=0;v<Values-1;v++){
224 link[0] = (v+0)*Values + (vv+0);
225 if(Plot[(link[0])*NType+t] < .1)
continue;
227 link[1] = (v+0)*Values + (vv+1);
228 link[2] = (v+1)*Values + (vv+0);
229 link[3] = (v+1)*Values + (vv+1);
231 for(
int lx=0;lx<2;lx++){
232 for(
int ly=0;ly<2;ly++){
234 double NanoAdded = Plot[(link[l])*NType+2]/Bound[2]+Plot[(link[l])*NType+3]/Bound[3];
235 double Phob = t == 0 ? Plot[(link[l])*NType+0]/Bound[0] : 0.;
236 double Phil = t == 1 ? Plot[(link[l])*NType+1]/Bound[1] : 0.;
237 double r = (v +lx)*InvValues*
pEdge(3);
239 double dens = (Plot[(link[l])*NType+t]);
240 int l1 = pRef + (p+1)%4;
241 int l2 = pRef + (p+2)%4;
242 int l3 = pRef + (p+3)%4;
243 fprintf(FWrite,
"{t[%d %d %d] x(%lf %lf %lf) v(%lf %lf %lf) l[%d] l[%d] l[%d] }\n",p,c,t,r,z,dens,NanoAdded,Phob,Phil,l1,l2,l3);
254 double Threshold = .1;
255 int *IdSerial = (
int *)calloc(Values*Values*2,
sizeof(
int));
256 for(
int vv=0,p=0;vv<Values-1;vv++){
257 for(
int v=0;v<Values-1;v++){
258 int l = (vv+0)*Values + (v+0);
260 printf(
"%d %d %d %d\n",l,p,v,vv);
261 if(Plot[l*NType+t] < Threshold)
continue;
265 for(
int vv=0,p=0,c=0;vv<Values-1;vv++){
266 for(
int v=0;v<Values-1;v++){
267 link[0] = (v+0)*Values + (vv+0);
268 if(Plot[(link[0])*NType+t] < Threshold)
continue;
270 link[1] = (vv+0)*Values + (v+1);
271 link[2] = (vv+1)*Values + (v+0);
272 link[3] = (vv+1)*Values + (v+1);
273 printf(
"%d %d %d %d\n",link[0],link[1],link[2],link[3]);
274 for(
int l=0;l<4;l++){
275 link[l] = IdSerial[link[l]];
277 printf(
"%d %d %d %d\n",link[0],link[1],link[2],link[3]);
278 double NanoAdded = Plot[(link[0])*NType+2]/Bound[2]+Plot[(link[0])*NType+3]/Bound[3];
279 double Phob = t == 0 ? Plot[(link[0])*NType+0]/Bound[0] : 0.;
280 double Phil = t == 1 ? Plot[(link[0])*NType+1]/Bound[1] : 0.;
281 double r = (v)*InvValues*
pEdge(3);
283 double dens = (Plot[(link[0])*NType+t]);
284 fprintf(FWrite,
"{t[%d %d %d] x(%lf %lf %lf) v(%lf %lf %lf) l[%d] l[%d] l[%d] }\n",link[0],c,t,r,z,dens,NanoAdded,Phob,Phil,link[1],link[2],link[3]);
292 double InvNSample = 1./(double)NSample;
293 for(
int sx=0;sx<NSample;sx++){
294 for(
int sy=0;sy<NSample;sy++){
297 int l01 = (sx+0)*NSample+(sy+1)+OffSet;
298 if(sy == NSample - 1)
299 l01 = (sx+0)*NSample+(0)+OffSet;
300 int l10 = (sx+1)*NSample+(sy+0)+OffSet;
301 if(sx == NSample - 1)
302 l10 = (0)*NSample+(sy+0)+OffSet;
303 int lm0 = (sx-1)*NSample+(sy+0)+OffSet;
305 lm0 = (NSample - 1)*NSample+(sy+0)+OffSet;
306 int l0m = (sx+0)*NSample+(sy-1)+OffSet;
308 l0m = (sx)*NSample+(NSample-1)+OffSet;
309 fprintf(F2Write,
"{x(%lf %lf %lf) l[%d] l[%d] l[%d] l[%d]}\n",x,y,Plot[sx][sy],l01,l10,lm0,l0m);
int pNLink()
Maximum number of bonds.
double pTime()
Total time.
int NLink
How many links per particle.
double kappaN
Incompressibility.
BLOCK * Block
Information for every block.
LINKS * Ln
Array of linking between the particles.
void ShapeId(int iShape, char *Shape)
Identifier of the shape.
NANO * Nano
Extra particle.
double chiN
Incompatibility.
bool Write(char *OutFile)
Writes a "system-file" or a "x y z" file".
void StringNano(char *NString, int n)
String for the rigid inclusion in the header file.
double Edge[4]
xyzr edges of the simulation box
char cWhat2Draw[STRSIZE]
What to draw.
double WFuncStraight2
Weighting function straight length.
int CLat2
lateral coordinate
int NLink
Maximum number of bonds.
void WriteLinkedSurf(FILE *FWrite, double *Plot, int NSample, int NType, double *Bound, int *PId)
Write the positions of the egdes of the rectangles.
int Shape
0 none, 1 spherical, 2 cylindrical 3 wall
double pEdge(int d)
xyzr edges of the simulation box
int pNPCh()
Number of particle per chain.
bool WriteXvt(char *OutFile)
Writes a "system-file" or a "x y z" file".
MatInt * MInt
Matrix of the prefactor of the interactions.
int NChain
Number of chain.
int NEdge
Number of particles per edge.
double kappaSpring
Prefactor of the bond spring.
bool WriteTxvl(char *OutFile)
Writes a "system-file" or a "x y z" file".
int HeaderNano(FILE *FileToWrite)
Write the nano section of the header to the file.
int NPCh
Number of particle per chain.
int SysType
Contains the definition of the system.
double Coeff(int t1, int t2)
Prefactor of the force.
void WriteSurf(FILE *F2Write, double **Plot, int NSample, int OffSet)
Write the particle position as linked edges of squares.
int NPCh
particles per chain
bool WriteXyz(char *OutFile)
Writes a "system-file" or a "x y z" file".
int SysFormat
Contains the definition of the file format.
void HeaderInteraction(FILE *FileToWrite)
Header interactions.
double pReOverCutOff()
Re/CutOff.
double WFuncStraight3
Weighting function straight length.
double pPos(int p, int d)
Return back folded position.
unsigned long Step
Courrent step.
int HeaderSoft(char *Line)
Header soft.
int CLat1
lateral coordinate
int NSoft
Number of soft bodies.
void Rescale(double SFactor, int Order)
Rescale entries.
int NPart
Number of particle.
PART * Pm
Particle information of all particle.
double ReOverCutOff
Convertion unit R_e over CutOff.
int NBlock
Number of blocks.
void VarMessage(const char *s,...)
If enabled call the function position.
double rho
Density coexistence.
int CNorm
Normal coordinate.
double kappaBend
Prefactor of the bending potential.