36 #include "Element.hpp" 45 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
49 if (registerWithNodes)
55 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
64 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
67 for (
unsigned i=0; i<this->
mNodes.size(); i++)
73 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
88 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
91 assert(rIndex < this->
mNodes.size());
97 this->
mNodes[rIndex] = pNode;
103 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
117 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
129 assert(ELEMENT_DIM == SPACE_DIM);
130 c_vector<double, ELEMENT_DIM> rhs;
132 for (
unsigned j=0; j<ELEMENT_DIM; j++)
134 double squared_location=0.0;
135 for (
unsigned i=0; i<SPACE_DIM; i++)
138 squared_location += rJacobian(i,j)*rJacobian(i,j);
140 rhs[j]=squared_location/2.0;
143 c_vector<double, SPACE_DIM> centre;
144 centre = prod(rhs, rInverseJacobian);
145 c_vector<double, SPACE_DIM+1> circum;
146 double squared_radius = 0.0;
147 for (
unsigned i=0; i<SPACE_DIM; i++)
150 squared_radius += centre[i]*centre[i];
152 circum[SPACE_DIM] = squared_radius;
162 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
165 assert(SPACE_DIM == ELEMENT_DIM);
171 c_matrix<double, SPACE_DIM, ELEMENT_DIM> jacobian;
172 c_matrix<double, ELEMENT_DIM, SPACE_DIM> jacobian_inverse;
173 double jacobian_determinant;
187 return 2.0*jacobian_determinant/(3.0*sqrt(3.0)*circum[SPACE_DIM]);
189 assert(SPACE_DIM == 3);
198 return (3.0*sqrt(3.0)*jacobian_determinant)
199 /(16.0*circum[SPACE_DIM]*sqrt(circum[SPACE_DIM]));
202 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
205 c_vector <double, 2> min_max;
206 min_max[0] = DBL_MAX;
208 for (
unsigned i=0; i<=ELEMENT_DIM; i++)
211 for (
unsigned j=i+1; j<=ELEMENT_DIM; j++)
214 if (length < min_max[0])
218 if (length > min_max[1])
227 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
231 assert(ELEMENT_DIM == SPACE_DIM);
233 c_vector<double, SPACE_DIM+1> weights;
235 c_vector<double, SPACE_DIM> xi =
CalculateXi(rTestPoint);
239 for (
unsigned i=1; i<=SPACE_DIM; i++)
241 weights[0] -= xi[i-1];
242 weights[i] = xi[i-1];
247 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
251 assert(ELEMENT_DIM == SPACE_DIM);
256 bool negative_weight =
false;
258 for (
unsigned i=0; i<=SPACE_DIM; i++)
260 if (weights[i] < 0.0)
264 negative_weight =
true;
268 if (negative_weight ==
false)
277 double sum = norm_1 (weights);
281 assert( sum + DBL_EPSILON >= 1.0);
284 weights = weights/sum;
289 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
293 assert(ELEMENT_DIM == SPACE_DIM);
301 c_matrix<double, SPACE_DIM, ELEMENT_DIM> jacobian;
302 c_matrix<double, ELEMENT_DIM, SPACE_DIM> inverse_jacobian;
303 double jacobian_determinant;
308 return prod(inverse_jacobian, test_location);
312 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
316 assert(ELEMENT_DIM == SPACE_DIM);
322 for (
unsigned i=0; i<=SPACE_DIM; i++)
327 if (weights[i] <= 2*DBL_EPSILON)
335 if (weights[i] < -2*DBL_EPSILON)
c_vector< double, SPACE_DIM+1 > CalculateCircumsphere(c_matrix< double, SPACE_DIM, ELEMENT_DIM > &rJacobian, c_matrix< double, ELEMENT_DIM, SPACE_DIM > &rInverseJacobian)
c_vector< double, DIM > & rGetLocation()
double CalculateQuality()
void UpdateNode(const unsigned &rIndex, Node< SPACE_DIM > *pNode)
void ResetIndex(unsigned index)
c_vector< double, SPACE_DIM > CalculateXi(const ChastePoint< SPACE_DIM > &rTestPoint)
void CalculateInverseJacobian(c_matrix< double, SPACE_DIM, ELEMENT_DIM > &rJacobian, double &rJacobianDeterminant, c_matrix< double, ELEMENT_DIM, SPACE_DIM > &rInverseJacobian)
std::vector< Node< SPACE_DIM > * > mNodes
unsigned GetNumNodes() const
Element(unsigned index, const std::vector< Node< SPACE_DIM > * > &rNodes, bool registerWithNodes=true)
bool IncludesPoint(const ChastePoint< SPACE_DIM > &rTestPoint, bool strict=false)
double GetNodeLocation(unsigned localIndex, unsigned dimension) const
c_vector< double, SPACE_DIM+1 > CalculateInterpolationWeights(const ChastePoint< SPACE_DIM > &rTestPoint)
c_vector< double, SPACE_DIM+1 > CalculateInterpolationWeightsWithProjection(const ChastePoint< SPACE_DIM > &rTestPoint)
c_vector< double, 2 > CalculateMinMaxEdgeLengths()