35 const std::string& filename)
37 std::ifstream in(filename.c_str());
40 ERR(
"GMSInterface::readBoreholeFromGMS(): Could not open file {:s}.",
45 double depth(-9999.0);
49 std::list<std::string>::const_iterator it;
53 std::getline(in, line);
56 while (std::getline(in, line))
60 if (fields.size() >= 5)
62 if (*fields.begin() == cName)
65 auto const pnt = parsePointCoordinates(it);
72 if (newBorehole ==
nullptr)
74 newBorehole->
addSoilLayer(pnt[0], pnt[1], pnt[2], sName);
81 "GMSInterface::readBoreholeFromGMS(): Skipped layer "
82 "'{:s}' in borehole '{:s}' because of thickness 0.0.",
88 if (newBorehole !=
nullptr)
90 newBorehole->
setDepth((*newBorehole)[2] - depth);
91 boreholes.push_back(newBorehole);
93 cName = *fields.begin();
95 auto const pnt = parsePointCoordinates(it);
98 cName, pnt[0], pnt[1], pnt[2], 0);
104 ERR(
"GMSInterface::readBoreholeFromGMS(): Error reading format.");
108 if (newBorehole !=
nullptr)
110 newBorehole->
setDepth((*newBorehole)[2] - depth);
111 boreholes.push_back(newBorehole);
115 if (boreholes.empty())
123 const std::vector<GeoLib::Point*>* stations,
const std::string& filename)
125 std::ofstream out(filename.c_str(), std::ios::out);
129 <<
"\t" << std::fixed <<
"X"
138 for (
auto station_as_point : *stations)
140 auto const* station =
142 std::vector<GeoLib::Point*>
const& profile = station->
getProfile();
143 std::vector<std::string>
const& soilNames = station->getSoilNames();
144 std::string current_soil_name;
146 std::size_t nLayers = profile.size();
147 for (std::size_t i = 1; i < nLayers; i++)
149 if ((i > 1) && (soilNames[i] == soilNames[i - 1]))
153 current_soil_name = soilNames[i];
155 out << station->getName() <<
"\t" << std::fixed
156 << (*(profile[i - 1]))[0] <<
"\t" << (*(profile[i - 1]))[1]
157 <<
"\t" << (*(profile[i - 1]))[2] <<
"\t"
158 << current_soil_name <<
"\n";
160 out << station->getName() <<
"\t" << std::fixed
161 << (*(profile[nLayers - 1]))[0] <<
"\t"
162 << (*(profile[nLayers - 1]))[1] <<
"\t"
163 << (*(profile[nLayers - 1]))[2] <<
"\t" << current_soil_name
174 std::ifstream in(filename.c_str());
177 ERR(
"GMSInterface::readMesh(): Could not open file {:s}.", filename);
182 std::getline(in, line);
183 if (line !=
"MESH3D" && line !=
"MESH2D")
185 ERR(
"GMSInterface::readMesh(): Could not read expected file "
189 bool const is_3d = (line ==
"MESH3D");
192 INFO(
"Reading SMS/GMS mesh...");
193 std::vector<MeshLib::Node*> nodes;
194 std::vector<MeshLib::Element*> elements;
195 std::vector<int> mat_ids;
196 std::map<unsigned, unsigned> id_map;
205 while (std::getline(in, line))
209 std::stringstream str(line);
210 str >> dummy >>
id >> x[0] >> x[1] >> x[2];
212 id_map.insert(std::pair<unsigned, unsigned>(
id, count++));
213 nodes.push_back(node);
220 in.open(filename.c_str());
221 std::getline(in, line);
222 unsigned node_idx[6];
224 while (std::getline(in, line))
226 std::string element_id(line.substr(0, 3));
227 std::stringstream str(line);
229 if (element_id ==
"MES")
231 str >> dummy >> mesh_name;
232 mesh_name = mesh_name.substr(1, mesh_name.length() - 2);
234 else if (!is_3d && element_id ==
"E3T")
236 str >> dummy >>
id >> node_idx[0] >> node_idx[1] >> node_idx[2] >>
238 std::array<MeshLib::Node*, 3> tri_nodes;
239 for (
unsigned k(0); k < 3; k++)
241 tri_nodes[k] = nodes[id_map.find(node_idx[k])->second];
244 mat_ids.push_back(mat_id);
246 else if (!is_3d && element_id ==
"E6T")
248 str >> dummy >>
id >> node_idx[0] >> node_idx[3] >> node_idx[1] >>
249 node_idx[4] >> node_idx[2] >> node_idx[5] >> mat_id;
250 std::array<MeshLib::Node*, 3> tri_nodes;
251 for (
unsigned k(0); k < 3; k++)
253 tri_nodes[k] = nodes[id_map.find(node_idx[k])->second];
256 mat_ids.push_back(mat_id);
258 else if (is_3d && element_id ==
"E6W")
260 str >> dummy >>
id >> node_idx[0] >> node_idx[1] >> node_idx[2] >>
261 node_idx[3] >> node_idx[4] >> node_idx[5] >> mat_id;
262 std::array<MeshLib::Node*, 6> prism_nodes;
263 for (
unsigned k(0); k < 6; k++)
265 prism_nodes[k] = nodes[id_map.find(node_idx[k])->second];
268 mat_ids.push_back(mat_id);
270 else if (is_3d && element_id ==
"E4T")
272 str >> dummy >>
id >> node_idx[0] >> node_idx[1] >> node_idx[2] >>
273 node_idx[3] >> mat_id;
274 std::array<MeshLib::Node*, 4> tet_nodes;
275 for (
unsigned k(0); k < 4; k++)
277 tet_nodes[k] = nodes[id_map.find(node_idx[k])->second];
280 mat_ids.push_back(mat_id);
283 else if (is_3d && (element_id ==
"E4P" || element_id ==
"E5P"))
285 str >> dummy >>
id >> node_idx[0] >> node_idx[1] >> node_idx[2] >>
286 node_idx[3] >> node_idx[4] >> mat_id;
287 std::array<MeshLib::Node*, 5> pyramid_nodes;
288 for (
unsigned k(0); k < 5; k++)
290 pyramid_nodes[k] = nodes[id_map.find(node_idx[k])->second];
293 mat_ids.push_back(mat_id);
295 else if (element_id ==
"ND ")
302 "GMSInterface::readMesh() - Element type '{:s}' not "
313 if (mat_ids.size() == elements.size())
319 ERR(
"Could not create PropertyVector for material ids.");
327 ERR(
"Ignoring Material IDs information (does not match number of "
static StationBorehole * createStation(const std::string &name, double x, double y, double z, double depth, const std::string &date="")
Creates a new borehole object based on the given parameters.