Commit 5e2099ca authored by Ole Klein's avatar Ole Klein

add equality comp., switched axpy and list insertion method

parent d0a2edd0
......@@ -672,6 +672,11 @@ namespace Dune {
return *this;
}
RandomField& axpy(const RF alpha, const RandomField& other)
{
return axpy(other,alpha);
}
/**
* @brief Scalar product
*/
......@@ -810,6 +815,16 @@ namespace Dune {
return std::max(trendPart.infNorm(), stochasticPart.infNorm());
}
bool operator==(const RandomField& other) const
{
return (trendPart == other.trendPart && stochasticPart == other.stochasticPart);
}
bool operator!=(const RandomField& other) const
{
return !operator==(other);
}
void localize(const typename Traits::DomainType& center, const RF radius)
{
stochasticPart.localize(center,radius);
......@@ -1030,6 +1045,18 @@ namespace Dune {
return *this;
}
/**
* @brief Insert additional random field into list
*/
void insert(const std::string& type, const SubRandomField& field, bool activate = true)
{
fieldNames.push_back(type);
if (activate)
activeTypes.push_back(type);
list.insert({type, std::make_shared<SubRandomField>(field)});
}
/**
* @brief Define subset of fields kept constant (i.e. not changed by calculus operators)
*/
......@@ -1255,6 +1282,11 @@ namespace Dune {
return *this;
}
RandomFieldList& axpy(const RF alpha, const RandomFieldList& other)
{
return axpy(other,alpha);
}
/**
* @brief Scalar product
*/
......@@ -1336,6 +1368,29 @@ namespace Dune {
return max;
}
bool operator==(const RandomFieldList& other) const
{
bool same = true;
for (const std::string& type : fieldNames)
{
if (other.list.find(type) == other.list.end())
DUNE_THROW(Dune::Exception,"RandomFieldLists don't match in operator==");
if (!(list.find(type)->second->operator==(*(other.list.find(type)->second))))
{
same = false;
break;
}
}
return same;
}
bool operator!=(const RandomFieldList& other) const
{
return !operator==(other);
}
void localize(const typename GridTraits::Domain& center, const RF radius)
{
for(const std::string& type : activeTypes)
......
......@@ -338,6 +338,26 @@ namespace Dune {
return sum;
}
bool operator==(const StochasticPart& other) const
{
int same = true, mySame = true;
for (unsigned int i = 0; i < localDomainSize; ++i)
if (dataVector[i] != other.dataVector[i])
{
mySame = false;
break;
}
MPI_Allreduce(&mySame,&same,1,MPI_INT,MPI_MIN,(*traits).comm);
return same;
}
bool operator!=(const StochasticPart& other) const
{
return !operator==(other);
}
/**
* @brief Evaluate stochastic part at given location
*/
......
......@@ -388,6 +388,25 @@ namespace Dune {
return output;
}
bool operator==(const TrendComponent<Traits>& other) const
{
bool same = true;
for (unsigned int i = 0; i < shiftVector.size(); i++)
if (shiftVector[i] != other.shiftVector[i])
{
same = false;
break;
}
return same;
}
bool operator!=(const TrendComponent<Traits>& other) const
{
return !operator==(other);
}
/**
* @brief Evaluate the trend component at a given location
*/
......@@ -1010,6 +1029,28 @@ namespace Dune {
return output;
}
bool operator==(const TrendPart<Traits>& other) const
{
bool same = true;
for (unsigned int i = 0; i < componentVector.size(); i++)
if (! (componentVector[i] == other.componentVector[i]))
{
same = false;
break;
}
if (imageComponent)
same = same && (*imageComponent == *(other.imageComponent));
return same;
}
bool operator!=(const TrendPart<Traits>& other) const
{
return !operator==(other);
}
/**
* @brief Infinity norm
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment