36#include "AbstractElement.hpp"
47template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
53 mpElementAttributes(nullptr)
56 assert(ELEMENT_DIM <= SPACE_DIM);
59template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
64 mpElementAttributes(nullptr)
67template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
70 delete mpElementAttributes;
73template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
76 assert(pOldNode != pNewNode);
77 for (
unsigned i=0; i<this->mNodes.size(); i++)
79 if (this->mNodes[i] == pOldNode)
81 UpdateNode(i, pNewNode);
85 EXCEPTION(
"You didn't have that node to start with.");
88template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
91 assert(dimension < SPACE_DIM);
92 assert((
unsigned)localIndex < mNodes.size());
93 return mNodes[localIndex]->rGetLocation()[dimension];
101template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
104 assert((
unsigned)localIndex < mNodes.size());
105 return mNodes[localIndex]->rGetLocation();
108template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
111 assert((
unsigned)localIndex < mNodes.size());
112 return mNodes[localIndex]->GetIndex();
115template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
118 assert((
unsigned)localIndex < mNodes.size());
119 return mNodes[localIndex];
122template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
125 return mNodes.size();
128template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
131 mNodes.push_back(pNode);
134template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
140template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
146template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
152template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
158template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
161 mOwnership = ownership;
164template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
167 ConstructElementAttributes();
169 mpElementAttributes->SetFirstAttribute(attribute);
172template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
175 ConstructElementAttributes();
177 return mpElementAttributes->GetFirstAttribute();
180template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
183 double double_attr = GetAttribute();
184 unsigned unsigned_attr = (
unsigned) (double_attr + 0.5);
188 EXCEPTION(
"Element attribute '"<< double_attr <<
"' cannot be converted to an unsigned.");
190 return unsigned_attr;
193template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
196 if (mpElementAttributes ==
nullptr)
202template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
205 ConstructElementAttributes();
207 mpElementAttributes->AddAttribute(attribute);
210template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
213 if (mpElementAttributes ==
nullptr)
215 EXCEPTION(
"Element has no attributes associated with it. Construct attributes first");
218 return mpElementAttributes->rGetAttributes();
221template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
224 return mpElementAttributes ==
nullptr ? 0 : mpElementAttributes->rGetAttributes().size();
#define EXCEPTION(message)
void SetAttribute(double attribute)
void ReplaceNode(Node< SPACE_DIM > *pOldNode, Node< SPACE_DIM > *pNewNode)
Node< SPACE_DIM > * GetNode(unsigned localIndex) const
unsigned GetUnsignedAttribute()
virtual ~AbstractElement()
void ConstructElementAttributes()
std::vector< double > & rGetElementAttributes()
double GetNodeLocation(unsigned localIndex, unsigned dimension) const
unsigned GetNumElementAttributes()
void AddElementAttribute(double attribute)
unsigned GetNumNodes() const
AbstractElement(unsigned index, const std::vector< Node< SPACE_DIM > * > &rNodes)
unsigned GetNodeGlobalIndex(unsigned localIndex) const
bool GetOwnership() const
void AddNode(Node< SPACE_DIM > *pNode)
unsigned GetIndex() const
void SetOwnership(bool ownership)
void SetIndex(unsigned index)
static bool WithinAnyTolerance(double number1, double number2, double relTol=DBL_EPSILON, double absTol=DBL_EPSILON, bool printError=false)