| 46 | |
| 47 | |
| 48 | int main(int argc, char** argv) |
| 49 | { |
| 50 | utils::Args args; |
| 51 | args.addOption("input", 'i', "Input file (.srf)"); |
| 52 | args.addOption("mcs", 'm', "Proj.4 string that describes the mesh coordinate system (e.g. \"+proj=utm +zone=10 +datum=WGS84 +units=m +no_defs\").", utils::Args::Required, false); |
| 53 | args.addOption("output", 'o', "Output file (.nrf)", utils::Args::Required, false); |
| 54 | args.addOption("normalize-onset", 'n', "Subtract the minimum onset time from all onsets.", utils::Args::No, false); |
| 55 | args.addOption("vcs", 'v', "Proj.4 string that describes the coordinate system for visualisation (defaults to geocentric if mcs not given, i.e. \"+proj=geocent +datum=WGS84 +units=m +no_def\").", utils::Args::Required, false); |
| 56 | args.addOption("xdmf", 'x', "Output for visualisation (.xmf)", utils::Args::Required, false); |
| 57 | |
| 58 | args.setCustomHelpMessage("\nWith rconv you may either convert a SRF file to a NRF file, which you can use as input in SeisSol.\n" |
| 59 | "In this case, give the options -i, -m, -o, and optionally -n.\n\n" |
| 60 | "You may also write a file which may be loaded in Paraview for visualisation of the SRF file.\n" |
| 61 | "In this case, give the options -i, -x, and optionally -v.\n\n" |
| 62 | "You may write both files simultaneously by giving all options.\n"); |
| 63 | |
| 64 | if (args.parse(argc, argv) == utils::Args::Success) { |
| 65 | std::string in = args.getArgument<std::string>("input"); |
| 66 | std::string mcs = args.getArgument<std::string>("mcs", ""); |
| 67 | std::string out = args.getArgument<std::string>("output", ""); |
| 68 | bool normalizeOnset = args.isSet("normalize-onset"); |
| 69 | std::string vcs = args.getArgument<std::string>("vcs", ""); |
| 70 | std::string xdmf = args.getArgument<std::string>("xdmf", ""); |
| 71 | |
| 72 | if (mcs.empty() && vcs.empty()) { |
| 73 | vcs = "+proj=geocent +datum=WGS84 +units=m +no_defs"; |
| 74 | } else if (vcs.empty()) { |
| 75 | vcs = mcs; |
| 76 | } |
| 77 | |
| 78 | std::cout << "Reading SRF..." << std::flush; |
| 79 | std::vector<SRFPointSource> srf = parseSRF(in.c_str()); |
| 80 | std::cout << "finished." << std::endl; |
| 81 | |
| 82 | if (mcs.empty() != out.empty()) { |
| 83 | std::cerr << "Error: -o and -m may only be given simultaneously." << std::endl; |
| 84 | return -1; |
| 85 | } else if (!mcs.empty()) { |
| 86 | Map map(mcs); |
| 87 | std::cout << "Writing NRF..." << std::flush; |
| 88 | writeNRF(out.c_str(), srf, map, normalizeOnset); |
| 89 | std::cout << "finished." << std::endl; |
| 90 | } |
| 91 | |
| 92 | if (!xdmf.empty()) { |
| 93 | Map mapGeocent(vcs); |
| 94 | std::cout << "Writing XDMF..." << std::flush; |
| 95 | writeXMF(xdmf.c_str(), srf, mapGeocent); |
| 96 | std::cout << "finished." << std::endl; |
| 97 | } |
| 98 | } else { |
| 99 | return -1; |
| 100 | } |
| 101 | |
| 102 | return 0; |
| 103 | } |