44 bool read_binary =
fileExists(basename +
".bpts");
45 std::string pts_file = read_binary ? basename +
".bpts" : basename +
".pts";
47 FILE* pts_fd = fopen(pts_file.c_str(),
"r");
49 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", pts_file.c_str());
55 if(read_binary) fread(buffer,
sizeof(
char),
HDR_SIZE, pts_fd);
56 else fgets( buffer, 2048, pts_fd);
57 sscanf(buffer,
"%lu", &numpts);
75 inline void read_headers(FILE* ele_fd, FILE* fib_fd,
bool read_binary,
size_t & numelem,
int & nFib)
80 fread(buffer,
sizeof(
char),
HDR_SIZE, ele_fd);
85 sscanf(buffer,
"%lu", &numelem);
90 fread(buffer,
sizeof(
char),
HDR_SIZE, fib_fd);
91 sscanf(buffer,
"%d", &nFib);
97 short nread = sscanf(buffer,
"%f %f %f %f %f %f", fbuff, fbuff+1, fbuff+2, fbuff+3, fbuff+4, fbuff+5);
99 case 1: nFib = fbuff[0];
break;
100 case 3: nFib = 1;
break;
101 case 6: nFib = 2;
break;
103 fprintf(stderr,
"%s error: read %d values in line 1 of fiber file."
104 "This is unexpected! Setting number of fibers to 1.\n",
112 fseek(fib_fd, 0, SEEK_SET);
130 inline void write_elem_headers(FILE* & ele_fd, FILE* & fib_fd,
bool binary,
size_t numelem,
int nFib)
140 snprintf(header,
sizeof header,
"%lu %d %d", numelem,
MT_ENDIANNESS, checksum);
141 fwrite(header,
HDR_SIZE,
sizeof(
char), ele_fd);
144 fprintf(ele_fd,
"%lu\n", numelem);
150 snprintf(header,
sizeof header,
"%d %lu %d %d", nFib, (
unsigned long int)numelem,
MT_ENDIANNESS, checksum);
151 fwrite(header,
sizeof(
char),
HDR_SIZE, fib_fd);
154 fprintf(fib_fd,
"%d\n", nFib);
176 snprintf(header,
sizeof header,
"%lu %d %d", numpts,
MT_ENDIANNESS, checksum);
177 fwrite(header,
HDR_SIZE,
sizeof(
char), pts_fd);
180 fprintf(pts_fd,
"%lu\n", numpts);
193 template<
class T,
class S>
196 const int bufsize = 2048;
197 const int max_elem_size = 9;
199 char buffer[bufsize];
201 int n[max_elem_size];
206 mesh.
dsp.resize(bsize+1);
207 mesh.
tag.resize(bsize);
209 mesh.
con.resize(bsize*max_elem_size);
211 size_t ele_read = 0, con_size = 0;
213 T* elem = mesh.
con.data();
215 for(
size_t i=0; i<bsize; i++)
219 size_t r = fread(&etbuff,
sizeof(
int), 1, fd);
224 char* ptr = fgets( buffer, bufsize, fd);
225 if(ptr == NULL)
break;
226 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);
262 fprintf(stderr,
"Error: Unsupported element type!\n");
265 mesh.
dsp[i+1] = mesh.
dsp[i] + nodes;
270 fread(n,
sizeof(
int), nodes+1, fd);
272 for(
int j=0; j<nodes; j++) elem[j] = n[j];
274 mesh.
tag[i] = n[nodes];
275 ref_eidx[i] = bstart + i;
280 mesh.
dsp.resize(ele_read+1);
281 mesh.
tag.resize(ele_read);
283 ref_eidx.
resize(ele_read);
284 mesh.
con.resize(con_size);
297 template<
class T,
class S>
300 const T* con = mesh.
con.data();
306 for(
size_t eidx=0; eidx < mesh.
l_numelem; eidx++)
308 fwrite(&mesh.
type[eidx], 1,
sizeof(
elem_t), fd);
309 T esize = mesh.
dsp[eidx+1] - mesh.
dsp[eidx];
311 wbuff[esize] = mesh.
tag[eidx];
313 fwrite(wbuff, esize+1,
sizeof(
int), fd);
319 for(
size_t eidx=0; eidx < mesh.
l_numelem; eidx++)
321 switch(mesh.
type[eidx])
324 fprintf(fd,
"Ln %lld %lld %lld\n",
325 static_cast<long long>(con[0]),
326 static_cast<long long>(con[1]),
327 static_cast<long long>(mesh.
tag[eidx]));
332 fprintf(fd,
"Tr %lld %lld %lld %lld\n",
333 static_cast<long long>(con[0]),
334 static_cast<long long>(con[1]),
335 static_cast<long long>(con[2]),
336 static_cast<long long>(mesh.
tag[eidx]));
341 fprintf(fd,
"Qd %lld %lld %lld %lld %lld\n",
342 static_cast<long long>(con[0]),
343 static_cast<long long>(con[1]),
344 static_cast<long long>(con[2]),
345 static_cast<long long>(con[3]),
346 static_cast<long long>(mesh.
tag[eidx]));
351 fprintf(fd,
"Tt %lld %lld %lld %lld %lld\n",
352 static_cast<long long>(con[0]),
353 static_cast<long long>(con[1]),
354 static_cast<long long>(con[2]),
355 static_cast<long long>(con[3]),
356 static_cast<long long>(mesh.
tag[eidx]));
361 fprintf(fd,
"Py %lld %lld %lld %lld %lld %lld\n",
362 static_cast<long long>(con[0]),
363 static_cast<long long>(con[1]),
364 static_cast<long long>(con[2]),
365 static_cast<long long>(con[3]),
366 static_cast<long long>(con[4]),
367 static_cast<long long>(mesh.
tag[eidx]));
372 fprintf(fd,
"Pr %lld %lld %lld %lld %lld %lld %lld\n",
373 static_cast<long long>(con[0]),
374 static_cast<long long>(con[1]),
375 static_cast<long long>(con[2]),
376 static_cast<long long>(con[3]),
377 static_cast<long long>(con[4]),
378 static_cast<long long>(con[5]),
379 static_cast<long long>(mesh.
tag[eidx]));
384 fprintf(fd,
"Hx %lld %lld %lld %lld %lld %lld %lld %lld %lld\n",
385 static_cast<long long>(con[0]),
386 static_cast<long long>(con[1]),
387 static_cast<long long>(con[2]),
388 static_cast<long long>(con[3]),
389 static_cast<long long>(con[4]),
390 static_cast<long long>(con[5]),
391 static_cast<long long>(con[6]),
392 static_cast<long long>(con[7]),
393 static_cast<long long>(mesh.
tag[eidx]));
398 fprintf(stderr,
"Error: Unsupported element type!\n");
415 template<
class T,
class S>
418 const int bufsize = 2048;
419 char buffer[bufsize];
428 for(
size_t i=0; i<bsize; i++) {
430 size_t r = fread(fib,
sizeof(
float), 6, fd);
434 char* ptr = fgets( buffer, bufsize, fd);
435 if(ptr == NULL)
break;
436 sscanf(buffer,
"%f %f %f %f %f %f", fib, fib+1, fib+2, fib+3, fib+4, fib+5);
438 mesh.
fib[nr*3+0] = fib[0];
439 mesh.
fib[nr*3+1] = fib[1];
440 mesh.
fib[nr*3+2] = fib[2];
441 mesh.
she[nr*3+0] = fib[3];
442 mesh.
she[nr*3+1] = fib[4];
443 mesh.
she[nr*3+2] = fib[5];
450 else if (nFib == 1) {
456 for(
size_t i=0; i<bsize; i++) {
458 size_t r = fread(fib,
sizeof(
float), 3, fd);
462 char* ptr = fgets( buffer, bufsize, fd);
463 if(ptr == NULL)
break;
464 sscanf(buffer,
"%f %f %f", fib, fib+1, fib+2);
467 mesh.
fib[nr*3+0] = fib[0];
468 mesh.
fib[nr*3+1] = fib[1];
469 mesh.
fib[nr*3+2] = fib[2];
485 template<
class T,
class S>
500 fib[0] = mesh.
fib[i*3+0];
501 fib[1] = mesh.
fib[i*3+1];
502 fib[2] = mesh.
fib[i*3+2];
503 fib[3] = mesh.
she[i*3+0];
504 fib[4] = mesh.
she[i*3+1];
505 fib[5] = mesh.
she[i*3+2];
508 fwrite(fib, 6,
sizeof(
float), fd);
510 fprintf(fd,
"%f %f %f %f %f %f\n", fib[0], fib[1], fib[2], fib[3], fib[4], fib[5]);
517 fib[0] = mesh.
fib[i*3+0];
518 fib[1] = mesh.
fib[i*3+1];
519 fib[2] = mesh.
fib[i*3+2];
522 fwrite(fib, 3,
sizeof(
float), fd);
524 fprintf(fd,
"%f %f %f\n", fib[0], fib[1], fib[2]);
540 template<
class T,
class S>
543 MPI_Comm comm = mesh.
comm;
545 MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
548 size_t gnumelems_file = 0;
554 fprintf(stderr,
"Error: could not open tag file: %s. Aborting!\n",
filename.c_str());
558 MPI_Allreduce(MPI_IN_PLACE, &err, 1, MPI_INT, MPI_SUM, comm);
559 if (err) exit(EXIT_FAILURE);
563 if (!fgets(buffer,
HDR_SIZE, fd) || sscanf(buffer,
"%lu", &gnumelems_file) != 1) {
564 fprintf(stderr,
"Error: could not read element count from tag file: %s. Aborting!\n",
filename.c_str());
568 MPI_Allreduce(MPI_IN_PLACE, &err, 1, MPI_INT, MPI_SUM, comm);
570 if (rank == 0) fclose(fd);
574 MPI_Bcast(&gnumelems_file,
sizeof(
size_t), MPI_BYTE, 0, comm);
578 fprintf(stderr,
"Error: tag file %s declares %lu elements, mesh has %lu. Aborting!\n",
580 if (rank == 0) fclose(fd);
584 size_t blocksize = (mesh.
g_numelem + size - 1) / size;
587 for (
size_t i = 0; i < mesh.
l_numelem; i++) {
589 if (fscanf(fd,
"%d", &t) != 1) {
590 fprintf(stderr,
"Error: unexpected end of tag file %s at element %lu. Aborting!\n",
591 filename.c_str(), (
unsigned long)i);
595 mesh.
tag[i] =
static_cast<T
>(t);
599 for (
int pid = 1; pid < size; pid++) {
602 for (
size_t i = 0; i < bsize; 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)((
size_t)pid * blocksize + i));
610 buf[i] =
static_cast<T
>(t);
612 MPI_Send(buf.
data(), bsize *
sizeof(T), MPI_BYTE, pid,
SF_MPITAG, comm);
631 template<
class T,
class S>
635 MPI_Comm comm = mesh.
comm;
638 MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
640 FILE* ele_fd = NULL, *fib_fd = NULL;
641 size_t gnumelems = 0;
643 bool read_binary =
false;
648 read_binary =
fileExists(basename +
".belem");
649 std::string ele_file = read_binary ? basename +
".belem" : basename +
".elem";
650 std::string fib_file = read_binary ? basename +
".blon" : basename +
".lon";
652 ele_fd = fopen(ele_file.c_str(),
"r");
654 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", ele_file.c_str());
658 fib_fd = fopen(fib_file.c_str(),
"r");
659 if((!fib_fd) && require_fibers) {
660 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", fib_file.c_str());
665 MPI_Allreduce(MPI_IN_PLACE, &err, 1, MPI_INT, MPI_SUM, comm);
671 read_headers(ele_fd, fib_fd, read_binary, gnumelems, nFib);
673 MPI_Bcast(&gnumelems,
sizeof(
size_t), MPI_BYTE, 0, comm);
674 MPI_Bcast(&nFib,
sizeof(
int), MPI_BYTE, 0, comm);
678 size_t blocksize = (gnumelems + size - 1) / size;
689 for(
int pid=1; pid<size; pid++) {
691 read_elem_block(ele_fd, read_binary, pid*blocksize, blocksize, meshbuff);
698 MPI_Send(meshbuff.
dsp.data(), meshbuff.
dsp.size()*
sizeof(T), MPI_BYTE, pid,
SF_MPITAG, comm);
699 MPI_Send(meshbuff.
tag.data(), meshbuff.
tag.size()*
sizeof(T), MPI_BYTE, pid,
SF_MPITAG, comm);
700 MPI_Send(ref_eidx.
data(), ref_eidx.
size()*
sizeof(T), MPI_BYTE, pid,
SF_MPITAG, comm);
707 size_t con_size = meshbuff.
con.size();
708 MPI_Send(&con_size,
sizeof(
size_t), MPI_BYTE, pid,
SF_MPITAG, comm);
709 MPI_Send(meshbuff.
con.data(), con_size*
sizeof(T), MPI_BYTE, pid,
SF_MPITAG, comm);
713 if(nFib>=1) fclose(fib_fd);
730 MPI_Recv(mesh.
dsp.data(), mesh.
dsp.size()*
sizeof(T), MPI_BYTE, 0,
SF_MPITAG, comm, &stat);
731 MPI_Recv(mesh.
tag.data(), mesh.
tag.size()*
sizeof(T), MPI_BYTE, 0,
SF_MPITAG, comm, &stat);
732 MPI_Recv(ref_eidx.
data(), ref_eidx.
size()*
sizeof(T), MPI_BYTE, 0,
SF_MPITAG, comm, &stat);
740 MPI_Recv(&con_size,
sizeof(
size_t), MPI_BYTE, 0,
SF_MPITAG, comm, &stat);
741 mesh.
con.resize(con_size);
742 MPI_Recv(mesh.
con.data(), con_size*
sizeof(T), MPI_BYTE, 0,
SF_MPITAG, comm, &stat);
759 template<
class T,
class S>
762 const MPI_Comm comm = mesh.
comm;
765 MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
767 FILE* ele_fd = NULL, *fib_fd = NULL;
774 std::string ele_file = binary ? basename +
".belem" : basename +
".elem";
775 std::string fib_file = binary ? basename +
".blon" : basename +
".lon";
779 ele_fd = fopen(ele_file.c_str(),
"w");
781 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", ele_file.c_str());
785 fib_fd = fopen(fib_file.c_str(),
"w");
787 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", fib_file.c_str());
794 if (nFib>=1) fclose(fib_fd);
798 for(
int pid=0; pid < size; pid++)
802 ele_fd = fopen(ele_file.c_str(),
"a");
804 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", ele_file.c_str());
808 fib_fd = fopen(fib_file.c_str(),
"a");
810 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", fib_file.c_str());
819 if(nFib>=1) fclose(fib_fd);
825 template<
class T,
class S>
828 const MPI_Comm comm = surfmesh.
comm;
829 const bool binary =
false;
832 MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
838 ele_fd = fopen(surffile.c_str(),
"w");
840 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", surffile.c_str());
843 fprintf(ele_fd,
"%lu\n", surfmesh.
g_numelem);
848 for(
int pid=0; pid < size; pid++)
851 ele_fd = fopen(surffile.c_str(),
"a");
853 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", surffile.c_str());
876 const int bufsize = 2048;
877 char buffer[bufsize];
883 for(
size_t i=0; i<bsize; i++) {
885 size_t r = fread(pts,
sizeof(
float), 3, fd);
889 char* ptr = fgets( buffer, bufsize, fd);
890 if(ptr == NULL)
break;
891 sscanf(buffer,
"%f %f %f", pts, pts+1, pts+2);
893 xyz[nr*3+0] = pts[0];
894 xyz[nr*3+1] = pts[1];
895 xyz[nr*3+2] = pts[2];
913 size_t nnodes = xyz.
size() / 3;
916 for(
size_t i=0; i<nnodes; i++)
923 fwrite(pt, 3,
sizeof(
float), fd);
925 fprintf(fd,
"%f %f %f\n", pt[0], pt[1], pt[2]);
937 template<
class T,
class S>
941 MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
945 bool read_binary =
false;
950 std::string pts_file = read_binary ? basename +
".bpts" : basename +
".pts";
952 pts_fd = fopen(pts_file.c_str(),
"r");
954 fprintf(stderr,
"Error: could not open file: %s. Aborting!\n", pts_file.c_str());
960 if(read_binary) fread(buffer,
sizeof(
char),
HDR_SIZE, pts_fd);
961 else fgets( buffer, 2048, pts_fd);
962 sscanf(buffer,
"%lu", &gnumpts);
964 MPI_Bcast(&gnumpts,
sizeof(
size_t), MPI_BYTE, 0, comm);
967 size_t blocksize = (gnumpts + size - 1) / size;
975 for(
int pid = 1; pid < size; pid++) {
977 long int numsend = buff.
size();
979 MPI_Send(&numsend, 1, MPI_LONG, pid,
SF_MPITAG, comm);
980 MPI_Send(buff.
data(), numsend*
sizeof(S), MPI_BYTE, pid,
SF_MPITAG, comm);
985 long int numrecv = 0;
986 MPI_Recv(&numrecv, 1, MPI_LONG, 0,
SF_MPITAG, comm, &stat);
989 MPI_Recv(pts.
data(), numrecv*
sizeof(S), MPI_BYTE, 0,
SF_MPITAG, comm, &stat);
992 long int mysize = pts.
size() / 3;
996 interval(ptsidx, layout[rank], layout[rank+1]);
998 if(rank == 0) fclose(pts_fd);
1007 template<
class T,
class S>
1012 assert(meshlist.size() > 0);
1013 assert(pts.
size() == (ptsidx.
size() * 3));
1017 MPI_Comm comm = (*meshlist.begin())->comm;
1020 MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
1025 for(
int pid = 0; pid < size; pid++) {
1026 size_t numsend = pts.
size();
1027 MPI_Bcast(&numsend,
sizeof(
size_t), MPI_BYTE, pid, comm);
1035 idxbuff.
resize(numsend / 3);
1038 MPI_Bcast(ptsbuff.
data(), ptsbuff.
size()*
sizeof(S), MPI_BYTE, pid, comm);
1039 MPI_Bcast(idxbuff.
data(), idxbuff.
size()*
sizeof(T), MPI_BYTE, pid, comm);
1043 for(
auto it = meshlist.begin(); it != meshlist.end(); ++it)
1051 for(
size_t i=0; i<rnod.
size(); i++)
1059 for(
size_t j=0; j<idxbuff.
size(); j++) {
1060 if(g2l.
count(idxbuff[j])) {
1067 for(
size_t j=0; j<ridx.
size(); j++) {
1068 T w = widx[j], r = ridx[j];
1069 mesh.
xyz[w*3+0] = ptsbuff[r*3+0];
1070 mesh.
xyz[w*3+1] = ptsbuff[r*3+1];
1071 mesh.
xyz[w*3+2] = ptsbuff[r*3+2];
1083 template<
class T,
class S>
1086 FILE* vtk_file = fopen(file.c_str(),
"w");
1087 if(vtk_file == NULL)
return;
1090 fprintf (vtk_file,
"# vtk DataFile Version 3.0\n");
1091 fprintf (vtk_file,
"vtk output\n");
1092 fprintf (vtk_file,
"binary\n");
1093 fprintf (vtk_file,
"DATASET UNSTRUCTURED_GRID\n\n");
1094 fprintf (vtk_file,
"POINTS %lu float\n", mesh.
l_numpts);
1099 for (
unsigned long int i=0; i<mesh.
l_numpts; i++ ) {
1100 pts[0] =
htobe(p[0]);
1101 pts[1] =
htobe(p[1]);
1102 pts[2] =
htobe(p[2]);
1103 fwrite(pts,
sizeof(
float), 3, vtk_file);
1106 fprintf(vtk_file,
"\n");
1108 fprintf (vtk_file,
"CELL_TYPES %lu\n", mesh.
l_numelem);
1109 unsigned long int valcount = 0;
1111 for(
unsigned long int i=0; i< mesh.
l_numelem; i++) {
1138 vtk_type =
htobe(vtk_type);
1139 fwrite(&vtk_type,
sizeof(
int), 1, vtk_file);
1140 valcount += mesh.
dsp[i+1] - mesh.
dsp[i] + 1;
1142 fprintf(vtk_file,
"\n");
1144 fprintf(vtk_file,
"CELLS %lu %lu\n", mesh.
l_numelem, valcount);
1145 const T* elem = mesh.
con.data();
1146 for(
unsigned long int i=0; i<mesh.
l_numelem; i++)
1148 int nodes = mesh.
dsp[i+1] - mesh.
dsp[i], n;
1149 int be_nodes =
htobe(nodes);
1150 fwrite(&be_nodes,
sizeof(
int), 1, vtk_file);
1152 for(
int j=0; j<nodes; j++) {
1153 n = elem[j]; n =
htobe(n);
1154 fwrite(&n,
sizeof(
int), 1, vtk_file);
1158 fprintf(vtk_file,
"\n");
1160 fprintf (vtk_file,
"CELL_DATA %lu \n", mesh.
l_numelem);
1161 fprintf (vtk_file,
"SCALARS elemTag int 1\n");
1162 fprintf (vtk_file,
"LOOKUP_TABLE default\n");
1163 for (
unsigned long int i=0; i<mesh.
l_numelem; i++ ) {
1165 fwrite(&t,
sizeof(
int), 1, vtk_file);
1176 fprintf (vtk_file,
"VECTORS fiber float\n");
1177 for (
unsigned long int i=0; i<mesh.
l_numelem; i++ ) {
1178 pts[0] =
htobe(
float(mesh.
fib[i*3+0])),
1179 pts[1] =
htobe(
float(mesh.
fib[i*3+1])),
1180 pts[2] =
htobe(
float(mesh.
fib[i*3+2]));
1181 fwrite(pts,
sizeof(
float), 3, vtk_file);
1183 fprintf(vtk_file,
"\n");
1186 fprintf (vtk_file,
"VECTORS sheet float\n");
1187 for (
unsigned long int i=0; i<mesh.
l_numelem; i++ ) {
1188 pts[0] =
htobe(
float(mesh.
she[i*3+0])),
1189 pts[1] =
htobe(
float(mesh.
she[i*3+1])),
1190 pts[2] =
htobe(
float(mesh.
she[i*3+2]));
1191 fwrite(pts,
sizeof(
float), 3, vtk_file);
1193 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)