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 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
|
/////////////////////////////////////////////////////////////
// //
// Copyright (c) 2003-2014 by The University of Queensland //
// Centre for Geoscience Computing //
// http://earth.uq.edu.au/centre-geoscience-computing //
// //
// Primary Business: Brisbane, Queensland, Australia //
// Licensed under the Open Software License version 3.0 //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
/////////////////////////////////////////////////////////////
/*
-i inputfile_prefix
-o outputfile_name
-ip output fractures at _initial_ particle positions
*/
// --- System includes ---
#include <string>
#include <sstream>
#include <iostream>
#include <cstdlib>
using std::cout;
using std::cerr;
using std::endl;
using std::string;
using std::ostringstream;
// --- Project includes ---
#include "fracframe.h"
#include "fracwriter.h"
#include "FitPlane.h"
#include "frac_dist.h"
#include "Geometry/Plane3D.h"
int main(int argc,char** argv)
{
bool options_valid=true;
bool is_rot=false;
bool is_tagged=false;
bool do_fitplane=false;
bool write_distrib=false;
bool write_profile=false;
bool write_list=false;
bool write_format_vtk=false;
bool write_ip=false;
string ofilename;
string basefilename;
string listbasename;
string prof_file;
int t0_frame=0;
int tstart=0;
int nt=0;
int dt=0;
int tag=0;
double dist_min=0.0;
double dist_max=0.0;
double ymin=0.0, ymax=0.0;
int prof_nbin=0;
int dist_nbin=0;
string dist_filename;
// process args
int args_read=1;
while(args_read<argc){
string option=string(argv[args_read]);
if(option=="-i"){
if(argc>args_read){
basefilename=string(argv[args_read+1]);
args_read+=2;
} else {
options_valid=false;
}
} else if(option=="-o"){
if(argc>args_read){
ofilename=argv[args_read+1];
args_read+=2;
} else {
options_valid=false;
}
} else if(option=="-tag"){
if(argc>args_read){
tag=atoi(argv[args_read+1]);
is_tagged=true;
args_read+=2;
} else {
options_valid=false;
}
} else if(option=="-t0"){
if(argc>args_read){
t0_frame=atoi(argv[args_read+1]);
args_read+=2;
} else {
options_valid=false;
}
} else if(option=="-dist"){
if(argc>args_read+3){
write_distrib=true;
dist_filename=string(argv[args_read+1]);
dist_min=atof(argv[args_read+2]);
dist_max=atof(argv[args_read+3]);
dist_nbin=atoi(argv[args_read+4]);
args_read+=5;
} else {
options_valid=false;
}
} else if(option=="-prof"){
if(argc>args_read+3){
write_profile=true;
prof_file=string(argv[args_read+1]);
ymin=atof(argv[args_read+2]);
ymax=atof(argv[args_read+3]);
prof_nbin=atoi(argv[args_read+4]);
args_read+=5;
} else {
options_valid=false;
}
} else if(option=="-list"){
if(argc>args_read){
listbasename=string(argv[args_read+1]);
write_list=true;
args_read+=2;
} else {
options_valid=false;
}
} else if(option=="-rot"){
is_rot=true;
args_read++;
} else if(option=="-pl"){
do_fitplane=true;
args_read++;
} else if (option=="-vtk"){
write_format_vtk=true;
args_read++;
} else if (option=="-ip"){
write_ip=true;
args_read++;
} else if(option=="-t"){
if(argc>args_read+2){
tstart=atoi(argv[args_read+1]);
nt=atoi(argv[args_read+2]);
dt=atoi(argv[args_read+3]);
args_read+=4;
if(nt<2){
options_valid=false;
}
} else {
options_valid=false;
}
} else {
cerr << "Unknown option " << option << endl;
options_valid = false;
break;
}
}
// DO STUFF
if(options_valid){
FracWriter FW;
FracFrame F1;
ostringstream infilename1;
// make filename
infilename1 << basefilename << "_t=" << tstart << "_0.txt";
if(is_tagged){
if(is_rot){
F1.readFileRotTagged(infilename1.str(),tag);
} else {
F1.readFileTagged(infilename1.str(),tag);
}
} else {
if(is_rot){
F1.readFileRot(infilename1.str(),write_ip);
} else {
F1.readFile(infilename1.str());
}
}
for(int i=1;i<nt;i++){
FracFrame F2;
// make filename
ostringstream infilename2;
infilename2 << basefilename << "_t=" << tstart+i*dt << "_0.txt";
if(is_tagged){
if(is_rot){
F2.readFileRotTagged(infilename2.str(),tag);
} else {
F2.readFileTagged(infilename2.str(),tag);
}
} else {
if(is_rot){
F2.readFileRot(infilename2.str(),write_ip);
} else {
F2.readFile(infilename2.str());
}
}
vector<FracFrame::fdata> newfrac=F1.getFrac(F2);
F1=F2;
if(write_distrib){
FracDist fd=FracDist(newfrac,dist_min,dist_max,dist_nbin);
fd.write(dist_filename);
} else {
FW.addData(newfrac,tstart+i*dt);
if (write_list) {
ostringstream listfilename;
listfilename << listbasename << "_t=" << tstart+i*dt << "_0.txt";
FW.writeParticleList(listfilename.str());
}
if(do_fitplane){
Plane3D Pl=fitPlaneToFracture(newfrac);
cout << "Normal: [" << Pl.getNormal() << "] Position: [" << Pl.getPos() << "]" << endl;
cout << "Spanning vectors: [" << Pl.GetU() << "] [" << Pl.GetV() << "]" << endl;
FW.addPlane(Pl);
}
}
}
if(!write_distrib){
if(write_profile){
FW.writeProfile(ymin,ymax,prof_nbin,prof_file);
} else if (write_format_vtk) {
FW.write(ofilename);
} else {
FW.writeText(ofilename);
}
}
}
return 0;
}
|