MercuryDPM  0.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MD_xballs.icc
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
29 //icc means included cc file
31 {
32  //data_file.precision(14);
34  //This outputs the data about particle i again to the file.
35  switch(get_format())
36  {
37  case 8:
38  {
39  if (get_dim()==1) {
41  break;
42  } else {
43  data_file
44  << getParticleHandler().getObject(i)->get_Position().X << " "
45  << getParticleHandler().getObject(i)->get_Position().Y << " "
46  << getParticleHandler().getObject(i)->get_Velocity().X << " "
47  << getParticleHandler().getObject(i)->get_Velocity().Y << " "
48  << getParticleHandler().getObject(i)->get_Radius() << " "
49  << -getParticleHandler().getObject(i)->get_Angle().Z << " " // negative b/c we are plotting (x,y) coordinates on the xz-axis of xballs
51  << getInfo(*getParticleHandler().getObject(i)) <<std::endl;
52  }
53  break;
54  }
55  case 14:
56  {
57  data_file
58  << getParticleHandler().getObject(i)->get_Position().X << " "
59  << getParticleHandler().getObject(i)->get_Position().Y << " "
60  << getParticleHandler().getObject(i)->get_Position().Z << " "
61  << getParticleHandler().getObject(i)->get_Velocity().X << " "
62  << getParticleHandler().getObject(i)->get_Velocity().Y << " "
63  << getParticleHandler().getObject(i)->get_Velocity().Z << " "
64  << getParticleHandler().getObject(i)->get_Radius() << " "
65  << getParticleHandler().getObject(i)->get_Angle().X << " " // negative b/c we are plotting (x,y) coordinates on the xz-axis of xballs
66  << getParticleHandler().getObject(i)->get_Angle().Y << " " // negative b/c we are plotting (x,y) coordinates on the xz-axis of xballs
67  << getParticleHandler().getObject(i)->get_Angle().Z << " " // negative b/c we are plotting (x,y) coordinates on the xz-axis of xballs
71  << getInfo(*getParticleHandler().getObject(i)) <<std::endl;
72  break;
73  } //end case 3
74  default:
75  {
76  std::cerr << "format not found" << std::endl;
77  }
78  } //end switch statement
79 }
80 
85 {
86 
87  std::stringstream file_name;
88  std::ofstream script_file;
89  file_name << problem_name.str() <<".xballs";
90  script_file.open((file_name.str()).c_str());
91 
93  script_file << "#!/bin/bash" << std::endl;
94  script_file << "x=$(echo $0 | cut -c2-)" << std::endl;
95  script_file << "file=$PWD$x" << std::endl;
96  script_file << "dirname=`dirname \"$file\"`" << std::endl;
97  script_file << "cd $dirname" << std::endl;
98 
99  Mdouble scale;
100  int format;
101 
102  if (dim<3)
103  { // dim = 1 or 2
104  format = 8;
105  if (xballs_scale<0)
106  {
107  scale = 1.0 / std::max( ymax-ymin, xmax-xmin );
108  }
109  else
110  {
111  scale=xballs_scale;
112  }
113  }
114  else
115  { //dim==3
116  format = 14;
117  if (xballs_scale<0)
118  {
119  scale = 1.2 / std::max( zmax-zmin, xmax-xmin );
120  }
121  else
122  {
123  scale=xballs_scale;
124  }
125 
126  }
127 
128  script_file << "../../xballs/xballs -format " << format
129  << " -f " << data_filename.str() << ((get_options_data()==2)?".0000":"")
130  << " -s " << scale
131  << " -cmode " << xballs_cmode
132  << " -cmax -sort "
134  << " $*";
136  if (xballs_vscale>-1)
137  {
138  script_file << " -vscale " << xballs_vscale;
139  }
140  script_file.close();
141 
142  //This line changes teh file permision and give the owener (i.e. you) read, write and excute permission to the file.
143  #ifdef UNIX
144  chmod((file_name.str().c_str()),S_IRWXU);
145  #endif
146 
147 }
148 
149 
150 
151 
std::string xballs_additional_arguments
Definition: MD.h:698
Mdouble X
Definition: Vector.h:44
int format
Definition: MD.h:699
const Vec3D & get_Velocity() const
std::stringstream data_filename
These store the save file names, by default they are derived from problem_name.
Definition: STD_save.h:246
T * getObject(const unsigned int id) const
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:176
Mdouble xballs_scale
Definition: MD.h:697
int dim
The dimension of the simulation.
Definition: MD.h:660
int get_dim()
Allows the dimension of the simulation to be accessed.
Definition: MD.h:369
std::stringstream problem_name
Stores the problem_name.
Definition: STD_save.h:242
Mdouble get_Radius() const
int xballs_cmode
Definition: MD.h:695
std::fstream data_file
Stream used for data files.
Definition: STD_save.h:252
virtual void output_xballs_data_particle(int i)
This function outputs the location and velocity of the particle in a format the xballs progream can r...
Definition: MD_xballs.icc:30
Mdouble xmax
Definition: MD.h:668
unsigned int get_options_data(void)
Definition: STD_save.h:162
Mdouble zmax
Definition: MD.h:668
double Mdouble
Definition: ExtendedMath.h:33
const Vec3D & get_Position() const
Mdouble Y
Definition: Vector.h:44
int get_format()
Definition: MD.h:508
ParticleHandler & getParticleHandler()
Definition: MD.h:147
Mdouble xballs_vscale
Definition: MD.h:696
const Vec3D & get_Angle() const
Mdouble xmin
These store the size of the domain, assume walls at the ends.
Definition: MD.h:668
virtual double getInfo(BaseParticle &P)
Allows the user to set what is written into the info column in the data file. By default is store the...
Definition: MD.h:463
Mdouble Z
Definition: Vector.h:44
Mdouble ymin
Definition: MD.h:668
Mdouble zmin
Definition: MD.h:668
Mdouble ymax
Definition: MD.h:668
const Vec3D & get_AngularVelocity() const
virtual void create_xballs_script()
This creates a scipt which can be used to load the xballs problem to display the data just generated...
Definition: MD_xballs.icc:84