Loading...
Searching...
No Matches
WellFractureSeeds.hpp
/*
Copyright 2025 Equinor ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_WELL_FRACTURE_SEED_HPP_INCLUDED
#define OPM_WELL_FRACTURE_SEED_HPP_INCLUDED
#include <array>
#include <cstddef>
#include <string>
#include <utility>
#include <vector>
namespace Opm {
class WellFractureSeeds
{
public:
struct SeedIndex
{
std::size_t i{};
};
struct SeedCell
{
std::size_t c{};
};
using NormalVector = std::array<double, 3>;
class SeedSize
{
private:
enum class Quant : std::size_t {
Vertical,
Horizontal,
Width,
Num,
};
using SizeVector = std::array<double, static_cast<std::underlying_type_t<Quant>>(Quant::Num)>;
SizeVector v_{};
static constexpr auto ix(const Quant i)
{
return static_cast<std::underlying_type_t<Quant>>(i);
}
public:
SeedSize() = default;
explicit SeedSize(const double ev, const double eh, const double wd)
: v_{ {ev, eh, wd} }
{}
SeedSize(const SeedSize& rhs) = default;
SeedSize(SeedSize&& rhs) = default;
SeedSize& operator=(const SeedSize& rhs) = default;
SeedSize& operator=(SeedSize&& rhs) = default;
bool operator==(const SeedSize& that) const
{
return this->v_ == that.v_;
}
bool operator!=(const SeedSize& that) const
{
return ! (*this == that);
}
SeedSize& horizontalExtent(const double eh)
{
this->v_[ix(Quant::Horizontal)] = eh;
return *this;
}
SeedSize& verticalExtent(const double ev)
{
this->v_[ix(Quant::Vertical)] = ev;
return *this;
}
SeedSize& width(const double wd)
{
this->v_[ix(Quant::Width)] = wd;
return *this;
}
auto horizontalExtent() const
{
return this->v_[ix(Quant::Horizontal)];
}
auto verticalExtent() const
{
return this->v_[ix(Quant::Vertical)];
}
auto width() const
{
return this->v_[ix(Quant::Width)];
}
static SeedSize serializationTestObject();
template <class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(this->v_);
}
};
WellFractureSeeds() = default;
explicit WellFractureSeeds(const std::string& wellName)
: wellName_ { wellName }
{}
const std::string& name() const
{
return this->wellName_;
}
bool updateSeed(const std::size_t seedCellGlobal,
const NormalVector& seedNormal,
const SeedSize& seedSize);
void finalizeSeeds();
bool empty() const { return this->seedCell_.empty(); }
auto numSeeds() const { return this->seedCell_.size(); }
const NormalVector* getNormal(const SeedCell& c) const;
const SeedSize* getSize(const SeedCell& c) const;
const NormalVector& getNormal(const SeedIndex& i) const
{
return this->seedNormal_[i.i];
}
const SeedSize& getSize(const SeedIndex& i) const
{
return this->seedSize_[i.i];
}
const std::vector<std::size_t>& seedCells() const
{
return this->seedCell_;
}
bool operator==(const WellFractureSeeds& that) const;
static WellFractureSeeds serializationTestObject();
template <class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(this->wellName_);
serializer(this->seedCell_);
serializer(this->seedNormal_);
serializer(this->seedSize_);
serializer(this->lookup_);
}
private:
using NormalVectorIx = std::vector<NormalVector>::size_type;
std::string wellName_{};
std::vector<std::size_t> seedCell_{};
std::vector<NormalVector> seedNormal_{};
std::vector<SeedSize> seedSize_{};
std::vector<NormalVectorIx> lookup_{};
void establishLookup();
NormalVectorIx seedIndex(const std::size_t seedCellGlobal) const;
NormalVectorIx seedIndexBinarySearch(const std::size_t seedCellGlobal) const;
NormalVectorIx seedIndexLinearSearch(const std::size_t seedCellGlobal) const;
bool insertNewSeed(const std::size_t seedCellGlobal,
const NormalVector& seedNormal,
const SeedSize& seedSize);
bool updateExistingSeed(const NormalVectorIx ix,
const NormalVector& seedNormal,
const SeedSize& seedSize);
};
} // namespace Opm
#endif // OPM_WELL_FRACTURE_SEED_HPP_INCLUDED
Opm::Serializer
Class for (de-)serializing.
Definition Serializer.hpp:94
Opm::WellFractureSeeds::SeedSize
Vertical extent, horizontal extent, and width of initial fracture at a seed point.
Definition WellFractureSeeds.hpp:56
Opm::WellFractureSeeds::SeedSize::operator==
bool operator==(const SeedSize &that) const
Equality predicate.
Definition WellFractureSeeds.hpp:127
Opm::WellFractureSeeds::SeedSize::operator=
SeedSize & operator=(SeedSize &&rhs)=default
Move assignment operator.
Opm::WellFractureSeeds::SeedSize::SeedSize
SeedSize()=default
Default constructor.
Opm::WellFractureSeeds::SeedSize::horizontalExtent
SeedSize & horizontalExtent(const double eh)
Assign horizontal extent.
Definition WellFractureSeeds.hpp:151
Opm::WellFractureSeeds::SeedSize::SeedSize
SeedSize(const SeedSize &rhs)=default
Copy constructor.
Opm::WellFractureSeeds::SeedSize::verticalExtent
SeedSize & verticalExtent(const double ev)
Assign vertical extent.
Definition WellFractureSeeds.hpp:164
Opm::WellFractureSeeds::SeedSize::width
SeedSize & width(const double wd)
Assign initial fracture width.
Definition WellFractureSeeds.hpp:177
Opm::WellFractureSeeds::SeedSize::SeedSize
SeedSize(const double ev, const double eh, const double wd)
Constructor.
Definition WellFractureSeeds.hpp:104
Opm::WellFractureSeeds::SeedSize::horizontalExtent
auto horizontalExtent() const
Seed's horizontal extent.
Definition WellFractureSeeds.hpp:184
Opm::WellFractureSeeds::SeedSize::serializeOp
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition WellFractureSeeds.hpp:210
Opm::WellFractureSeeds::SeedSize::verticalExtent
auto verticalExtent() const
Seed's vertical extent.
Definition WellFractureSeeds.hpp:190
Opm::WellFractureSeeds::SeedSize::operator=
SeedSize & operator=(const SeedSize &rhs)=default
Assignment operator.
Opm::WellFractureSeeds::SeedSize::width
auto width() const
Seed's initial fracture width.
Definition WellFractureSeeds.hpp:196
Opm::WellFractureSeeds::SeedSize::operator!=
bool operator!=(const SeedSize &that) const
Inequality predicate.
Definition WellFractureSeeds.hpp:139
Opm::WellFractureSeeds::SeedSize::SeedSize
SeedSize(SeedSize &&rhs)=default
Move constructor.
Opm::WellFractureSeeds
Fracture seed points attached to a single well.
Definition WellFractureSeeds.hpp:32
Opm::WellFractureSeeds::empty
bool empty() const
Predicate for empty fracture seed collection.
Definition WellFractureSeeds.hpp:270
Opm::WellFractureSeeds::name
const std::string & name() const
Named well to which this seed collection is associated.
Definition WellFractureSeeds.hpp:234
Opm::WellFractureSeeds::seedCells
const std::vector< std::size_t > & seedCells() const
Retrieve this collection's fracture seed cells.
Definition WellFractureSeeds.hpp:330
Opm::WellFractureSeeds::serializeOp
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition WellFractureSeeds.hpp:352
Opm::WellFractureSeeds::getNormal
const NormalVector & getNormal(const SeedIndex &i) const
Retrieve fracturing plane normal vector based on insertion order/record index.
Definition WellFractureSeeds.hpp:302
Opm::WellFractureSeeds::WellFractureSeeds
WellFractureSeeds(const std::string &wellName)
Constructor.
Definition WellFractureSeeds.hpp:226
Opm::WellFractureSeeds::WellFractureSeeds
WellFractureSeeds()=default
Default constructor.
Opm::WellFractureSeeds::numSeeds
auto numSeeds() const
Number of fracture seeds in the current collection.
Definition WellFractureSeeds.hpp:273
Opm::WellFractureSeeds::NormalVector
std::array< double, 3 > NormalVector
Type alias for the normal vector at a single seed point.
Definition WellFractureSeeds.hpp:51
Opm::WellFractureSeeds::serializationTestObject
static WellFractureSeeds serializationTestObject()
Create a serialisation test object.
Definition WellFractureSeeds.cpp:92
Opm::WellFractureSeeds::getSize
const SeedSize & getSize(const SeedIndex &i) const
Retrieve initial fracture size vector based on insertion order/record index.
Definition WellFractureSeeds.hpp:320
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::WellFractureSeeds::SeedCell
Disambiguating type for requesting fracture plane normal vectors based on Cartesian cell indices.
Definition WellFractureSeeds.hpp:45
Opm::WellFractureSeeds::SeedCell::c
std::size_t c
Cartesian cell index.
Definition WellFractureSeeds.hpp:47
Opm::WellFractureSeeds::SeedIndex
Disambiguating type for requesting fracture plane normal vectors based on insertion indices.
Definition WellFractureSeeds.hpp:37
Opm::WellFractureSeeds::SeedIndex::i
std::size_t i
Insertion/record index.
Definition WellFractureSeeds.hpp:39