36 #include "AbstractElement.hpp"
47 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
53 mpElementAttributes(NULL)
56 assert(ELEMENT_DIM <= SPACE_DIM);
59 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
64 mpElementAttributes(NULL)
67 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
70 delete mpElementAttributes;
73 template <
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.");
88 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
91 assert(dimension < SPACE_DIM);
92 assert((
unsigned)localIndex < mNodes.size());
93 return mNodes[localIndex]->rGetLocation()[dimension];
101 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
104 assert((
unsigned)localIndex < mNodes.size());
105 return mNodes[localIndex]->rGetLocation();
108 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
111 assert((
unsigned)localIndex < mNodes.size());
112 return mNodes[localIndex]->GetIndex();
115 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
118 assert((
unsigned)localIndex < mNodes.size());
119 return mNodes[localIndex];
122 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
125 return mNodes.size();
128 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
131 mNodes.push_back(pNode);
134 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
140 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
146 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
152 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
158 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
161 mOwnership = ownership;
164 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
167 ConstructElementAttributes();
169 mpElementAttributes->SetFirstAttribute(attribute);
172 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
175 ConstructElementAttributes();
177 return mpElementAttributes->GetFirstAttribute();
180 template <
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;
193 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
196 if (mpElementAttributes == NULL)
202 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
205 ConstructElementAttributes();
207 mpElementAttributes->AddAttribute(attribute);
210 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
213 if (mpElementAttributes == NULL)
215 EXCEPTION(
"Element has no attributes associated with it. Construct attributes first");
218 return mpElementAttributes->rGetAttributes();
221 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
224 return mpElementAttributes == NULL ? 0 : mpElementAttributes->rGetAttributes().size();
void SetAttribute(double attribute)
void AddElementAttribute(double attribute)
static bool WithinAnyTolerance(double number1, double number2, double relTol=DBL_EPSILON, double absTol=DBL_EPSILON, bool printError=false)
unsigned GetNodeGlobalIndex(unsigned localIndex) const
void SetIndex(unsigned index)
#define EXCEPTION(message)
void ReplaceNode(Node< SPACE_DIM > *pOldNode, Node< SPACE_DIM > *pNewNode)
void SetOwnership(bool ownership)
unsigned GetNumElementAttributes()
Node< SPACE_DIM > * GetNode(unsigned localIndex) const
AbstractElement(unsigned index, const std::vector< Node< SPACE_DIM > * > &rNodes)
bool GetOwnership() const
void ConstructElementAttributes()
std::vector< double > & rGetElementAttributes()
unsigned GetNumNodes() const
virtual ~AbstractElement()
unsigned GetUnsignedAttribute()
unsigned GetIndex() const
void AddNode(Node< SPACE_DIM > *pNode)
double GetNodeLocation(unsigned localIndex, unsigned dimension) const