Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SMF_Reader Class Reference

#include <SMF_Reader.h>

Public Member Functions

 SMF_Reader ()
 
int read_mesh (const char *fname, const std::string &wname)
 

Private Types

enum  { MAXLEN =255 }
 

Private Member Functions

void get_nextline (std::istream &is, char *str)
 
void read_pane_coors (std::istream &is, const std::string &wname)
 
void read_pane_elems (std::istream &is, const std::string &wname)
 

Private Attributes

char buf [MAXLEN+1]
 

Detailed Description

Definition at line 39 of file SMF_Reader.h.

Member Enumeration Documentation

anonymous enum
private
Enumerator
MAXLEN 

Definition at line 139 of file SMF_Reader.h.

139 {MAXLEN=255};

Constructor & Destructor Documentation

SMF_Reader ( )
inline

Definition at line 42 of file SMF_Reader.h.

42 {}

Member Function Documentation

void get_nextline ( std::istream &  is,
char *  str 
)
inlineprivate

Definition at line 66 of file SMF_Reader.h.

References MAXLEN.

Referenced by read_pane_coors(), and read_pane_elems().

66  {
67  char accpet[]={'0','1','2','3','4','5','6','7','8','9',
68  '.','+','-','e','E'};
69 
70  do {
71  if ( is.eof()) { str[0] = '\0'; return; }
72  str[0] = '\1'; str[1] = '\0';
73  is.getline( str, MAXLEN);
74  if ( str[0] == '\1') return;
75  } while ( (str[0]!='v' && str[0]!='f') || strpbrk( str,accpet)==NULL);
76  }

Here is the caller graph for this function:

int read_mesh ( const char *  fname,
const std::string &  wname 
)
inline

Definition at line 46 of file SMF_Reader.h.

References COM_get_window_handle(), COM_new_window(), read_pane_coors(), and read_pane_elems().

Referenced by main().

46  {
47  std::ifstream is( fname);
48  if ( is == NULL) {
49  std::cerr << "Error: Could not open file " << fname << std::endl;
50  exit(-1);
51  }
52 
53  // Create the window if not yet exist
54  int h=COM_get_window_handle(wname.c_str());
55  if ( h<=0) COM_new_window( wname.c_str());
56 
57  std::cout << "Reading file " << fname << std::endl;
58 
59  read_pane_coors( is, wname);
60  read_pane_elems( is, wname);
61 
62  return 1;
63  }
void read_pane_elems(std::istream &is, const std::string &wname)
Definition: SMF_Reader.h:109
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
int COM_get_window_handle(const char *wname)
Definition: roccom_c++.h:404
void read_pane_coors(std::istream &is, const std::string &wname)
Definition: SMF_Reader.h:79

Here is the call graph for this function:

Here is the caller graph for this function:

void read_pane_coors ( std::istream &  is,
const std::string &  wname 
)
inlineprivate

Definition at line 79 of file SMF_Reader.h.

References buf, COM_allocate_array(), COM_assertion_msg, COM_set_size(), copy, get_nextline(), and n.

Referenced by read_mesh().

79  {
80  std::vector<SURF::Point_3<double> > coors;
81 
82  int n=0;
83  for (;;) {
84  get_nextline( is, buf);
85 
86  if ( buf[0] == 'v') {
87  if ( buf[1] == 't' || buf[1] == 'n') continue;
88  SURF::Point_3<double> p;
89 
90  std::sscanf( &buf[2], "%lf %lf %lf", &p[0], &p[1], &p[2]);
91  coors.push_back( p);
92 
93  ++n;
94  }
95  else
96  break;
97  }
98  COM_assertion_msg( n>0, "Did not find any nodes");
99  std::cout << "Read in " << n << " nodes" << std::endl;
100 
101  COM_set_size( (wname+".nc").c_str(), 1, n);
102  SURF::Point_3<double> *p;
103  COM_allocate_array( (wname+".nc").c_str(), 1, &(void*&)p);
104 
105  std::copy( coors.begin(), coors.end(), p);
106  }
#define COM_assertion_msg(EX, msg)
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
void get_nextline(std::istream &is, char *str)
Definition: SMF_Reader.h:66
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to ** copy
Definition: roccomf90.h:20
const NT & n
void COM_allocate_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=0, int cap=0)
Allocate space for an attribute on a specific pane and return the address by setting addr...
Definition: roccom_c++.h:196
char buf[MAXLEN+1]
Definition: SMF_Reader.h:140

Here is the call graph for this function:

Here is the caller graph for this function:

void read_pane_elems ( std::istream &  is,
const std::string &  wname 
)
inlineprivate

Definition at line 109 of file SMF_Reader.h.

References buf, COM_allocate_array(), COM_assertion_msg, COM_set_size(), copy, get_nextline(), and n.

Referenced by read_mesh().

109  {
110  std::vector<SURF::Vector_3<int> > elems;
111 
112  // When entering this routine, buf[0] should start with 'f'
113  int n=0;
114  for (;;) {
115  if ( buf[0] == 'f') {
116  if ( buf[1] != 't' && buf[1] != 'n') {
117  SURF::Vector_3<int> p;
118 
119  std::sscanf( &buf[2], "%d %d %d", &p[0], &p[1], &p[2]);
120  elems.push_back( p);
121 
122  ++n;
123  }
124  get_nextline( is, buf);
125  }
126  else break;
127  }
128  COM_assertion_msg( n>0, "Did not find any faces");
129  std::cout << "Read in " << n << " faces" << std::endl;
130 
131  COM_set_size( (wname+".:t3:").c_str(), 1, n);
132  SURF::Vector_3<int> *p;
133  COM_allocate_array( (wname+".:t3:").c_str(), 1, &(void*&)p);
134 
135  std::copy( elems.begin(), elems.end(), p);
136  }
#define COM_assertion_msg(EX, msg)
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
void get_nextline(std::istream &is, char *str)
Definition: SMF_Reader.h:66
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to ** copy
Definition: roccomf90.h:20
const NT & n
void COM_allocate_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=0, int cap=0)
Allocate space for an attribute on a specific pane and return the address by setting addr...
Definition: roccom_c++.h:196
char buf[MAXLEN+1]
Definition: SMF_Reader.h:140

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

char buf[MAXLEN+1]
private

Definition at line 140 of file SMF_Reader.h.

Referenced by read_pane_coors(), and read_pane_elems().


The documentation for this class was generated from the following file: