@@ -176,6 +176,7 @@ void SAR_Calculation::AddEFieldAndCondictivity(float freq, ArrayLib::ArrayNIJK<s
176176 float * loc_cpd_data = loc_cpd->data ();
177177 float * cell_vol = m_cell_volume->data ();
178178 float * cell_dens = m_cell_density->data ();
179+ float cond=0 ;
179180 double max_lp=0 ;
180181 unsigned int loc=0 ;
181182 unsigned int pos[3 ];
@@ -193,9 +194,10 @@ void SAR_Calculation::AddEFieldAndCondictivity(float freq, ArrayLib::ArrayNIJK<s
193194 {
194195 for (pos[2 ]=0 ; pos[2 ]<m_numLines[2 ]; ++pos[2 ])
195196 {
196- l_pow = (*cell_conductivity)(pos[0 ], pos[1 ], pos[2 ])*abs ((*e_field)(0 , pos[0 ], pos[1 ], pos[2 ])) * abs ((*e_field)(0 , pos[0 ], pos[1 ], pos[2 ]));
197- l_pow += (*cell_conductivity)(pos[0 ], pos[1 ], pos[2 ])*abs ((*e_field)(1 , pos[0 ], pos[1 ], pos[2 ])) * abs ((*e_field)(1 , pos[0 ], pos[1 ], pos[2 ]));
198- l_pow += (*cell_conductivity)(pos[0 ], pos[1 ], pos[2 ])*abs ((*e_field)(2 , pos[0 ], pos[1 ], pos[2 ])) * abs ((*e_field)(2 , pos[0 ], pos[1 ], pos[2 ]));
197+ cond = (*cell_conductivity)(pos[0 ], pos[1 ], pos[2 ]);
198+ l_pow = cond*abs ((*e_field)(0 , pos[0 ], pos[1 ], pos[2 ])) * abs ((*e_field)(0 , pos[0 ], pos[1 ], pos[2 ]));
199+ l_pow += cond*abs ((*e_field)(1 , pos[0 ], pos[1 ], pos[2 ])) * abs ((*e_field)(1 , pos[0 ], pos[1 ], pos[2 ]));
200+ l_pow += cond*abs ((*e_field)(2 , pos[0 ], pos[1 ], pos[2 ])) * abs ((*e_field)(2 , pos[0 ], pos[1 ], pos[2 ]));
199201 l_pow *= 0.5 *(cell_dens[loc]>0 );
200202 max_lp = max (max_lp, l_pow);
201203 power += l_pow*cell_vol[loc];
@@ -287,6 +289,12 @@ bool SAR_Calculation::CheckValid()
287289 if (m_avg_mass<0 )
288290 return false ;
289291
292+ // check that read in data was not swapped
293+ if (m_cell_density->wasSwapped ())
294+ return false ;
295+ if (m_cell_volume->wasSwapped ())
296+ return false ;
297+
290298 // vaildate sizes
291299 for (int n=0 ;n<3 ;++n)
292300 {
@@ -429,6 +437,8 @@ bool SAR_Calculation::WriteToHDF5(std::string out_name, bool legacyHDF5)
429437 out_file.WriteAtrribute (" /" ," openEMS_HDF5_version" , OPENEMS_HDF5_VERSION);
430438 out_file.SetCurrentGroup (" /FieldData/FD" );
431439 out_file.WriteAtrribute (" /FieldData/FD" ," frequency" ,m_freq);
440+ if (legacyHDF5)
441+ out_file.WriteAtrribute (" /" , " legacy_fmt" , true );
432442
433443 return WriteToHDF5 (out_file, legacyHDF5);
434444}
@@ -462,25 +472,25 @@ bool SAR_Calculation::WriteToHDF5(HDF5_File_Writer &out_file, bool legacyHDF5)
462472 stringstream ss;
463473 ss << " f" << n;
464474 if (out_file.WriteScalarField <float >(ss.str (), *m_SAR.at (n), legacyHDF5)==false )
465- cerr << " SAR_Calculation::CalcFromHDF5 : can't dump to file...! " << endl;
475+ cerr << " SAR_Calculation::WriteToHDF5 : can't dump to file...! " << endl;
466476 if (m_cube_type.data ()!=NULL )
467477 if (out_file.WriteData (ss.str () + " _CubeType" , H5T_NATIVE_UCHAR, m_cube_type.data (), 3 , dims)==false )
468- cerr << " SAR_Calculation::CalcFromHDF5 : can't dump to file...! " << endl;
478+ cerr << " SAR_Calculation::WriteToHDF5 : can't dump to file...! " << endl;
469479 if (m_cube_mass.data ()!=NULL )
470480 if (out_file.WriteData (ss.str () + " _CubeMass" , H5T_NATIVE_FLOAT, m_cube_mass.data (), 3 , dims)==false )
471- cerr << " SAR_Calculation::CalcFromHDF5 : can't dump to file...! " << endl;
481+ cerr << " SAR_Calculation::WriteToHDF5 : can't dump to file...! " << endl;
472482 if (m_cube_volume.data ()!=NULL )
473483 if (out_file.WriteData (ss.str () + " _CubeVol" , H5T_NATIVE_FLOAT, m_cube_volume.data (), 3 , dims)==false )
474- cerr << " SAR_Calculation::CalcFromHDF5 : can't dump to file...! " << endl;
484+ cerr << " SAR_Calculation::WriteToHDF5 : can't dump to file...! " << endl;
475485 if (out_file.WriteAtrribute (" /FieldData/FD/" +ss.str ()," frequency" ,m_freq.at (n))==false )
476- cerr << " ProcessFieldsSAR::DumpFDData : can't dump to file...! " << endl;
486+ cerr << " SAR_Calculation::WriteToHDF5 : can't dump to file...! " << endl;
477487 if (out_file.WriteAtrribute (" /FieldData/FD/" +ss.str ()," power" ,pwr)==false )
478- cerr << " ProcessFieldsSAR::DumpFDData : can't dump to file...! " << endl;
488+ cerr << " SAR_Calculation::WriteToHDF5 : can't dump to file...! " << endl;
479489 if (out_file.WriteAtrribute (" /FieldData/FD/" +ss.str ()," maxSAR" , m_maxSAR.at (n))==false )
480- cerr << " ProcessFieldsSAR::DumpFDData : can't dump to file...! " << endl;
490+ cerr << " SAR_Calculation::WriteToHDF5 : can't dump to file...! " << endl;
481491 std::vector<unsigned int > idx = {m_maxSAR_Idx.at (n)[0 ],m_maxSAR_Idx.at (n)[1 ],m_maxSAR_Idx.at (n)[2 ]};
482492 if (out_file.WriteAtrribute (" /FieldData/FD/" +ss.str ()," maxSAR_idx" , idx)==false )
483- cerr << " ProcessFieldsSAR::DumpFDData : can't dump to file...! " << endl;
493+ cerr << " SAR_Calculation::WriteToHDF5 : can't dump to file...! " << endl;
484494 }
485495
486496 out_file.WriteAtrribute (" /FieldData/FD" ," valid_cubes" ,m_Used);
@@ -1313,7 +1323,7 @@ bool SAR_Calculation::CalcAveragedSAR(unsigned int numThreads)
13131323 if (m_Valid+m_Used+m_Unused+m_AirVoxel!=Vx_Valid.size ())
13141324 {
13151325 cerr << " SAR_Calculation::CalcAveragedSAR: critical error, mismatch in voxel status count... EXIT" << endl;
1316- // exit(1);
1326+ exit (1 );
13171327 }
13181328
13191329 if (m_DebugLevel>0 )
0 commit comments