Loading...
Searching...
No Matches
dependency.hh
Go to the documentation of this file.
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_AMG_DEPENDENCY_HH
#define DUNE_AMG_DEPENDENCY_HH
#include <bitset>
#include <ostream>
#include "graph.hh"
#include "properties.hh"
#include <dune/common/propertymap.hh>
namespace Dune
{
namespace Amg
{
class EdgeProperties
{
friend std::ostream& operator<<(std::ostream& os, const EdgeProperties& props);
public:
enum {INFLUENCE, DEPEND, SIZE};
private:
std::bitset<SIZE> flags_;
public:
EdgeProperties();
std::bitset<SIZE>::reference operator[](std::size_t v);
bool operator[](std::size_t v) const;
bool depends() const;
void setDepends();
void resetDepends();
bool influences() const;
void setInfluences();
void resetInfluences();
bool isOneWay() const;
bool isTwoWay() const;
bool isStrong() const;
void reset();
void printFlags() const;
};
class VertexProperties {
friend std::ostream& operator<<(std::ostream& os, const VertexProperties& props);
public:
enum { ISOLATED, VISITED, FRONT, BORDER, SIZE };
private:
std::bitset<SIZE> flags_;
public:
VertexProperties();
std::bitset<SIZE>::reference operator[](std::size_t v);
bool operator[](std::size_t v) const;
void setIsolated();
bool isolated() const;
void resetIsolated();
void setVisited();
bool visited() const;
void resetVisited();
void setFront();
bool front() const;
void resetFront();
void setExcludedBorder();
bool excludedBorder() const;
void resetExcludedBorder();
void reset();
};
template<typename G, std::size_t i>
class PropertyGraphVertexPropertyMap
: public RAPropertyMapHelper<typename std::bitset<VertexProperties::SIZE>::reference,
PropertyGraphVertexPropertyMap<G,i> >
{
public:
typedef ReadWritePropertyMapTag Category;
enum {
index = i
};
typedef G Graph;
typedef std::bitset<VertexProperties::SIZE> BitSet;
typedef typename BitSet::reference Reference;
typedef bool ValueType;
typedef typename G::VertexDescriptor Vertex;
PropertyGraphVertexPropertyMap(G& g)
: graph_(&g)
{}
PropertyGraphVertexPropertyMap()
: graph_(0)
{}
Reference operator[](const Vertex& vertex) const
{
return graph_->getVertexProperties(vertex)[index];
}
private:
Graph* graph_;
};
} // end namespace Amg
template<typename G, typename EP, typename VM, typename EM>
struct PropertyMapTypeSelector<Amg::VertexVisitedTag,Amg::PropertiesGraph<G,Amg::VertexProperties,EP,VM,EM> >
{
typedef Amg::PropertyGraphVertexPropertyMap<Amg::PropertiesGraph<G,Amg::VertexProperties,EP,VM,EM>, Amg::VertexProperties::VISITED> Type;
};
template<typename G, typename EP, typename VM, typename EM>
typename PropertyMapTypeSelector<Amg::VertexVisitedTag,Amg::PropertiesGraph<G,Amg::VertexProperties,EP,VM,EM> >::Type
get([[maybe_unused]] const Amg::VertexVisitedTag& tag, Amg::PropertiesGraph<G,Amg::VertexProperties,EP,VM,EM>& graph)
{
return Amg::PropertyGraphVertexPropertyMap<Amg::PropertiesGraph<G,Amg::VertexProperties,EP,VM,EM>, Amg::VertexProperties::VISITED>(graph);
}
namespace Amg
{
inline std::ostream& operator<<(std::ostream& os, const EdgeProperties& props)
{
return os << props.flags_;
}
inline EdgeProperties::EdgeProperties()
: flags_()
{}
inline std::bitset<EdgeProperties::SIZE>::reference
EdgeProperties::operator[](std::size_t v)
{
return flags_[v];
}
inline bool EdgeProperties::operator[](std::size_t i) const
{
return flags_[i];
}
inline void EdgeProperties::reset()
{
flags_.reset();
}
inline void EdgeProperties::setInfluences()
{
// Set the INFLUENCE bit
//flags_ |= (1<<INFLUENCE);
flags_.set(INFLUENCE);
}
inline bool EdgeProperties::influences() const
{
// Test the INFLUENCE bit
return flags_.test(INFLUENCE);
}
inline void EdgeProperties::setDepends()
{
// Set the first bit.
//flags_ |= (1<<DEPEND);
flags_.set(DEPEND);
}
inline void EdgeProperties::resetDepends()
{
// reset the first bit.
//flags_ &= ~(1<<DEPEND);
flags_.reset(DEPEND);
}
inline bool EdgeProperties::depends() const
{
// Return the first bit.
return flags_.test(DEPEND);
}
inline void EdgeProperties::resetInfluences()
{
// reset the second bit.
flags_ &= ~(1<<INFLUENCE);
}
inline bool EdgeProperties::isOneWay() const
{
// Test whether only the first bit is set
//return isStrong() && !isTwoWay();
return ((flags_) & std::bitset<SIZE>((1<<INFLUENCE)|(1<<DEPEND)))==(1<<DEPEND);
}
inline bool EdgeProperties::isTwoWay() const
{
// Test whether the first and second bit is set
return ((flags_) & std::bitset<SIZE>((1<<INFLUENCE)|(1<<DEPEND)))==((1<<INFLUENCE)|(1<<DEPEND));
}
inline bool EdgeProperties::isStrong() const
{
// Test whether the first or second bit is set
return ((flags_) & std::bitset<SIZE>((1<<INFLUENCE)|(1<<DEPEND))).to_ulong();
}
inline std::ostream& operator<<(std::ostream& os, const VertexProperties& props)
{
return os << props.flags_;
}
inline VertexProperties::VertexProperties()
: flags_()
{}
inline std::bitset<VertexProperties::SIZE>::reference
VertexProperties::operator[](std::size_t v)
{
return flags_[v];
}
inline bool VertexProperties::operator[](std::size_t v) const
{
return flags_[v];
}
inline void VertexProperties::setIsolated()
{
flags_.set(ISOLATED);
}
inline bool VertexProperties::isolated() const
{
return flags_.test(ISOLATED);
}
inline void VertexProperties::resetIsolated()
{
flags_.reset(ISOLATED);
}
inline void VertexProperties::setVisited()
{
flags_.set(VISITED);
}
inline bool VertexProperties::visited() const
{
return flags_.test(VISITED);
}
inline void VertexProperties::resetVisited()
{
flags_.reset(VISITED);
}
inline void VertexProperties::setFront()
{
flags_.set(FRONT);
}
inline bool VertexProperties::front() const
{
return flags_.test(FRONT);
}
inline void VertexProperties::resetFront()
{
flags_.reset(FRONT);
}
inline void VertexProperties::setExcludedBorder()
{
flags_.set(BORDER);
}
inline bool VertexProperties::excludedBorder() const
{
return flags_.test(BORDER);
}
inline void VertexProperties::resetExcludedBorder()
{
flags_.reset(BORDER);
}
inline void VertexProperties::reset()
{
flags_.reset();
}
}
}
#endif
graph.hh
Provides classes for building the matrix graph.
properties.hh
Provides classes for handling internal properties in a graph.
Dune::Amg::EdgeProperties::depends
bool depends() const
Checks whether the vertex the edge points to depends on the vertex the edge starts.
Definition dependency.hh:352
Dune::Amg::VertexProperties::resetFront
void resetFront()
Resets the front node flag.
Definition dependency.hh:445
Dune::Amg::PropertyGraphVertexPropertyMap::BitSet
std::bitset< VertexProperties::SIZE > BitSet
The type of the bitset.
Definition dependency.hh:238
Dune::Amg::VertexProperties::isolated
bool isolated() const
Checks whether the node is isolated.
Definition dependency.hh:410
Dune::Amg::PropertyGraphVertexPropertyMap::ValueType
bool ValueType
The value type.
Definition dependency.hh:248
Dune::Amg::VertexProperties::operator<<
friend std::ostream & operator<<(std::ostream &os, const VertexProperties &props)
Definition dependency.hh:384
Dune::Amg::PropertyGraphVertexPropertyMap::Reference
BitSet::reference Reference
The reference type.
Definition dependency.hh:243
Dune::Amg::EdgeProperties::isTwoWay
bool isTwoWay() const
Checks whether the edge is two way. I.e. both the influence flag and the depends flag are that.
Definition dependency.hh:371
Dune::Amg::EdgeProperties::setInfluences
void setInfluences()
Marks the edge as one of which the start vertex by the end vertex.
Definition dependency.hh:325
Dune::Amg::VertexProperties::VertexProperties
VertexProperties()
Constructor.
Definition dependency.hh:389
Dune::Amg::EdgeProperties::setDepends
void setDepends()
Marks the edge as one of which the end point depends on the starting point.
Definition dependency.hh:338
Dune::Amg::PropertyGraphVertexPropertyMap::PropertyGraphVertexPropertyMap
PropertyGraphVertexPropertyMap()
Default constructor.
Definition dependency.hh:266
Dune::Amg::PropertyGraphVertexPropertyMap::PropertyGraphVertexPropertyMap
PropertyGraphVertexPropertyMap(G &g)
Constructor.
Definition dependency.hh:259
Dune::Amg::PropertyGraphVertexPropertyMap::Vertex
G::VertexDescriptor Vertex
The vertex descriptor.
Definition dependency.hh:253
Dune::Amg::VertexProperties::resetExcludedBorder
void resetExcludedBorder()
Marks the vertex as included in the aggregation.
Definition dependency.hh:460
Dune::Amg::VertexProperties::setFront
void setFront()
Marks the node as belonging to the current clusters front.
Definition dependency.hh:435
Dune::Amg::VertexProperties::reset
void reset()
Reset all flags.
Definition dependency.hh:465
Dune::Amg::VertexProperties::setVisited
void setVisited()
Mark the node as already visited.
Definition dependency.hh:420
Dune::Amg::EdgeProperties::EdgeProperties
EdgeProperties()
Constructor.
Definition dependency.hh:305
Dune::Amg::EdgeProperties::resetInfluences
void resetInfluences()
Resets the influence flag.
Definition dependency.hh:358
Dune::Amg::PropertyGraphVertexPropertyMap::Graph
G Graph
The type of the graph with internal properties.
Definition dependency.hh:233
Dune::Amg::VertexProperties::operator[]
std::bitset< SIZE >::reference operator[](std::size_t v)
Access the bits directly.
Definition dependency.hh:395
Dune::Amg::EdgeProperties::printFlags
void printFlags() const
Prints the attributes of the edge for debugging.
Dune::Amg::EdgeProperties::operator<<
friend std::ostream & operator<<(std::ostream &os, const EdgeProperties &props)
Definition dependency.hh:300
Dune::PropertyMapTypeSelector< Amg::VertexVisitedTag, Amg::PropertiesGraph< G, Amg::VertexProperties, EP, VM, EM > >::Type
Amg::PropertyGraphVertexPropertyMap< Amg::PropertiesGraph< G, Amg::VertexProperties, EP, VM, EM >, Amg::VertexProperties::VISITED > Type
Definition dependency.hh:288
Dune::Amg::EdgeProperties::influences
bool influences() const
Checks whether the start vertex is influenced by the end vertex.
Definition dependency.hh:332
Dune::Amg::VertexProperties::setIsolated
void setIsolated()
Marks that node as being isolated.
Definition dependency.hh:405
Dune::Amg::VertexProperties::excludedBorder
bool excludedBorder() const
Tests whether the vertex is excluded from the aggregation.
Definition dependency.hh:455
Dune::Amg::VertexProperties::resetVisited
void resetVisited()
Resets the visited flag.
Definition dependency.hh:430
Dune::Amg::VertexProperties::visited
bool visited() const
Checks whether the node is marked as visited.
Definition dependency.hh:425
Dune::Amg::PropertyGraphVertexPropertyMap::operator[]
Reference operator[](const Vertex &vertex) const
Get the properties associated to a vertex.
Definition dependency.hh:275
Dune::Amg::EdgeProperties::reset
void reset()
Reset all flags.
Definition dependency.hh:320
Dune::Amg::EdgeProperties::resetDepends
void resetDepends()
Resets the depends flag.
Definition dependency.hh:345
Dune::Amg::PropertyGraphVertexPropertyMap::Category
ReadWritePropertyMapTag Category
Definition dependency.hh:223
Dune::Amg::VertexProperties::resetIsolated
void resetIsolated()
Resets the isolated flag.
Definition dependency.hh:415
Dune::Amg::operator<<
std::ostream & operator<<(std::ostream &os, const AggregationCriterion< T > &criterion)
Definition aggregates.hh:115
Dune::Amg::EdgeProperties::isStrong
bool isStrong() const
Checks whether the edge is strong. I.e. the influence or depends flag is set.
Definition dependency.hh:377
Dune::Amg::VertexProperties::front
bool front() const
Checks whether the node is marked as a front node.
Definition dependency.hh:440
Dune::Amg::EdgeProperties::operator[]
std::bitset< SIZE >::reference operator[](std::size_t v)
Access the bits directly.
Definition dependency.hh:310
Dune::Amg::VertexProperties::setExcludedBorder
void setExcludedBorder()
Marks the vertex as excluded from the aggregation.
Definition dependency.hh:450
Dune::Amg::EdgeProperties::isOneWay
bool isOneWay() const
Checks whether the edge is one way. I.e. either the influence or the depends flag but is set.
Definition dependency.hh:364
Dune::Amg::VertexProperties::VISITED
@ VISITED
Definition dependency.hh:129
Dune::Amg::VertexProperties::ISOLATED
@ ISOLATED
Definition dependency.hh:129
Dune::Amg::VertexProperties::SIZE
@ SIZE
Definition dependency.hh:129
Dune::Amg::VertexProperties::BORDER
@ BORDER
Definition dependency.hh:129
Dune::Amg::VertexProperties::FRONT
@ FRONT
Definition dependency.hh:129
Dune::Amg::PropertyGraphVertexPropertyMap< Amg::PropertiesGraph< G, Amg::VertexProperties, EP, VM, EM >, Amg::VertexProperties::VISITED >::index
@ index
Definition dependency.hh:227
Dune::Amg::EdgeProperties::DEPEND
@ DEPEND
Definition dependency.hh:43
Dune::Amg::EdgeProperties::SIZE
@ SIZE
Definition dependency.hh:43
Dune::Amg::EdgeProperties::INFLUENCE
@ INFLUENCE
Definition dependency.hh:43
Dune
Definition allocator.hh:11
Dune::get
PropertyMapTypeSelector< Amg::VertexVisitedTag, Amg::PropertiesGraph< G, Amg::VertexProperties, EP, VM, EM > >::Type get(const Amg::VertexVisitedTag &tag, Amg::PropertiesGraph< G, Amg::VertexProperties, EP, VM, EM > &graph)
Definition dependency.hh:293
Dune::Amg
Definition novlpschwarz.hh:256
Dune::Amg::PropertyGraphVertexPropertyMap
Definition dependency.hh:220
Dune::Amg::PropertiesGraph
Attaches properties to the edges and vertices of a graph.
Definition graph.hh:978
Dune::Amg::VertexVisitedTag
Tag idnetifying the visited property of a vertex.
Definition properties.hh:29