OGS
FileIO::PetrelInterface Class Referencefinal

Detailed Description

Definition at line 20 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 15 of file PetrelInterface.cpp.

19 : _unique_name(unique_model_name)
20{
21 for (auto const& surface_fname : sfc_fnames)
22 {
23 INFO("PetrelInterface::PetrelInterface(): open surface file.");
24 std::ifstream in(surface_fname);
25 if (in)
26 {
27 INFO("PetrelInterface::PetrelInterface(): \tdone.");
29 in.close();
30 }
31 else
32 {
33 WARN(
34 "PetrelInterface::PetrelInterface(): \tCould not open file "
35 "{:s}.",
36 surface_fname);
37 }
38 }
39
40 for (auto const& well_path_fname : well_path_fnames)
41 {
42 INFO("PetrelInterface::PetrelInterface(): open well path file.");
43 std::ifstream in(well_path_fname);
44 if (in)
45 {
46 INFO("PetrelInterface::PetrelInterface(): \tdone.");
48 in.close();
49 }
50 else
51 {
52 WARN(
53 "PetrelInterface::PetrelInterface(): \tCould not open well "
54 "path file {:s}.",
55 well_path_fname);
56 }
57 }
58
59 // move data to GEOObject
60 geo_obj->addPointVec(std::move(pnt_vec), _unique_name);
61 if (!well_vec.empty())
62 {
63 geo_obj->addStationVec(std::move(well_vec), _unique_name);
64 }
65}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:34
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.

Referenced by PetrelInterface(), PetrelInterface(), operator=(), and operator=().

◆ PetrelInterface() [2/3]

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

References PetrelInterface().

◆ PetrelInterface() [3/3]

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

References PetrelInterface().

Member Function Documentation

◆ operator=() [1/2]

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

References PetrelInterface().

◆ operator=() [2/2]

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

References PetrelInterface().

◆ readPetrelSurfacePoints()

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

Definition at line 79 of file PetrelInterface.cpp.

80{
81 std::string line = readLine(in);
82
83 if (line.find("# Petrel Points with attributes") != std::string::npos)
84 {
85 // read header
86 // read Version string
87 readLine(in);
88 // read string BEGIN HEADER
89 readLine(in);
90
91 line = readLine(in);
92 while (line.find("END HEADER") == std::string::npos)
93 {
94 line = readLine(in);
95 }
96
97 // read points
98 while (in)
99 {
100 auto point = std::make_unique<GeoLib::Point>();
101 in >> (*point)[0] >> (*point)[1] >> (*point)[2];
102 if (in)
103 {
104 pnt_vec.push_back(point.release());
105 }
106 }
107 }
108 else
109 {
110 WARN(
111 "PetrelInterface::readPetrelSurface(): problem reading petrel "
112 "points from line\n'{:s}'.",
113 line);
114 }
115}
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 132 of file PetrelInterface.cpp.

133{
134 std::string line = readLine(in);
135
136 if (line.find("# WELL TRACE FROM PETREL") == std::string::npos)
137 {
138 return;
139 }
140
141 auto printInfo = [](auto const& list, std::string_view const message)
142 { printListInfo(list, "readPetrelWellTrace", message); };
143
144 {
145 // read header
146 // read well name
147 printInfo(split(readLine(in)), "well name");
148
149 // read well head x coordinate
150 auto str_list = split(readLine(in));
151 printInfo(str_list, "well head x coord");
152 double const well_head_x = getLastNumberFromList(str_list);
153
154 // read well head y coordinate
155 str_list = split(readLine(in));
156 printInfo(str_list, "well head y coord");
157 double const well_head_y = getLastNumberFromList(str_list);
158
159 // read well KB
160 str_list = split(readLine(in));
161 printInfo(str_list, "well kb entry");
162 double const well_kb = getLastNumberFromList(str_list);
163
164 INFO("PetrelInterface::readPetrelWellTrace(): {:f}, {:f}, {:f}.",
165 well_head_x,
166 well_head_y,
167 well_kb);
168 double const depth = 0.0;
169 std::string const borehole_name = "";
170 int const date = 0;
171 well_vec.push_back(new GeoLib::StationBorehole(
172 well_head_x, well_head_y, well_kb, depth, borehole_name, date));
173
174 // read well type
175 readLine(in);
176 // std::string type(*((str_list.end())--));
177
179 }
180}
void readPetrelWellTraceData(std::istream &in)
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 182 of file PetrelInterface.cpp.

183{
184 readLine(in);
185
186 // read yet another header line
187 std::string line = readLine(in);
188 while (line[0] == '#')
189 {
190 line = readLine(in);
191 }
192
193 // read column information
194 printListInfo(split(line), "readPetrelWellTraceData", "column information");
195
196 // read points
197 double md;
198 double x;
199 double y;
200 double z;
201 double tvd;
202 double dx;
203 double dy;
204 double azim;
205 double incl;
206 double dls;
207 line = readLine(in);
208 while (in)
209 {
210 if (line.size() > 1 && line[0] != '#')
211 {
212 std::stringstream stream(line);
213 stream >> md;
214 stream >> x >> y >> z;
215 // pnt_vec->push_back (new GeoLib::Point (x,y,z));
216 static_cast<GeoLib::StationBorehole*>(well_vec.back())
217 ->addSoilLayer(x, y, z, "unknown");
218 stream >> tvd >> dx >> dy >> azim >> incl >> dls;
219 }
220 line = readLine(in);
221 }
222}

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 37 of file PetrelInterface.h.

Referenced by PetrelInterface().

◆ pnt_vec

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

Definition at line 38 of file PetrelInterface.h.

Referenced by PetrelInterface(), and readPetrelSurfacePoints().

◆ well_vec

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

Definition at line 39 of file PetrelInterface.h.

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


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