Files
opm-simulators/opm/simulators/wells/ALQState.cpp
T

115 lines
2.7 KiB
C++
Raw Normal View History

/*
Copyright 2021 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/>.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H
2023-02-02 11:52:08 +01:00
#include <opm/simulators/wells/ALQState.hpp>
#include <cstddef>
#include <stdexcept>
2023-02-02 11:52:08 +01:00
namespace Opm {
2024-02-17 18:13:46 +01:00
template<class Scalar>
ALQState<Scalar> ALQState<Scalar>::serializationTestObject()
2023-02-02 11:52:08 +01:00
{
ALQState result;
2025-05-14 15:21:23 +02:00
result.current_alq_ = {1.0};
result.default_alq_ = {2.0};
result.alq_increase_count_= {4};
result.alq_decrease_count_= {5};
2023-02-02 11:52:08 +01:00
return result;
}
template<class Scalar>
2025-05-14 15:21:23 +02:00
Scalar ALQState<Scalar>::get() const
2024-02-17 18:13:46 +01:00
{
2025-05-14 15:21:23 +02:00
if (this->current_alq_)
return *this->current_alq_;
2025-05-14 15:21:23 +02:00
return this->default_alq_;
}
2024-02-17 18:13:46 +01:00
template<class Scalar>
2025-05-14 15:21:23 +02:00
void ALQState<Scalar>::update_default(Scalar value)
2024-02-17 18:13:46 +01:00
{
2025-05-14 15:21:23 +02:00
if (default_alq_ != value) {
this->default_alq_ = value;
this->current_alq_ = value;
}
}
2024-02-17 18:13:46 +01:00
template<class Scalar>
2025-05-14 15:21:23 +02:00
void ALQState<Scalar>::set(Scalar value)
2024-02-17 18:13:46 +01:00
{
2025-05-14 15:21:23 +02:00
this->current_alq_ = value;
2022-01-23 20:37:26 +01:00
}
2024-02-17 18:13:46 +01:00
template<class Scalar>
2025-05-14 15:21:23 +02:00
bool ALQState<Scalar>::oscillation() const
2024-02-17 18:13:46 +01:00
{
2025-05-30 08:01:22 +02:00
return this->alq_increase_count_ > 0 && this->alq_decrease_count_ >= 1;
}
2024-02-17 18:13:46 +01:00
template<class Scalar>
2025-05-14 15:21:23 +02:00
void ALQState<Scalar>::update_count(bool increase)
2024-02-17 18:13:46 +01:00
{
if (increase)
2025-05-14 15:21:23 +02:00
this->alq_increase_count_ += 1;
else
2025-05-14 15:21:23 +02:00
this->alq_decrease_count_ += 1;
}
2024-02-17 18:13:46 +01:00
template<class Scalar>
void ALQState<Scalar>::reset_count()
{
2025-05-14 15:21:23 +02:00
this->alq_decrease_count_ = 0;
this->alq_increase_count_ = 0;
}
2024-02-17 18:13:46 +01:00
template<class Scalar>
2025-05-14 15:21:23 +02:00
int ALQState<Scalar>::get_increment_count() const
2024-02-17 18:13:46 +01:00
{
2025-05-14 15:21:23 +02:00
return this->alq_increase_count_;
}
2024-02-17 18:13:46 +01:00
template<class Scalar>
2025-05-14 15:21:23 +02:00
int ALQState<Scalar>::get_decrement_count() const
2024-02-17 18:13:46 +01:00
{
2025-05-14 15:21:23 +02:00
return this->alq_decrease_count_;
}
2024-02-17 18:13:46 +01:00
template<class Scalar>
bool ALQState<Scalar>::operator==(const ALQState& rhs) const
2023-02-02 11:52:08 +01:00
{
return this->current_alq_ == rhs.current_alq_ &&
this->default_alq_ == rhs.default_alq_ &&
this->alq_increase_count_ == rhs.alq_increase_count_ &&
2025-05-14 15:21:23 +02:00
this->alq_decrease_count_ == rhs.alq_decrease_count_;
2023-02-02 11:52:08 +01:00
}
2024-02-17 18:13:46 +01:00
template class ALQState<double>;
2024-04-12 13:11:09 +02:00
#if FLOW_INSTANTIATE_FLOAT
template class ALQState<float>;
#endif
2024-02-17 18:13:46 +01:00
}