28 #include "../Rocsurf/include/surfbasic.h"
41 bool isfinite(
double x) {
return x>-HUGE_VAL && x<HUGE_VAL; }
46 int flag; MPI_Initialized(&flag);
47 if ( !flag || comm == MPI_COMM_NULL) {
51 MPI_Comm_rank( comm, &
_rank);
52 MPI_Comm_size( comm, &
_size);
56 typedef bool (*
Func_ptr)(
int pane_id,
int comm_rank,
int comm_size);
61 const char *lastdot=std::strrchr( fname,
'.');
62 if ( lastdot && (std::strcmp( lastdot,
".hdf")==0 ||
63 std::strcmp( lastdot,
".cgns")==0 ||
64 std::strcmp( lastdot,
".txt")==0)) {
69 if ( std::strcmp( lastdot,
".hdf") == 0 ||
70 std::strcmp( lastdot,
".cgns") == 0)
93 else if (!lastdot || std::strcmp( lastdot,
".im")) {
94 std::cerr <<
"Unknown file format with suffix " << lastdot << std::endl;
102 int read_mesh(
const char *fname,
const std::string &wname,
104 std::ifstream is( fname);
106 std::cerr <<
"Error: Could not open file " << fname << std::endl;
114 std::cout <<
"Reading file " << fname << std::endl;
117 int num_panes, mesh_type;
120 std::sscanf(
buf,
"%d%c%d", &num_panes, &t, &mesh_type);
122 std::cerr <<
"Error: The number of panes must be positive." << std::endl;
129 for (
int i=0;
i<num_panes; ++
i) {
132 std::sscanf(
buf,
"%d", &pid);
134 std::cerr <<
"Error: Found nonpositive pane id " << pid << std::endl;
146 for (
int i=0;
i<num_panes; ++
i) {
149 std::sscanf(
buf,
"%d", &pid);
151 std::cerr <<
"Error: Found nonpositive pane id " << pid << std::endl;
161 for (
int i=0;
i<num_panes; ++
i) {
164 std::sscanf(
buf,
"%d", &pid);
166 std::cerr <<
"Error: Found nonpositive pane id " << pid << std::endl;
176 std::cerr <<
"Error: File: " << fname
177 <<
" has unknown mesh type" << mesh_type << std::endl;
180 std::cout <<
"Finished reading file " << fname << std::endl;
186 char accpet[]={
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
187 '.',
'+',
'-',
'e',
'E'};
191 std::cerr <<
"Error: Unexpected EOF" << std::endl;
195 }
while ( str[0]==
'#' || strpbrk( str,accpet)==NULL);
200 int pid,
int n,
bool local) {
201 SURF::Point_3<double> *coors=NULL;
208 for (
int i=0;
i<
n; ++
i) {
211 std::sscanf(
buf,
"%lf %lf %lf", &coors[
i][0], &coors[i][1], &coors[i][2]);
214 std::cerr <<
"Error: Got invalid coordinates " << coors[
i]
215 <<
" for node " << i+1 <<
" on pane " << pid
216 <<
" of window " << wname << std::endl;
223 for (
int i=0;
i<
n; ++
i) {
230 int num_elems,
int nodes_per_elem,
bool local){
233 const char *types[] = {
".:t3:",
".:q4:",
"",
".:t6:"};
235 COM_set_size( (wname+types[nodes_per_elem-3]).c_str(), pid, num_elems);
237 pid, &(
void*&)elems);
240 for (
int i=0;
i<num_elems; ++
i) {
243 int *p = &elems[
i*nodes_per_elem];
244 switch ( nodes_per_elem) {
245 case 3: std::sscanf(
buf,
"%d %d %d", p, p+1, p+2);
break;
246 case 4: std::sscanf(
buf,
"%d %d %d %d", p, p+1, p+2, p+3);
break;
247 case 6: std::sscanf(
buf,
"%d %d %d %d %d %d", p, p+1, p+2, p+3, p+4, p+5);
break;
248 default: assert(
false); abort();
256 int pid,
bool local) {
259 std::sscanf(
buf,
"%d %d", &dims[0], &dims[1]);
260 if ( dims[0]<0 && dims[1]<0) {
261 std::cerr <<
"Error: Negative mesh dimension " << std::endl;
271 int pid,
int nodes_per_elem,
bool local) {
275 std::sscanf(
buf,
"%d %d", &num_nodes, &num_elmes);
276 if ( num_nodes<0 || num_elmes<0) {
277 std::cerr <<
"Error: Negative node or element size" << std::endl;
287 int pid,
bool local) {
290 std::sscanf(
buf,
"%d %d %d", &num_nodes, &num_tris, &num_quads);
291 if ( num_nodes<0 && num_tris<0 || num_quads<0) {
292 std::cerr <<
"Error: Negative node or element size" << std::endl;
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_WORLD
void get_nextline(std::istream &is, char *str)
void read_pane_coors(std::istream &is, const std::string &wname, int pid, int n, bool local)
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
void read_pane_elems(std::istream &is, const std::string &wname, int pid, int num_elems, int nodes_per_elem, bool local)
void read_pane_mixed(std::istream &is, const std::string &wname, int pid, bool local)
int COM_get_attribute_handle(const char *waname)
void COM_delete_attribute(const char *wa_str)
Delete an existing attribute.
bool is_local(int pid, int comm_rank, int comm_size)
#define COM_UNLOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
int read_mesh(const char *fname, const std::string &wname, Func_ptr is_local)
bool(* Func_ptr)(int pane_id, int comm_rank, int comm_size)
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
void COM_call_function(const int wf, int argc,...)
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...
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.
int COM_get_window_handle(const char *wname)
IM_Reader(MPI_Comm comm=MPI_COMM_WORLD, double a=1)
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
int read_winmesh(const char *fname, const std::string &wname, bool del=true)
void read_pane_uns(std::istream &is, const std::string &wname, int pid, int nodes_per_elem, bool local)
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
void read_pane_ij(std::istream &is, const std::string &wname, int pid, bool local)
void COM_resize_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=-1, int cap=0)
Resize an attribute on a specific pane and return the address by setting addr.
int COM_get_function_handle(const char *wfname)
#define COM_EXTERN_MODULE(moduleName)