59 bool read_binary =
fileExists(basename +
".bpts");
60 std::string pts_file = read_binary ? basename +
".bpts" : basename +
".pts";
62 FILE* pts_fd = fopen(pts_file.c_str(),
"r");
64 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", pts_file.c_str());
70 if(read_binary) fread(buffer,
sizeof(
char),
HDR_SIZE, pts_fd);
71 else fgets( buffer, 2048, pts_fd);
72 sscanf(buffer,
"%lu", &numpts);
90 inline void read_headers(FILE* ele_fd, FILE* fib_fd,
bool read_binary,
size_t & numelem,
int & nFib)
95 fread(buffer,
sizeof(
char),
HDR_SIZE, ele_fd);
100 sscanf(buffer,
"%lu", &numelem);
105 fread(buffer,
sizeof(
char),
HDR_SIZE, fib_fd);
106 sscanf(buffer,
"%d", &nFib);
112 short nread = sscanf(buffer,
"%f %f %f %f %f %f", fbuff, fbuff+1, fbuff+2, fbuff+3, fbuff+4, fbuff+5);
114 case 1: nFib = fbuff[0];
break;
115 case 3: nFib = 1;
break;
116 case 6: nFib = 2;
break;
118 fprintf(stderr,
"%s error: read %d values in line 1 of fiber file."
119 "This is unexpected! Setting number of fibers to 1.\n",
127 fseek(fib_fd, 0, SEEK_SET);
145 inline void write_elem_headers(FILE* & ele_fd, FILE* & fib_fd,
bool binary,
size_t numelem,
int nFib)
155 snprintf(header,
sizeof header,
"%lu %d %d", numelem,
MT_ENDIANNESS, checksum);
156 fwrite(header,
HDR_SIZE,
sizeof(
char), ele_fd);
159 fprintf(ele_fd,
"%lu\n", numelem);
165 snprintf(header,
sizeof header,
"%d %lu %d %d", nFib, (
unsigned long int)numelem,
MT_ENDIANNESS, checksum);
166 fwrite(header,
sizeof(
char),
HDR_SIZE, fib_fd);
169 fprintf(fib_fd,
"%d\n", nFib);
191 snprintf(header,
sizeof header,
"%lu %d %d", numpts,
MT_ENDIANNESS, checksum);
192 fwrite(header,
HDR_SIZE,
sizeof(
char), pts_fd);
195 fprintf(pts_fd,
"%lu\n", numpts);
208 template<
class T,
class S>
211 const int bufsize = 2048;
212 const int max_elem_size = 9;
214 char buffer[bufsize];
216 int n[max_elem_size];
221 mesh.
dsp.resize(bsize+1);
222 mesh.
tag.resize(bsize);
224 mesh.
con.resize(bsize*max_elem_size);
226 size_t ele_read = 0, con_size = 0;
228 T* elem = mesh.
con.data();
230 for(
size_t i=0; i<bsize; i++)
234 size_t r = fread(&etbuff,
sizeof(
int), 1, fd);
239 char* ptr = fgets( buffer, bufsize, fd);
240 if(ptr == NULL)
break;
241 sscanf(buffer,
"%s %d %d %d %d %d %d %d %d %d", etype_str, n, n+1, n+2, n+3, n+4, n+5, n+6, n+7, n+8);
277 fprintf(stderr,
"Error: Unsupported element type!\n");
280 mesh.
dsp[i+1] = mesh.
dsp[i] + nodes;
285 fread(n,
sizeof(
int), nodes+1, fd);
287 for(
int j=0; j<nodes; j++) elem[j] = n[j];
289 mesh.
tag[i] = n[nodes];
290 ref_eidx[i] = bstart + i;
295 mesh.
dsp.resize(ele_read+1);
296 mesh.
tag.resize(ele_read);
298 ref_eidx.
resize(ele_read);
299 mesh.
con.resize(con_size);
312 template<
class T,
class S>
315 const T* con = mesh.
con.data();
321 for(
size_t eidx=0; eidx < mesh.
l_numelem; eidx++)
323 fwrite(&mesh.
type[eidx], 1,
sizeof(
elem_t), fd);
324 T esize = mesh.
dsp[eidx+1] - mesh.
dsp[eidx];
326 wbuff[esize] = mesh.
tag[eidx];
328 fwrite(wbuff, esize+1,
sizeof(
int), fd);
334 for(
size_t eidx=0; eidx < mesh.
l_numelem; eidx++)
336 switch(mesh.
type[eidx])
339 fprintf(fd,
"Ln %lld %lld %lld\n",
340 static_cast<long long>(con[0]),
341 static_cast<long long>(con[1]),
342 static_cast<long long>(mesh.
tag[eidx]));
347 fprintf(fd,
"Tr %lld %lld %lld %lld\n",
348 static_cast<long long>(con[0]),
349 static_cast<long long>(con[1]),
350 static_cast<long long>(con[2]),
351 static_cast<long long>(mesh.
tag[eidx]));
356 fprintf(fd,
"Qd %lld %lld %lld %lld %lld\n",
357 static_cast<long long>(con[0]),
358 static_cast<long long>(con[1]),
359 static_cast<long long>(con[2]),
360 static_cast<long long>(con[3]),
361 static_cast<long long>(mesh.
tag[eidx]));
366 fprintf(fd,
"Tt %lld %lld %lld %lld %lld\n",
367 static_cast<long long>(con[0]),
368 static_cast<long long>(con[1]),
369 static_cast<long long>(con[2]),
370 static_cast<long long>(con[3]),
371 static_cast<long long>(mesh.
tag[eidx]));
376 fprintf(fd,
"Py %lld %lld %lld %lld %lld %lld\n",
377 static_cast<long long>(con[0]),
378 static_cast<long long>(con[1]),
379 static_cast<long long>(con[2]),
380 static_cast<long long>(con[3]),
381 static_cast<long long>(con[4]),
382 static_cast<long long>(mesh.
tag[eidx]));
387 fprintf(fd,
"Pr %lld %lld %lld %lld %lld %lld %lld\n",
388 static_cast<long long>(con[0]),
389 static_cast<long long>(con[1]),
390 static_cast<long long>(con[2]),
391 static_cast<long long>(con[3]),
392 static_cast<long long>(con[4]),
393 static_cast<long long>(con[5]),
394 static_cast<long long>(mesh.
tag[eidx]));
399 fprintf(fd,
"Hx %lld %lld %lld %lld %lld %lld %lld %lld %lld\n",
400 static_cast<long long>(con[0]),
401 static_cast<long long>(con[1]),
402 static_cast<long long>(con[2]),
403 static_cast<long long>(con[3]),
404 static_cast<long long>(con[4]),
405 static_cast<long long>(con[5]),
406 static_cast<long long>(con[6]),
407 static_cast<long long>(con[7]),
408 static_cast<long long>(mesh.
tag[eidx]));
413 fprintf(stderr,
"Error: Unsupported element type!\n");
430 template<
class T,
class S>
433 const int bufsize = 2048;
434 char buffer[bufsize];
443 for(
size_t i=0; i<bsize; i++) {
445 size_t r = fread(fib,
sizeof(
float), 6, fd);
449 char* ptr = fgets( buffer, bufsize, fd);
450 if(ptr == NULL)
break;
451 sscanf(buffer,
"%f %f %f %f %f %f", fib, fib+1, fib+2, fib+3, fib+4, fib+5);
453 mesh.
fib[nr*3+0] = fib[0];
454 mesh.
fib[nr*3+1] = fib[1];
455 mesh.
fib[nr*3+2] = fib[2];
456 mesh.
she[nr*3+0] = fib[3];
457 mesh.
she[nr*3+1] = fib[4];
458 mesh.
she[nr*3+2] = fib[5];
465 else if (nFib == 1) {
471 for(
size_t i=0; i<bsize; i++) {
473 size_t r = fread(fib,
sizeof(
float), 3, fd);
477 char* ptr = fgets( buffer, bufsize, fd);
478 if(ptr == NULL)
break;
479 sscanf(buffer,
"%f %f %f", fib, fib+1, fib+2);
482 mesh.
fib[nr*3+0] = fib[0];
483 mesh.
fib[nr*3+1] = fib[1];
484 mesh.
fib[nr*3+2] = fib[2];
500 template<
class T,
class S>
515 fib[0] = mesh.
fib[i*3+0];
516 fib[1] = mesh.
fib[i*3+1];
517 fib[2] = mesh.
fib[i*3+2];
518 fib[3] = mesh.
she[i*3+0];
519 fib[4] = mesh.
she[i*3+1];
520 fib[5] = mesh.
she[i*3+2];
523 fwrite(fib, 6,
sizeof(
float), fd);
525 fprintf(fd,
"%f %f %f %f %f %f\n", fib[0], fib[1], fib[2], fib[3], fib[4], fib[5]);
532 fib[0] = mesh.
fib[i*3+0];
533 fib[1] = mesh.
fib[i*3+1];
534 fib[2] = mesh.
fib[i*3+2];
537 fwrite(fib, 3,
sizeof(
float), fd);
539 fprintf(fd,
"%f %f %f\n", fib[0], fib[1], fib[2]);
555 template<
class T,
class S>
558 MPI_Comm comm = mesh.
comm;
560 MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
563 size_t gnumelems_file = 0;
569 fprintf(stderr,
"Error: could not open tag file: %s. Aborting!\n",
filename.c_str());
573 MPI_Allreduce(MPI_IN_PLACE, &err, 1, MPI_INT, MPI_SUM, comm);
574 if (err) exit(EXIT_FAILURE);
578 if (!fgets(buffer,
HDR_SIZE, fd) || sscanf(buffer,
"%lu", &gnumelems_file) != 1) {
579 fprintf(stderr,
"Error: could not read element count from tag file: %s. Aborting!\n",
filename.c_str());
583 MPI_Allreduce(MPI_IN_PLACE, &err, 1, MPI_INT, MPI_SUM, comm);
585 if (rank == 0) fclose(fd);
589 MPI_Bcast(&gnumelems_file,
sizeof(
size_t), MPI_BYTE, 0, comm);
593 fprintf(stderr,
"Error: tag file %s declares %lu elements, mesh has %lu. Aborting!\n",
595 if (rank == 0) fclose(fd);
599 size_t blocksize = (mesh.
g_numelem + size - 1) / size;
602 for (
size_t i = 0; i < mesh.
l_numelem; i++) {
604 if (fscanf(fd,
"%d", &t) != 1) {
605 fprintf(stderr,
"Error: unexpected end of tag file %s at element %lu. Aborting!\n",
606 filename.c_str(), (
unsigned long)i);
610 mesh.
tag[i] =
static_cast<T
>(t);
614 for (
int pid = 1; pid < size; pid++) {
617 for (
size_t i = 0; i < bsize; i++) {
619 if (fscanf(fd,
"%d", &t) != 1) {
620 fprintf(stderr,
"Error: unexpected end of tag file %s at element %lu. Aborting!\n",
621 filename.c_str(), (
unsigned long)((
size_t)pid * blocksize + i));
625 buf[i] =
static_cast<T
>(t);
627 MPI_Send(buf.
data(), bsize *
sizeof(T), MPI_BYTE, pid,
SF_MPITAG, comm);
646 template<
class T,
class S>
650 MPI_Comm comm = mesh.
comm;
653 MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
655 FILE* ele_fd = NULL, *fib_fd = NULL;
656 size_t gnumelems = 0;
658 bool read_binary =
false;
663 read_binary =
fileExists(basename +
".belem");
664 std::string ele_file = read_binary ? basename +
".belem" : basename +
".elem";
665 std::string fib_file = read_binary ? basename +
".blon" : basename +
".lon";
667 ele_fd = fopen(ele_file.c_str(),
"r");
669 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", ele_file.c_str());
673 fib_fd = fopen(fib_file.c_str(),
"r");
674 if((!fib_fd) && require_fibers) {
675 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", fib_file.c_str());
680 MPI_Allreduce(MPI_IN_PLACE, &err, 1, MPI_INT, MPI_SUM, comm);
686 read_headers(ele_fd, fib_fd, read_binary, gnumelems, nFib);
688 MPI_Bcast(&gnumelems,
sizeof(
size_t), MPI_BYTE, 0, comm);
689 MPI_Bcast(&nFib,
sizeof(
int), MPI_BYTE, 0, comm);
693 size_t blocksize = (gnumelems + size - 1) / size;
704 for(
int pid=1; pid<size; pid++) {
706 read_elem_block(ele_fd, read_binary, pid*blocksize, blocksize, meshbuff);
713 MPI_Send(meshbuff.
dsp.data(), meshbuff.
dsp.size()*
sizeof(T), MPI_BYTE, pid,
SF_MPITAG, comm);
714 MPI_Send(meshbuff.
tag.data(), meshbuff.
tag.size()*
sizeof(T), MPI_BYTE, pid,
SF_MPITAG, comm);
715 MPI_Send(ref_eidx.
data(), ref_eidx.
size()*
sizeof(T), MPI_BYTE, pid,
SF_MPITAG, comm);
722 size_t con_size = meshbuff.
con.size();
723 MPI_Send(&con_size,
sizeof(
size_t), MPI_BYTE, pid,
SF_MPITAG, comm);
724 MPI_Send(meshbuff.
con.data(), con_size*
sizeof(T), MPI_BYTE, pid,
SF_MPITAG, comm);
728 if(nFib>=1) fclose(fib_fd);
745 MPI_Recv(mesh.
dsp.data(), mesh.
dsp.size()*
sizeof(T), MPI_BYTE, 0,
SF_MPITAG, comm, &stat);
746 MPI_Recv(mesh.
tag.data(), mesh.
tag.size()*
sizeof(T), MPI_BYTE, 0,
SF_MPITAG, comm, &stat);
747 MPI_Recv(ref_eidx.
data(), ref_eidx.
size()*
sizeof(T), MPI_BYTE, 0,
SF_MPITAG, comm, &stat);
755 MPI_Recv(&con_size,
sizeof(
size_t), MPI_BYTE, 0,
SF_MPITAG, comm, &stat);
756 mesh.
con.resize(con_size);
757 MPI_Recv(mesh.
con.data(), con_size*
sizeof(T), MPI_BYTE, 0,
SF_MPITAG, comm, &stat);
774 template<
class T,
class S>
777 const MPI_Comm comm = mesh.
comm;
780 MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
782 FILE* ele_fd = NULL, *fib_fd = NULL;
789 std::string ele_file = binary ? basename +
".belem" : basename +
".elem";
790 std::string fib_file = binary ? basename +
".blon" : basename +
".lon";
794 ele_fd = fopen(ele_file.c_str(),
"w");
796 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", ele_file.c_str());
800 fib_fd = fopen(fib_file.c_str(),
"w");
802 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", fib_file.c_str());
809 if (nFib>=1) fclose(fib_fd);
813 for(
int pid=0; pid < size; pid++)
817 ele_fd = fopen(ele_file.c_str(),
"a");
819 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", ele_file.c_str());
823 fib_fd = fopen(fib_file.c_str(),
"a");
825 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", fib_file.c_str());
834 if(nFib>=1) fclose(fib_fd);
840 template<
class T,
class S>
843 const MPI_Comm comm = surfmesh.
comm;
844 const bool binary =
false;
847 MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
853 ele_fd = fopen(surffile.c_str(),
"w");
855 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", surffile.c_str());
858 fprintf(ele_fd,
"%lu\n", surfmesh.
g_numelem);
863 for(
int pid=0; pid < size; pid++)
866 ele_fd = fopen(surffile.c_str(),
"a");
868 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", surffile.c_str());
891 const int bufsize = 2048;
892 char buffer[bufsize];
898 for(
size_t i=0; i<bsize; i++) {
900 size_t r = fread(pts,
sizeof(
float), 3, fd);
904 char* ptr = fgets( buffer, bufsize, fd);
905 if(ptr == NULL)
break;
906 sscanf(buffer,
"%f %f %f", pts, pts+1, pts+2);
908 xyz[nr*3+0] = pts[0];
909 xyz[nr*3+1] = pts[1];
910 xyz[nr*3+2] = pts[2];
928 size_t nnodes = xyz.
size() / 3;
931 for(
size_t i=0; i<nnodes; i++)
938 fwrite(pt, 3,
sizeof(
float), fd);
940 fprintf(fd,
"%f %f %f\n", pt[0], pt[1], pt[2]);
952 template<
class T,
class S>
956 MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
960 bool read_binary =
false;
965 std::string pts_file = read_binary ? basename +
".bpts" : basename +
".pts";
967 pts_fd = fopen(pts_file.c_str(),
"r");
969 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", pts_file.c_str());
975 if(read_binary) fread(buffer,
sizeof(
char),
HDR_SIZE, pts_fd);
976 else fgets( buffer, 2048, pts_fd);
977 sscanf(buffer,
"%lu", &gnumpts);
979 MPI_Bcast(&gnumpts,
sizeof(
size_t), MPI_BYTE, 0, comm);
982 size_t blocksize = (gnumpts + size - 1) / size;
990 for(
int pid = 1; pid < size; pid++) {
992 long int numsend = buff.
size();
994 MPI_Send(&numsend, 1, MPI_LONG, pid,
SF_MPITAG, comm);
995 MPI_Send(buff.
data(), numsend*
sizeof(S), MPI_BYTE, pid,
SF_MPITAG, comm);
1000 long int numrecv = 0;
1001 MPI_Recv(&numrecv, 1, MPI_LONG, 0,
SF_MPITAG, comm, &stat);
1004 MPI_Recv(pts.
data(), numrecv*
sizeof(S), MPI_BYTE, 0,
SF_MPITAG, comm, &stat);
1007 long int mysize = pts.
size() / 3;
1011 interval(ptsidx, layout[rank], layout[rank+1]);
1013 if(rank == 0) fclose(pts_fd);
1022 template<
class T,
class S>
1027 assert(meshlist.size() > 0);
1028 assert(pts.
size() == (ptsidx.
size() * 3));
1032 MPI_Comm comm = (*meshlist.begin())->comm;
1035 MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
1040 for(
int pid = 0; pid < size; pid++) {
1041 size_t numsend = pts.
size();
1042 MPI_Bcast(&numsend,
sizeof(
size_t), MPI_BYTE, pid, comm);
1050 idxbuff.
resize(numsend / 3);
1053 MPI_Bcast(ptsbuff.
data(), ptsbuff.
size()*
sizeof(S), MPI_BYTE, pid, comm);
1054 MPI_Bcast(idxbuff.
data(), idxbuff.
size()*
sizeof(T), MPI_BYTE, pid, comm);
1058 for(
auto it = meshlist.begin(); it != meshlist.end(); ++it)
1066 for(
size_t i=0; i<rnod.
size(); i++)
1074 for(
size_t j=0; j<idxbuff.
size(); j++) {
1075 if(g2l.
count(idxbuff[j])) {
1082 for(
size_t j=0; j<ridx.
size(); j++) {
1083 T w = widx[j], r = ridx[j];
1084 mesh.
xyz[w*3+0] = ptsbuff[r*3+0];
1085 mesh.
xyz[w*3+1] = ptsbuff[r*3+1];
1086 mesh.
xyz[w*3+2] = ptsbuff[r*3+2];
1098 template<
class T,
class S>
1101 FILE* vtk_file = fopen(file.c_str(),
"w");
1102 if(vtk_file == NULL)
return;
1105 fprintf (vtk_file,
"# vtk DataFile Version 3.0\n");
1106 fprintf (vtk_file,
"vtk output\n");
1107 fprintf (vtk_file,
"binary\n");
1108 fprintf (vtk_file,
"DATASET UNSTRUCTURED_GRID\n\n");
1109 fprintf (vtk_file,
"POINTS %lu float\n", mesh.
l_numpts);
1114 for (
unsigned long int i=0; i<mesh.
l_numpts; i++ ) {
1115 pts[0] =
htobe(p[0]);
1116 pts[1] =
htobe(p[1]);
1117 pts[2] =
htobe(p[2]);
1118 fwrite(pts,
sizeof(
float), 3, vtk_file);
1121 fprintf(vtk_file,
"\n");
1123 fprintf (vtk_file,
"CELL_TYPES %lu\n", mesh.
l_numelem);
1124 unsigned long int valcount = 0;
1126 for(
unsigned long int i=0; i< mesh.
l_numelem; i++) {
1153 vtk_type =
htobe(vtk_type);
1154 fwrite(&vtk_type,
sizeof(
int), 1, vtk_file);
1155 valcount += mesh.
dsp[i+1] - mesh.
dsp[i] + 1;
1157 fprintf(vtk_file,
"\n");
1159 fprintf(vtk_file,
"CELLS %lu %lu\n", mesh.
l_numelem, valcount);
1160 const T* elem = mesh.
con.data();
1161 for(
unsigned long int i=0; i<mesh.
l_numelem; i++)
1163 int nodes = mesh.
dsp[i+1] - mesh.
dsp[i], n;
1164 int be_nodes =
htobe(nodes);
1165 fwrite(&be_nodes,
sizeof(
int), 1, vtk_file);
1167 for(
int j=0; j<nodes; j++) {
1168 n = elem[j]; n =
htobe(n);
1169 fwrite(&n,
sizeof(
int), 1, vtk_file);
1173 fprintf(vtk_file,
"\n");
1175 fprintf (vtk_file,
"CELL_DATA %lu \n", mesh.
l_numelem);
1176 fprintf (vtk_file,
"SCALARS elemTag int 1\n");
1177 fprintf (vtk_file,
"LOOKUP_TABLE default\n");
1178 for (
unsigned long int i=0; i<mesh.
l_numelem; i++ ) {
1180 fwrite(&t,
sizeof(
int), 1, vtk_file);
1191 fprintf (vtk_file,
"VECTORS fiber float\n");
1192 for (
unsigned long int i=0; i<mesh.
l_numelem; i++ ) {
1193 pts[0] =
htobe(
float(mesh.
fib[i*3+0])),
1194 pts[1] =
htobe(
float(mesh.
fib[i*3+1])),
1195 pts[2] =
htobe(
float(mesh.
fib[i*3+2]));
1196 fwrite(pts,
sizeof(
float), 3, vtk_file);
1198 fprintf(vtk_file,
"\n");
1201 fprintf (vtk_file,
"VECTORS sheet float\n");
1202 for (
unsigned long int i=0; i<mesh.
l_numelem; i++ ) {
1203 pts[0] =
htobe(
float(mesh.
she[i*3+0])),
1204 pts[1] =
htobe(
float(mesh.
she[i*3+1])),
1205 pts[2] =
htobe(
float(mesh.
she[i*3+2]));
1206 fwrite(pts,
sizeof(
float), 3, vtk_file);
1208 fprintf(vtk_file,
"\n");
#define SF_MPITAG
the MPI tag when communicating
Functions related to network communication.
The vector class and related algorithms.
The mesh storage class. It contains both element and vertex data.
vector< T > dsp
connectivity starting index of each element
vector< S > she
sheet direction
vector< S > fib
fiber direction
size_t l_numelem
local number of elements
vector< elem_t > type
element type
vector< T > & register_numbering(SF_nbr nbr_type)
Register a new numbering to the mesh and return the associated index vector.
vector< S > xyz
node cooridnates
size_t l_numpts
local number of points
size_t g_numelem
global number of elements
void localize(SF_nbr nbr_type)
Localize the connectivity data w.r.t. a given numbering.
MPI_Comm comm
the parallel mesh is defined on a MPI world
vector< T > & get_numbering(SF_nbr nbr_type)
Get the vector defining a certain numbering.
vector< T > tag
element tag
A vector storing arbitrary data.
size_t size() const
The current size of the vector.
void resize(size_t n)
Resize a vector.
T * data()
Pointer to the vector's start.
hm_int count(const K &key) const
Check if key exists.
void read_pts_block(FILE *&fd, bool read_binary, size_t bsize, vector< S > &xyz)
Read a chunk of points from a file descriptor.
void read_headers(FILE *ele_fd, FILE *fib_fd, bool read_binary, size_t &numelem, int &nFib)
Read the header from the element and fiber files.
void read_points(const std::string basename, const MPI_Comm comm, vector< S > &pts, vector< T > &ptsidx)
Read the points and insert them into a list of meshes.
void read_fib_block(FILE *&fd, bool read_binary, int nFib, size_t bsize, meshdata< T, S > &mesh)
Read a chunk of fibers from a file descriptor.
void write_pts_block(FILE *&fd, bool write_binary, const vector< S > &xyz)
Write a chunk of points to a file.
void interval(vector< T > &vec, size_t start, size_t end)
Create an integer interval between start and end.
void write_surface(const meshdata< T, S > &surfmesh, std::string surffile)
void write_elements(const meshdata< T, S > &mesh, bool binary, std::string basename)
Read the element data (elements and fibers) of a CARP mesh.
void writeVTKmesh_binary(const meshdata< T, S > &mesh, std::string file)
Write a mesh in binary vtk format.
void insert_points(const vector< S > &pts, const vector< T > &ptsidx, std::list< meshdata< T, S > * > &meshlist)
Insert the points from the read-in buffers into a list of distributed meshes.
void read_element_tags(meshdata< T, S > &mesh, std::string filename)
Override element tags from an ASCII file (one int per element, global element order).
void write_pts_header(FILE *&pts_fd, bool binary, size_t numpts)
Write the header of the points file.
void read_elem_block(FILE *&fd, bool read_binary, size_t bstart, size_t bsize, meshdata< T, S > &mesh)
Read a block of size bsize from an CARP element file.
void write_elem_headers(FILE *&ele_fd, FILE *&fib_fd, bool binary, size_t numelem, int nFib)
Write the header of the element and fiber files.
void write_fib_block(FILE *&fd, bool write_binary, const meshdata< T, S > &mesh)
Write the local chunk of fibers to a file.
void vec_assign(S *lhs, const V *rhs, size_t size)
Assign the values in rhs to lhs. The data-type of rhs is cast to the type of lhs.
bool fileExists(std::string filename)
Function which checks if a given file exists.
elem_t getElemTypeID(char *eletype)
Generate element type enum from string.
void layout_from_count(const T count, vector< T > &layout, MPI_Comm comm)
size_t read_num_pts(std::string basename)
Function returns the number of points in a CARP points file.
void read_elements(meshdata< T, S > &mesh, std::string basename, bool require_fibers=true)
Read the element data (elements and fibers) of a CARP mesh.
@ NBR_ELEM_REF
The element numbering of the reference mesh (the one stored on HD).
@ NBR_REF
The nodal numbering of the reference mesh (the one stored on HD).
void write_elem_block(FILE *fd, bool write_binary, const meshdata< T, S > &mesh)
Write the local element block to a file.
constexpr T min(T a, T b)