Loading...
Searching...
No Matches
ParameterRequirement.hpp
//===========================================================================
//
// File: ParameterRequirement.hpp
//
// Created: Tue Jun 2 19:05:02 2009
//
// Author(s): Bård Skaflestad <bard.skaflestad@sintef.no>
// Atgeirr F Rasmussen <atgeirr@sintef.no>
//
// $Date$
//
// $Revision$
//
//===========================================================================
/*
Copyright 2009, 2010 SINTEF ICT, Applied Mathematics.
Copyright 2009, 2010 Statoil 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_PARAMETERREQUIREMENT_HEADER
#define OPM_PARAMETERREQUIREMENT_HEADER
#include <string>
#include <vector>
namespace Opm {
struct ParameterRequirementNone {
template<typename T>
std::string operator()(const T&) const {
return "";
}
};
struct ParameterRequirementProbability {
std::string operator()(double x) const;
};
struct ParameterRequirementPositive {
template<typename T>
std::string operator()(const T& x) const {
if (x > 0) {
return "";
} else {
return "The value '" + std::to_string(x) +
"' is not positive.";
}
}
};
struct ParameterRequirementNegative {
template<typename T>
std::string operator()(const T& x) const {
if (x < 0) {
return "";
} else {
return "The value '" + std::to_string(x) +
"' is not negative.";
}
}
};
struct ParameterRequirementNonPositive {
template<typename T>
std::string operator()(const T& x) const {
if (x > 0) {
return "The value '" + std::to_string(x) +
"' is positive.";
} else {
return "";
}
}
};
struct ParameterRequirementNonNegative {
template<typename T>
std::string operator()(const T& x) const {
if (x < 0) {
return "The value '" + std::to_string(x) +
"' is negative.";
} else {
return "";
}
}
};
struct ParameterRequirementNonZero {
template<typename T>
std::string operator()(const T& x) const {
if (x != 0) {
return "";
} else {
return "The value was zero.";
}
}
};
struct ParameterRequirementNonEmpty {
std::string operator()(const std::string& x) const {
if (x != "") {
return "The string was empty.";
} else {
return "";
}
}
};
template<class Requirement1, class Requirement2>
struct ParameterRequirementAnd {
ParameterRequirementAnd(const Requirement1& r1, const Requirement2& r2) :
r1_(r1), r2_(r2) { }
template<typename T>
std::string operator()(const T& t) const {
std::string e1 = r1_(t);
std::string e2 = r2_(t);
if (e1 == "") {
return e2;
} else if (e2 == "") {
return e1;
} else {
return e1 + " AND " + e2;
}
}
private:
const Requirement1 r1_;
const Requirement2 r2_;
};
struct ParameterRequirementMemberOf {
explicit ParameterRequirementMemberOf(const std::vector<std::string>& elements);
std::string operator()(const std::string& x) const;
private:
const std::vector<std::string> elements_;
};
} // namespace Opm
#endif // OPM_PARAMETERREQUIREMENT_HEADER
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::ParameterRequirementMemberOf::operator()
std::string operator()(const std::string &x) const
Definition ParameterRequirement.cpp:66
Opm::ParameterRequirementNegative
Definition ParameterRequirement.hpp:85
Opm::ParameterRequirementNonEmpty
Definition ParameterRequirement.hpp:151
Opm::ParameterRequirementNonNegative
Definition ParameterRequirement.hpp:119
Opm::ParameterRequirementNonPositive
Definition ParameterRequirement.hpp:102
Opm::ParameterRequirementNonZero
Definition ParameterRequirement.hpp:136
Opm::ParameterRequirementNone
Definition ParameterRequirement.hpp:48
Opm::ParameterRequirementPositive
Definition ParameterRequirement.hpp:68
Opm::ParameterRequirementProbability
Definition ParameterRequirement.hpp:59