OGS
FileIO::PetrelInterface Class Referencefinal

Detailed Description

Definition at line 30 of file PetrelInterface.h.

#include <PetrelInterface.h>

Public Member Functions

 PetrelInterface (std::list< std::string > const &sfc_fnames, std::list< std::string > const &well_path_fnames, std::string &unique_model_name, GeoLib::GEOObjects *geo_obj)
 
 PetrelInterface (PetrelInterface const &other)=delete
 
 PetrelInterface (PetrelInterface &&other)=delete
 
PetrelInterfaceoperator= (PetrelInterface const &)=delete
 
PetrelInterfaceoperator= (PetrelInterface &&)=delete
 

Private Member Functions

void readPetrelSurfacePoints (std::istream &in)
 
void readPetrelWellTrace (std::istream &in)
 
void readPetrelWellTraceData (std::istream &in)
 

Private Attributes

std::string _unique_name
 
std::vector< GeoLib::Point * > pnt_vec
 
std::vector< GeoLib::Point * > well_vec
 

Constructor & Destructor Documentation

◆ PetrelInterface() [1/3]

FileIO::PetrelInterface::PetrelInterface ( std::list< std::string > const & sfc_fnames,
std::list< std::string > const & well_path_fnames,
std::string & unique_model_name,
GeoLib::GEOObjects * geo_obj )

Definition at line 25 of file PetrelInterface.cpp.

29 : _unique_name(unique_model_name)
30{
31 for (auto const& surface_fname : sfc_fnames)
32 {
33 INFO("PetrelInterface::PetrelInterface(): open surface file.");
34 std::ifstream in(surface_fname);
35 if (in)
36 {
37 INFO("PetrelInterface::PetrelInterface(): \tdone.");
39 in.close();
40 }
41 else
42 {
43 WARN(
44 "PetrelInterface::PetrelInterface(): \tCould not open file "
45 "{:s}.",
46 surface_fname);
47 }
48 }
49
50 for (auto const& well_path_fname : well_path_fnames)
51 {
52 INFO("PetrelInterface::PetrelInterface(): open well path file.");
53 std::ifstream in(well_path_fname);
54 if (in)
55 {
56 INFO("PetrelInterface::PetrelInterface(): \tdone.");
58 in.close();
59 }
60 else
61 {
62 WARN(
63 "PetrelInterface::PetrelInterface(): \tCould not open well "
64 "path file {:s}.",
65 well_path_fname);
66 }
67 }
68
69 // move data to GEOObject
70 geo_obj->addPointVec(std::move(pnt_vec), _unique_name);
71 if (!well_vec.empty())
72 {
73 geo_obj->addStationVec(std::move(well_vec), _unique_name);
74 }
75}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
std::vector< GeoLib::Point * > pnt_vec
void readPetrelSurfacePoints(std::istream &in)
void readPetrelWellTrace(std::istream &in)
std::vector< GeoLib::Point * > well_vec
void addPointVec(std::vector< Point * > &&points, std::string &name, PointVec::NameIdMap &&pnt_id_name_map, double const eps=std::sqrt(std::numeric_limits< double >::epsilon()))
void addStationVec(std::vector< Point * > &&stations, std::string &name)
Adds a vector of stations with the given name and colour to GEOObjects.

References _unique_name, GeoLib::GEOObjects::addPointVec(), INFO(), pnt_vec, readPetrelSurfacePoints(), readPetrelWellTrace(), WARN(), and well_vec.

◆ PetrelInterface() [2/3]

FileIO::PetrelInterface::PetrelInterface ( PetrelInterface const & other)
delete

◆ PetrelInterface() [3/3]

FileIO::PetrelInterface::PetrelInterface ( PetrelInterface && other)
delete

Member Function Documentation

◆ operator=() [1/2]

PetrelInterface & FileIO::PetrelInterface::operator= ( PetrelInterface && )
delete

◆ operator=() [2/2]

PetrelInterface & FileIO::PetrelInterface::operator= ( PetrelInterface const & )
delete

◆ readPetrelSurfacePoints()

void FileIO::PetrelInterface::readPetrelSurfacePoints ( std::istream & in)
private

Definition at line 89 of file PetrelInterface.cpp.

90{
91 std::string line = readLine(in);
92
93 if (line.find("# Petrel Points with attributes") != std::string::npos)
94 {
95 // read header
96 // read Version string
97 readLine(in);
98 // read string BEGIN HEADER
99 readLine(in);
100
101 line = readLine(in);
102 while (line.find("END HEADER") == std::string::npos)
103 {
104 line = readLine(in);
105 }
106
107 // read points
108 while (in)
109 {
110 auto point = std::make_unique<GeoLib::Point>();
111 in >> (*point)[0] >> (*point)[1] >> (*point)[2];
112 if (in)
113 {
114 pnt_vec.push_back(point.release());
115 }
116 }
117 }
118 else
119 {
120 WARN(
121 "PetrelInterface::readPetrelSurface(): problem reading petrel "
122 "points from line\n'{:s}'.",
123 line);
124 }
125}
static std::string readLine(std::istream &in)

