Evaluation: move stream operator support to compile unit
This commit is contained in:
@@ -44,6 +44,7 @@ list (APPEND MAIN_SOURCE_FILES
|
||||
src/opm/common/utility/shmatch.cpp
|
||||
src/opm/common/utility/TimeService.cpp
|
||||
src/opm/material/components/CO2.cpp
|
||||
src/opm/material/densead/Evaluation.cpp
|
||||
src/opm/material/fluidmatrixinteractions/EclEpsScalingPoints.cpp
|
||||
)
|
||||
if(ENABLE_ECL_INPUT)
|
||||
|
||||
@@ -86,7 +86,8 @@ specializationTemplate = \
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -436,18 +437,6 @@ public:
|
||||
}
|
||||
{% endif %}\
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
@@ -881,10 +870,31 @@ Evaluation<ValueType, numVars, staticSize> operator*(const RhsValueType& a, cons
|
||||
return result;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
struct is_evaluation
|
||||
{
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template <class ValueType, int numVars, unsigned staticSize>
|
||||
struct is_evaluation<Evaluation<ValueType,numVars,staticSize>>
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template <class ValueType, int numVars, unsigned staticSize>
|
||||
void printEvaluation(std::ostream& os,
|
||||
const Evaluation<ValueType, numVars, staticSize>& eval,
|
||||
bool withDer = false);
|
||||
|
||||
template <class ValueType, int numVars, unsigned staticSize>
|
||||
std::ostream& operator<<(std::ostream& os, const Evaluation<ValueType, numVars, staticSize>& eval)
|
||||
{
|
||||
os << eval.value();
|
||||
if constexpr (is_evaluation<ValueType>::value)
|
||||
printEvaluation(os, eval.value(), false);
|
||||
else
|
||||
printEvaluation(os, eval, false);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -225,18 +226,6 @@ public:
|
||||
return Evaluation(x.size(), value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -218,18 +219,6 @@ public:
|
||||
return Evaluation(value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
@@ -604,10 +593,31 @@ Evaluation<ValueType, numVars, staticSize> operator*(const RhsValueType& a, cons
|
||||
return result;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
struct is_evaluation
|
||||
{
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template <class ValueType, int numVars, unsigned staticSize>
|
||||
struct is_evaluation<Evaluation<ValueType,numVars,staticSize>>
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template <class ValueType, int numVars, unsigned staticSize>
|
||||
void printEvaluation(std::ostream& os,
|
||||
const Evaluation<ValueType, numVars, staticSize>& eval,
|
||||
bool withDer = false);
|
||||
|
||||
template <class ValueType, int numVars, unsigned staticSize>
|
||||
std::ostream& operator<<(std::ostream& os, const Evaluation<ValueType, numVars, staticSize>& eval)
|
||||
{
|
||||
os << eval.value();
|
||||
if constexpr (is_evaluation<ValueType>::value)
|
||||
printEvaluation(os, eval.value(), false);
|
||||
else
|
||||
printEvaluation(os, eval, false);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -209,18 +210,6 @@ public:
|
||||
return Evaluation(value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -218,18 +219,6 @@ public:
|
||||
return Evaluation(value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -219,18 +220,6 @@ public:
|
||||
return Evaluation(value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -220,18 +221,6 @@ public:
|
||||
return Evaluation(value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -210,18 +211,6 @@ public:
|
||||
return Evaluation(value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -211,18 +212,6 @@ public:
|
||||
return Evaluation(value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -212,18 +213,6 @@ public:
|
||||
return Evaluation(value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -213,18 +214,6 @@ public:
|
||||
return Evaluation(value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -214,18 +215,6 @@ public:
|
||||
return Evaluation(value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -215,18 +216,6 @@ public:
|
||||
return Evaluation(value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -216,18 +217,6 @@ public:
|
||||
return Evaluation(value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
@@ -217,18 +218,6 @@ public:
|
||||
return Evaluation(value);
|
||||
}
|
||||
|
||||
// print the value and the derivatives of the function evaluation
|
||||
void print(std::ostream& os = std::cout) const
|
||||
{
|
||||
// print value
|
||||
os << "v: " << value() << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < size(); ++varIdx) {
|
||||
os << " " << derivative(varIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// copy all derivatives from other
|
||||
void copyDerivatives(const Evaluation& other)
|
||||
{
|
||||
|
||||
84
src/opm/material/densead/Evaluation.cpp
Normal file
84
src/opm/material/densead/Evaluation.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
// vi: set et ts=4 sw=4 sts=4:
|
||||
/*
|
||||
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 2 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/>.
|
||||
|
||||
Consult the COPYING file in the top-level source directory of this
|
||||
module for the precise wording of the license and the list of
|
||||
copyright holders.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <opm/material/densead/Evaluation.hpp>
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace Opm {
|
||||
namespace DenseAd {
|
||||
|
||||
template <class ValueT, int numDerivs, unsigned staticSize>
|
||||
void printEvaluation(std::ostream& os,
|
||||
const Evaluation<ValueT,numDerivs,staticSize>& eval,
|
||||
bool withDer)
|
||||
{
|
||||
// print value
|
||||
os << "v: " << eval.value();
|
||||
|
||||
if (withDer) {
|
||||
os << " / d:";
|
||||
|
||||
// print derivatives
|
||||
for (int varIdx = 0; varIdx < eval.size(); ++varIdx) {
|
||||
os << " " << eval.derivative(varIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define INSTANCE_IMPL(T,size1,size2) \
|
||||
template void printEvaluation(std::ostream&, \
|
||||
const Evaluation<T,size1,size2>&, \
|
||||
bool);
|
||||
|
||||
#define INSTANCE(size) \
|
||||
INSTANCE_IMPL(double,size,0u) \
|
||||
INSTANCE_IMPL(float,size,0u)
|
||||
|
||||
#define INSTANCE_DYN(size) \
|
||||
INSTANCE_IMPL(double,-1,size) \
|
||||
INSTANCE_IMPL(float,-1,size)
|
||||
|
||||
INSTANCE(1)
|
||||
INSTANCE(2)
|
||||
INSTANCE(3)
|
||||
INSTANCE(4)
|
||||
INSTANCE(5)
|
||||
INSTANCE(6)
|
||||
INSTANCE(7)
|
||||
INSTANCE(8)
|
||||
INSTANCE(9)
|
||||
INSTANCE(12)
|
||||
INSTANCE(24)
|
||||
|
||||
INSTANCE_DYN(4u)
|
||||
INSTANCE_DYN(5u)
|
||||
INSTANCE_DYN(6u)
|
||||
INSTANCE_DYN(7u)
|
||||
INSTANCE_DYN(8u)
|
||||
INSTANCE_DYN(9u)
|
||||
INSTANCE_DYN(10u)
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user