Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RocfluFunctions.C
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 #include <iostream>
24 #include <fstream>
25 #include <string>
26 #include <list>
27 #include <map>
28 #include <sstream>
29 #include <iomanip>
30 #include <vector>
31 #include <cmath>
32 #include <cassert>
33 
34 //#ifdef _TRAIL_MPI_
35 #include "mpi.h"
36 //#endif
37 
38 #include "GEM.H"
39 #include "TRAIL.H"
40 #include "TRAIL_Flu.H"
41 
42 //#ifdef _ROCSTAR_X_
43 #include "roccom.h"
44 //#endif
45 
46 using namespace std;
47 
48 istream &
49 SkipLines(istream &ioo,unsigned int n)
50 {
51  string line;
52  unsigned int l = 0;
53  while(l++ < n)
54  getline(ioo,line);
55  return(ioo);
56 }
57 
58 bool
59 TRAIL_FluInitSolver(GEM_Partition &gp,const string &prefix)
60 {
61  if(!TRAIL_FluReadControlFile(gp,prefix))
62  return(false);
63  gp._solver_data._int_data.resize(2);
64  gp._solver_data._stride_int.resize(2);
65  gp._solver_data._int_data[1].resize(1);
66  gp._solver_data._stride_int[1] = 1;
68  if(gp._solver_data._int_data[1][0] == 0)
69  return(false);
70  return true;
71 }
72 
73 bool
74 TRAIL_FluReadControlFile(GEM_Partition &gp,const string &prefix)
75 {
76  ifstream Inf;
77  string fname;
78  if(!prefix.empty())
79  fname = prefix + "/RocfluControl.txt";
80  Inf.open(fname.c_str());
81  if(!Inf)
82  return false;
83  gp._solver_data._string_data.resize(3);
84  gp._solver_data._string_data[2] = prefix; // solver name
85  // casename and casepath
86  Inf >> gp._solver_data._string_data[0] >> gp._solver_data._string_data[1];
87  Inf.close();
88  return(true);
89 }
90 
91 bool
92 TRAIL_FluWriteCOM(GEM_Partition &gp,const std::string &path)
93 {
94  if(gp._solver_data._string_data.size() < 3){
95  if(gp._out)
96  *gp._out << "TRAIL_FluWriteCOM::Error: No casename or path found."
97  << std::endl;
98  return(false);
99  }
100  string pre("./" + path + "/" + gp._solver_data._string_data[0]);
101  if(gp._solver_data._int_data.empty()){
102  if(gp._out)
103  *gp._out
104  << "TRAIL_FluWriteCOM: Error, called with empty rbid's."
105  << endl;
106  return(false);
107  }
108  assert(gp._solver_data._int_data[0].size() == gp._pb.size());
109  ofstream Ouf;
110  ostringstream Ostr;
111  Ostr << pre << ".com_";
112  Ostr << setw(5) << setfill('0');
113  Ostr << gp._id;
114  Ouf.open(Ostr.str().c_str());
115  if(!Ouf){
116  if(gp._out)
117  *gp._out
118  << "TRAIL_FluWriteCOM: Error: Could not open " << Ostr.str() << "."
119  << std::endl;
120  return(false);
121  }
122  Ouf << "# ROCFLU communication lists file" << endl
123  << "# Dimensions" << endl
124  << setw(8) << gp._pb.size() << endl
125  << "# Information" << endl;
126  int pbindex = 0;
127  vector<GEM_PartitionBoundary>::iterator fbi = gp._pb.begin();
128  while(fbi != gp._pb.end()){
129  Ouf << setw(8) << fbi->_rpart << setw(8)
130  << gp._solver_data._int_data[0][pbindex++]
131  << endl;
132  fbi++;
133  }
134  Ouf << "# Cells" << endl;
135  fbi = gp._pb.begin();
136  while(fbi != gp._pb.end()){
137  Ouf << setw(8) << fbi->_sendcells.size() << setw(8)
138  << fbi->_recvcells.size() << endl;
139  int line = 0;
140  vector<unsigned int>::iterator sci = fbi->_sendcells.begin();
141  while(sci != fbi->_sendcells.end()){
142  Ouf << setw(8) << *sci++;
143  line++;
144  if(line == 10){
145  Ouf << endl;
146  line = 0;
147  }
148  }
149  if(line){
150  Ouf << endl;
151  line = 0;
152  }
153  sci = fbi->_recvcells.begin();
154  while(sci != fbi->_recvcells.end()){
155  Ouf << setw(8) << *sci++;
156  line++;
157  if(line == 10){
158  Ouf << endl;
159  line = 0;
160  }
161  }
162  if(line){
163  Ouf << endl;
164  line = 0;
165  }
166  fbi++;
167  }
168  Ouf << "# Vertices" << endl;
169  fbi = gp._pb.begin();
170  while(fbi != gp._pb.end()){
171  Ouf << setw(8) << fbi->_sendnodes.size() << setw(8)
172  << fbi->_recvnodes.size() << setw(8) << fbi->_sharenodes.size()
173  << endl;
174  vector<unsigned int>::iterator ni = fbi->_sendnodes.begin();
175  int line = 0;
176  while(ni != fbi->_sendnodes.end()){
177  Ouf << setw(8) << *ni++;
178  line++;
179  if(line == 10){
180  Ouf << endl;
181  line = 0;
182  }
183  }
184  if(line || fbi->_sendnodes.empty()){
185  Ouf << endl;
186  line = 0;
187  }
188  ni = fbi->_recvnodes.begin();
189  line = 0;
190  while(ni != fbi->_recvnodes.end()){
191  Ouf << setw(8) << *ni++;
192  line++;
193  if(line == 10){
194  Ouf << endl;
195  line = 0;
196  }
197  }
198  if(line || fbi->_recvnodes.empty()){
199  Ouf << endl;
200  line = 0;
201  }
202  ni = fbi->_sharenodes.begin();
203  line = 0;
204  while(ni != fbi->_sharenodes.end()){
205  Ouf << setw(8) << *ni++;
206  line++;
207  if(line == 10){
208  Ouf << endl;
209  line = 0;
210  }
211  }
212  if(line || fbi->_sharenodes.empty()){
213  Ouf << endl;
214  line = 0;
215  }
216  fbi++;
217  }
218  Ouf << "# End" << endl;
219  return(true);
220 }
221 
222 bool
224 {
225  if(gp._solver_data._string_data.size() < 3){
226  if(gp._out)
227  *gp._out << "TRAIL_FluReadCOM::Error: No casename or path found."
228  << std::endl;
229  return(false);
230  }
231 
232  string pre(gp._solver_data._string_data[1] + "/" +
233  gp._solver_data._string_data[0]);
234  if(gp._solver_data._int_data.empty()){
235  if(gp._out)
236  *gp._out
237  << "TRAIL_FluReadCOM: Error,called with empty _int_data."
238  << endl;
239 
240  return(false);
241  }
242  ifstream Inf;
243  ostringstream Ostr;
244  Ostr << pre << ".com_";
245  Ostr << setw(5) << setfill('0');
246  Ostr << gp._id;
247  Inf.open(Ostr.str().c_str());
248  if(!Inf){
249  if(gp._out)
250  *gp._out
251  << "TRAIL_FluReadCOM: Error: Cannot open " << Ostr.str() << "."
252  << std::endl;
253  return(false);
254  }
255  string line;
256  SkipLines(Inf,2);
257  unsigned int nborders = 0;
258  Inf >> nborders;
259  if(gp._debug && gp._out)
260  *gp._out << "TRAIL_FluReadCOM(" << gp._id << "): nborders: "
261  << nborders << "\n";
262  assert(nborders == gp._pb.size() && nborders ==
263  gp._solver_data._int_data[0].size());
264  SkipLines(Inf,2);
265  unsigned int pbindex = 0;
266  vector<GEM_PartitionBoundary>::iterator fbi = gp._pb.begin();
267  while(fbi != gp._pb.end()){
268  unsigned int rpart;
269  int rbid;
270  Inf >> rpart >> rbid;
271  assert(fbi->_rpart == rpart &&
272  gp._solver_data._int_data[0][pbindex++] == rbid);
273  fbi++;
274  }
275  SkipLines(Inf,2);
276  fbi = gp._pb.begin();
277  while(fbi != gp._pb.end()){
278  unsigned int rcells,scells;
279  Inf >> scells >> rcells;
280  assert(scells == fbi->_sendcells.size() &&
281  rcells == fbi->_recvcells.size());
282  int cell = 0;
283  int ncells = fbi->_sendcells.size();
284  while(cell < ncells)
285  Inf >> fbi->_sendcells[cell++];
286  cell = 0;
287  ncells = fbi->_recvcells.size();
288  while(cell < ncells)
289  Inf >> fbi->_recvcells[cell++];
290  fbi++;
291  }
292  SkipLines(Inf,2);
293  fbi = gp._pb.begin();
294  while(fbi != gp._pb.end()){
295  unsigned int nshare,nsend,nrecv;
296  Inf >> nsend >> nrecv >> nshare;
297  assert(nsend == fbi->_sendnodes.size() &&
298  nrecv == fbi->_recvnodes.size() &&
299  nshare == fbi->_sharenodes.size());
300  unsigned int node = 0;
301  unsigned int nnodes = fbi->_sendnodes.size();
302  while(node < nnodes)
303  Inf >> fbi->_sendnodes[node++];
304  node = 0;
305  nnodes = fbi->_recvnodes.size();
306  while(node < nnodes)
307  Inf >> fbi->_recvnodes[node++];
308  nnodes = fbi->_sharenodes.size();
309  node = 0;
310  while(node < nnodes)
311  Inf >> fbi->_sharenodes[node++];
312  fbi++;
313  }
314  Inf.close();
315  return(true);
316 }
317 
318 bool
319 TRAIL_FluWriteMAP(GEM_Partition &gp,unsigned int nproc,
320  unsigned int nregions,const std::string &path)
321 {
322  if(gp._solver_data._string_data.size() < 3){
323  if(gp._out)
324  *gp._out << "TRAIL_FluWriteMAP::Error: No casename or path found."
325  << std::endl;
326  return(false);
327  }
328  std::string pre("./" + path + "/" + gp._solver_data._string_data[0]);
329  ofstream Ouf;
330  ostringstream Ostr;
331  Ostr << pre << ".map";
332  Ouf.open(Ostr.str().c_str());
333  if(!Ouf)
334  return(false);
335  Ouf << "# ROCFLU region mapping file" << endl
336  << "# Number of regions" << endl
337  << setw(8) << nregions << endl
338  << "# Number of processes" << endl
339  << setw(8) << nproc << endl;
340  unsigned int regpproc = nregions/nproc;
341  if(regpproc == 0)
342  return(false);
343  unsigned int left = nregions%nproc;
344  unsigned int proc = 0;
345  unsigned int reg = 0;
346  while(proc < nproc){
347  unsigned int nreg = regpproc;
348  if(left > 0){
349  nreg++;
350  left--;
351  }
352  Ouf << "# Process " << setw(6) << setfill('0') << proc+1 << endl
353  << setfill(' ') << setw(8) << nreg << endl;
354  unsigned int uplimit = reg + nreg;
355  while(reg < uplimit)
356  Ouf << setw(8) << (1+reg++) << endl;
357  proc++;
358  }
359  Ouf << "# End" << endl;
360  Ouf.close();
361  return(true);
362 }
363 
364 bool
365 TRAIL_FluWriteDIM(GEM_Partition &gp,double t, bool unsteady,
366  const std::string &path)
367 {
368  if(gp._solver_data._string_data.size() < 3){
369  if(gp._out)
370  *gp._out << "TRAIL_FluWriteDIM::Error: No casename or path found."
371  << std::endl;
372  return(false);
373  }
374  std::string pre("./" + path + "/" + gp._solver_data._string_data[0]);
375  std::ofstream Ouf;
376  std::ostringstream Ostr;
377  Ostr << pre << ".dim_";
378  Ostr << setw(5) << setfill('0');
379  Ostr << gp._id;
380  std::string filebase(Ostr.str());
381  if(unsteady){
382  Ostr.clear();
383  Ostr.str("");
384  Ostr << "_" << scientific << setprecision(5) << t;
385  std::string timestring(Ostr.str());
386  timestring.replace(8,1,"E");
387  filebase+=timestring;
388  }
389  Ouf.open(filebase.c_str());
390  if(!Ouf){
391  if(gp._out)
392  *gp._out << "TRAIL_FluWriteDIM::Error: Could not open " << filebase << "."
393  << std::endl;
394  return(false);
395  }
396  unsigned int ntet = gp._tetconn.size()/4;
397  unsigned int nnodes = gp._nc.size()/3;
398  unsigned int nhex = gp._hexconn.size()/8;
399  unsigned int npris = gp._prisconn.size()/6;
400  unsigned int npyr = gp._pyrconn.size()/5;
401  unsigned int nelem = ntet + nhex + npris + npyr;
402  Ouf << "# ROCFLU dimensions file" << endl
403  << "# Vertices" << endl
404  << setw(8) << nnodes - gp._ngnodes << setw(8) << nnodes
405  << setw(8) << nnodes+(nnodes/5) << endl
406  << "# Cells" << endl
407  << setw(8) << (nelem-gp._ngtet-gp._ngpyr-gp._ngpris-gp._nghex)
408  << setw(8) << nelem
409  << setw(8) << (nelem+(nelem/5)) << endl
410  << "# Tetrahedra" << endl
411  << setw(8) << ntet - gp._ngtet << setw(8) << ntet << setw(8)
412  << (ntet+(ntet/5))
413  << endl
414  << "# Hexahedra" << endl
415  << setw(8) << nhex - gp._nghex << setw(8) << nhex << setw(8)
416  << (nhex+(nhex/5))
417  << endl
418  << "# Prisms" << endl
419  << setw(8) << npris - gp._ngpris << setw(8) << npris << setw(8)
420  << npris+(npris/5)
421  << endl
422  << "# Pyramids" << endl
423  << setw(8) << npyr - gp._ngpyr << setw(8) << npyr
424  << setw(8) << npyr+(npyr/5)
425  << endl
426  << "# Patches" << endl
427  << setw(8) << gp._db.size() << setw(8)
428  << gp._solver_data._int_data[1][0] << endl; // total_num_patches
429  vector<GEM_DomainBoundary>::iterator fpi = gp._db.begin();
430  while(fpi != gp._db.end()){
431  Ouf << setw(8) << fpi->_id << setw(8)
432  << fpi->_triconn.size()/3 - fpi->_ngtri
433  << setw(8) << fpi->_triconn.size()/3 << setw(8)
434  << fpi->_quadconn.size()/4 - fpi->_ngquad
435  << setw(8) << fpi->_quadconn.size()/4 << endl;
436  fpi++;
437  }
438  Ouf << "# Borders" << endl
439  << setw(8) << gp._pb.size() << endl;
440  vector<GEM_PartitionBoundary>::iterator fbi = gp._pb.begin();
441  unsigned int pbindex = 0;
442  assert(gp._solver_data._int_data[0].size() == gp._pb.size());
443  while(fbi != gp._pb.end()){
444  Ouf << setw(8) << fbi->_rpart << setw(8)
445  << gp._solver_data._int_data[0][pbindex++]
446  << setw(8)
447  << fbi->_sendcells.size() << setw(8) << fbi->_recvcells.size()
448  << setw(8)
449  << fbi->_sendnodes.size() << setw(8) << fbi->_recvnodes.size()
450  << setw(8)
451  << fbi->_sharenodes.size() << endl;
452  fbi++;
453  }
454  Ouf << "# End" << endl;
455  return(true);
456 }
457 
458 bool
459 TRAIL_FluReadDIM(GEM_Partition &gp,double t,bool unsteady)
460 {
461  if(gp._debug && gp._out)
462  *gp._out << "TRAIL_FluReadDIM: Entry" << "\n";
463  if(gp._solver_data._string_data.size() < 3){
464  if(gp._out)
465  *gp._out << "TRAIL_FluReadDIM::Error: No casename or path found."
466  << std::endl;
467  return(false);
468  }
469  string pre(gp._solver_data._string_data[1] + "/" +
470  gp._solver_data._string_data[0]);
471  ifstream Inf;
472  ostringstream Ostr;
473  Ostr << pre << ".dim_";
474  Ostr << setw(5) << setfill('0');
475  Ostr << gp._id;
476  string filebase(Ostr.str());
477  if(unsteady){
478  Ostr.clear();
479  Ostr.str("");
480  Ostr << "_" << scientific << setprecision(5) << t;
481  string timestring(Ostr.str());
482  timestring.replace(8,1,"E");
483  filebase+=timestring;
484  }
485  Inf.open(filebase.c_str());
486  if(!Inf){
487  if(gp._debug && gp._out)
488  *gp._out << "TRAIL_FluReadDIM: Unable to open " << filebase
489  << " for reading." << endl;
490  return(false);
491  }
492  string line;
493  unsigned int nreal_cells = 0;
494  unsigned int ncells = 0;
495  unsigned int npatches = 0;
496  unsigned int nreal_tets = 0;
497  unsigned int nreal_hex = 0;
498  unsigned int nreal_pris = 0;
499  unsigned int nreal_pyr = 0;
500  unsigned int nreal_nodes = 0;
501  unsigned int ntet = 0;
502  unsigned int nhex = 0;
503  unsigned int npris = 0;
504  unsigned int npyr = 0;
505  unsigned int nnodes = 0;
506  SkipLines(Inf,2);
507  Inf >> nreal_nodes >> nnodes;
508  SkipLines(Inf,2);
509  Inf >> nreal_cells >> ncells;
510  SkipLines(Inf,2);
511  Inf >> nreal_tets >> ntet;
512  SkipLines(Inf,2);
513  Inf >> nreal_hex >> nhex;
514  SkipLines(Inf,2);
515  Inf >> nreal_pris >> npris;
516  SkipLines(Inf,2);
517  Inf >> nreal_pyr >> npyr;
518  SkipLines(Inf,2);
519  unsigned int nelem = ntet + nhex + npyr + npris;
520  Inf >> npatches >> gp._solver_data._int_data[1][0]; // npatches_total
521  gp._ngnodes = nnodes - nreal_nodes;
522  gp._ngtet = ntet - nreal_tets;
523  gp._nghex = nhex - nreal_hex;
524  gp._ngpyr = npyr - nreal_pyr;
525  gp._ngpris = npris - nreal_pris;
526  assert(nelem == ncells);
527  if(gp._debug && gp._out)
528  *gp._out << "TRAIL_FluReadDIM: Elems: (" << nelem << ","
529  << gp._ngtet+gp._nghex+gp._ngpyr+gp._ngpris << ")" << endl
530  << "TRAIL_FluReadDIM: Nodes: (" << nnodes << ","
531  << gp._ngnodes << ")" << endl
532  << "TRAIL_FluReadDIM: Patches: (" << npatches << ","
533  << gp._solver_data._int_data[1][0] << ")" << endl;
534  gp._db.resize(npatches);
535  gp._tetconn.resize(4*ntet);
536  gp._hexconn.resize(8*nhex);
537  gp._prisconn.resize(6*npris);
538  gp._pyrconn.resize(5*npyr);
539  gp._nc.resize(3*nnodes);
540  vector<GEM_DomainBoundary>::iterator fpi = gp._db.begin();
541  while(fpi != gp._db.end()){
542  unsigned int nreal_tri = 0;
543  unsigned int nreal_quad = 0;
544  unsigned int ntri = 0;
545  unsigned int nquad = 0;
546  Inf >> fpi->_id >> nreal_tri >> ntri >> nreal_quad >> nquad;
547  fpi->_ngtri = ntri - nreal_tri;
548  fpi->_ngquad = nquad - nreal_quad;
549  fpi->_triconn.resize(ntri*3);
550  fpi->_quadconn.resize(nquad*4);
551  fpi++;
552  }
553  unsigned int nborders = 0;
554  SkipLines(Inf,2);
555  Inf >> nborders;
556  if(gp._debug && gp._out)
557  *gp._out << "TRAIL_FluReadDIM: Number of borders: " << nborders
558  << endl;
559  gp._pb.resize(nborders);
560  gp._solver_data._int_data[0].resize(nborders);
561  unsigned int pbindex = 0;
562  vector<GEM_PartitionBoundary>::iterator fbi = gp._pb.begin();
563  while(fbi != gp._pb.end()){
564  unsigned int nsend,nrecv,nshared,csend,crecv;
565  Inf >> fbi->_rpart
566  >> gp._solver_data._int_data[0][pbindex++] >> csend >> crecv
567  >> nsend >> nrecv >> nshared;
568  if(gp._debug && gp._out)
569  *gp._out << "TRAIL_FluReadDIM: Border: ("
570  << fbi->_rpart << ","
571  << gp._solver_data._int_data[0][pbindex - 1] << ","
572  << csend << "," << crecv << "," << nsend << "," << nrecv
573  << "," << nshared << ")" << endl;
574  fbi->_sharenodes.resize(nshared);
575  fbi->_sendnodes.resize(nsend);
576  fbi->_recvnodes.resize(nrecv);
577  fbi->_sendcells.resize(csend);
578  fbi->_recvcells.resize(crecv);
579  fbi++;
580  }
581  Inf.close();
582  if(gp._debug && gp._out)
583  *gp._out << "TRAIL_FluReadDIM: Exit" << endl;
584  return(true);
585 }
586 
587 bool
588 TRAIL_FluPopRemBordIndFILE(GEM_Partition &gp,double t,bool unsteady,
589  const std::string &path)
590 {
591  if(gp._solver_data._string_data.size() < 3){
592  if(gp._out)
593  *gp._out << "TRAIL_FluPopRemBordIndFILE:Error: No casename or path found."
594  << std::endl;
595  return(false);
596  }
597  std::string pre("./" + path + "/" + gp._solver_data._string_data[0]);
598  unsigned int pbindex = 0;
599  std::vector<GEM_PartitionBoundary>::iterator fbi = gp._pb.begin();
600  while(fbi != gp._pb.end()){
601  std::ifstream Inf;
602  std::ostringstream Ostr;
603  Ostr << pre << ".dim_";
604  Ostr << setw(5) << setfill('0');
605  Ostr << fbi->_rpart;
606  std::string filebase(Ostr.str());
607  if(unsteady){
608  Ostr.clear();
609  Ostr.str("");
610  Ostr << "_" << scientific << setprecision(5) << t;
611  std::string timestring(Ostr.str());
612  timestring.replace(8,1,"E");
613  filebase+=timestring;
614  }
615  Inf.open(filebase.c_str());
616  if(!Inf){
617  if(gp._debug && gp._out)
618  *gp._out
619  << "TRAIL_FluPopRemBordIndFILE: Unable to open "
620  << filebase << " for reading.\n";
621  return(false);
622  }
623  string line;
624  unsigned int fakeout = 0;
625  unsigned int nreal_cells = 0;
626  unsigned int nnodes = 0;
627  unsigned int nhex = 0;
628  unsigned int ntet = 0;
629  unsigned int npris = 0;
630  unsigned int npyr = 0;
631  unsigned int ncells = 0;
632  unsigned int npatches = 0;
633  unsigned int nreal_tets = 0;
634  unsigned int nreal_hex = 0;
635  unsigned int nreal_pris = 0;
636  unsigned int nreal_pyr = 0;
637  unsigned int nreal_nodes = 0;
638  unsigned int npatches_total = 0;
639  unsigned int ngnodes = 0;
640  unsigned int ngtet = 0;
641  unsigned int nghex = 0;
642  unsigned int ngpris = 0;
643  unsigned int ngpyr = 0;
644  SkipLines(Inf,2);
645  Inf >> nreal_nodes >> nnodes;
646  SkipLines(Inf,2);
647  Inf >> nreal_cells >> ncells;
648  SkipLines(Inf,2);
649  Inf >> nreal_tets >> ntet;
650  SkipLines(Inf,2);
651  Inf >> nreal_hex >> nhex;
652  SkipLines(Inf,2);
653  Inf >> nreal_pris >> npris;
654  SkipLines(Inf,2);
655  Inf >> nreal_pyr >> npyr;
656  SkipLines(Inf,2);
657  Inf >> npatches >> npatches_total;
658  ngnodes = nnodes - nreal_nodes;
659  ngtet = ntet - nreal_tets;
660  nghex = nhex - nreal_hex;
661  ngpyr = npyr - nreal_pyr;
662  ngpris = npris - nreal_pris;
663  if(gp._debug && gp._out)
664  *gp._out << "GEM_Partition(" << gp._id
665  << ")::PopRemBordIndFILE::Elems: ("
666  << ntet+npris+nhex+npyr
667  << "," << ngtet+nghex+ngpyr+ngpris << ")\n"
668  << "GEM_Partition(" << gp._id << ")::PopRemBordIndFILE"
669  << "::Nodes: ("
670  << nnodes << ","
671  << ngnodes << ")\n"
672  << "GEM_Partition(" << gp._id
673  << ")::PopRemBordIndFILE:: Patches: ("
674  << npatches << ","
675  << npatches_total << ")\n";
676  for(unsigned int pind = 0;pind < npatches;pind++){
677  unsigned int nreal_tri = 0;
678  unsigned int nreal_quad = 0;
679  Inf >> fakeout >> nreal_tri >> fakeout >> nreal_quad >> fakeout;
680  }
681  unsigned int nborders = 0;
682  SkipLines(Inf,2);
683  Inf >> nborders;
684  if(gp._debug && gp._out)
685  *gp._out << "GEM_Partition(" << gp._id << ")::PopRemBordIndFILE:: "
686  << "Number of borders: " << nborders
687  << "\n";
688  bool done = false;
689  for(unsigned int bind = 0;(bind < nborders && !done);bind++){
690  unsigned int rpart;
691  Inf >> rpart;
692  if(rpart == gp._id){
693  gp._solver_data._int_data[0][pbindex++] = bind+1;
694  done = true;
695  }
696  else
697  Inf >> fakeout >> fakeout >> fakeout >> fakeout >> fakeout >> fakeout;
698  }
699  if(!done)
700  return(false);
701  Inf.close();
702  // this->WriteFluDIM(prefix,t,unsteady);
703  fbi++;
704  }
705  return(true);
706 }
707 
708 bool
709 TRAIL_FluWriteCMP(GEM_Partition &gp,const std::string &path)
710 {
711  if(gp._solver_data._string_data.size() < 3){
712  if(gp._out)
713  *gp._out << "TRAIL_FluWriteCMP:Error: No casename or path found."
714  << std::endl;
715  return(false);
716  }
717  std::string pre("./" + path + "/" + gp._solver_data._string_data[0]);
718  std::ofstream Ouf;
719  std::ostringstream Ostr;
720  Ostr << pre << ".cmp_";
721  Ostr << setw(5) << setfill('0');
722  Ostr << gp._id;
723  Ouf.open(Ostr.str().c_str());
724  if(!Ouf)
725  return(false);
726  unsigned int ntet = gp._tetconn.size()/4;
727  unsigned int nhex = gp._hexconn.size()/8;
728  unsigned int npris = gp._prisconn.size()/6;
729  unsigned int npyr = gp._pyrconn.size()/5;
730  // BuildCellMapping();
731  Ouf << "# ROCFLU cell mapping file" << endl
732  << "# Dimensions" << endl
733  << setw(8) << ntet << setw(8) << nhex << setw(8) << npris
734  << setw(8) << npyr << endl;
735  // vector<pair<unsigned int,unsigned int> >::iterator ci = _cellmap.begin();
736  // int line = 0;
737  unsigned int el = 0;
738  unsigned int npl = 10;
739  if(ntet > 0){
740  el = 0;
741  Ouf << "# Tetrahedra" << endl;
742  while(el < ntet){
743  Ouf << setw(8) << gp.Elem2Cell(make_pair(1,++el));
744  if(!(el%npl))
745  Ouf << endl;
746  }
747  if(el%npl) Ouf << endl;
748  }
749  if(nhex > 0){
750  el = 0;
751  Ouf << "# Hexahedra" << endl;
752  while(el < nhex){
753  Ouf << setw(8) << gp.Elem2Cell(make_pair(4,++el));
754  if(!(el%npl))
755  Ouf << endl;
756  }
757  if(el%npl) Ouf << endl;
758  }
759  if(npris > 0){
760  el = 0;
761  Ouf << "# Prisms" << endl;
762  while(el < npris){
763  Ouf << setw(8) << gp.Elem2Cell(make_pair(3,++el));
764  if(!(el%npl))
765  Ouf << endl;
766  }
767  if(el%npl) Ouf << endl;
768  }
769  if(npyr > 0){
770  el = 0;
771  Ouf << "# Pyramids" << endl;
772  while(el<npyr){
773  Ouf << setw(8) << gp.Elem2Cell(make_pair(2,++el));
774  if(!(el%npl))
775  Ouf << endl;
776  }
777  if(el%npl) Ouf << endl;
778  }
779  Ouf << "# End" << endl;
780  Ouf.close();
781  return(true);
782 }
783 
784 void
786 {
787  unsigned int ncells = gp._tetconn.size()/4 + gp._prisconn.size()/6 +
788  gp._pyrconn.size()/5 + gp._hexconn.size()/8;
789  unsigned int nnodes = gp._nc.size()/3;
790  unsigned int nvfaces = gp._nvface;
791  if(gp._debug && gp._out)
792  *gp._out << "TRAIL_FluResizeVolSoln: Allocating for " << ncells << " cells"
793  << ", " << nnodes << " nodes and " << nvfaces << " volume faces."
794  << std::endl;
795  gp._data._int_data.resize(1);
796  gp._data._stride_int.resize(1);
797  gp._data._int_data[0].resize(1); // unsteady flag
798  gp._data._int_data[0][0] = 1; // unsteady yes
799  gp._data._field_data.resize(10);
800  gp._data._stride_field.resize(10);
801  gp._data._field_data[0].resize(1); // _current_time
802  gp._data._stride_field[0] = 1;
803  gp._data._field_data[0][0] = 0.0;
804  gp._data._field_data[1].resize(1); // _residual
805  gp._data._field_data[1][0] = 0.0;
806  gp._data._stride_field[1] = 1;
807  gp._data._field_data[2].resize(ncells,0.0); // rhof
808  gp._data._stride_field[2] = 1;
809  gp._data._field_data[3].resize(3*ncells,0.0); // rhovf
810  gp._data._stride_field[3] = 3;
811  gp._data._field_data[4].resize(ncells,0.0); //rhoEf
812  gp._data._stride_field[4] = 1;
813  gp._data._field_data[5].resize(ncells,0.0); // pf
814  gp._data._stride_field[5] = 1;
815  gp._data._field_data[6].resize(ncells,0.0); // Tf
816  gp._data._stride_field[6] = 1;
817  gp._data._field_data[7].resize(ncells,0.0); // af
818  gp._data._stride_field[7] = 1;
819  gp._data._field_data[8].resize(nnodes*3,0.0); // disp
820  gp._data._stride_field[8] = 3;
821  gp._data._field_data[9].resize(nvfaces,0.0); // gridspeeds
822  gp._data._stride_field[9] = 1;
823  if(gp._debug && gp._out)
824  *gp._out << "TRAIL_FluResizeVolSoln: Volume data allocated." << std::endl;
825 }
826 
827 bool
829 {
830  if(gp._solver_data._string_data.size() < 3 ||
831  gp._solver_data._string_data[1].empty()){
832  if(gp._out)
833  *gp._out << " TRAIL_FluInitVolSoln::Error: Solver data contains no path."
834  << std::endl;
835 
836  return(false);
837  }
838  string pre(gp._solver_data._string_data[1]+"/"+
839  gp._solver_data._string_data[0]);
840  string fname(pre+".inp");
841  ifstream Inf;
842  Inf.open(fname.c_str());
843  if(!Inf){
844  if(gp._out)
845  *gp._out << " TRAIL_FluInitVolSoln::Error: Could not open " << fname
846  << "." << std::endl;
847 
848  return false;
849  }
850  unsigned int ntet = gp._tetconn.size()/4;
851  unsigned int npyr = gp._pyrconn.size()/5;
852  unsigned int nhex = gp._hexconn.size()/8;
853  unsigned int npris = gp._prisconn.size()/6;
854  unsigned int nelem = ntet + npyr + npris + nhex;
855  // unsigned int nvert = gp._nc.size()/3;
857  string line;
858  double cp = -1.0;
859  double gamma = -1.0;
860  double velx = 0.0;
861  double vely = 0.0;
862  double velz = 0.0;
863  double press = -1.0;
864  double rho = -1.0;
865  if(gp._debug && gp._out)
866  *gp._out << "TRAIL_FluInitVolSoln: Initializing volume data." << std::endl;
867  while(getline(Inf,line)){
868  if(line[0] != '#'){
869  string::size_type xtime = line.find("STARTTIME");
870  string::size_type ftype = line.find("FLOWTYPE");
871  string::size_type xgamma = line.find("GAMMA");
872  string::size_type xpress = line.find("PRESS");
873  string::size_type x_dens = line.find("DENS");
874  string::size_type x_velx = line.find("VELX");
875  string::size_type x_vely = line.find("VELY");
876  string::size_type x_velz = line.find("VELZ");
877  string::size_type x_cp = line.find("CP");
878  string tstr;
879  istringstream Istr(line);
880  if(xtime != string::npos)
881  Istr >> tstr >> gp._data._field_data[0][0]; // current time
882  if(ftype != string::npos)
883  Istr >> tstr >> gp._data._int_data[0][0]; // flowtype (steady/unsteady)
884  if(xgamma != string::npos)
885  Istr >> tstr >> gamma;
886  if(xpress != string::npos)
887  Istr >> tstr >> press;
888  if(x_dens != string::npos)
889  Istr >> tstr >> rho;
890  if(x_velx != string::npos)
891  Istr >> tstr >> velx;
892  if(x_vely != string::npos)
893  Istr >> tstr >> vely;
894  if(x_velz != string::npos)
895  Istr >> tstr >> velz;
896  if(x_cp != string::npos)
897  Istr >> tstr >> cp;
898  }
899  }
900  if(gamma < 0 || press < 0 || rho < 0 || cp < 0)
901  return(false);
902  gp._data._field_data[2].resize(nelem,rho); // rhof
903  gp._data._stride_field[2] = 1;
904  double E = press/(rho*(gamma - 1.0)) +
905  (velx*velx + vely*vely + velz*velz)/2.0;
906  gp._data._field_data[3].resize(3*nelem,0.0); // rhovf
907  gp._data._stride_field[3] = 3;
908  if(velx != 0.0 || vely != 0.0 || velz != 0.0){
909  unsigned int index = 0;
910  for(unsigned int el = 0;el < nelem;el++){
911  gp._data._field_data[3][index++] = rho*velx;
912  gp._data._field_data[3][index++] = rho*vely;
913  gp._data._field_data[3][index++] = rho*velz;
914  }
915  }
916  double R = (cp*(gamma-1.0))/gamma;
917  double Ti = press/(rho*R);
918  double C = sqrt(gamma*press/rho);
919  gp._data._field_data[4].resize(nelem,rho*E); // rhoEf
920  gp._data._stride_field[4] = 1;
921  gp._data._field_data[5].resize(nelem,press); // pf
922  gp._data._stride_field[5] = 1;
923  gp._data._field_data[6].resize(nelem,Ti); // Tf
924  gp._data._stride_field[6] = 1;
925  gp._data._field_data[7].resize(nelem,C); // af
926  gp._data._stride_field[7] = 1;
927  // _data._field_data[8].resize(gp._nc.size(),0.0); // disp
928  // _data._stride_field[8] = 3;
929  // gp._data._field_data[9].resize(gp._nvface,0.0); // gridspeeds (gsp)
930  // gp._data._stride_field[9] = 1;
931  if(gp._debug && gp._out)
932  *gp._out << "TRAIL_FluInitVolSoln: Volume data initialized." << std::endl;
933  return(true);
934 }
935 
936 
937 void
939 {
940  unsigned int nfaces = db._triconn.size()/3 + db._quadconn.size()/4;
941  unsigned int nvert = db.NNodes();
942  if(db._debug && db._out)
943  *db._out << "TRAIL_FluResizeSurfSoln: Resizing with " << nfaces << " faces"
944  << " and " << nvert << " vertices." << std::endl;
945  db._data._field_data.resize(21);
946  db._data._stride_field.resize(21);
947  db._data._int_data.resize(3);
948  db._data._stride_int.resize(3);
949  db._data._int_data[1].resize(1); // bcflag
950  db._data._stride_int[1] = 1;
951  db._data._int_data[2].resize(1); // cnstr_type
952  db._data._stride_int[2] = 1;
953  db._data._field_data[0].resize(nfaces,0.0); // gsp
954  db._data._stride_field[0] = 1;
955  db._data._field_data[1].resize(3*nfaces,0.0); // rhofvf_alp
956  db._data._stride_field[1] = 3;
957  db._data._field_data[2].resize(3*nfaces,0.0); // nf_alp
958  db._data._stride_field[2] = 3;
959  db._data._field_data[3].resize(nfaces,0.0); // rhof_alp
960  db._data._stride_field[3] = 1;
961  db._data._field_data[4].resize(nfaces,0.0); // pf
962  db._data._stride_field[4] = 1;
963  db._data._field_data[5].resize(nfaces,0.0); // qc
964  db._data._stride_field[5] = 1;
965  db._data._field_data[6].resize(nfaces,0.0); // qr
966  db._data._stride_field[6] = 1;
967  db._data._field_data[7].resize(3*nfaces,0.0); // tf
968  db._data._stride_field[7] = 3;
969  db._data._field_data[8].resize(nfaces,0.0); // Tb_alp
970  db._data._stride_field[8] = 1;
971  db._data._field_data[9].resize(nfaces,0.0); // mdot_alp
972  db._data._stride_field[9] = 1;
973  db._data._field_data[10].resize(nfaces,0.0); // Tflm_alp
974  db._data._stride_field[10] = 1;
975  db._data._int_data[0].resize(nfaces,0); // bflag
976  db._data._stride_int[0] = 1;
977  db._data._field_data[11].resize(nfaces,0.0); // Tf
978  db._data._stride_field[11] = 1;
979  db._data._field_data[12].resize(3*nvert,0.0); // vm
980  db._data._stride_field[12] = 3;
981  db._data._field_data[13].resize(3*nfaces,0.0); // vs
982  db._data._stride_field[13] = 3;
983  db._data._field_data[14].resize(3*nfaces,0.0); // vs_old
984  db._data._stride_field[14] = 3;
985  db._data._field_data[15].resize(nfaces,0.0); // ts
986  db._data._stride_field[15] = 1;
987  db._data._field_data[16].resize(nfaces,0.0); // mdot
988  db._data._stride_field[16] = 1;
989  db._data._field_data[17].resize(nfaces,0.0); // mdot_old
990  db._data._stride_field[17] = 1;
991  db._data._field_data[18].resize(nvert*3,0.0); // du_alp
992  db._data._stride_field[18] = 3;
993  db._data._field_data[19].resize(3*nvert,0.0); // nc_t0
994  db._data._stride_field[19] = 3;
995  db._data._field_data[20].resize(nvert,0.0); // sq_dist
996  db._data._stride_field[20] = 1;
997  if(db._debug && db._out)
998  *db._out << "TRAIL_FluResizeSurfSoln: Resizing done." << std::endl;
999 }
1000 
1001 bool
1002 TRAIL_FluInitSurfSoln(GEM_DomainBoundary &db,const std::string &prefix,bool all)
1003 {
1004  string pre(prefix);
1005  if(pre.empty())
1006  return(false);
1007  unsigned int ntri = db._triconn.size()/3;
1008  unsigned int nquad = db._quadconn.size()/4;
1009  unsigned int nfaces = ntri + nquad;
1010  // unsigned int nvert = db.NNodes();
1011  // if(all){
1012  // FIXME FIXME
1013  //#ifdef _ROCSTAR_X_
1015  //#else
1016  // Rocflu only needs only gsp for field data
1017  // nfaces = (ntri+nquad)- (_ngtri + _ngquad);
1018  // TRAIL_FluResizeSurfSoln(nfaces,nvert,db);
1019  // for(int i = 1;i < 22;i++){
1020  // db._data._field_data[i].resize(0);
1021  // db._data._stride_field[i] = 0;
1022  // }
1023  //#endif
1024  // }
1025  //#ifdef _ROCSTAR_X_
1026  int constraint_map[] = { 2 , 120, 121, 122, -122, -121, -120, 0};
1027  // Populate the Rocstar data living on the surface
1028  string fname(pre+".bc");
1029  ifstream Inf;
1030  Inf.open(fname.c_str());
1031  if(!Inf){
1032  if(db._out)
1033  *db._out << "TRAIL_FluInitSurfSoln: Error: could not locate bc file, "
1034  << fname << "." << std::endl;
1035  return false;
1036  }
1037  string line;
1038  bool found_patch = false;
1039  while(getline(Inf,line) && !found_patch){
1040  if(line[0] != '#'){
1041  string::size_type patchx = line.find("PATCH");
1042  if( patchx != string::npos){
1043  string tstr;
1044  unsigned int ubound,lbound;
1045  istringstream Istr(line);
1046  Istr >> tstr >> lbound >> ubound;
1047  if(db._id >= lbound && db._id <= ubound)
1048  found_patch = true;
1049  }
1050  }
1051  }
1052  if(!found_patch){
1053  if(db._out)
1054  *db._out << "TRAIL_FluInitSurfSoln: Error: "
1055  << "Did not find patch " << db._id << " in bc file." << endl;
1056  return(false);
1057  }
1058  // Now we want to search forward for the relevant data until we encounter #
1059  bool end_section = false;
1060  db._data._int_data[1][0] = 2; //_bcflag = 2;
1061  db._data._int_data[2][0] = 2; // _constr_type = 2;
1062  db._data._stride_int[1] = 1;
1063  db._data._stride_int[2] = 1;
1064  while(getline(Inf,line) && !end_section){
1065  if(line[0] == '#') end_section = true;
1066  else{
1067  string::size_type movx = line.find("MOVEDIR");
1068  string::size_type coupx = line.find("COUPLED");
1069  string::size_type burn = line.find("BFLAG");
1070  if(movx != string::npos){
1071  string tstr;
1072  int mvdir;
1073  istringstream Istr(line);
1074  Istr >> tstr >> mvdir;
1075  db._data._int_data[2][0] = constraint_map[mvdir];
1076  }
1077  if(coupx != string::npos){
1078  string tstr;
1079  istringstream Istr(line);
1080  Istr >> tstr >> db._data._int_data[1][0];
1081  }
1082  if(burn != string::npos){
1083  string tstr;
1084  unsigned int burnf = 0;
1085  istringstream Istr(line);
1086  Istr >> tstr >> burnf;
1087  db._data._int_data[0].resize(nfaces,burnf);
1088  db._data._stride_int[0] = 1;
1089  }
1090  }
1091  }
1092  //#endif
1093  Inf.close();
1094  if(db._debug && db._out)
1095  *db._out << "TRAIL_FluInitSurfSoln: Exit" << endl;
1096  return true;
1097 }
1098 
1099 int
1101 {
1102  if(gp._solver_data._string_data.size() < 3 ||
1103  gp._solver_data._string_data[0].empty() ||
1104  gp._solver_data._string_data[1].empty()){
1105  if(gp._out)
1106  *gp._out << "TRAIL_FluNumPatches:Error: solver data has no casename"
1107  << " or path." << std::endl;
1108  return 0;
1109  }
1110  string pre(gp._solver_data._string_data[1]+ "/" +
1111  gp._solver_data._string_data[0]);
1112  string filename(pre+".bc");
1113  ifstream Inf;
1114  Inf.open(filename.c_str());
1115  string line;
1116  int npatches = 0;
1117  if(!Inf) return 0;
1118  while(!Inf.eof()){
1119  bool found = false;
1120  while(!found){
1121  getline(Inf,line);
1122  if(line[0] == '#')
1123  found = true;
1124  }
1125  found = false;
1126  while(getline(Inf,line) && !found){
1127  if(line[0] != '#'){
1128  string::size_type patchx = line.find("PATCH");
1129  if( patchx != string::npos){
1130  string tstr;
1131  unsigned int ubound,lbound;
1132  istringstream Istr(line);
1133  Istr >> tstr >> lbound >> ubound;
1134  npatches += ((ubound - lbound) + 1);
1135  found = true;
1136  }
1137  }
1138  }
1139  }
1140  Inf.close();
1141  return npatches;
1142 }
1143 
1144 bool
1146 {
1147  if(gp._solver_data._string_data.size() < 3 ||
1148  gp._solver_data._string_data[1].empty()){
1149  if(gp._out)
1150  *gp._out << "TRAIL_FluInitSurfSoln::Error: Solver data contains no"
1151  << " path." << std::endl;
1152  return(false);
1153  }
1154  unsigned int ndb = gp._db.size();
1155  unsigned int n = 0;
1156  std::string pre(gp._solver_data._string_data[1]+"/"+
1157  gp._solver_data._string_data[0]);
1158  while(n < ndb){
1159  if(!TRAIL_FluInitSurfSoln(gp._db[n++],pre,true))
1160  return(false);
1161  }
1162  return(true);
1163 }
1164 
1165 bool
1167 {
1168  gp.Create_com_volsoln("rhof",gp._data._field_data[2],1,"kg/m^3");
1169  gp.Create_com_volsoln("rhovf",gp._data._field_data[3],3,"kg/(m^2s)");
1170  gp.Create_com_volsoln("rhoEf",gp._data._field_data[4],1,"J/m^3");
1171  COM_new_attribute((gp.volume_window+".gs"),'p',COM_DOUBLE,1,"m/s");
1172  COM_set_size((gp.volume_window+".gs"),gp.pane_id,gp._nvface);
1173  if(gp._data._field_data[9].size() != 0)
1174  COM_set_array((gp.volume_window+".gs"),gp.pane_id,
1175  &(gp._data._field_data[9][0]));
1176  gp.Create_com_volsoln("pf",gp._data._field_data[5],1,"Pa");
1177  gp.Create_com_volsoln("Tf",gp._data._field_data[6],1,"K");
1178  gp.Create_com_volsoln("af",gp._data._field_data[7],1,"m/s");
1179  return(true);
1180 }
1181 
1182 bool
1183 TRAIL_FluRegisterSurfSoln(GEM_DomainBoundary &db,const string &wname,bool all)
1184 {
1185  if(db._debug && db._out)
1186  *db._out << "TRAIL_FluRegisterSoln: "
1187  << "Registering pane " << db.pane_id << "." << endl;
1188  if(db._data._field_data[0].size() != 0){
1189  COM_set_array((wname+".gs"),db.pane_id,&(db._data._field_data[0][0]));
1190  }
1191  COM_set_size((wname+".patchNo"),db.pane_id,1);
1192  COM_set_array((wname+".patchNo"),db.pane_id,&db._id);
1193  COM_set_size((wname+".bcflag"),db.pane_id,1);
1194  COM_set_array((wname+".bcflag"),db.pane_id,&db._data._int_data[1][0]);
1195  COM_set_size((wname+".cnstr_type"),db.pane_id,1);
1196  COM_set_array((wname+".cnstr_type"),db.pane_id,&db._data._int_data[2][0]);
1197  if(db._data._int_data[0].size() > 0)
1198  COM_set_array((wname+".bflag"),db.pane_id,&(db._data._int_data[0]));
1199  if(all){
1200  db.Create_com_surfsoln(wname,"rhofvf_alp",db._data._field_data[1],
1201  3,"kg/(m^2s)");
1202  db.Create_com_surfsoln(wname,"nf_alp",db._data._field_data[2],3,"");
1203  db.Create_com_surfsoln(wname,"rhof_alp",db._data._field_data[3],
1204  1,"kg/m^3");
1205  db.Create_com_surfsoln(wname,"pf",db._data._field_data[4],1,"Pa");
1206  db.Create_com_surfsoln(wname,"qc",db._data._field_data[5],1,"W/m^2");
1207  db.Create_com_surfsoln(wname,"qr",db._data._field_data[6],1,"W/m^2");
1208  db.Create_com_surfsoln(wname,"tf",db._data._field_data[7],3,"Pa");
1209  db.Create_com_surfsoln(wname,"Tb_alp",db._data._field_data[8],1,"K");
1210  db.Create_com_surfsoln(wname,"mdot_alp",db._data._field_data[9],
1211  1,"kg/(m^2s)");
1212  db.Create_com_surfsoln(wname,"Tflm_alp",db._data._field_data[10],1,"K");
1213  db.Create_com_surfsoln(wname,"Tf",db._data._field_data[11],1,"K");
1214  db.Create_com_surfsoln(wname,"vs",db._data._field_data[13],3,"m/s");
1215  db.Create_com_surfsoln(wname,"vs_old",db._data._field_data[14],3,"m/s");
1216  db.Create_com_surfsoln(wname,"ts",db._data._field_data[15],1,"Pa");
1217  db.Create_com_surfsoln(wname,"mdot",db._data._field_data[16],
1218  1,"kg/(m^2s)");
1219  db.Create_com_surfsoln(wname,"mdot_old",db._data._field_data[17],
1220  1,"kg/(m^2s)");
1221  // Nodal Data
1222  if(db._data._field_data[19].size() > 0)
1223  COM_set_array((wname+".nc_t0"),db.pane_id,&db._data._field_data[19][0]);
1224  if(db._data._field_data[18].size() > 0)
1225  COM_set_array((wname+".du_alp"),db.pane_id,&db._data._field_data[18][0]);
1226  if(db._data._field_data[12].size() > 0)
1227  COM_set_array((wname+".vm"),db.pane_id,&db._data._field_data[12][0]);
1228  if(db._data._field_data[20].size() > 0)
1229  COM_set_array((wname+".sq_dist"),db.pane_id,
1230  &db._data._field_data[20][0]);
1231 
1232  }
1233  return(true);
1234 }
1235 
1236 bool
1238 {
1239 
1240  if(gp._debug && gp._out)
1241  *gp._out << "TRAIL_FluRegisterSurfSoln Enter"
1242  << endl;
1243  COM_new_attribute((gp.surface_window+".gs"),'e',COM_DOUBLE,1,"m/s");
1244  COM_new_attribute((gp.surface_window+".bcflag"),'p',COM_INT,1,"");
1245  COM_new_attribute((gp.surface_window+".cnstr_type"),'p',COM_INT,1,"");
1246  COM_new_attribute((gp.surface_window+".patchNo"),'p',COM_INT,1,"");
1247  COM_new_attribute((gp.surface_window+".bflag"),'e',COM_INT,1,"");
1248  if(all){
1249  COM_new_attribute(gp.surface_window+".rhofvf_alp",'e',
1250  COM_DOUBLE,3,"kg/(m^2s)");
1251  COM_new_attribute(gp.surface_window+".nf_alp",'e',COM_DOUBLE,3,"");
1252  COM_new_attribute(gp.surface_window+".rhof_alp",'e',COM_DOUBLE,1,"kg/m^3");
1253  COM_new_attribute(gp.surface_window+".pf",'e',COM_DOUBLE,1,"Pa");
1254  COM_new_attribute(gp.surface_window+".qc",'e',COM_DOUBLE,1,"W/m^2");
1255  COM_new_attribute(gp.surface_window+".qr",'e',COM_DOUBLE,1,"W/m^2");
1256  COM_new_attribute(gp.surface_window+".tf",'e',COM_DOUBLE,3,"Pa");
1257  COM_new_attribute(gp.surface_window+".Tb_alp",'e',COM_DOUBLE,1,"K");
1258  COM_new_attribute(gp.surface_window+".mdot_alp",'e',COM_DOUBLE,1,
1259  "kg/(m^2s)");
1260  COM_new_attribute(gp.surface_window+".Tflm_alp",'e',COM_DOUBLE,1,"K");
1261  COM_new_attribute(gp.surface_window+".Tf",'e',COM_DOUBLE,1,"K");
1262  COM_new_attribute(gp.surface_window+".ts",'e',COM_DOUBLE,1,"Pa");
1263  COM_new_attribute(gp.surface_window+".mdot",'e',COM_DOUBLE,1,"kg/(m^2s)");
1264  COM_new_attribute(gp.surface_window+".mdot_old",'e',COM_DOUBLE,1,
1265  "kg/(m^2s)");
1266  COM_new_attribute(gp.surface_window+".vs",'e',COM_DOUBLE,3,"m/s");
1267  COM_new_attribute(gp.surface_window+".vs_old",'e',COM_DOUBLE,3,"m/s");
1268 
1269  // Nodal data
1270  COM_new_attribute((gp.surface_window+".nc_t0"),'n',COM_DOUBLE,3,"m");
1271  COM_new_attribute((gp.surface_window+".vm"),'n',COM_DOUBLE,3,"m/s");
1272  COM_new_attribute((gp.surface_window+".sq_dist"),'n',COM_DOUBLE,1,"m");
1273  COM_new_attribute((gp.surface_window+".du_alp"),'n',COM_DOUBLE,3,"m");
1274  }
1275  vector<GEM_DomainBoundary>::iterator fpi = gp._db.begin();
1276  if(gp._debug && gp._out)
1277  *gp._out << "TRAIL_FluRegisterSurfSoln: "
1278  << "Registering domain boundaries..." << endl;
1279  while(fpi != gp._db.end()){
1280  GEM_DomainBoundary &fp = *fpi++;
1282  }
1283  if(gp._debug && gp._out)
1284  *gp._out << "TRAIL_FluRegisterSurfSoln: "
1285  << "Registering domain boundaries done." << endl;
1286  return(true);
1287 }
1288 
1289 bool
1291 {
1292  COM_new_attribute((gp.surface_window+".t3g:real"),'p',COM_INT,3,"");
1293  COM_new_attribute((gp.surface_window+".t3g:virtual"),'p',COM_INT,3,"");
1294  COM_new_attribute((gp.surface_window+".q4g:real"),'p',COM_INT,4,"");
1295  COM_new_attribute((gp.surface_window+".q4g:virtual"),'p',COM_INT,4,"");
1296 
1297  vector<GEM_DomainBoundary>::iterator fpi = gp._db.begin();
1298  while(fpi != gp._db.end()){
1299  GEM_DomainBoundary &fp = *fpi++;
1300  unsigned int nreal = fp._triconn.size()/3 - fp._ngtri;
1301  if(nreal > 0){
1302  COM_set_size((gp.surface_window+".t3g:real"),fp.pane_id,nreal);
1303  COM_set_array((gp.surface_window+".t3g:real"),fp.pane_id,
1304  &(fp._triconn[0]),3);
1305  }
1306  nreal = fp._quadconn.size()/4 - fp._ngquad;
1307  if(nreal > 0){
1308  COM_set_size((gp.surface_window+".q4g:real"),fp.pane_id,nreal);
1309  COM_set_array((gp.surface_window+".q4g:real"),fp.pane_id,
1310  &(fp._quadconn[0]),4);
1311  }
1312  if(fp._ngtri > 0){
1313  nreal = fp._triconn.size()/3 - fp._ngtri;
1314  COM_set_size((gp.surface_window+".t3g:virtual"),fp.pane_id,
1315  fp._ngtri,fp._ngtri);
1316  COM_set_array((gp.surface_window+".t3g:virtual"),fp.pane_id,
1317  &(fp._triconn[nreal*3]),3);
1318  }
1319  if(fp._ngquad > 0){
1320  nreal = fp._quadconn.size()/4 - fp._ngquad;
1321  COM_set_size((gp.surface_window+".q4g:virtual"),fp.pane_id,
1322  fp._ngquad,fp._ngquad);
1323  COM_set_array((gp.surface_window+".q4g:virtual"),fp.pane_id,
1324  &(fp._quadconn[nreal*4]),4);
1325  }
1326  }
1327  return(true);
1328 }
1329 
1330 bool
1331 TRAIL_FluBuildPatchMapping(map<unsigned int,unsigned int> &pmap,
1332  const string &prefix)
1333 {
1334  // Build the patch mapping from the hand produced patch mapping file
1335  ostringstream Ostr;
1336  string pre(prefix);
1337  // if(pre.empty()){
1338  // if(_casename.empty())
1339  // pre = "./";
1340  // else
1341  // pre = _casepath + "/" + _casename;
1342  //}
1343  Ostr << pre << ".cgi";
1344  ifstream bcfile;
1345  bcfile.open(Ostr.str().c_str());
1346  if(!bcfile)
1347  return(false);
1348  // map< unsigned int,unsigned int > pmap;
1349  unsigned int nggpmap_lines;
1350  unsigned int npatches_total;
1351  // _solver_data._int_data[1][0] is _npatches_total
1352  bcfile >> npatches_total >> nggpmap_lines;
1353  unsigned int patch_line = 0;
1354  while(patch_line < nggpmap_lines){
1355  unsigned int low, high, flupatch;
1356  bcfile >> low >> high >> flupatch;
1357  unsigned int p = low;
1358  while(p <= high)
1359  pmap[p++] = flupatch;
1360  patch_line++;
1361  }
1362  // if(_debug && _out){
1363  // *_out << "BuildFluPatchMapping: Patch Mapping:\n";
1364  // map<unsigned int,unsigned int>::iterator mi = pmap.begin();
1365  // while(mi != pmap.end()){
1366  // *_out << "BuildFluPatchMapping: (" << mi->first << ","
1367  // << mi->second << ")\n";
1368  // mi++;
1369  // }
1370  // }
1371  bcfile.close();
1372  return(true);
1373 }
1374 
1375 
1376 bool
1378 {
1379  if(gp._solver_data._string_data.size() < 3 ||
1380  gp._solver_data._string_data[0].empty() ||
1381  gp._solver_data._string_data[1].empty()){
1382  if(gp._out)
1383  *gp._out << "TRAIL_FluPopulatePatches:Error: solver data has no casename"
1384  << " or path." << std::endl;
1385  return(false);
1386  }
1387  string pre(gp._solver_data._string_data[1]+ "/" +
1388  gp._solver_data._string_data[0]);
1389  map<unsigned int,unsigned int> patch_mapping;
1390  TRAIL_FluBuildPatchMapping(patch_mapping,pre);
1391  gp.MapDomainBoundaries(patch_mapping);
1392  return(true);
1393 }
1394 
1395 bool
1396 TRAIL_FluWriteNative(GEM_Partition &gp,const std::string &path)
1397 {
1398  bool error = false;
1399  if(gp._solver_data._string_data.size() < 3)
1400  error = true;
1401  if(gp._solver_data._string_data[0].empty() ||
1402  gp._solver_data._string_data[1].empty())
1403  error = true;
1404  if(gp._solver_data._int_data.empty())
1405  error = true;
1406  if(error){
1407  if(gp._out)
1408  *(gp._out) << "TRAIL_FluWriteNative: Error. Called with empty"
1409  << " solver data." << endl;
1410  return false;
1411  }
1412  if(!TRAIL_FluWriteCMP(gp,path))
1413  error = true;
1414  if(gp._solver_data._int_data[0].empty()){
1415  gp._solver_data._int_data[0].resize(gp._pb.size(),0);
1416  gp._solver_data._stride_int[0] = gp._pb.size();
1417  }
1418  if(!TRAIL_FluWriteDIM(gp,0.0,true,path))
1419  error = true;
1420  if(!TRAIL_FluWriteCOM(gp,path))
1421  error = true;
1422  return(!error);
1423 }
1424 
1425 
1426 
1427 // Populates our connectivites from the ASCII grid files
1428 // pre should contain the path + casename
1429 // Ex: /my/directory/StarSlice
1430 bool
1431 TRAIL_FluReadGridASCII(GEM_Partition &gp,double t,bool unsteady)
1432 {
1433  if(gp._solver_data._string_data.size() < 3 ||
1434  gp._solver_data._string_data[0].empty() ||
1435  gp._solver_data._string_data[1].empty()){
1436  if(gp._out)
1437  *gp._out << "TRAIL_FluReadGridASCII:Error: solver data has no casename"
1438  << " or path." << std::endl;
1439  return 0;
1440  }
1441  string pre(gp._solver_data._string_data[1]+ "/" +
1442  gp._solver_data._string_data[0]);
1443  ostringstream Ostr;
1444  Ostr << pre << ".grda_" << setw(5) << setfill('0') << gp._id;
1445  string filebase(Ostr.str());
1446  Ostr.clear();
1447  Ostr.str("");
1448  Ostr << "_" << scientific << setprecision(5) << t;
1449  string timestring(Ostr.str());
1450  timestring.replace(8,1,"E");
1451  if(unsteady) filebase+=timestring;
1452  ifstream Inf;
1453  Inf.open(filebase.c_str());
1454  if(!Inf){
1455  if(gp._debug && gp._out)
1456  *gp._out << "TRAIL_FluReadGridASCII: Unable to open " << filebase
1457  << " for reading.\n";
1458  return(false);
1459  }
1460  string line;
1461  SkipLines(Inf,6);
1462  unsigned int nnode,ntet,nhex,npris,npyr;
1463  Inf >> nnode >> ntet >> nhex >> npris >> npyr;
1464  assert(nnode == gp._nc.size()/3 &&
1465  ntet == gp._tetconn.size()/4 &&
1466  nhex == gp._hexconn.size()/8 &&
1467  npris == gp._prisconn.size()/6 &&
1468  npyr == gp._pyrconn.size()/5);
1469  SkipLines(Inf,2);
1470  for(int i = 0; i < 3;i++){
1471  unsigned int node = 0;
1472  while(node < nnode)
1473  Inf >> gp._nc[(node++)*3+i];
1474  }
1475  if(ntet > 0){
1476  gp._tetconn.resize(ntet*4);
1477  SkipLines(Inf,2);
1478  for(int i = 0;i < 4;i++){
1479  unsigned int el = 0;
1480  while(el < ntet)
1481  Inf >> gp._tetconn[(el++)*4+i];
1482  }
1483  }
1484  if(nhex > 0){
1485  gp._hexconn.resize(nhex*8);
1486  SkipLines(Inf,2);
1487  for(int i = 0;i < 8;i++){
1488  unsigned int el = 0;
1489  while(el < nhex)
1490  Inf >> gp._hexconn[(el++)*8+i];
1491  }
1492  }
1493  if(npris > 0){
1494  gp._prisconn.resize(npris*6);
1495  SkipLines(Inf,2);
1496  for(int i = 0;i < 6;i++){
1497  unsigned int el = 0;
1498  while(el < npris)
1499  Inf >> gp._prisconn[(el++)*6+i];
1500  }
1501  }
1502  if(npyr > 0){
1503  gp._pyrconn.resize(npyr*5);
1504  SkipLines(Inf,2);
1505  for(int i = 0;i < 5;i++){
1506  unsigned int el = 0;
1507  while(el < npyr)
1508  Inf >> gp._pyrconn[(el++)*5+i];
1509  }
1510  }
1511  SkipLines(Inf,2);
1512  unsigned int npatches = 0;
1513  unsigned int patch = 0;
1514  Inf >> npatches;
1515  assert(npatches == gp._db.size());
1516  while(patch < npatches){
1517  GEM_DomainBoundary &fp = gp._db[patch++];
1518  unsigned int ntri,nquad;
1519  Inf >> ntri >> nquad;
1520  // assert(ntri == fp._ntri && nquad == fp._nquad);
1521  if(ntri > 0){
1522  fp._triconn.resize(3*ntri);
1523  for(int i = 0;i < 3;i++){
1524  unsigned int tri = 0;
1525  while(tri < ntri)
1526  Inf >> fp._triconn[(tri++)*3+i];
1527  }
1528  }
1529  if(nquad > 0){
1530  fp._quadconn.resize(4*nquad);
1531  for(int i = 0;i < 4;i++){
1532  unsigned int quad = 0;
1533  while(quad < nquad)
1534  Inf >> fp._quadconn[(quad++)*4+i];
1535  }
1536  }
1537  }
1538  Inf.close();
1539  return true;
1540 }
1541 
1542 void
1543 TRAIL_FluCopyCaseFiles(GEM_Partition &gp,const std::string &path)
1544 {
1545  std::string casename(gp._solver_data._string_data[0]);
1546  std::string casepath(gp._solver_data._string_data[1]);
1547  std::ifstream Inf;
1548  std::ofstream Ouf;
1549  std::string filename;
1550  filename.assign(casename+".bc");
1551  Inf.open((casepath+"/"+filename).c_str());
1552  Ouf.open((path+"/"+filename).c_str());
1553  Ouf << Inf.rdbuf();
1554  Ouf.close();
1555  Inf.close();
1556  Ouf.clear();
1557  Inf.clear();
1558  filename.assign(casename+".cgi");
1559  Inf.open((casepath+"/"+filename).c_str());
1560  Ouf.open((path+"/"+filename).c_str());
1561  Ouf << Inf.rdbuf();
1562  Ouf.close();
1563  Inf.close();
1564  Ouf.clear();
1565  Inf.clear();
1566  filename.assign(casename+".inp");
1567  Inf.open((casepath+"/"+filename).c_str());
1568  Ouf.open((path+"/"+filename).c_str());
1569  Ouf << Inf.rdbuf();
1570  Ouf.close();
1571  Inf.close();
1572  Ouf.clear();
1573  Inf.clear();
1574  filename.assign(casename+".map");
1575  Inf.open((casepath+"/"+filename).c_str());
1576  Ouf.open((path+"/"+filename).c_str());
1577  Ouf << Inf.rdbuf();
1578  Ouf.close();
1579  Inf.close();
1580 }
1581 
1582 // bool
1583 // ReadFluSolnASCII(const string &prefix,unsigned int n,
1584 // double t,bool unsteady,GEM_Partition &gp)
1585 // {
1586 // string pre(prefix);
1587 // if(pre.empty()){
1588 // // if(_casename.empty())
1589 // // pre = "./";
1590 // // else
1591 // // pre = _casepath + "/" + _casename;
1592 // pre = "rocflu";
1593 // }
1594 // ostringstream Ostr;
1595 // Ostr << pre << ".mixt.cva_" << setw(5) << setfill('0') << gp._id << "_";
1596 // string filebase(Ostr.str());
1597 // Ostr.str("");
1598 // Ostr << setw(6) << setfill('0') << n;
1599 // string iterstring(Ostr.str());
1600 // Ostr.clear();
1601 // Ostr.str("");
1602 // Ostr << scientific << setprecision(5) << t;
1603 // string timestring(Ostr.str());
1604 // timestring.replace(7,1,"E");
1605 // ifstream Inf;
1606 // if(unsteady) filebase+=timestring;
1607 // else filebase+=iterstring;
1608 // Inf.open(filebase.c_str());
1609 // if(!Inf){
1610 // if(gp._debug && gp._out)
1611 // *gp._out << "FluRegion::ReadFluSolnASCII: Unable to open " << filebase
1612 // << " for reading.\n";
1613 // return(false);
1614 // }
1615 // string line;
1616 // SkipLines(Inf,4);
1617 // Inf >> _soln._resid;
1618 // SkipLines(Inf,2);
1619 // Inf >> _soln._current_time;
1620 // SkipLines(Inf,2);
1621 // unsigned int ncells = 0;
1622 // Inf >> ncells;
1623 // assert(ncells == nelem());
1624 // SkipLines(Inf,2);
1625 // unsigned int cell = 0;
1626 // _soln._rhof.resize(ncells,0.0);
1627 // _soln._rhovf.resize(3*ncells,0.0);
1628 // _soln._rhoEf.resize(ncells,0.0);
1629 // while(cell < ncells)
1630 // Inf >> _soln._rhof[cell++];
1631 // SkipLines(Inf,2);
1632 // for(int i = 0;i < 3;i++){
1633 // cell = 0;
1634 // while(cell < ncells)
1635 // Inf >> _soln._rhovf[(cell++)*3+i];
1636 // SkipLines(Inf,2);
1637 // }
1638 // cell = 0;
1639 // while(cell < ncells)
1640 // Inf >> _soln._rhoEf[cell++];
1641 // if(!ReadGSPASCII(pre,n,t,unsteady)){
1642 // if(_debug && _out)
1643 // *_out
1644 // << "FluRegion::ReadFluSolnASCII: Unable to process grid speed file."
1645 // << "\n";
1646 // return(false);
1647 // }
1648 // Inf.close();
1649 // return(true);
1650 // }
1651 // bool
1652 // FluRegion::WriteFluSolnASCII(const string &prefix,unsigned int n,
1653 // double t,bool unsteady)
1654 // {
1655 // if(_debug && _out)
1656 // *_out << "FluRegion::WriteFluSolnASCII: Enter\n";
1657 // string pre(prefix);
1658 // if(pre.empty()){
1659 // if(_casename.empty())
1660 // pre = "./";
1661 // else
1662 // pre = _casepath + "/" + _casename + ".";
1663 // }
1664 // else
1665 // pre += ".";
1666 // ostringstream Ostr;
1667 // Ostr << pre << "mixt.cva_" << setw(5) << setfill('0') << _id << "_";
1668 // string filebase(Ostr.str());
1669 // Ostr.str("");
1670 // Ostr << setw(6) << setfill('0') << n;
1671 // string iterstring(Ostr.str());
1672 // Ostr.clear();
1673 // Ostr.str("");
1674 // Ostr << scientific << setprecision(5) << t;
1675 // string timestring(Ostr.str());
1676 // timestring.replace(7,1,"E");
1677 // ofstream Ouf;
1678 // if(!unsteady)
1679 // filebase+=iterstring;
1680 // else
1681 // filebase+=timestring;
1682 // Ouf.open(filebase.c_str());
1683 // if(!Ouf)
1684 // return false;
1685 // unsigned int ncells = nelem();
1686 // unsigned int n_cvar = 5;
1687 // Ouf << "# ROCFLU flow file" << endl
1688 // << "# Precision and range" << endl
1689 // << setw(8) << 15 << setw(8) << 307 << endl
1690 // << "# Initial residual" << endl
1691 // << setw(23) << scientific << setprecision(16)
1692 // << _soln._resid << endl
1693 // << "# Physical time" << endl
1694 // << setw(23) << scientific << setprecision(16)
1695 // << _soln._current_time << endl
1696 // << "# Dimensions" << endl
1697 // << setw(8) << ncells << setw(8) << n_cvar << endl
1698 // << "# Mixture density" << endl;
1699 // unsigned int cell = 0;
1700 // unsigned int ll = 5;
1701 // while(cell < ncells){
1702 // Ouf << setw(23) << scientific << setprecision(16)
1703 // << _soln._rhof[cell++];
1704 // if(!(cell%ll))
1705 // Ouf << endl;
1706 // }
1707 // if(cell%ll)
1708 // Ouf << endl;
1709 // for(int i = 0;i < 3;i++){
1710 // Ouf << "# Mixture "
1711 // << (i == 0 ? "x-momentum" :
1712 // i == 1 ? "y-momentum" : "z-momentum")
1713 // << endl;
1714 // cell = 0;
1715 // while(cell < ncells){
1716 // Ouf << setw(23) << scientific << setprecision(16)
1717 // << _soln._rhovf[(cell++)*3+i];
1718 // if(!(cell%ll))
1719 // Ouf << endl;
1720 // }
1721 // if(cell%ll)
1722 // Ouf << endl;
1723 // }
1724 // Ouf << "# Mixture total internal energy" << endl;
1725 // cell = 0;
1726 // while(cell < ncells){
1727 // Ouf << setw(23) << scientific << setprecision(16)
1728 // << _soln._rhoEf[cell++];
1729 // if(!(cell%ll))
1730 // Ouf << endl;
1731 // }
1732 // if(cell%ll)
1733 // Ouf << endl;
1734 // Ouf << "# End" << endl;
1735 // Ouf.close();
1736 // WriteGSPASCII(pre,n,t);
1737 // if(_debug && _out)
1738 // *_out << "FluRegion::WriteFluSolnASCII: Exit\n";
1739 // return(true);
1740 // }
1741 
1742 // bool
1743 // FluRegion::WriteGSPASCII(const string &prefix,unsigned int n,
1744 // double t,bool unsteady)
1745 // {
1746 // if(_debug && _out)
1747 // *_out << "FluRegion::WriteGSPASCII: Enter\n";
1748 // string pre(prefix);
1749 // if(pre.empty()){
1750 // if(_casename.empty())
1751 // pre = "./";
1752 // else
1753 // pre = _casepath + "/" + _casename + ".";
1754 // }
1755 // else
1756 // pre += ".";
1757 // ostringstream Ostr;
1758 // Ostr << pre << "gspa_" << setw(5) << setfill('0') << _id << "_";
1759 // string filebase(Ostr.str());
1760 // Ostr.str("");
1761 // Ostr << setw(6) << setfill('0') << n;
1762 // string iterstring(Ostr.str());
1763 // Ostr.clear();
1764 // Ostr.str("");
1765 // Ostr << scientific << setprecision(5) << t;
1766 // string timestring(Ostr.str());
1767 // timestring.replace(7,1,"E");
1768 // ofstream Ouf;
1769 // if(!unsteady) filebase+=iterstring;
1770 // else filebase+=timestring;
1771 // Ouf.open(filebase.c_str());
1772 // if(!Ouf)
1773 // return false;
1774 // Ouf << "# ROCFLU grid speeds file" << endl
1775 // << "# Precision and range" << endl
1776 // << setw(8) << 15 << setw(8) << 307 << endl
1777 // << "# Physical time" << endl
1778 // << setw(23) << scientific << setprecision(16)
1779 // << t << endl
1780 // << "# Dimensions" << endl
1781 // << setw(8) << _nvface << endl
1782 // << "# Grid speeds" << endl;
1783 // unsigned int face = 0;
1784 // unsigned int ll = 5;
1785 // bool gsp = (_soln._gsp.size() != 0);
1786 // if(_debug && _out){
1787 // *_out << "FluRegion::WriteGSPASCII: nvface = " << _nvface << "\n";
1788 // if(!gsp)
1789 // *_out
1790 // << "FluRegion::WriteGSPASCII:no gridspeeds for the volume faces.\n";
1791 // }
1792 // while(face < _nvface){
1793 // Ouf << setw(23) << scientific << setprecision(16)
1794 // << (gsp ? _soln._gsp[face] : 0);
1795 // face++;
1796 // if(!(face%ll))
1797 // Ouf << endl;
1798 // }
1799 // if(face%ll)
1800 // Ouf << endl;
1801 // if(_debug && _out)
1802 // *_out << "FluRegion::WriteGSPASCII: npatches = " << _patches.size()
1803 // << "\n";
1804 // vector<FluPatch>::iterator fpi = _patches.begin();
1805 // while(fpi != _patches.end()){
1806 // FluPatch &fp = *fpi++;
1807 // gsp = (fp._soln._gsp.size() != 0);
1808 // unsigned int nfaces = fp._ntri+fp._nquad-(fp._ngtri+fp._ngquad);
1809 // if(_debug && _out){
1810 // *_out << "FluRegion::WriteGSPASCII: npatch_faces = " << nfaces << "\n";
1811 // if(!gsp)
1812 // *_out << "FluRegion::WriteGSPASCII: no gridspeeds for patch faces."
1813 // << "\n";
1814 // }
1815 // face = 0;
1816 // while(face < nfaces){
1817 // Ouf << setw(23) << scientific << setprecision(16)
1818 // << (gsp ? fp._soln._gsp[face] : 0);
1819 // face++;
1820 // if(!(face%ll))
1821 // Ouf << endl;
1822 // }
1823 // if(face%ll)
1824 // Ouf << endl;
1825 // }
1826 // Ouf << "# End" << endl;
1827 // Ouf.close();
1828 // if(_debug && _out)
1829 // *_out << "FluRegion::WriteGSPASCII: Exit\n";
1830 // return true;
1831 // }
1832 
1833 // bool
1834 // FluRegion::ReadGSPASCII(const string &prefix,unsigned int n,
1835 // double t,bool unsteady)
1836 // {
1837 // if(_debug && _out)
1838 // *_out << "FluRegion::ReadGSPASCII: Enter\n";
1839 // string pre(prefix);
1840 // if(pre.empty()){
1841 // if(_casename.empty())
1842 // pre = "./";
1843 // else
1844 // pre = _casepath + "/" + _casename;
1845 // }
1846 // ostringstream Ostr;
1847 // Ostr << pre << ".gspa_" << setw(5) << setfill('0') << _id << "_";
1848 // string filebase(Ostr.str());
1849 // Ostr.str("");
1850 // Ostr << setw(6) << setfill('0') << n;
1851 // string iterstring(Ostr.str());
1852 // Ostr.clear();
1853 // Ostr.str("");
1854 // Ostr << scientific << setprecision(5) << t;
1855 // string timestring(Ostr.str());
1856 // timestring.replace(7,1,"E");
1857 // ifstream Inf;
1858 // if(!unsteady)
1859 // Inf.open((filebase+iterstring).c_str());
1860 // else
1861 // Inf.open((filebase+timestring).c_str());
1862 // if(!Inf)
1863 // return false;
1864 // string line;
1865 // SkipLines(Inf,6);
1866 // Inf >> _nvface;
1867 // _soln._gsp.resize(_nvface,0.0);
1868 // SkipLines(Inf,2);
1869 // unsigned int face = 0;
1870 // while(face < _nvface)
1871 // Inf >> _soln._gsp[face++];
1872 // vector<FluPatch>::iterator fpi = _patches.begin();
1873 // while(fpi != _patches.end()){
1874 // FluPatch &fp = *fpi++;
1875 // unsigned int nfaces = fp._ntri+fp._nquad-(fp._ngtri+fp._ngquad);
1876 // fp._soln._gsp.resize(nfaces,0.0);
1877 // face = 0;
1878 // while(face < nfaces)
1879 // Inf >> fp._soln._gsp[face++];
1880 // fp.InitSurfaceSoln(pre,false);
1881 // }
1882 // Inf.close();
1883 // return true;
1884 // }
1885 // bool
1886 // FluRegion::ReadRegionASCII(const string &prefix,unsigned int region_id,
1887 // unsigned int n,double t,bool unsteady)
1888 // {
1889 // if(_debug && _out)
1890 // *_out << "FluRegion::ReadRegionASCII:: Reading Rocflu Region "
1891 // << "from Rocflu native files...\n";
1892 // string pre(prefix);
1893 // if(pre.empty()){
1894 // if(_casename.empty())
1895 // pre = "./";
1896 // else
1897 // pre = _casepath + "/" + _casename;
1898 // }
1899 // _id = region_id;
1900 // if(!ReadFluDIM(pre,t,unsteady))
1901 // return(false);
1902 // if(!ReadFluCOM(pre)){
1903 // if(_debug && _out)
1904 // *_out << "FluRegion::ReadRegionASCII: ReadFluCOM failed.\n";
1905 // return(false);
1906 // }
1907 // if(!ReadFluGridASCII(pre,t,unsteady)){
1908 // if(_debug && _out)
1909 // *_out << "FluRegion::ReadRegionASCII: ReadFluGridASCII failed.\n";
1910 // return(false);
1911 // }
1912 // if(!ReadFluSolnASCII(pre,n,t,unsteady)){
1913 // if(_debug && _out)
1914 // *_out << "FluRegion::ReadRegionASCII: ReadFluSolnASCII failed.\n";
1915 // return(false);
1916 // }
1917 // if(_debug && _out)
1918 // *_out << "FluRegion::ReadRegionASCII:: Done reading Rocflu Region "
1919 // << "from Rocflu native files.\n";
1920 // return(true);
1921 // }
1922 
1923 
1924 
1925 
1926 
1927 
1928 
1929 
1930 
1931 
void TRAIL_FluResizeSurfSoln(GEM_DomainBoundary &db)
bool TRAIL_FluWriteCOM(GEM_Partition &gp, const std::string &path)
bool TRAIL_FluReadControlFile(GEM_Partition &gp, const std::string &prefix="./")
void Create_com_surfsoln(const std::string &wname, const std::string &fname, std::vector< double > &fvec, unsigned int ncomp, const std::string &unit)
Definition: GEM.C:426
GEM_UserData _data
Definition: GEM.H:306
void MapDomainBoundaries(std::map< unsigned int, unsigned int > &bcmap)
Definition: GEM.C:1385
void Create_com_volsoln(const std::string &fname, std::vector< double > &fvec, unsigned int ncomp, const std::string &unit)
Definition: GEM.C:413
bool TRAIL_FluWriteMAP(GEM_Partition &gp, unsigned int nproc, unsigned int nregions, const std::string &path)
bool TRAIL_FluInitSolver(GEM_Partition &gp, const std::string &prefix="./")
std::vector< unsigned int > _tetconn
Definition: GEM.H:295
bool TRAIL_FluBuildPatchMapping(std::map< unsigned int, unsigned int > &pmap, const std::string &prefix)
std::vector< std::vector< int > > _int_data
Definition: GEM.H:100
bool TRAIL_FluReadCOM(GEM_Partition &gp)
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
Definition: roccom_c++.h:136
std::vector< std::string > _string_data
Definition: GEM.H:105
This file contains the prototypes for Roccom API.
unsigned int NNodes(void)
Definition: GEM.C:1103
bool TRAIL_FluInitVolSoln(GEM_Partition &gp)
double sqrt(double d)
Definition: double.h:73
std::vector< unsigned int > _quadconn
Definition: GEM.H:132
Definition: adj.h:150
unsigned int _ngnodes
Definition: GEM.H:286
std::vector< std::vector< double > > _field_data
Definition: GEM.H:95
bool TRAIL_FluInitSurfSoln(GEM_DomainBoundary &db, const std::string &, bool all=true)
bool TRAIL_FluWriteCMP(GEM_Partition &gp, const std::string &path)
std::vector< int > _stride_int
Definition: GEM.H:104
unsigned int _ngpris
Definition: GEM.H:290
unsigned int _nvface
Definition: GEM.H:291
bool TRAIL_FluRegisterSurfMesh(GEM_Partition &gp)
unsigned int Elem2Cell(std::pair< unsigned int, unsigned int >)
Definition: GEM.C:956
Definition: patch.h:74
unsigned int _id
Definition: GEM.H:127
std::vector< unsigned int > _triconn
Definition: GEM.H:131
bool TRAIL_FluPopulatePatches(GEM_Partition &gp)
unsigned int _id
Definition: GEM.H:284
std::vector< GEM_DomainBoundary > _db
Definition: GEM.H:305
std::ostream * _out
Definition: GEM.H:308
unsigned int _ngquad
Definition: GEM.H:129
int pane_id
Definition: GEM.H:315
bool TRAIL_FluRegisterSurfSoln(GEM_DomainBoundary &db, const std::string &wname, bool all=true)
bool TRAIL_FluWriteNative(GEM_Partition &gp, const std::string &path)
std::vector< unsigned int > _pyrconn
Definition: GEM.H:297
blockLoc i
Definition: read.cpp:79
std::vector< unsigned int > _hexconn
Definition: GEM.H:301
const NT & n
void TRAIL_FluResizeVolSoln(GEM_Partition &gp)
std::vector< int > _stride_field
Definition: GEM.H:103
bool TRAIL_FluReadDIM(GEM_Partition &gp, double t=0.0, bool unsteady=true)
bool TRAIL_FluPopRemBordIndFILE(GEM_Partition &gp, double t=0.0, bool unsteady=true, const std::string &path="./")
std::vector< GEM_PartitionBoundary > _pb
Definition: GEM.H:304
void COM_set_array(const char *wa_str, int pane_id, void *addr, int strd=0, int cap=0)
Associates an array with an attribute for a specific pane.
Definition: roccom_c++.h:156
bool TRAIL_FluReadGridASCII(GEM_Partition &gp, double t=0.0, bool unsteady=true)
std::string volume_window
Definition: GEM.H:318
GEM_UserData _data
Definition: GEM.H:137
bool _debug
Definition: GEM.H:310
unsigned int _ngtet
Definition: GEM.H:287
GEM_UserData _solver_data
Definition: GEM.H:307
std::ostream * _out
Definition: GEM.H:140
void int int REAL REAL REAL *z blockDim dim * ni
Definition: read.cpp:77
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
Definition: roccom_c++.h:118
istream & SkipLines(istream &, unsigned int=1)
std::vector< double > _nc
Definition: GEM.H:293
std::vector< unsigned int > _prisconn
Definition: GEM.H:299
bool TRAIL_FluRegisterVolSoln(GEM_Partition &gp, bool all=true)
void TRAIL_FluCopyCaseFiles(GEM_Partition &gp, const std::string &path)
unsigned int _ngpyr
Definition: GEM.H:289
std::string surface_window
Definition: GEM.H:319
bool TRAIL_FluWriteDIM(GEM_Partition &gp, double t=0.0, bool unsteady=true, const std::string &path="./")
unsigned int _nghex
Definition: GEM.H:288
int TRAIL_FluNumPatches(GEM_Partition &gp)
unsigned int _ngtri
Definition: GEM.H:128