19 std::string mplist, std::string prnsol,
31 std::ifstream fmplist;
32 fmplist.open(mplist.c_str(), std::ios::in);
35 std::cerr <<
" Could not open material file " << mplist
37 std::cerr <<
" The file perhaps does not exist.\n";
43 int il = 0, icurrmat = -1;
44 bool readerror =
false;
45 while (fmplist.getline(line, size,
'\n')) {
48 if (strcmp(line,
"1") == 0) {
49 fmplist.getline(line, size,
'\n');
51 fmplist.getline(line, size,
'\n');
53 fmplist.getline(line, size,
'\n');
55 fmplist.getline(line, size,
'\n');
57 fmplist.getline(line, size,
'\n');
63 token = strtok(line,
" ");
65 if (!token || strcmp(token,
" ") == 0 || strcmp(token,
"\n") == 0 ||
66 strcmp(token,
"TEMPERATURE") == 0 || strcmp(token,
"PROPERTY=") == 0 ||
67 int(token[0]) == 10 ||
int(token[0]) == 13)
71 if (strcmp(token,
"LIST") == 0) {
72 token = strtok(NULL,
" ");
73 token = strtok(NULL,
" ");
74 token = strtok(NULL,
" ");
75 token = strtok(NULL,
" ");
79 std::cerr <<
" Error reading file " << mplist <<
" (line " << il
93 std::cout <<
" Number of materials: " <<
nMaterials <<
"\n";
95 }
else if (strcmp(token,
"MATERIAL") == 0) {
97 token = strtok(NULL,
" ");
98 token = strtok(NULL,
" ");
102 std::cerr <<
" Error reading file " << mplist <<
" (line " << il
108 }
else if (strcmp(token,
"TEMP") == 0) {
110 token = strtok(NULL,
" ");
112 if (strncmp(token,
"PERX", 4) == 0) {
114 }
else if (strncmp(token,
"RSVX", 4) == 0) {
118 std::cerr <<
" Found unknown material property flag " << token
120 std::cerr <<
" on material properties file " << mplist <<
" (line "
124 fmplist.getline(line, size,
'\n');
127 token = strtok(line,
" ");
130 std::cerr <<
" Found out-of-range current material index "
132 std::cerr <<
" in material properties file " << mplist <<
".\n";
135 }
else if (itype == 1) {
137 }
else if (itype == 2) {
142 std::cerr <<
" Error reading file " << mplist <<
" line " << il
148 }
else if (strcmp(token,
"PROPERTY") == 0) {
150 token = strtok(NULL,
" ");
151 token = strtok(NULL,
" ");
153 if (strcmp(token,
"PERX") == 0) {
155 }
else if (strcmp(token,
"RSVX") == 0) {
159 std::cerr <<
" Found unknown material property flag " << token
161 std::cerr <<
" on material properties file " << mplist <<
" (line "
165 token = strtok(NULL,
" ");
166 token = strtok(NULL,
" ");
170 std::cerr <<
" Error reading file " << mplist <<
" (line " << il
177 std::cerr <<
" Found out-of-range material index " << imat <<
"\n";
178 std::cerr <<
" in material properties file " << mplist <<
".\n";
181 fmplist.getline(line, size,
'\n');
183 fmplist.getline(line, size,
'\n');
186 token = strtok(line,
" ");
187 token = strtok(NULL,
" ");
190 }
else if (itype == 2) {
195 std::cerr <<
" Error reading file " << mplist <<
" (line " << il
211 for (
int imat = 0; imat <
nMaterials; ++imat) {
215 std::cerr <<
" Material " << imat
216 <<
" has been assigned a permittivity\n";
217 std::cerr <<
" equal to zero in " << mplist <<
".\n";
219 }
else if (iepsmin < 0 || epsmin >
materials[imat].eps) {
227 std::cerr <<
" No material with positive permittivity found \n";
228 std::cerr <<
" in material list " << mplist <<
".\n";
231 for (
int imat = 0; imat <
nMaterials; ++imat) {
232 if (imat == iepsmin) {
242 std::cout <<
" Read properties of " <<
nMaterials
243 <<
" materials from file " << mplist <<
".\n";
247 std::ifstream felist;
248 felist.open(elist.c_str(), std::ios::in);
251 std::cerr <<
" Could not open element file " << elist
252 <<
" for reading.\n";
253 std::cerr <<
" The file perhaps does not exist.\n";
264 while (felist.getline(line, size,
'\n')) {
267 if (strcmp(line,
"1") == 0) {
268 felist.getline(line, size,
'\n');
270 felist.getline(line, size,
'\n');
272 felist.getline(line, size,
'\n');
274 felist.getline(line, size,
'\n');
276 felist.getline(line, size,
'\n');
283 token = strtok(line,
" ");
285 if (!token || strcmp(token,
" ") == 0 || strcmp(token,
"\n") == 0 ||
286 int(token[0]) == 10 ||
int(token[0]) == 13 ||
287 strcmp(token,
"LIST") == 0 || strcmp(token,
"ELEM") == 0) {
292 token = strtok(NULL,
" ");
294 token = strtok(NULL,
" ");
295 token = strtok(NULL,
" ");
296 token = strtok(NULL,
" ");
297 token = strtok(NULL,
" ");
298 token = strtok(NULL,
" ");
300 token = strtok(NULL,
" ");
302 token = strtok(NULL,
" ");
304 token = strtok(NULL,
" ");
306 token = strtok(NULL,
" ");
308 token = strtok(NULL,
" ");
310 token = strtok(NULL,
" ");
312 token = strtok(NULL,
" ");
314 if (!felist.getline(line, size,
'\n')) {
316 std::cerr <<
" Error reading element " << ielem <<
".\n";
321 token = strtok(line,
" ");
323 token = strtok(NULL,
" ");
329 std::cerr <<
" Error reading file " << elist <<
" (line " << il
334 }
else if (ielem - 1 !=
nElements + nbackground) {
336 std::cerr <<
" Synchronisation lost on file " << elist <<
" (line "
338 std::cerr <<
" Element: " << ielem <<
" (expected " <<
nElements
339 <<
"), material: " << imat <<
",\n";
340 std::cerr <<
" nodes: (" << in0 <<
", " << in1 <<
", " << in2 <<
", "
341 << in3 <<
", " << in4 <<
", " << in5 <<
", " << in6 <<
", "
342 << in7 <<
", " << in8 <<
", " << in9 <<
")\n";
349 std::cerr <<
" Out-of-range material number on file " << elist
350 <<
" (line " << il <<
").\n";
351 std::cerr <<
" Element: " << ielem <<
", material: " << imat <<
",\n";
352 std::cerr <<
" nodes: (" << in0 <<
", " << in1 <<
", " << in2 <<
", "
353 << in3 <<
", " << in4 <<
", " << in5 <<
", " << in6 <<
", "
354 << in7 <<
", " << in8 <<
", " << in9 <<
")\n";
359 std::cerr <<
" Element " << ielem <<
" in element list " << elist
361 std::cerr <<
" uses material " << imat
362 <<
" which has not been assigned\n";
363 std::cerr <<
" a positive permittivity in material list " << mplist
369 if (in0 < 1 || in1 < 1 || in2 < 1 || in3 < 1 || in4 < 1 || in5 < 1 ||
370 in6 < 1 || in7 < 1 || in8 < 1 || in9 < 1) {
372 std::cerr <<
" Found a node number < 1 on file " << elist <<
" (line "
374 std::cerr <<
" Element: " << ielem <<
", material: " << imat <<
",\n";
375 std::cerr <<
" nodes: (" << in0 <<
", " << in1 <<
", " << in2 <<
", "
376 << in3 <<
", " << in4 <<
", " << in5 <<
", " << in6 <<
", "
377 << in7 <<
", " << in8 <<
", " << in9 <<
")\n";
380 if (in0 > highestnode) highestnode = in0;
381 if (in1 > highestnode) highestnode = in1;
382 if (in2 > highestnode) highestnode = in2;
383 if (in3 > highestnode) highestnode = in3;
384 if (in4 > highestnode) highestnode = in4;
385 if (in5 > highestnode) highestnode = in5;
386 if (in6 > highestnode) highestnode = in6;
387 if (in7 > highestnode) highestnode = in7;
388 if (in8 > highestnode) highestnode = in8;
389 if (in9 > highestnode) highestnode = in9;
398 if (in0 == in1 || in0 == in2 || in0 == in3 || in0 == in4 || in0 == in5 ||
399 in0 == in6 || in0 == in7 || in0 == in8 || in0 == in9 || in1 == in2 ||
400 in1 == in3 || in1 == in4 || in1 == in5 || in1 == in6 || in1 == in7 ||
401 in1 == in8 || in1 == in9 || in2 == in3 || in2 == in4 || in2 == in5 ||
402 in2 == in6 || in2 == in7 || in2 == in8 || in2 == in9 || in3 == in4 ||
403 in3 == in5 || in3 == in6 || in3 == in7 || in3 == in8 || in3 == in9 ||
404 in4 == in5 || in4 == in6 || in4 == in7 || in4 == in8 || in4 == in9 ||
405 in5 == in6 || in5 == in7 || in5 == in8 || in5 == in9 || in6 == in7 ||
406 in6 == in8 || in6 == in9 || in7 == in8 || in7 == in9 || in8 == in9) {
408 std::cerr <<
" Element " << ielem <<
" of file " << elist
409 <<
" is degenerate,\n";
410 std::cerr <<
" no such elements allowed in this type of map.\n";
417 newElement.
matmap = imat - 1;
420 newElement.
emap[0] = in0 - 1;
421 newElement.
emap[1] = in1 - 1;
422 newElement.
emap[2] = in2 - 1;
423 newElement.
emap[3] = in3 - 1;
424 newElement.
emap[4] = in4 - 1;
425 newElement.
emap[7] = in5 - 1;
426 newElement.
emap[5] = in6 - 1;
427 newElement.
emap[6] = in7 - 1;
428 newElement.
emap[8] = in8 - 1;
429 newElement.
emap[9] = in9 - 1;
438 std::cout <<
" Read " <<
nElements <<
" elements from file " << elist
440 std::cout <<
" highest node number: " << highestnode <<
",\n";
441 std::cout <<
" background elements skipped: " << nbackground <<
"\n";
444 if (strcmp(unit.c_str(),
"mum") == 0 || strcmp(unit.c_str(),
"micron") == 0 ||
445 strcmp(unit.c_str(),
"micrometer") == 0) {
447 }
else if (strcmp(unit.c_str(),
"mm") == 0 ||
448 strcmp(unit.c_str(),
"millimeter") == 0) {
450 }
else if (strcmp(unit.c_str(),
"cm") == 0 ||
451 strcmp(unit.c_str(),
"centimeter") == 0) {
453 }
else if (strcmp(unit.c_str(),
"m") == 0 ||
454 strcmp(unit.c_str(),
"meter") == 0) {
458 std::cerr <<
" Unknown length unit " << unit <<
".\n";
464 std::cout <<
" Unit scaling factor = " << funit <<
".\n";
468 std::ifstream fnlist;
469 fnlist.open(nlist.c_str(), std::ios::in);
472 std::cerr <<
" Could not open nodes file " << nlist <<
" for reading.\n";
473 std::cerr <<
" The file perhaps does not exist.\n";
483 while (fnlist.getline(line, size,
'\n')) {
486 if (strcmp(line,
"1") == 0) {
487 fnlist.getline(line, size,
'\n');
489 fnlist.getline(line, size,
'\n');
491 fnlist.getline(line, size,
'\n');
493 fnlist.getline(line, size,
'\n');
495 fnlist.getline(line, size,
'\n');
501 token = strtok(line,
" ");
503 if (!token || strcmp(token,
" ") == 0 || strcmp(token,
"\n") == 0 ||
504 int(token[0]) == 10 ||
int(token[0]) == 13 ||
505 strcmp(token,
"LIST") == 0 || strcmp(token,
"NODE") == 0)
509 token = strtok(NULL,
" ");
510 double xnode =
ReadDouble(token, -1, readerror);
511 token = strtok(NULL,
" ");
512 double ynode =
ReadDouble(token, -1, readerror);
513 token = strtok(NULL,
" ");
514 double znode =
ReadDouble(token, -1, readerror);
518 std::cerr <<
" Error reading file " << nlist <<
" (line " << il
525 if (inode - 1 !=
nNodes) {
527 std::cerr <<
" Synchronisation lost on file " << nlist <<
" (line "
529 std::cerr <<
" Node: " << inode <<
" (expected " <<
nNodes
530 <<
"), (x,y,z) = (" << xnode <<
", " << ynode <<
", " << znode
535 newNode.
x = xnode * funit;
536 newNode.
y = ynode * funit;
537 newNode.
z = znode * funit;
538 nodes.push_back(newNode);
545 std::cout <<
" Read " <<
nNodes <<
" nodes from file " << nlist <<
".\n";
547 if (
nNodes != highestnode) {
549 std::cerr <<
" Number of nodes read (" <<
nNodes <<
") on " << nlist
551 std::cerr <<
" does not match element list (" << highestnode <<
").\n";
556 std::ifstream fprnsol;
557 fprnsol.open(prnsol.c_str(), std::ios::in);
558 if (fprnsol.fail()) {
560 std::cerr <<
" Could not open potential file " << prnsol
561 <<
" for reading.\n";
562 std::cerr <<
" The file perhaps does not exist.\n";
569 while (fprnsol.getline(line, size,
'\n')) {
572 if (strcmp(line,
"1") == 0) {
573 fprnsol.getline(line, size,
'\n');
575 fprnsol.getline(line, size,
'\n');
577 fprnsol.getline(line, size,
'\n');
579 fprnsol.getline(line, size,
'\n');
581 fprnsol.getline(line, size,
'\n');
587 token = strtok(line,
" ");
589 if (!token || strcmp(token,
" ") == 0 || strcmp(token,
"\n") == 0 ||
590 int(token[0]) == 10 ||
int(token[0]) == 13 ||
591 strcmp(token,
"PRINT") == 0 || strcmp(token,
"*****") == 0 ||
592 strcmp(token,
"LOAD") == 0 || strcmp(token,
"TIME=") == 0 ||
593 strcmp(token,
"MAXIMUM") == 0 || strcmp(token,
"VALUE") == 0 ||
594 strcmp(token,
"NODE") == 0)
598 token = strtok(NULL,
" ");
599 double volt =
ReadDouble(token, -1, readerror);
603 std::cerr <<
" Error reading file " << prnsol <<
" (line << " << il
610 if (inode < 1 || inode > highestnode) {
612 std::cerr <<
" Node number " << inode <<
" out of range\n";
613 std::cerr <<
" on potential file " << prnsol <<
" (line " << il
617 nodes[inode - 1].v = volt;
625 std::cout <<
" Read " << nread <<
" potentials from file " << prnsol
630 std::cerr <<
" Number of nodes read (" << nread <<
") on potential file "
632 std::cerr <<
" does not match the node list (" <<
nNodes <<
").\n";
642 <<
" Field map could not be read and can not be interpolated.\n";
661 std::cerr <<
m_className <<
"::SetWeightingField:\n";
662 std::cerr <<
" No valid field map is present.\n";
663 std::cerr <<
" Weighting field cannot be added.\n";
668 std::ifstream fprnsol;
669 fprnsol.open(prnsol.c_str(), std::ios::in);
670 if (fprnsol.fail()) {
671 std::cerr <<
m_className <<
"::SetWeightingField:\n";
672 std::cerr <<
" Could not open potential file " << prnsol
673 <<
" for reading.\n";
674 std::cerr <<
" The file perhaps does not exist.\n";
690 for (
int j =
nNodes; j--;) {
694 std::cout <<
m_className <<
"::SetWeightingField:\n";
695 std::cout <<
" Replacing existing weighting field " << label <<
".\n";
701 const int size = 100;
708 bool readerror =
false;
710 while (fprnsol.getline(line, size,
'\n')) {
713 if (strcmp(line,
"1") == 0) {
714 fprnsol.getline(line, size,
'\n');
716 fprnsol.getline(line, size,
'\n');
718 fprnsol.getline(line, size,
'\n');
720 fprnsol.getline(line, size,
'\n');
722 fprnsol.getline(line, size,
'\n');
728 token = strtok(line,
" ");
730 if (!token || strcmp(token,
" ") == 0 || strcmp(token,
"\n") == 0 ||
731 int(token[0]) == 10 ||
int(token[0]) == 13 ||
732 strcmp(token,
"PRINT") == 0 || strcmp(token,
"*****") == 0 ||
733 strcmp(token,
"LOAD") == 0 || strcmp(token,
"TIME=") == 0 ||
734 strcmp(token,
"MAXIMUM") == 0 || strcmp(token,
"VALUE") == 0 ||
735 strcmp(token,
"NODE") == 0)
739 token = strtok(NULL,
" ");
740 double volt =
ReadDouble(token, -1, readerror);
743 std::cerr <<
m_className <<
"::SetWeightingField:\n";
744 std::cerr <<
" Error reading file " << prnsol.c_str() <<
" (line "
750 if (inode < 1 || inode >
nNodes) {
751 std::cerr <<
m_className <<
"::SetWeightingField:\n";
752 std::cerr <<
" Node number " << inode <<
" out of range\n";
753 std::cerr <<
" on potential file " << prnsol.c_str() <<
" (line " << il
757 nodes[inode - 1].w[iw] = volt;
764 std::cout <<
m_className <<
"::SetWeightingField:\n";
765 std::cout <<
" Read " << nread <<
" potentials from file "
766 << prnsol.c_str() <<
".\n";
769 std::cerr <<
m_className <<
"::SetWeightingField:\n";
770 std::cerr <<
" Number of nodes read (" << nread <<
") "
771 <<
" on potential file " << prnsol.c_str() <<
"\n";
772 std::cerr <<
" does not match the node list (" <<
nNodes <<
").\n";
779 std::cerr <<
m_className <<
"::SetWeightingField:\n";
780 std::cerr <<
" Field map could not be read "
781 <<
"and cannot be interpolated.\n";
788 const double z,
double& ex,
double& ey,
789 double& ez,
Medium*& m,
int& status) {
796 const double zin,
double& ex,
double& ey,
797 double& ez,
double& volt,
Medium*& m,
801 double x = xin, y = yin, z = zin;
804 bool xmirrored, ymirrored, zmirrored;
805 double rcoordinate, rotation;
806 MapCoordinates(x, y, z, xmirrored, ymirrored, zmirrored, rcoordinate,
810 ex = ey = ez = volt = 0.;
818 std::cerr <<
" Field map not available for interpolation.\n";
824 std::cerr <<
" Warnings have been issued for this field map.\n";
828 double t1, t2, t3, t4, jac[4][4], det;
833 std::cerr <<
" Point (" << x <<
", " << y <<
", " << z
834 <<
") not in the mesh.\n";
842 std::cout <<
" Global: (" << x <<
", " << y <<
", " << z <<
"),\n";
843 std::cout <<
" Local: (" << t1 <<
", " << t2 <<
", " << t3 <<
", " << t4
844 <<
") in element " << imap <<
".\n";
846 <<
" Node x y z V\n";
847 for (
int i = 0; i < 10; i++) {
848 printf(
" %-5d %12g %12g %12g %12g\n",
elements[imap].emap[i],
866 ex = -(
nodes[
elements[imap].emap[0]].v * (4 * t1 - 1) * jac[0][1] +
871 (4 * t2 * jac[0][1] + 4 * t1 * jac[1][1]) +
873 (4 * t3 * jac[0][1] + 4 * t1 * jac[2][1]) +
875 (4 * t4 * jac[0][1] + 4 * t1 * jac[3][1]) +
877 (4 * t3 * jac[1][1] + 4 * t2 * jac[2][1]) +
879 (4 * t4 * jac[1][1] + 4 * t2 * jac[3][1]) +
881 (4 * t4 * jac[2][1] + 4 * t3 * jac[3][1])) /
884 ey = -(
nodes[
elements[imap].emap[0]].v * (4 * t1 - 1) * jac[0][2] +
889 (4 * t2 * jac[0][2] + 4 * t1 * jac[1][2]) +
891 (4 * t3 * jac[0][2] + 4 * t1 * jac[2][2]) +
893 (4 * t4 * jac[0][2] + 4 * t1 * jac[3][2]) +
895 (4 * t3 * jac[1][2] + 4 * t2 * jac[2][2]) +
897 (4 * t4 * jac[1][2] + 4 * t2 * jac[3][2]) +
899 (4 * t4 * jac[2][2] + 4 * t3 * jac[3][2])) /
902 ez = -(
nodes[
elements[imap].emap[0]].v * (4 * t1 - 1) * jac[0][3] +
907 (4 * t2 * jac[0][3] + 4 * t1 * jac[1][3]) +
909 (4 * t3 * jac[0][3] + 4 * t1 * jac[2][3]) +
911 (4 * t4 * jac[0][3] + 4 * t1 * jac[3][3]) +
913 (4 * t3 * jac[1][3] + 4 * t2 * jac[2][3]) +
915 (4 * t4 * jac[1][3] + 4 * t2 * jac[3][3]) +
917 (4 * t4 * jac[2][3] + 4 * t3 * jac[3][3])) /
921 UnmapFields(ex, ey, ez, x, y, z, xmirrored, ymirrored, zmirrored, rcoordinate,
927 std::cout <<
" Material " <<
elements[imap].matmap <<
", drift flag "
940 const double zin,
double& wx,
double& wy,
941 double& wz,
const std::string label) {
966 double x = xin, y = yin, z = zin;
969 bool xmirrored, ymirrored, zmirrored;
970 double rcoordinate, rotation;
971 MapCoordinates(x, y, z, xmirrored, ymirrored, zmirrored, rcoordinate,
976 std::cerr <<
" Warnings have been issued for this field map.\n";
980 double t1, t2, t3, t4, jac[4][4], det;
983 if (imap < 0)
return;
987 std::cout <<
" Global: (" << x <<
", " << y <<
", " << z <<
")\n";
988 std::cout <<
" Local: (" << t1 <<
", " << t2 <<
", " << t3 <<
", " << t4
989 <<
") in element " << imap <<
"\n",
990 std::cout <<
" Node x y z "
992 for (
int i = 0; i < 10; i++) {
993 printf(
" %-5d %12g %12g %12g %12g\n",
elements[imap].emap[i],
1001 wx = -(
nodes[
elements[imap].emap[0]].w[iw] * (4 * t1 - 1) * jac[0][1] +
1002 nodes[
elements[imap].emap[1]].w[iw] * (4 * t2 - 1) * jac[1][1] +
1003 nodes[
elements[imap].emap[2]].w[iw] * (4 * t3 - 1) * jac[2][1] +
1004 nodes[
elements[imap].emap[3]].w[iw] * (4 * t4 - 1) * jac[3][1] +
1006 (4 * t2 * jac[0][1] + 4 * t1 * jac[1][1]) +
1008 (4 * t3 * jac[0][1] + 4 * t1 * jac[2][1]) +
1010 (4 * t4 * jac[0][1] + 4 * t1 * jac[3][1]) +
1012 (4 * t3 * jac[1][1] + 4 * t2 * jac[2][1]) +
1014 (4 * t4 * jac[1][1] + 4 * t2 * jac[3][1]) +
1016 (4 * t4 * jac[2][1] + 4 * t3 * jac[3][1])) /
1019 wy = -(
nodes[
elements[imap].emap[0]].w[iw] * (4 * t1 - 1) * jac[0][2] +
1020 nodes[
elements[imap].emap[1]].w[iw] * (4 * t2 - 1) * jac[1][2] +
1021 nodes[
elements[imap].emap[2]].w[iw] * (4 * t3 - 1) * jac[2][2] +
1022 nodes[
elements[imap].emap[3]].w[iw] * (4 * t4 - 1) * jac[3][2] +
1024 (4 * t2 * jac[0][2] + 4 * t1 * jac[1][2]) +
1026 (4 * t3 * jac[0][2] + 4 * t1 * jac[2][2]) +
1028 (4 * t4 * jac[0][2] + 4 * t1 * jac[3][2]) +
1030 (4 * t3 * jac[1][2] + 4 * t2 * jac[2][2]) +
1032 (4 * t4 * jac[1][2] + 4 * t2 * jac[3][2]) +
1034 (4 * t4 * jac[2][2] + 4 * t3 * jac[3][2])) /
1037 wz = -(
nodes[
elements[imap].emap[0]].w[iw] * (4 * t1 - 1) * jac[0][3] +
1038 nodes[
elements[imap].emap[1]].w[iw] * (4 * t2 - 1) * jac[1][3] +
1039 nodes[
elements[imap].emap[2]].w[iw] * (4 * t3 - 1) * jac[2][3] +
1040 nodes[
elements[imap].emap[3]].w[iw] * (4 * t4 - 1) * jac[3][3] +
1042 (4 * t2 * jac[0][3] + 4 * t1 * jac[1][3]) +
1044 (4 * t3 * jac[0][3] + 4 * t1 * jac[2][3]) +
1046 (4 * t4 * jac[0][3] + 4 * t1 * jac[3][3]) +
1048 (4 * t3 * jac[1][3] + 4 * t2 * jac[2][3]) +
1050 (4 * t4 * jac[1][3] + 4 * t2 * jac[3][3]) +
1052 (4 * t4 * jac[2][3] + 4 * t3 * jac[3][3])) /
1056 UnmapFields(wx, wy, wz, x, y, z, xmirrored, ymirrored, zmirrored, rcoordinate,
1062 const std::string label) {
1065 if (!
ready)
return 0.;
1079 if (!found)
return 0.;
1084 double x = xin, y = yin, z = zin;
1087 bool xmirrored, ymirrored, zmirrored;
1088 double rcoordinate, rotation;
1089 MapCoordinates(x, y, z, xmirrored, ymirrored, zmirrored, rcoordinate,
1093 std::cerr <<
m_className <<
"::WeightingPotential:\n";
1094 std::cerr <<
" Warnings have been issued for this field map.\n";
1098 double t1, t2, t3, t4, jac[4][4], det;
1099 int imap =
FindElement13(x, y, z, t1, t2, t3, t4, jac, det);
1100 if (imap < 0)
return 0.;
1103 std::cerr <<
m_className <<
"::WeightingPotential:\n";
1104 std::cout <<
" Global: (" << x <<
", " << y <<
", "
1105 <<
", " << z <<
")\n";
1106 std::cout <<
" Local: (" << t1 <<
", " << t2 <<
", " << t3 <<
", " << t4
1107 <<
") in element " << imap <<
"\n";
1109 <<
" Node x y z V\n";
1110 for (
int i = 0; i < 10; i++) {
1111 printf(
" %-5d %12g %12g %12g %12g\n",
elements[imap].emap[i],
1118 return nodes[
elements[imap].emap[0]].w[iw] * t1 * (2 * t1 - 1) +
1131 const double& zin) {
1134 double x = xin, y = yin, z = zin;
1137 bool xmirrored, ymirrored, zmirrored;
1138 double rcoordinate, rotation;
1139 MapCoordinates(x, y, z, xmirrored, ymirrored, zmirrored, rcoordinate,
1145 std::cerr <<
" Field map not available for interpolation.\n";
1150 std::cerr <<
" Warnings have been issued for this field map.\n";
1154 double t1, t2, t3, t4, jac[4][4], det;
1155 int imap =
FindElement13(x, y, z, t1, t2, t3, t4, jac, det);
1159 std::cerr <<
" Point (" << x <<
", " << y <<
", " << z
1160 <<
") not in the mesh.\n";
1167 std::cerr <<
" Point (" << x <<
", " << y <<
", " << z <<
")"
1168 <<
" has out of range material number " << imap <<
".\n";
1175 std::cout <<
" Global: (" << x <<
", " << y <<
", " << z <<
")\n";
1176 std::cout <<
" Local: (" << t1 <<
", " << t2 <<
", " << t3 <<
", " << t4
1177 <<
") in element " << imap <<
"\n";
1179 <<
" Node x y z V\n";
1180 for (
int ii = 0; ii < 10; ++ii) {
1181 printf(
" %-5d %12g %12g %12g %12g\n",
elements[imap].emap[ii],
1232 for (
int j = 0; j < np - 1; ++j) {
1233 for (
int k = j + 1; k < np; ++k) {
1235 const double dist =
sqrt(
1243 if (dist < dmin) dmin = dist;
1244 if (dist > dmax) dmax = dist;
DoubleAc pow(const DoubleAc &f, double p)
DoubleAc sqrt(const DoubleAc &f)
DoubleAc fabs(const DoubleAc &f)
bool Initialise(std::string elist="ELIST.lis", std::string nlist="NLIST.lis", std::string mplist="MPLIST.lis", std::string prnsol="PRNSOL.lis", std::string unit="cm")
double GetElementVolume(const int i)
void GetAspectRatio(const int i, double &dmin, double &dmax)
Medium * GetMedium(const double &x, const double &y, const double &z)
double WeightingPotential(const double x, const double y, const double z, const std::string label)
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)
bool SetWeightingField(std::string prnsol, std::string label)
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string label)
double ReadDouble(char *token, double def, bool &error)
std::vector< bool > wfieldsOk
void MapCoordinates(double &xpos, double &ypos, double &zpos, bool &xmirrored, bool &ymirrored, bool &zmirrored, double &rcoordinate, double &rotation) const
std::vector< material > materials
void UnmapFields(double &ex, double &ey, double &ez, double &xpos, double &ypos, double &zpos, bool &xmirrored, bool &ymirrored, bool &zmirrored, double &rcoordinate, double &rotation)
int ReadInteger(char *token, int def, bool &error)
std::vector< element > elements
std::vector< node > nodes
int FindElement13(const double x, const double y, const double z, double &t1, double &t2, double &t3, double &t4, double jac[4][4], double &det)
std::vector< std::string > wfields