31 disableFieldComponent[0] =
false;
32 disableFieldComponent[1] =
false;
33 disableFieldComponent[2] =
false;
38 std::string mplist, std::string prnsol,
49 std::ifstream fmplist;
50 fmplist.open(mplist.c_str(), std::ios::in);
52 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
53 std::cerr <<
" Could not open material file " << mplist
54 <<
" for reading." << std::endl,
55 std::cerr <<
" The file perhaps does not exist." << std::endl;
62 bool readerror =
false;
63 while (fmplist.getline(line, size,
'\n')) {
67 token = strtok(line,
" ");
69 if (!token || strcmp(token,
" ") == 0 || strcmp(token,
"\n") == 0 ||
70 int(token[0]) == 10 ||
int(token[0]) == 13)
74 if (strcmp(token,
"Materials") == 0) {
75 token = strtok(NULL,
" ");
78 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
79 std::cerr <<
" Error reading file " << mplist <<
" (line " << il
92 std::cout <<
m_className <<
"::Initialise:" << std::endl;
93 std::cout <<
" Number of materials: " <<
nMaterials <<
""
96 }
else if (strcmp(token,
"Material") == 0) {
97 token = strtok(NULL,
" ");
100 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
101 std::cerr <<
" Error reading file " << mplist <<
" (line " << il
107 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
108 std::cerr <<
" Found out-of-range material index " << imat <<
"in"
110 std::cerr <<
" material properties file " << mplist <<
"."
114 token = strtok(NULL,
" ");
116 if (strcmp(token,
"PERX") == 0) {
118 }
else if (strcmp(token,
"RSVX") == 0) {
121 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
122 std::cerr <<
" Found unknown material property flag " << token
124 std::cerr <<
" on material properties file " << mplist <<
"(line "
125 << il <<
")." << std::endl;
128 token = strtok(NULL,
" ");
131 }
else if (itype == 2) {
133 token = strtok(NULL,
" ");
134 if (strcmp(token,
"PERX") != 0) {
135 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
136 std::cerr <<
" Found unknown material property falg " << token
138 std::cerr <<
" on material file " << mplist <<
" (material "
142 token = strtok(NULL,
" ");
147 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
148 std::cerr <<
" Error reading file " << mplist <<
"(line " << il
149 <<
")." << std::endl;
155 std::cout <<
m_className <<
"::Initialise:" << std::endl;
156 std::cout <<
" Read material properties for material "
157 << (imat - 1) <<
"" << std::endl;
159 std::cout <<
" eps = " <<
materials[imat - 1].eps
160 <<
" ohm = " <<
materials[imat - 1].ohm <<
""
163 std::cout <<
" eps = " <<
materials[imat - 1].eps <<
""
175 for (
int imat = 0; imat <
nMaterials; ++imat) {
178 std::cout <<
m_className <<
"::Initialise:" << std::endl;
179 std::cout <<
" Material " << imat
180 <<
" has been assigned a permittivity" << std::endl;
181 std::cout <<
" equal to zero in " << mplist <<
"." << std::endl;
183 }
else if (iepsmin < 0 || epsmin >
materials[imat].eps) {
189 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
190 std::cerr <<
" No material with positive permittivity found in"
192 std::cerr <<
" material list " << mplist.c_str() <<
"." << std::endl;
195 for (
int imat = 0; imat <
nMaterials; ++imat) {
196 if (imat == iepsmin) {
204 std::cout <<
m_className <<
"::Initialise:" << std::endl;
205 std::cout <<
" Read properties of " <<
nMaterials <<
" materials"
207 std::cout <<
" from file " << mplist <<
"." << std::endl;
212 if (strcmp(unit.c_str(),
"mum") == 0 || strcmp(unit.c_str(),
"micron") == 0 ||
213 strcmp(unit.c_str(),
"micrometer") == 0) {
215 }
else if (strcmp(unit.c_str(),
"mm") == 0 ||
216 strcmp(unit.c_str(),
"millimeter") == 0) {
218 }
else if (strcmp(unit.c_str(),
"cm") == 0 ||
219 strcmp(unit.c_str(),
"centimeter") == 0) {
221 }
else if (strcmp(unit.c_str(),
"m") == 0 ||
222 strcmp(unit.c_str(),
"meter") == 0) {
225 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
226 std::cerr <<
" Unknown length unit " << unit <<
"." << std::endl;
231 std::cout <<
m_className <<
"::Initialise:" << std::endl;
232 std::cout <<
" Unit scaling factor = " << funit <<
"." << std::endl;
236 std::ifstream fnlist;
237 fnlist.open(nlist.c_str(), std::ios::in);
239 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
240 std::cerr <<
" Could not open nodes file " << nlist <<
" for reading."
242 std::cerr <<
" The file perhaps does not exist." << std::endl;
248 int xlines = 0, ylines = 0, zlines = 0;
251 while (fnlist.getline(line, size,
'\n')) {
256 token = strtok(line,
" ");
258 if (!token || strcmp(token,
" ") == 0 || strcmp(token,
"\n") == 0 ||
259 int(token[0]) == 10 ||
int(token[0]) == 13)
262 if (strcmp(token,
"xmax") == 0) {
263 token = strtok(NULL,
" ");
265 token = strtok(NULL,
" ");
266 token = strtok(NULL,
" ");
268 token = strtok(NULL,
" ");
269 token = strtok(NULL,
" ");
271 if (readerror)
break;
274 if (strcmp(token,
"x-lines\n") == 0 || strcmp(token,
"x-lines") == 0) {
277 std::cout <<
m_className <<
"::Initialise:" << std::endl;
278 std::cout <<
" Reading x-lines from file " << nlist <<
"."
283 if (strcmp(token,
"y-lines\n") == 0 || strcmp(token,
"y-lines") == 0) {
286 std::cout <<
m_className <<
"::Initialise:" << std::endl;
287 std::cout <<
" Reading y-lines from file " << nlist <<
"."
292 if (strcmp(token,
"z-lines\n") == 0 || strcmp(token,
"z-lines") == 0) {
295 std::cout <<
m_className <<
"::Initialise:" << std::endl;
296 std::cout <<
" Reading z-lines from file " << nlist <<
"."
303 m_xlines.push_back(line_tmp * funit);
304 else if (lines_type == 2)
305 m_ylines.push_back(line_tmp * funit);
306 else if (lines_type == 3)
307 m_zlines.push_back(line_tmp * funit);
309 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
310 std::cerr <<
" Line type was not set in " << nlist <<
" (line " << il
311 <<
", token = " << token <<
")." << std::endl;
312 std::cerr <<
" Maybe it is in the wrong format" << std::endl;
313 std::cerr <<
" e.g. missing tailing space after x-lines." << std::endl;
317 if (readerror)
break;
321 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
322 std::cerr <<
" Error reading file " << nlist <<
" (line " << il <<
")."
331 if ((
unsigned)xlines == m_xlines.size() &&
332 (
unsigned)ylines == m_ylines.size() &&
333 (
unsigned)zlines == m_zlines.size()) {
334 std::cout <<
m_className <<
"::Initialise:" << std::endl;
335 std::cout <<
" Found in file " << nlist <<
"\n " << xlines
336 <<
" x-lines\n " << ylines <<
" y-lines\n " << zlines
337 <<
" z-lines" << std::endl;
339 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
340 std::cerr <<
" There should be " << xlines <<
" x-lines, " << ylines
341 <<
" y-lines and " << zlines <<
" z-lines in file " << nlist
342 <<
" but I found :\n " << m_xlines.size() <<
" x-lines, "
343 << m_ylines.size() <<
" x-lines, " << m_zlines.size()
344 <<
" z-lines." << std::endl;
346 m_nx = m_xlines.size();
347 m_ny = m_ylines.size();
348 m_nz = m_zlines.size();
353 std::cout <<
m_className <<
"::Initialise:" << std::endl;
354 std::cout <<
" Read " <<
nNodes <<
" nodes from file " << nlist <<
"."
359 std::ifstream felist;
360 felist.open(elist.c_str(), std::ios::in);
362 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
363 std::cerr <<
" Could not open element file " << elist <<
" for reading."
365 std::cerr <<
" The file perhaps does not exist." << std::endl;
371 while (felist.getline(line, size,
'\n')) {
376 token = strtok(line,
" ");
378 if (!token || strcmp(token,
" ") == 0 || strcmp(token,
"\n") == 0 ||
379 int(token[0]) == 10 ||
int(token[0]) == 13 ||
380 strcmp(token,
"LIST") == 0 || strcmp(token,
"ELEM") == 0)
384 token = strtok(NULL,
" ");
385 unsigned char imat = atoi(token);
387 std::vector<int> node_nb;
390 m_elementMaterial.at(ielem) = (imat-1);
392 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
393 std::cerr <<
" Error reading file " << elist <<
" (line " << il <<
")." << std::endl;
394 std::cerr <<
" The element index (" << ielem <<
") is not in the expected range: 0 - " <<
nElements << std::endl;
400 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
401 std::cerr <<
" Out-of-range material number on file " << elist
402 <<
" (line " << il <<
")." << std::endl;
403 std::cerr <<
" Element: " << ielem <<
", material: " << imat << std::endl;
407 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
408 std::cerr <<
" Element " << ielem <<
" in element list " << elist
409 <<
" uses material " << imat <<
" which" << std::endl;
410 std::cerr <<
" has not been assigned a positive permittivity"
412 std::cerr <<
" in material list " << mplist <<
"." << std::endl;
419 std::cout <<
m_className <<
"::Initialise:" << std::endl;
420 std::cout <<
" Read " <<
nElements <<
" elements from file " << elist
424 m_potential.resize(
nNodes);
425 std::ifstream fprnsol;
426 fprnsol.open(prnsol.c_str(), std::ios::in);
427 if (fprnsol.fail()) {
428 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
429 std::cerr <<
" Could not open potential file " << prnsol
430 <<
" for reading." << std::endl;
431 std::cerr <<
" The file perhaps does not exist." << std::endl;
438 while (fprnsol.getline(line, size,
'\n')) {
442 token = strtok(line,
" ");
444 if (!token || strcmp(token,
" ") == 0 || strcmp(token,
"\n") == 0 ||
445 int(token[0]) == 10 ||
int(token[0]) == 13 || strcmp(token,
"Max") == 0)
449 token = strtok(NULL,
" ");
450 double volt =
ReadDouble(token, -1, readerror);
453 m_potential.at(inode-1) = volt;
456 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
457 std::cerr <<
" Error reading file " << prnsol <<
" (line " << il <<
")." << std::endl;
458 std::cerr <<
" The node index (" << inode-1 <<
") is not in the expected range: 0 - " <<
nNodes << std::endl;
465 std::cout <<
m_className <<
"::Initialise:" << std::endl;
466 std::cout <<
" Read " << nread <<
"/" <<
nNodes <<
" (expected) potentials from file " << prnsol <<
"."
470 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
471 std::cerr <<
" Number of nodes read (" << nread <<
") on potential file "
472 << prnsol <<
" does not" << std::endl;
473 std::cerr <<
" match the node list (" <<
nNodes <<
")." << std::endl;
480 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
481 std::cerr <<
" Field map could not be read and cannot be interpolated."
499 if (strcmp(unit.c_str(),
"mum") == 0 || strcmp(unit.c_str(),
"micron") == 0 ||
500 strcmp(unit.c_str(),
"micrometer") == 0) {
502 }
else if (strcmp(unit.c_str(),
"mm") == 0 ||
503 strcmp(unit.c_str(),
"millimeter") == 0) {
505 }
else if (strcmp(unit.c_str(),
"cm") == 0 ||
506 strcmp(unit.c_str(),
"centimeter") == 0) {
508 }
else if (strcmp(unit.c_str(),
"m") == 0 ||
509 strcmp(unit.c_str(),
"meter") == 0) {
512 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
513 std::cerr <<
" Unknown length unit " << unit <<
"." << std::endl;
518 std::cout <<
m_className <<
"::Initialise:" << std::endl;
519 std::cout <<
" Unit scaling factor = " << funit <<
"." << std::endl;
521 FILE* f = fopen(dataFile.c_str(),
"rb");
523 std::cerr <<
m_className <<
"::Initilise:" << std::endl;
524 std::cerr <<
" Could not open file:" << dataFile.c_str() << std::endl;
528 struct stat fileStatus;
529 stat(dataFile.c_str(), &fileStatus);
530 int fileSize = fileStatus.st_size;
532 if (fileSize < 1000) {
534 std::cerr <<
m_className <<
"::Initilise:" << std::endl;
535 std::cerr <<
" Error. The file is extremely short and does not seem to contain a header or data." << std::endl;
539 char header[headerSize];
541 result = fread(header,
sizeof(
char), headerSize, f);
542 if (result != headerSize) {fputs (
"Reading error while reading header.",stderr); exit (3);}
544 int nx = 0, ny = 0, nz = 0;
545 int m_x = 0, m_y = 0, m_z = 0;
546 int n_s = 0, n_x = 0, n_y = 0, n_z = 0;
547 int e_s = 0, e_x = 0, e_y = 0, e_z = 0;
551 filled = std::sscanf(header, (std::string(
"mesh_nx=%d mesh_ny=%d mesh_nz=%d\n")+
552 std::string(
"mesh_xlines=%d mesh_ylines=%d mesh_zlines=%d\n")+
553 std::string(
"nodes_scalar=%d nodes_vector_x=%d nodes_vector_y=%d nodes_vector_z=%d\n")+
554 std::string(
"elements_scalar=%d elements_vector_x=%d elements_vector_y=%d elements_vector_z=%d\n")+
555 std::string(
"elements_material=%d\n")+
556 std::string(
"n_materials=%d\n")).c_str(),
559 &n_s, &n_x, &n_y, &n_z,
560 &e_s, &e_x, &e_y, &e_z,
564 std::cerr <<
m_className <<
"::Initilise:" << std::endl;
565 std::cerr <<
" Error. File header of " << dataFile.c_str() <<
" is broken." << std::endl;
568 if (fileSize < 1000+(m_x+m_y+m_z)*8+(n_s+n_x+n_y+n_z+e_s+e_x+e_y+e_z)*4+e_m*1+
nMaterials*20) {
573 std::cout <<
m_className <<
"::Initialise:" << std::endl;
574 std::cout <<
" Information about the data stored in the given binary file:" << std::endl;
575 std::cout <<
" Mesh (nx): " << nx <<
"\t Mesh (ny): " << ny <<
"\t Mesh (nz): " << nz << std::endl;
576 std::cout <<
" Mesh (x_lines): " << m_x <<
"\t Mesh (y_lines): " << m_y <<
"\t Mesh (z_lines): " << m_z << std::endl;
577 std::cout <<
" Nodes (scalar): " << n_s <<
"\t Nodes (x): " << n_x <<
"\t Nodes (y): " << n_y <<
"\t Nodes (z): " << n_z << std::endl;
578 std::cout <<
" Field (scalar): " << e_s <<
"\t Field (x): " << e_x <<
"\t Field (y): " << e_y <<
"\t Field (z): " << e_z << std::endl;
579 std::cout <<
" Elements: " << e_m <<
"\t Materials: " <<
nMaterials << std::endl;
587 m_xlines.resize(m_x);
588 m_ylines.resize(m_y);
589 m_zlines.resize(m_z);
590 m_potential.resize(n_s);
591 m_elementMaterial.resize(e_m);
594 result = fread(m_xlines.data(),
sizeof(
double), m_xlines.size(), f);
595 if (result != m_xlines.size()) {fputs (
"Reading error while reading xlines.",stderr); exit (3);}
596 else if (result == 0) {fputs (
"No xlines are stored in the data file.",stderr); exit (3);}
597 result = fread(m_ylines.data(),
sizeof(
double), m_ylines.size(), f);
598 if (result != m_ylines.size()) {fputs (
"Reading error while reading ylines",stderr); exit (3);}
599 else if (result == 0) {fputs (
"No ylines are stored in the data file.",stderr); exit (3);}
600 result = fread(m_zlines.data(),
sizeof(
double), m_zlines.size(), f);
601 if (result != m_zlines.size()) {fputs (
"Reading error while reasing zlines",stderr); exit (3);}
602 else if (result == 0) {fputs (
"No zlines are stored in the data file.",stderr); exit (3);}
603 result = fread(m_potential.data(),
sizeof(
float), m_potential.size(), f);
604 if (result != m_potential.size()) {fputs (
"Reading error while reading nodes.",stderr); exit (3);}
605 else if (result == 0) {fputs (
"No potentials are stored in the data file.",stderr); exit (3);}
606 fseek(f, e_s*
sizeof(
float), SEEK_CUR);
608 result = fread(m_elementMaterial.data(),
sizeof(
unsigned char), m_elementMaterial.size(), f);
609 if (result != m_elementMaterial.size()) {fputs (
"Reading error while reading element material",stderr); exit (3);}
610 std::stringstream st;
616 for (
unsigned int i = 0; i<
materials.size(); i++) {
618 result = fread(&(
id),
sizeof(
float), 1, f);
619 if (result != 1) {fputs (
"Input error while reading material id.",stderr); exit (3);}
620 unsigned int description_size = 0;
621 result = fread(&(description_size),
sizeof(
int), 1, f);
622 if (result != 1) {fputs (
"Input error while reading material description size.",stderr); exit (3);}
623 char* c =
new char[description_size];
624 result = fread(c,
sizeof(
char), description_size, f);
625 if (result != description_size) {fputs (
"Input error while reading material description.",stderr); exit (3);}
626 std::string name = c;
627 st <<
" Read material: " << name.c_str();
628 if(name.compare(
"gas") == 0){
629 st <<
" (considered as drift medium)";
636 result = fread(&(tmp_eps),
sizeof(
float), 1, f);
638 if (result != 1) {fputs (
"Reading error while reading eps.",stderr); exit (3);}
644 st <<
"; eps is: " <<
materials.at(
id).eps <<
647 "\t id is: " <<
id << std::endl;
649 fseek(f, 2*
sizeof(
float),SEEK_CUR);
654 std::cout << st.str();
655 for(std::vector<material>::iterator it =
materials.begin(), it_end =
materials.end(); it!=it_end;it++){
656 std::cout <<
"Material id: " << std::distance(
materials.begin(),it) <<
" \t driftable: " << (*it).driftmedium << std::endl;
660 std::sort(m_xlines.begin(),m_xlines.end());
661 std::sort(m_ylines.begin(),m_ylines.end());
662 std::sort(m_zlines.begin(),m_zlines.end());
664 std::transform(m_xlines.begin(), m_xlines.end(), m_xlines.begin(), std::bind1st(std::multiplies<double>(),funit));
665 std::transform(m_ylines.begin(), m_ylines.end(), m_ylines.begin(), std::bind1st(std::multiplies<double>(),funit));
666 std::transform(m_zlines.begin(), m_zlines.end(), m_zlines.begin(), std::bind1st(std::multiplies<double>(),funit));
669 std::cout <<
m_className <<
"::Initialise" << std::endl;
670 std::cout <<
" x range: " << *(m_xlines.begin()) <<
" - " << *(m_xlines.end()-1) << std::endl;
671 std::cout <<
" y range: " << *(m_ylines.begin()) <<
" - " << *(m_ylines.end()-1) << std::endl;
672 std::cout <<
" z range: " << *(m_zlines.begin()) <<
" - " << *(m_zlines.end()-1) << std::endl;
678 std::cerr <<
m_className <<
"::Initialise:" << std::endl;
679 std::cerr <<
" Field map could not be read and cannot be interpolated."
690 std::vector<float> potentials(
nNodes);
692 std::cerr <<
m_className <<
"::SetWeightingField:" << std::endl;
693 std::cerr <<
" No valid field map is present." << std::endl;
694 std::cerr <<
" Weighting field cannot be added." << std::endl;
699 std::ifstream fprnsol;
700 fprnsol.open(prnsol.c_str(), std::ios::in);
701 if (fprnsol.fail()) {
702 std::cerr <<
m_className <<
"::SetWeightingField:" << std::endl;
703 std::cerr <<
" Could not open potential file " << prnsol
704 <<
" for reading." << std::endl;
705 std::cerr <<
" The file perhaps does not exist." << std::endl;
709 std::map<std::string, std::vector<float> >::iterator it = m_weightingFields.find(label);
710 if (it != m_weightingFields.end()) {
711 std::cout <<
m_className <<
"::SetWeightingField:" << std::endl;
712 std::cout <<
" Replacing existing weighting field " << label <<
"."
719 if(std::distance(m_weightingFields.begin(),it) != std::distance(
wfields.begin(),find(
wfields.begin(),
wfields.end(),label))){
720 std::cerr <<
m_className <<
"::SetWeightingField:" << std::endl;
721 std::cerr <<
" Indexes of the weighting fields and the weighting field counter are not equal!" << std::endl;
724 unsigned int iField = std::distance(m_weightingFields.begin(),it);
729 std::cout <<
m_className <<
"::SetWeightingField:" << std::endl;
730 std::cout <<
" Reading weighting field from binary file:" << prnsol.c_str() << std::endl;
731 FILE* f = fopen(prnsol.c_str(),
"rb");
733 std::cerr <<
m_className <<
"::Initilise:" << std::endl;
734 std::cerr <<
" Could not open file:" << prnsol.c_str() << std::endl;
738 struct stat fileStatus;
739 stat(prnsol.c_str(), &fileStatus);
740 int fileSize = fileStatus.st_size;
742 if (fileSize < 1000) {
744 std::cerr <<
m_className <<
"::SetWeightingField:" << std::endl;
745 std::cerr <<
" Error. The file is extremely short and does not seem to contain a header or data." << std::endl;
749 char header[headerSize];
751 result = fread(header,
sizeof(
char), headerSize, f);
752 if (result != headerSize) {fputs (
"Reading error while reading header.",stderr); exit (3);}
754 int nx = 0, ny = 0, nz = 0;
755 int m_x = 0, m_y = 0, m_z = 0;
756 int n_x = 0, n_y = 0, n_z = 0;
757 int e_s = 0, e_x = 0, e_y = 0, e_z = 0;
761 filled = std::sscanf(header, (std::string(
"mesh_nx=%d mesh_ny=%d mesh_nz=%d\n")+
762 std::string(
"mesh_xlines=%d mesh_ylines=%d mesh_zlines=%d\n")+
763 std::string(
"nodes_scalar=%d nodes_vector_x=%d nodes_vector_y=%d nodes_vector_z=%d\n")+
764 std::string(
"elements_scalar=%d elements_vector_x=%d elements_vector_y=%d elements_vector_z=%d\n")+
765 std::string(
"elements_material=%d\n")+
766 std::string(
"n_materials=%d\n")).c_str(),
769 &nread, &n_x, &n_y, &n_z,
770 &e_s, &e_x, &e_y, &e_z,
774 std::cerr <<
m_className <<
"::SetWeightingField:" << std::endl;
775 std::cerr <<
" Error. File header of " << prnsol.c_str() <<
" is broken." << std::endl;
778 if (fileSize < 1000+(m_x+m_y+m_z)*8+(nread+n_x+n_y+n_z+e_s+e_x+e_y+e_z)*4+e_m*1+
nMaterials*20) {
783 std::cout <<
m_className <<
"::SetWeightingField:" << std::endl;
784 std::cout <<
" Information about the data stored in the given binary file:" << std::endl;
785 std::cout <<
" Mesh (nx): " << nx <<
"\t Mesh (ny): " << ny <<
"\t Mesh (nz): " << nz << std::endl;
786 std::cout <<
" Mesh (x_lines): " << m_x <<
"\t Mesh (y_lines): " << m_y <<
"\t Mesh (z_lines): " << m_z << std::endl;
787 std::cout <<
" Nodes (scalar): " << nread <<
"\t Nodes (x): " << n_x <<
"\t Nodes (y): " << n_y <<
"\t Nodes (z): " << n_z << std::endl;
788 std::cout <<
" Field (scalar): " << e_s <<
"\t Field (x): " << e_x <<
"\t Field (y): " << e_y <<
"\t Field (z): " << e_z << std::endl;
789 std::cout <<
" Elements: " << e_m <<
"\t Materials: " <<
nMaterials << std::endl;
792 fseek(f, m_x*
sizeof(
double), SEEK_CUR);
793 fseek(f, m_y*
sizeof(
double), SEEK_CUR);
794 fseek(f, m_z*
sizeof(
double), SEEK_CUR);
795 result = fread(potentials.data(),
sizeof(
float), potentials.size(), f);
796 if (result != potentials.size()) {fputs (
"Reading error while reading nodes.",stderr); exit (3);}
797 else if (result == 0) {fputs (
"No wighting potentials are stored in the data file.",stderr); exit (3);}
800 std::cout <<
m_className <<
"::SetWeightingField:" << std::endl;
801 std::cout <<
" Reading weighting field from text file:" << prnsol.c_str() << std::endl;
803 const int size = 100;
810 bool readerror =
false;
811 while (fprnsol.getline(line, size,
'\n')) {
815 token = strtok(line,
" ");
817 if (!token || strcmp(token,
" ") == 0 || strcmp(token,
"\n") == 0 ||
818 int(token[0]) == 10 ||
int(token[0]) == 13 ||
819 strcmp(token,
"PRINT") == 0 || strcmp(token,
"*****") == 0 ||
820 strcmp(token,
"LOAD") == 0 || strcmp(token,
"TIME=") == 0 ||
821 strcmp(token,
"MAXIMUM") == 0 || strcmp(token,
"VALUE") == 0 ||
822 strcmp(token,
"NODE") == 0)
826 token = strtok(NULL,
" ");
827 double volt =
ReadDouble(token, -1, readerror);
829 potentials.at(inode-1) = volt;
832 std::cerr <<
m_className <<
"::SetWeightingField:" << std::endl;
833 std::cerr <<
" Node number " << inode <<
" out of range." << std::endl;
834 std::cerr <<
" on potential file " << prnsol <<
" (line " << il <<
")." << std::endl;
835 std::cerr <<
" Size of the potential vector is: " << potentials.size() << std::endl;
843 std::cout <<
m_className <<
"::SetWeightingField:" << std::endl;
844 std::cout <<
" Read " << nread <<
"/" <<
nNodes <<
" (expected) potentials from file " << prnsol <<
"."
848 std::cerr <<
m_className <<
"::SetWeightingField:" << std::endl;
849 std::cerr <<
" Number of nodes read (" << nread <<
")"
850 <<
" on potential file (" << prnsol <<
")" << std::endl;
851 std::cerr <<
" does not match the node list (" <<
nNodes <<
")."
856 std::cerr <<
m_className <<
"::SetWeightingField:" << std::endl;
857 std::cerr <<
" Field map could not be read "
858 <<
"and cannot be interpolated." << std::endl;
862 m_weightingFields[label] = potentials;
870 std::transform(m_xlines.begin(), m_xlines.end(), m_xlines.begin(), std::bind1st(std::plus<double>(),xShift));
871 std::transform(m_ylines.begin(), m_ylines.end(), m_ylines.begin(), std::bind1st(std::plus<double>(),yShift));
872 std::transform(m_zlines.begin(), m_zlines.end(), m_zlines.begin(), std::bind1st(std::plus<double>(),zShift));
876 std::cout <<
m_className <<
"::ShiftComponent:" << std::endl;
877 std::cout <<
" Shifted component in x-direction: " << xShift
878 <<
"\t y-direction: " << yShift
879 <<
"\t z-direction: " << zShift << std::endl;
883 double& ex,
double& ey,
double& ez,
Medium*& m,
886 ElectricFieldBinary(xin, yin, zin, ex, ey, ez, volt, m, status);
890 double& ex,
double& ey,
double& ez,
double & volt,
Medium*& m,
892 ElectricFieldBinary(xin, yin, zin, ex, ey, ez, volt, m, status,
true);
896 const double zin,
double& wx,
double& wy,
897 double& wz,
const std::string label) {
906 std::map<std::string, std::vector<float> >::iterator it = m_weightingFields.find(label);
907 if(it == m_weightingFields.end()){
909 std::cerr <<
"No weighting field named " << label.c_str() <<
" found!" << std::endl;
914 if (!
wfieldsOk[std::distance(m_weightingFields.begin(),it)])
return;
917 double x = xin, y = yin, z = zin;
921 double rcoordinate, rotation;
923 double position_mapped[3] = {0., 0., 0.};
924 if(!
Coordinate2Index(x, y, z, i, j, k, position_mapped, mirrored, rcoordinate, rotation))
927 double rx = (position_mapped[0] - m_xlines.at(i))/(m_xlines.at(i+1) - m_xlines.at(i));
928 double ry = (position_mapped[1] - m_ylines.at(j))/(m_ylines.at(j+1) - m_ylines.at(j));
929 double rz = (position_mapped[2] - m_zlines.at(k))/(m_zlines.at(k+1) - m_zlines.at(k));
932 if(!disableFieldComponent[0])
933 fwx = GetFieldComponent(i, j, k, rx, ry, rz,
'x', &((*it).second));
934 if(!disableFieldComponent[1])
935 fwy = GetFieldComponent(i, j, k, rx, ry, rz,
'y', &((*it).second));
936 if(!disableFieldComponent[2])
937 fwz = GetFieldComponent(i, j, k, rx, ry, rz,
'z', &((*it).second));
939 if (m_elementMaterial.size()>0 && doShaping) {
940 ShapeField(fwx, fwy, fwz, rx, ry, rz, i, j, k, &((*it).second));
949 std::cout <<
m_className <<
"::WeightingField:" << std::endl;
950 std::cout <<
" Warnings have been issued for this field map."
954 if (!disableFieldComponent[0]) wx = fwx;
955 if (!disableFieldComponent[1]) wy = fwy;
956 if (!disableFieldComponent[2]) wz = fwz;
962 const std::string label) {
965 if (!
ready)
return 0.;
969 std::map<std::string, std::vector<float> >::iterator it = m_weightingFields.find(label);
970 if(it == m_weightingFields.end()){
972 std::cerr <<
"No weighting field named " << label.c_str() <<
" found!" << std::endl;
977 if (!
wfieldsOk[std::distance(m_weightingFields.begin(),it)])
return 0.;
980 double x = xin, y = yin, z = zin;
984 double rcoordinate, rotation;
986 double position_mapped[3] = {0., 0., 0.};
987 if(!
Coordinate2Index(x, y, z, i, j, k, position_mapped, mirrored, rcoordinate, rotation))
990 double rx = (position_mapped[0] - m_xlines.at(i))/(m_xlines.at(i+1) - m_xlines.at(i));
991 double ry = (position_mapped[1] - m_ylines.at(j))/(m_ylines.at(j+1) - m_ylines.at(j));
992 double rz = (position_mapped[2] - m_zlines.at(k))/(m_zlines.at(k+1) - m_zlines.at(k));
994 double potential = GetPotential(i, j, k, rx, ry, rz, &((*it).second));
997 std::cout <<
m_className <<
"::WeightingPotential:" << std::endl;
998 std::cout <<
" Global: (" << x <<
"," << y <<
"," << z <<
"),"
1000 std::cout <<
" Local: (" << rx <<
"," << ry <<
"," << rz
1001 <<
") in element with indexes: i=" << i <<
", j=" << j <<
", k=" << k << std::endl;
1002 std::cout <<
" Node xyzV:" << std::endl;
1003 std::cout <<
"Node 0 position: " << Index2Node(i+1, j , k ) <<
"\t potential: " << ((*it).second).at(Index2Node(i+1, j , k ))
1004 <<
"Node 1 position: " << Index2Node(i+1, j+1, k ) <<
"\t potential: " << ((*it).second).at(Index2Node(i+1, j+1, k ))
1005 <<
"Node 2 position: " << Index2Node(i , j+1, k ) <<
"\t potential: " << ((*it).second).at(Index2Node(i , j+1, k ))
1006 <<
"Node 3 position: " << Index2Node(i , j , k ) <<
"\t potential: " << ((*it).second).at(Index2Node(i , j , k ))
1007 <<
"Node 4 position: " << Index2Node(i+1, j , k+1) <<
"\t potential: " << ((*it).second).at(Index2Node(i+1, j , k+1))
1008 <<
"Node 5 position: " << Index2Node(i+1, j+1, k+1) <<
"\t potential: " << ((*it).second).at(Index2Node(i+1, j+1, k+1))
1009 <<
"Node 6 position: " << Index2Node(i , j+1, k+1) <<
"\t potential: " << ((*it).second).at(Index2Node(i , j+1, k+1))
1010 <<
"Node 7 position: " << Index2Node(i , j , k+1) <<
"\t potential: " << ((*it).second).at(Index2Node(i , j , k ))
1017 n_x = m_xlines.size();
1018 n_y = m_ylines.size();
1019 n_z = m_zlines.size();
1023 double &ymin,
double &ymax,
double &zmin,
double &zmax){
1025 Element2Index(
element, i, j, k);
1026 xmin = m_xlines.at(i);
1027 xmax = m_xlines.at(i+1);
1028 ymin = m_ylines.at(j);
1029 ymax = m_ylines.at(j+1);
1030 zmin = m_zlines.at(k);
1031 zmax = m_zlines.at(k+1);
1035 const double& zin) {
1036 unsigned int i, j, k;
1039 std::cout <<
m_className <<
"::GetMedium:" << std::endl;
1040 std::cout <<
" Found position (" << xin <<
", " << yin <<
", " << zin <<
"): " << std:: endl;
1041 std::cout <<
" Indexes are: x: " << i <<
"/" << m_xlines.size()
1042 <<
"\t y: " << j <<
"/" << m_ylines.size()
1043 <<
"\t z: " << k <<
"/" << m_zlines.size() << std::endl;
1044 std::cout <<
" Element material index: " <<
Index2Element(i, j, k) << std::endl;
1045 std::cout <<
" Element index: " << (int)m_elementMaterial.at(
Index2Element(i,j,k)) << std::endl;
1053 mapxmax = *(m_xlines.end()-1);
1055 mapymax = *(m_ylines.end()-1);
1057 mapzmax = *(m_zlines.end()-1);
1058 mapvmin = *std::min_element(m_potential.begin(),m_potential.end());
1059 mapvmax = *std::max_element(m_potential.begin(),m_potential.end());
1082 if (
fabs(zmax - zmin) <= 0.) {
1083 std::cerr <<
m_className <<
"::SetRangeZ:" << std::endl;
1084 std::cerr <<
" Zero range is not permitted." << std::endl;
1092 unsigned int &i,
unsigned int &j,
unsigned int &k){
1093 bool mirrored[3] = {
false,
false,
false};
1094 double position_mapped[3] = {0., 0., 0.};
1095 double rcoordinate, rotation;
1096 return Coordinate2Index(x ,y, z, i, j, k, position_mapped, mirrored, rcoordinate, rotation);
1102 if (i>m_nx-2 || j>m_ny-2 || k>m_nz-2) {
1103 throw "FieldMap::ElementByIndex: Error. Element indexes out of bounds.";
1105 return i+j*(m_nx-1)+k*(m_nx-1)*(m_ny-1);
1109 unsigned int &i,
unsigned int &j,
unsigned int &k,
1110 double *position_mapped,
bool *mirrored,
1111 double &rcoordinate,
double &rotation){
1113 position_mapped[0] = xin;
1114 position_mapped[1] = yin;
1115 position_mapped[2] = zin;
1116 MapCoordinates(position_mapped[0], position_mapped[1], position_mapped[2],
1117 mirrored[0], mirrored[1], mirrored[2], rcoordinate, rotation);
1119 std::vector<double>::iterator it_x, it_y, it_z;
1120 it_x = std::lower_bound(m_xlines.begin(),m_xlines.end(),position_mapped[0]);
1121 it_y = std::lower_bound(m_ylines.begin(),m_ylines.end(),position_mapped[1]);
1122 it_z = std::lower_bound(m_zlines.begin(),m_zlines.end(),position_mapped[2]);
1123 if(it_x == m_xlines.end() || it_y == m_ylines.end() || it_z == m_zlines.end() ||
1124 position_mapped[0] < m_xlines.at(0) || position_mapped[1] < m_ylines.at(0) || position_mapped[2] < m_zlines.at(0) ){
1126 std::cerr <<
m_className <<
"::ElectricFieldBinary:" << std::endl;
1127 std::cerr <<
" Could not find the given coordinate!" << std::endl;
1128 std::cerr <<
" You ask for the following position: " << xin <<
", " << yin <<
", " << zin << std::endl;
1129 std::cerr <<
" The mapped position is: " << position_mapped[0] <<
", " << position_mapped[1] <<
", " << position_mapped[2] << std::endl;
1139 if(it_x == m_xlines.begin())
1142 i = std::distance(m_xlines.begin(),it_x-1);
1143 if(it_y == m_ylines.begin())
1146 j = std::distance(m_ylines.begin(),it_y-1);
1147 if(it_z == m_zlines.begin())
1150 k = std::distance(m_zlines.begin(),it_z-1);
1162 if (element < 0 || element >=
nElements) {
1166 unsigned int i, j, k;
1167 Element2Index(
element, i, j, k);
1168 std::vector<double> distances;
1169 distances.push_back(m_xlines.at(i+1) - m_xlines.at(i));
1170 distances.push_back(m_ylines.at(j+1) - m_ylines.at(j));
1171 distances.push_back(m_zlines.at(k+1) - m_zlines.at(k));
1172 std::sort(distances.begin(), distances.end());
1173 dmin = distances.at(0);
1174 dmax = distances.at(2);
1179 if (element < 0 || element >=
nElements)
return 0.;
1181 Element2Index(
element, i, j, k);
1182 const double volume =
1183 fabs((m_xlines.at(i+1) - m_xlines.at(i)) *
1184 (m_xlines.at(j+1) - m_ylines.at(j)) *
1185 (m_xlines.at(k+1) - m_zlines.at(k)));
1189void ComponentCST::ElectricFieldBinary(
const double xin,
const double yin,
const double zin,
1190 double& ex,
double& ey,
double& ez,
double & volt,
Medium*& m,
1191 int& status,
bool calculatePotential) {
1193 double x = xin, y = yin, z = zin;
1198 double rcoordinate, rotation;
1200 double position_mapped[3] = {0., 0., 0.};
1201 if(!
Coordinate2Index(x, y, z, i, j, k, position_mapped, mirrored, rcoordinate, rotation))
1204 double rx = (position_mapped[0] - m_xlines.at(i))/(m_xlines.at(i+1) - m_xlines.at(i));
1205 double ry = (position_mapped[1] - m_ylines.at(j))/(m_ylines.at(j+1) - m_ylines.at(j));
1206 double rz = (position_mapped[2] - m_zlines.at(k))/(m_zlines.at(k+1) - m_zlines.at(k));
1208 float fex = GetFieldComponent(i, j, k, rx, ry, rz,
'x', &m_potential);
1209 float fey = GetFieldComponent(i, j, k, rx, ry, rz,
'y', &m_potential);
1210 float fez = GetFieldComponent(i, j, k, rx, ry, rz,
'z', &m_potential);
1212 if (m_elementMaterial.size()>0 && doShaping) {
1213 ShapeField(fex, fey, fez, rx, ry, rz, i, j, k, &m_potential);
1222 std::cout <<
m_className <<
"::ElectricFieldBinary:" << std::endl;
1223 std::cout <<
" Found position (" << x <<
", " << y <<
", " << z <<
"): " << std:: endl;
1224 std::cout <<
" Indexes are: x: " << i <<
"/" << m_xlines.size()
1225 <<
"\t y: " << j <<
"/" << m_ylines.size()
1226 <<
"\t z: " << k <<
"/" << m_zlines.size() << std::endl;
1227 if(i != 0 && j != 0 && k != 0){
1228 std::cout <<
" index: " << i <<
"\t x before: " << m_xlines.at(i-1) <<
"\t x behind: " << m_xlines.at(i) <<
"\t r = " << rx
1229 <<
"\n index: " << j <<
"\t y before: " << m_ylines.at(j-1) <<
"\t y behind: " << m_ylines.at(j) <<
"\t r = " << ry
1230 <<
"\n index: " << k <<
"\t z before: " << m_zlines.at(k-1) <<
"\t z behind: " << m_zlines.at(k) <<
"\t r = " << rz << std::endl;
1232 std::cout <<
" Electric field is: " << fex <<
", " << fey <<
", " << fez <<
"): " << std:: endl;
1243 if(!disableFieldComponent[0])
1245 if(!disableFieldComponent[1])
1247 if(!disableFieldComponent[2])
1249 if(calculatePotential)
1250 volt = GetPotential(i,j,k,rx,ry,rz,&m_potential);
1254float ComponentCST::GetFieldComponent(
const unsigned int i,
const unsigned int j,
const unsigned int k,
1255 const double rx,
const double ry ,
const double rz,
const char component,
const std::vector<float>* potentials){
1256 float dv1 = 0, dv2 = 0, dv3 = 0, dv4 = 0;
1257 float dv11 = 0, dv21 = 0, dv = 0;
1261 dv1 = potentials->at(Index2Node(i+1, j, k)) - potentials->at(Index2Node(i, j, k));
1262 dv2 = potentials->at(Index2Node(i+1, j+1, k)) - potentials->at(Index2Node(i, j+1, k));
1263 dv3 = potentials->at(Index2Node(i+1, j+1, k+1)) - potentials->at(Index2Node(i, j+1, k+1));
1264 dv4 = potentials->at(Index2Node(i+1, j, k+1)) - potentials->at(Index2Node(i, j, k+1));
1266 dv11 = dv1 + (dv4-dv1)*rz;
1267 dv21 = dv2 + (dv3-dv2)*rz;
1268 dv = dv11 + (dv21-dv11)*ry;
1269 e = -1*dv/(m_xlines.at(i+1)-m_xlines.at(i));
1273 dv1 = potentials->at(Index2Node(i, j+1, k)) - potentials->at(Index2Node(i, j, k));
1274 dv2 = potentials->at(Index2Node(i, j+1, k+1)) - potentials->at(Index2Node(i, j, k+1));
1275 dv3 = potentials->at(Index2Node(i+1, j+1, k+1)) - potentials->at(Index2Node(i+1, j, k+1));
1276 dv4 = potentials->at(Index2Node(i+1, j+1, k)) - potentials->at(Index2Node(i+1, j, k));
1278 dv11 = dv1 + (dv4-dv1)*rx;
1279 dv21 = dv2 + (dv3-dv2)*rx;
1280 dv = dv11 + (dv21-dv11)*rz;
1281 e = -1*dv/(m_ylines.at(j+1)-m_ylines.at(j));
1285 dv1 = potentials->at(Index2Node(i, j, k+1)) - potentials->at(Index2Node(i, j, k));
1286 dv2 = potentials->at(Index2Node(i+1, j, k+1)) - potentials->at(Index2Node(i+1, j, k));
1287 dv3 = potentials->at(Index2Node(i+1, j+1, k+1)) - potentials->at(Index2Node(i+1, j+1, k));
1288 dv4 = potentials->at(Index2Node(i, j+1, k+1)) - potentials->at(Index2Node(i, j+1, k));
1290 dv11 = dv1 + (dv4-dv1)*ry;
1291 dv21 = dv2 + (dv3-dv2)*ry;
1292 dv = dv11 + (dv21-dv11)*rx;
1293 e = -1*dv/(m_zlines.at(k+1)-m_zlines.at(k));
1298float ComponentCST::GetPotential(
const unsigned int i,
const unsigned int j,
const unsigned int k,
1299 const double rx,
const double ry ,
const double rz,
const std::vector<float>* potentials){
1300 double t1 = rx*2. - 1;
1301 double t2 = ry*2. - 1;
1302 double t3 = rz*2. - 1;
1303 return (potentials->at(Index2Node(i+1, j , k )) * (1 - t1) * (1 - t2) * (1 - t3) +
1304 potentials->at(Index2Node(i+1, j+1, k )) * (1 + t1) * (1 - t2) * (1 - t3) +
1305 potentials->at(Index2Node(i , j+1, k )) * (1 + t1) * (1 + t2) * (1 - t3) +
1306 potentials->at(Index2Node(i , j , k )) * (1 - t1) * (1 + t2) * (1 - t3) +
1307 potentials->at(Index2Node(i+1, j , k+1)) * (1 - t1) * (1 - t2) * (1 + t3) +
1308 potentials->at(Index2Node(i+1, j+1, k+1)) * (1 + t1) * (1 - t2) * (1 + t3) +
1309 potentials->at(Index2Node(i , j+1, k+1)) * (1 + t1) * (1 + t2) * (1 + t3) +
1310 potentials->at(Index2Node(i , j , k+1)) * (1 - t1) * (1 + t2) * (1 + t3)) /
1314void ComponentCST::ShapeField(
float &ex,
float &ey,
float &ez,
1315 const double rx,
const double ry,
const double rz,
1316 const unsigned int i,
const unsigned int j,
const unsigned int k,
1317 std::vector<float>* potentials){
1319 if ((i==0 && rx>=0.5) || (i==m_xlines.size()-2 && rx<0.5) || (i>0 && i<m_xlines.size()-2))
1327 float ex_next = GetFieldComponent(i+1, j, k, 0.5, ry, rz,
'x', potentials);
1328 ex = ex + (rx-0.5) * (ex_next - ex) * (m_xlines.at(i+1) - m_xlines.at(i)) / (m_xlines.at(i+2) - m_xlines.at(i+1));
1336 float ex_before = GetFieldComponent(i-1, j, k, 0.5, ry, rz,
'x', potentials);
1337 ex = ex_before + (rx+0.5) * (ex - ex_before) * (m_xlines.at(i) - m_xlines.at(i-1)) / (m_xlines.at(i+1) - m_xlines.at(i));
1342 if ((j==0 && ry>=0.5) || (j==m_ylines.size()-2 && ry<0.5) || (j>0 && j<m_ylines.size()-2))
1350 float ey_next = GetFieldComponent(i, j+1, k, rx, 0.5, rz,
'y', potentials);
1351 ey = ey + (ry-0.5) * (ey_next - ey) * (m_ylines.at(j+1) - m_ylines.at(j)) / (m_ylines.at(j+2) - m_ylines.at(j+1));
1359 float ey_next = GetFieldComponent(i, j-1, k, rx, 0.5, rz,
'y', potentials);
1360 ey = ey_next + (ry+0.5) * (ey - ey_next) * (m_ylines.at(j) - m_ylines.at(j-1)) / (m_ylines.at(j+1) - m_ylines.at(j));
1365 if ((k==0 && rz>=0.5) || (k==m_zlines.size()-2 && rz<0.5) || (k>0 && k<m_zlines.size()-2))
1373 float ez_next = GetFieldComponent(i, j, k+1, rx, ry, 0.5,
'z', potentials);
1374 ez = ez + (rz-0.5) * (ez_next - ez) * (m_zlines.at(k+1) - m_zlines.at(k)) / (m_zlines.at(k+2) - m_zlines.at(k+1));
1382 float ez_next = GetFieldComponent(i, j, k-1, rx, ry, 0.5,
'z', potentials);
1383 ez = ez_next + (rz+0.5) * (ez - ez_next) * (m_zlines.at(k) - m_zlines.at(k-1)) / (m_zlines.at(k+1) - m_zlines.at(k));
1389void ComponentCST::Element2Index(
int element,
unsigned int& i,
unsigned int& j,
unsigned int& k) {
1391 k = element / ((m_xlines.size() - 1) * (m_ylines.size() - 1));
1392 tmp -= k * (m_xlines.size() - 1) * (m_ylines.size() - 1);
1393 j = tmp / (m_xlines.size() - 1);
1394 i = element - j * (m_xlines.size() - 1) -
1395 k * (m_xlines.size() - 1) * (m_ylines.size() - 1);
1398int ComponentCST::Index2Node(
const unsigned int i,
const unsigned int j,
const unsigned int k){
1400 if (i>m_nx-1 || j>m_ny-1 || k>m_nz-1) {
1401 throw "FieldMap::NodeByIndex: Error. Node indexes out of bounds.";
1403 return i+j*m_nx+k*m_nx*m_ny;
DoubleAc fabs(const DoubleAc &f)
bool Coordinate2Index(const double x, const double y, const double z, unsigned int &i, unsigned int &j, unsigned int &k)
void GetNumberOfMeshLines(unsigned int &n_x, unsigned int &n_y, unsigned int &n_z)
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)
int Index2Element(const unsigned int i, const unsigned int j, const unsigned int k)
void GetAspectRatio(const int i, double &dmin, double &dmax)
double WeightingPotential(const double x, const double y, const double z, const std::string label)
bool Initialise(std::string elist, std::string nlist, std::string mplist, std::string prnsol, std::string unit="cm")
bool SetWeightingField(std::string prnsol, std::string label, bool isBinary=true)
void ShiftComponent(const double xShift, const double yShift, const double zShift)
void GetElementBoundaries(unsigned int element, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax)
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string label)
double GetElementVolume(const int i)
void SetRangeZ(const double zmin, const double zmax)
Medium * GetMedium(const double &x, const double &y, const double &z)
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 UpdatePeriodicityCommon()
int ReadInteger(char *token, int def, bool &error)
void UpdatePeriodicity2d()
std::vector< std::string > wfields