opm-common
Loading...
Searching...
No Matches
WellFractureSeeds.hpp
1/*
2 Copyright 2025 Equinor ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef OPM_WELL_FRACTURE_SEED_HPP_INCLUDED
20#define OPM_WELL_FRACTURE_SEED_HPP_INCLUDED
21
22#include <array>
23#include <cstddef>
24#include <string>
25#include <utility>
26#include <vector>
27
28namespace Opm {
29
32{
33public:
36 struct SeedIndex
37 {
39 std::size_t i{};
40 };
41
44 struct SeedCell
45 {
47 std::size_t c{};
48 };
49
51 using NormalVector = std::array<double, 3>;
52
56 {
57 private:
59 enum class Quant : std::size_t {
61 Vertical,
62
64 Horizontal,
65
67 Width,
68
72 Num,
73 };
74
76 using SizeVector = std::array<double, static_cast<std::underlying_type_t<Quant>>(Quant::Num)>;
77
79 SizeVector v_{};
80
86 static constexpr auto ix(const Quant i)
87 {
88 return static_cast<std::underlying_type_t<Quant>>(i);
89 }
90
91 public:
93 SeedSize() = default;
94
104 explicit SeedSize(const double ev, const double eh, const double wd)
105 : v_{ {ev, eh, wd} }
106 {}
107
109 SeedSize(const SeedSize& rhs) = default;
110
112 SeedSize(SeedSize&& rhs) = default;
113
115 SeedSize& operator=(const SeedSize& rhs) = default;
116
118 SeedSize& operator=(SeedSize&& rhs) = default;
119
127 bool operator==(const SeedSize& that) const
128 {
129 return this->v_ == that.v_;
130 }
131
139 bool operator!=(const SeedSize& that) const
140 {
141 return ! (*this == that);
142 }
143
151 SeedSize& horizontalExtent(const double eh)
152 {
153 this->v_[ix(Quant::Horizontal)] = eh;
154 return *this;
155 }
156
164 SeedSize& verticalExtent(const double ev)
165 {
166 this->v_[ix(Quant::Vertical)] = ev;
167 return *this;
168 }
169
177 SeedSize& width(const double wd)
178 {
179 this->v_[ix(Quant::Width)] = wd;
180 return *this;
181 }
182
184 auto horizontalExtent() const
185 {
186 return this->v_[ix(Quant::Horizontal)];
187 }
188
190 auto verticalExtent() const
191 {
192 return this->v_[ix(Quant::Vertical)];
193 }
194
196 auto width() const
197 {
198 return this->v_[ix(Quant::Width)];
199 }
200
203
209 template <class Serializer>
210 void serializeOp(Serializer& serializer)
211 {
212 serializer(this->v_);
213 }
214 };
215
220 WellFractureSeeds() = default;
221
226 explicit WellFractureSeeds(const std::string& wellName)
227 : wellName_ { wellName }
228 {}
229
234 const std::string& name() const
235 {
236 return this->wellName_;
237 }
238
252 bool updateSeed(const std::size_t seedCellGlobal,
253 const NormalVector& seedNormal,
254 const SeedSize& seedSize);
255
265 void finalizeSeeds();
266
270 bool empty() const { return this->seedCell_.empty(); }
271
273 auto numSeeds() const { return this->seedCell_.size(); }
274
281 const NormalVector* getNormal(const SeedCell& c) const;
282
289 const SeedSize* getSize(const SeedCell& c) const;
290
302 const NormalVector& getNormal(const SeedIndex& i) const
303 {
304 return this->seedNormal_[i.i];
305 }
306
320 const SeedSize& getSize(const SeedIndex& i) const
321 {
322 return this->seedSize_[i.i];
323 }
324
330 const std::vector<std::size_t>& seedCells() const
331 {
332 return this->seedCell_;
333 }
334
341 bool operator==(const WellFractureSeeds& that) const;
342
344 static WellFractureSeeds serializationTestObject();
345
351 template <class Serializer>
352 void serializeOp(Serializer& serializer)
353 {
354 serializer(this->wellName_);
355 serializer(this->seedCell_);
356 serializer(this->seedNormal_);
357 serializer(this->seedSize_);
358 serializer(this->lookup_);
359 }
360
361private:
362 using NormalVectorIx = std::vector<NormalVector>::size_type;
363
368 std::string wellName_{};
369
372 std::vector<std::size_t> seedCell_{};
373
375 std::vector<NormalVector> seedNormal_{};
376
378 std::vector<SeedSize> seedSize_{};
379
383 std::vector<NormalVectorIx> lookup_{};
384
389 void establishLookup();
390
400 NormalVectorIx seedIndex(const std::size_t seedCellGlobal) const;
401
409 NormalVectorIx seedIndexBinarySearch(const std::size_t seedCellGlobal) const;
410
418 NormalVectorIx seedIndexLinearSearch(const std::size_t seedCellGlobal) const;
419
432 bool insertNewSeed(const std::size_t seedCellGlobal,
433 const NormalVector& seedNormal,
434 const SeedSize& seedSize);
435
446 bool updateExistingSeed(const NormalVectorIx ix,
447 const NormalVector& seedNormal,
448 const SeedSize& seedSize);
449};
450
451} // namespace Opm
452
453#endif // OPM_WELL_FRACTURE_SEED_HPP_INCLUDED
Class for (de-)serializing.
Definition Serializer.hpp:94
Vertical extent, horizontal extent, and width of initial fracture at a seed point.
Definition WellFractureSeeds.hpp:56
bool operator==(const SeedSize &that) const
Equality predicate.
Definition WellFractureSeeds.hpp:127
SeedSize & operator=(SeedSize &&rhs)=default
Move assignment operator.
SeedSize()=default
Default constructor.
SeedSize & horizontalExtent(const double eh)
Assign horizontal extent.
Definition WellFractureSeeds.hpp:151
SeedSize(const SeedSize &rhs)=default
Copy constructor.
SeedSize & verticalExtent(const double ev)
Assign vertical extent.
Definition WellFractureSeeds.hpp:164
SeedSize & width(const double wd)
Assign initial fracture width.
Definition WellFractureSeeds.hpp:177
SeedSize(const double ev, const double eh, const double wd)
Constructor.
Definition WellFractureSeeds.hpp:104
auto horizontalExtent() const
Seed's horizontal extent.
Definition WellFractureSeeds.hpp:184
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition WellFractureSeeds.hpp:210
auto verticalExtent() const
Seed's vertical extent.
Definition WellFractureSeeds.hpp:190
SeedSize & operator=(const SeedSize &rhs)=default
Assignment operator.
auto width() const
Seed's initial fracture width.
Definition WellFractureSeeds.hpp:196
bool operator!=(const SeedSize &that) const
Inequality predicate.
Definition WellFractureSeeds.hpp:139
SeedSize(SeedSize &&rhs)=default
Move constructor.
Fracture seed points attached to a single well.
Definition WellFractureSeeds.hpp:32
bool empty() const
Predicate for empty fracture seed collection.
Definition WellFractureSeeds.hpp:270
const std::string & name() const
Named well to which this seed collection is associated.
Definition WellFractureSeeds.hpp:234
const std::vector< std::size_t > & seedCells() const
Retrieve this collection's fracture seed cells.
Definition WellFractureSeeds.hpp:330
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition WellFractureSeeds.hpp:352
const NormalVector & getNormal(const SeedIndex &i) const
Retrieve fracturing plane normal vector based on insertion order/record index.
Definition WellFractureSeeds.hpp:302
WellFractureSeeds(const std::string &wellName)
Constructor.
Definition WellFractureSeeds.hpp:226
WellFractureSeeds()=default
Default constructor.
auto numSeeds() const
Number of fracture seeds in the current collection.
Definition WellFractureSeeds.hpp:273
std::array< double, 3 > NormalVector
Type alias for the normal vector at a single seed point.
Definition WellFractureSeeds.hpp:51
static WellFractureSeeds serializationTestObject()
Create a serialisation test object.
Definition WellFractureSeeds.cpp:92
const SeedSize & getSize(const SeedIndex &i) const
Retrieve initial fracture size vector based on insertion order/record index.
Definition WellFractureSeeds.hpp:320
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Disambiguating type for requesting fracture plane normal vectors based on Cartesian cell indices.
Definition WellFractureSeeds.hpp:45
std::size_t c
Cartesian cell index.
Definition WellFractureSeeds.hpp:47
Disambiguating type for requesting fracture plane normal vectors based on insertion indices.
Definition WellFractureSeeds.hpp:37
std::size_t i
Insertion/record index.
Definition WellFractureSeeds.hpp:39