BoundaryElement.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #include "BoundaryElement.hpp"
00030 
00031 #include <cassert>
00032 
00034 // Implementation
00036 
00037 
00038 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00039 BoundaryElement<ELEMENT_DIM, SPACE_DIM>::BoundaryElement(unsigned index, std::vector<Node<SPACE_DIM>*> nodes)
00040     : AbstractTetrahedralElement<ELEMENT_DIM, SPACE_DIM>(index, nodes)
00041 {
00042     RegisterWithNodes();
00043 }
00044 
00045 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00046 BoundaryElement<ELEMENT_DIM, SPACE_DIM>::BoundaryElement(unsigned index, Node<SPACE_DIM>* pNode)
00047     : AbstractTetrahedralElement<ELEMENT_DIM,SPACE_DIM>(index)
00048 {
00049     assert(ELEMENT_DIM == 0);
00050 
00051     // Store Node pointer
00052     this->mNodes.push_back(pNode);
00053 
00054 //        this->mJacobian(0,0) = 1.0;
00055 //        this->mInverseJacobian(0,0) = 1.0;
00056 //        this->mWeightedDirection(0) = 1.0;
00057 //        this->mJacobianDeterminant = 1.0;
00058 
00059     RegisterWithNodes();
00060 }
00061 
00062 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00063 void BoundaryElement<ELEMENT_DIM, SPACE_DIM>::RegisterWithNodes()
00064 {
00065     for (unsigned i=0; i<this->mNodes.size(); i++)
00066     {
00067         this->mNodes[i]->AddBoundaryElement(this->mIndex);
00068     }
00069 }
00070 
00071 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00072 void BoundaryElement<ELEMENT_DIM, SPACE_DIM>::ResetIndex(unsigned index)
00073 {
00074     for (unsigned i=0; i<this->GetNumNodes(); i++)
00075     {
00076         this->mNodes[i]->RemoveBoundaryElement(this->mIndex);
00077     }
00078     this->mIndex = index;
00079     RegisterWithNodes();
00080 }
00081 
00082 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00083 void BoundaryElement<ELEMENT_DIM, SPACE_DIM>::MarkAsDeleted()
00084 {
00085     this->mIsDeleted = true;
00086 //        this->mJacobianDeterminant = 0.0;
00087     // Update nodes in this element so they know they are not contained by us
00088     for (unsigned i=0; i<this->GetNumNodes(); i++)
00089     {
00090         this->mNodes[i]->RemoveBoundaryElement(this->mIndex);
00091     }
00092 }
00093 
00094 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00095 void BoundaryElement<ELEMENT_DIM, SPACE_DIM>::UpdateNode(const unsigned& rIndex, Node<SPACE_DIM>* pNode)
00096 {
00097     assert(rIndex < this->mNodes.size());
00098 
00099     // Remove it from the node at this location
00100     this->mNodes[rIndex]->RemoveBoundaryElement(this->mIndex);
00101 
00102     // Update the node at this location
00103     this->mNodes[rIndex] = pNode;
00104 
00105     // Add element to this node
00106     this->mNodes[rIndex]->AddBoundaryElement(this->mIndex);
00107 }
00108 
00109 
00111 // Explicit instantiation
00113 
00114 template class BoundaryElement<0,1>;
00115 template class BoundaryElement<0,2>;
00116 template class BoundaryElement<1,2>;
00117 template class BoundaryElement<0,3>;
00118 template class BoundaryElement<1,3>;
00119 template class BoundaryElement<2,3>;

Generated on Tue Aug 4 16:10:22 2009 for Chaste by  doxygen 1.5.5