References pnt_vec, FileIO::readLine(), and WARN().

Referenced by PetrelInterface().

◆ readPetrelWellTrace()

void FileIO::PetrelInterface::readPetrelWellTrace ( std::istream & in)
private

Definition at line 142 of file PetrelInterface.cpp.

143{
144 std::string line = readLine(in);
145
146 if (line.find("# WELL TRACE FROM PETREL") == std::string::npos)
147 {
148 return;
149 }
150
151 auto printInfo = [](auto const& list, std::string_view const message)
152 { printListInfo(list, "readPetrelWellTrace", message); };
153
154 {
155 // read header
156 // read well name
157 printInfo(split(readLine(in)), "well name");
158
159 // read well head x coordinate
160 auto str_list = split(readLine(in));
161 printInfo(str_list, "well head x coord");
162 double const well_head_x = getLastNumberFromList(str_list);
163
164 // read well head y coordinate
165 str_list = split(readLine(in));
166 printInfo(str_list, "well head y coord");
167 double const well_head_y = getLastNumberFromList(str_list);
168
169 // read well KB
170 str_list = split(readLine(in));
171 printInfo(str_list, "well kb entry");
172 double const well_kb = getLastNumberFromList(str_list);
173
174 INFO("PetrelInterface::readPetrelWellTrace(): {:f}, {:f}, {:f}.",
175 well_head_x,
176 well_head_y,
177 well_kb);
178 double const depth = 0.0;
179 std::string const borehole_name = "";
180 int const date = 0;
181 well_vec.push_back(new GeoLib::StationBorehole(
182 well_head_x, well_head_y, well_kb, depth, borehole_name, date));
183
184 // read well type
185 readLine(in);
186 // std::string type(*((str_list.end())--));
187
189 }
190}
void readPetrelWellTraceData(std::istream &in)
A borehole as a geometric object.
static void printListInfo(const std::list< std::string > &str_list, std::string_view const prefix, std::string_view const message)
static double getLastNumberFromList(const std::list< std::string > &str_list)
static std::list< std::string > split(std::string const &line)

References FileIO::getLastNumberFromList(), INFO(), FileIO::printListInfo(), FileIO::readLine(), readPetrelWellTraceData(), FileIO::split(), and well_vec.

Referenced by PetrelInterface().

◆ readPetrelWellTraceData()

void FileIO::PetrelInterface::readPetrelWellTraceData ( std::istream & in)
private

Definition at line 192 of file PetrelInterface.cpp.

193{
194 readLine(in);
195
196 // read yet another header line
197 std::string line = readLine(in);
198 while (line[0] == '#')
199 {
200 line = readLine(in);
201 }
202
203 // read column information
204 printListInfo(split(line), "readPetrelWellTraceData", "column information");
205
206 // read points
207 double md;
208 double x;
209 double y;
210 double z;
211 double tvd;
212 double dx;
213 double dy;
214 double azim;
215 double incl;
216 double dls;
217 line = readLine(in);
218 while (in)
219 {
220 if (line.size() > 1 && line[0] != '#')
221 {
222 std::stringstream stream(line);
223 stream >> md;
224 stream >> x >> y >> z;
225 // pnt_vec->push_back (new GeoLib::Point (x,y,z));
226 static_cast<GeoLib::StationBorehole*>(well_vec.back())
227 ->addSoilLayer(x, y, z, "unknown");
228 stream >> tvd >> dx >> dy >> azim >> incl >> dls;
229 }
230 line = readLine(in);
231 }
232}
void addSoilLayer(double thickness, const std::string &soil_name)
Add a soil layer to the boreholes stratigraphy.

References GeoLib::StationBorehole::addSoilLayer(), FileIO::printListInfo(), FileIO::readLine(), FileIO::split(), and well_vec.

Referenced by readPetrelWellTrace().

Member Data Documentation

◆ _unique_name

std::string FileIO::PetrelInterface::_unique_name
private

Definition at line 47 of file PetrelInterface.h.

Referenced by PetrelInterface().

◆ pnt_vec

std::vector<GeoLib::Point*> FileIO::PetrelInterface::pnt_vec
private

Definition at line 48 of file PetrelInterface.h.

Referenced by PetrelInterface(), and readPetrelSurfacePoints().

◆ well_vec

std::vector<GeoLib::Point*> FileIO::PetrelInterface::well_vec
private

Definition at line 49 of file PetrelInterface.h.

Referenced by PetrelInterface(), readPetrelWellTrace(), and readPetrelWellTraceData().


The documentation for this class was generated from the following files: