/ / /
| 222 | /***************************************************************/ |
| 223 | /***************************************************************/ |
| 224 | int main(int argc, char *argv[]) { |
| 225 | initialize mpi(argc, argv); |
| 226 | |
| 227 | double resolution = 10.0; |
| 228 | bool verbose = false; |
| 229 | for (int narg = 1; narg < argc; narg++) { |
| 230 | if (!strcasecmp(argv[narg], "--resolution")) { |
| 231 | if (narg + 1 >= argc) meep::abort("--resolution requires an argument"); |
| 232 | sscanf(argv[narg + 1], "%le", &resolution); |
| 233 | master_printf("Setting resolution=%e.\n", resolution); |
| 234 | narg++; |
| 235 | } |
| 236 | else if (!strcasecmp(argv[narg], "--verbose")) |
| 237 | verbose = true; |
| 238 | else |
| 239 | meep::abort("unknown argument %s", argv[narg]); |
| 240 | } |
| 241 | |
| 242 | std::complex<meep::realnum> *field_array = 0; |
| 243 | int array_rank; |
| 244 | size_t array_dims[3]; |
| 245 | Run(true, resolution, &field_array, &array_rank, array_dims); |
| 246 | Run(false, resolution); |
| 247 | |
| 248 | /* compare DFT field array to DFT HDF5 output */ |
| 249 | double L2ErrorArray = |
| 250 | compare_array_to_dataset(field_array, array_rank, array_dims, "dft-fields.h5", "ez_0"); |
| 251 | if (verbose) master_printf("L2Error (array<-->file) = %e\n", L2ErrorArray); |
| 252 | |
| 253 | /* compare DFT fields to CW fields *****************************/ |
| 254 | double max_dft; |
| 255 | double L2ErrorFile = |
| 256 | compare_complex_hdf5_datasets("dft-fields.h5", "ez_0", "cw-fields.h5", "ez", 2, &max_dft); |
| 257 | if (verbose) master_printf("L2Error (file<-->file) = %e\n", L2ErrorFile); |
| 258 | |
| 259 | bool unit_test = (argc == 1); // run unit-test checks if no command-line arguments |
| 260 | if (unit_test) { |
| 261 | if (L2ErrorFile == -1.0) // files couldn't be read or datasets had different sizes |
| 262 | { |
| 263 | master_printf("failed to compare data files"); |
| 264 | return -1; |
| 265 | } |
| 266 | |
| 267 | #define REF_MAX_DFT 6.740116e+00 |
| 268 | if ((max_dft - REF_MAX_DFT) > 1.0e-5 * REF_MAX_DFT) { |
| 269 | master_printf("max dft amplitude=%e, should be %e\n", max_dft, REF_MAX_DFT); |
| 270 | return -1; |
| 271 | } |
| 272 | |
| 273 | if (L2ErrorFile > 1.0) { |
| 274 | master_printf("L2 norm of file-file error=%e (should be <1)\n", L2ErrorFile); |
| 275 | return -1; |
| 276 | } |
| 277 | |
| 278 | if (L2ErrorArray == -1.0) { |
| 279 | master_printf("failed to compare array to data file"); |
| 280 | return -1; |
| 281 | } |
nothing calls this directly
no test coverage detected