Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
meshio.C File Reference
#include <cstdio>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cassert>
Include dependency graph for meshio.C:

Go to the source code of this file.

Functions

int read_obj (istream &is, vector< double > &coors, vector< int > &elems)
 
void read_ij (istream &is, vector< double > &coors, int dims[2])
 
void write_ij (ostream &os, const vector< double > &coors, int dims[])
 

Function Documentation

void read_ij ( istream &  is,
vector< double > &  coors,
int  dims[2] 
)

Definition at line 81 of file meshio.C.

References i, MAXLEN, p0, and p1.

Referenced by main().

81  {
82  const int MAXLEN=255;
83  char buf[MAXLEN];
84 
85  do { is.getline( buf, MAXLEN); } while ( buf[0]=='#' && !is.eof());
86  sscanf( buf, "%d %d", &dims[0], &dims[1]);
87 
88  int np=dims[0]*dims[1];
89  // Allocate space for points and faces.
90 
91  // Read in the coordinates
92  for ( int i=0; i<np; ++i) {
93  do { is.getline( buf, MAXLEN); } while ( buf[0]=='#' && !is.eof());
94  double p0, p1, p2;
95  sscanf( buf, "%lf %lf %lf", &p0, &p1, &p2);
96  coors.push_back( p0); coors.push_back( p1); coors.push_back( p2);
97  }
98 }
NT p1
#define MAXLEN
Definition: Coupling.h:41
NT p0
blockLoc i
Definition: read.cpp:79

Here is the caller graph for this function:

int read_obj ( istream &  is,
vector< double > &  coors,
vector< int > &  elems 
)

Definition at line 39 of file meshio.C.

References i, j, MAXLEN, p0, and p1.

Referenced by main().

40  {
41  const int MAXLEN=255;
42  char buf[MAXLEN];
43  int face_type = 3;
44 
45  is.getline( buf, MAXLEN);
46  if ( strncmp( buf, "#OBJ", 4)==0 && !is.eof()) {
47  face_type = buf[4] - '0';
48  assert( face_type == 3 || face_type == 4 || face_type == 6);
49  do { is.getline( buf, MAXLEN); } while ( buf[0]=='#' && !is.eof());
50  }
51  int np=0, nf=0;
52  if ( strcmp( buf, "off")==0 || strcmp( buf, "OFF")==0 )
53  do { is.getline( buf, MAXLEN); } while ( buf[0]=='#' && !is.eof());
54  sscanf( buf, "%d %d", &np, &nf);
55 
56  // Allocate space for points and faces.
57  coors.reserve( np*3); elems.reserve( nf*face_type);
58 
59  // Read in the coordinates
60  for ( int i=0; i<np; ++i) {
61  do { is.getline( buf, MAXLEN); } while ( buf[0]=='#' && !is.eof());
62  double p0, p1, p2;
63  sscanf( buf, "%lf %lf %lf", &p0, &p1, &p2);
64  coors.push_back( p0); coors.push_back( p1); coors.push_back( p2);
65  }
66 
67  // Read in faces
68  vector<int> f( face_type);
69  while( is.peek() == '#' && !is.eof()) is.getline( buf, MAXLEN);
70  for ( int i=0; i<nf; ++i) {
71  for ( int j=0; j<face_type; ++j) {
72  is >> f[j]; assert( f[j] >= 1 && f[j] <= np);
73  elems.push_back( f[j]);
74  }
75  }
76 
77  return face_type;
78 }
NT p1
#define MAXLEN
Definition: Coupling.h:41
NT p0
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6

Here is the caller graph for this function:

void write_ij ( ostream &  os,
const vector< double > &  coors,
int  dims[] 
)

Definition at line 101 of file meshio.C.

References i.

101  {
102  os << dims[0] << " " << dims[1] << endl;
103 
104  char buf[100];
105  // Write out the coordinates
106  for ( unsigned int i=0; i<coors.size(); i+=3) {
107  sprintf( buf, "%.10E\t%.10E\t%.10E", coors[i],
108  coors[i+1], coors[i+2]);
109  os << buf << endl;
110  }
111 }
blockLoc i
Definition: read.cpp:79