00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef ABSTRACTFESURFACENTEGRALASSEMBLER_HPP_
00037 #define ABSTRACTFESURFACENTEGRALASSEMBLER_HPP_
00038
00039 #include "AbstractFeAssemblerCommon.hpp"
00040 #include "GaussianQuadratureRule.hpp"
00041 #include "BoundaryConditionsContainer.hpp"
00042 #include "PetscVecTools.hpp"
00043 #include "PetscMatTools.hpp"
00044
00045
00060 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM>
00061 class AbstractFeSurfaceIntegralAssembler : public AbstractFeAssemblerCommon<ELEMENT_DIM,SPACE_DIM,PROBLEM_DIM,true,false,NORMAL>
00062 {
00063 protected:
00065 AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>* mpMesh;
00066
00068 BoundaryConditionsContainer<ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM>* mpBoundaryConditions;
00069
00071 GaussianQuadratureRule<ELEMENT_DIM-1>* mpSurfaceQuadRule;
00072
00074 typedef LinearBasisFunction<ELEMENT_DIM-1> SurfaceBasisFunction;
00075
00089 virtual c_vector<double, PROBLEM_DIM*ELEMENT_DIM> ComputeVectorSurfaceTerm(
00090 const BoundaryElement<ELEMENT_DIM-1,SPACE_DIM>& rSurfaceElement,
00091 c_vector<double, ELEMENT_DIM>& rPhi,
00092 ChastePoint<SPACE_DIM>& rX)
00093 {
00094
00095
00096 NEVER_REACHED;
00097 return zero_vector<double>(ELEMENT_DIM*PROBLEM_DIM);
00098 }
00099
00109 virtual void AssembleOnSurfaceElement(const BoundaryElement<ELEMENT_DIM-1,SPACE_DIM>& rSurfaceElement,
00110 c_vector<double, PROBLEM_DIM*ELEMENT_DIM>& rBSurfElem);
00111
00112
00116 void DoAssemble();
00117
00118
00119 public:
00126 AbstractFeSurfaceIntegralAssembler(AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* pMesh,
00127 BoundaryConditionsContainer<ELEMENT_DIM,SPACE_DIM,PROBLEM_DIM>* pBoundaryConditions);
00128
00132 virtual ~AbstractFeSurfaceIntegralAssembler();
00133
00138 void ResetBoundaryConditionsContainer(BoundaryConditionsContainer<ELEMENT_DIM,SPACE_DIM,PROBLEM_DIM>* pBoundaryConditions)
00139 {
00140 assert(pBoundaryConditions);
00141 this->mpBoundaryConditions = pBoundaryConditions;
00142 }
00143 };
00144
00145
00146 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM>
00147 AbstractFeSurfaceIntegralAssembler<ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM>::AbstractFeSurfaceIntegralAssembler(
00148 AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>* pMesh,
00149 BoundaryConditionsContainer<ELEMENT_DIM,SPACE_DIM,PROBLEM_DIM>* pBoundaryConditions)
00150 : AbstractFeAssemblerCommon<ELEMENT_DIM,SPACE_DIM,PROBLEM_DIM,true,false,NORMAL>(),
00151 mpMesh(pMesh),
00152 mpBoundaryConditions(pBoundaryConditions)
00153 {
00154 assert(pMesh);
00155 assert(pBoundaryConditions);
00156
00157
00158
00159 mpSurfaceQuadRule = new GaussianQuadratureRule<ELEMENT_DIM-1>(2);
00160 }
00161
00162 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM>
00163 AbstractFeSurfaceIntegralAssembler<ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM>::~AbstractFeSurfaceIntegralAssembler()
00164 {
00165 delete mpSurfaceQuadRule;
00166 }
00167
00168
00169 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM>
00170 void AbstractFeSurfaceIntegralAssembler<ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM>::DoAssemble()
00171 {
00172 assert(this->mAssembleVector);
00173
00174 HeartEventHandler::BeginEvent(HeartEventHandler::NEUMANN_BCS);
00175
00176
00177 if (mpBoundaryConditions->AnyNonZeroNeumannConditions())
00178 {
00179 typename BoundaryConditionsContainer<ELEMENT_DIM,SPACE_DIM,PROBLEM_DIM>::NeumannMapIterator
00180 neumann_iterator = mpBoundaryConditions->BeginNeumann();
00181
00182 c_vector<double, PROBLEM_DIM*ELEMENT_DIM> b_surf_elem;
00183
00184
00185 while (neumann_iterator != mpBoundaryConditions->EndNeumann())
00186 {
00187 const BoundaryElement<ELEMENT_DIM-1,SPACE_DIM>& r_surf_element = *(neumann_iterator->first);
00188 AssembleOnSurfaceElement(r_surf_element, b_surf_elem);
00189
00190 const size_t STENCIL_SIZE=PROBLEM_DIM*ELEMENT_DIM;
00191 unsigned p_indices[STENCIL_SIZE];
00192 r_surf_element.GetStiffnessMatrixGlobalIndices(PROBLEM_DIM, p_indices);
00193 PetscVecTools::AddMultipleValues<STENCIL_SIZE>(this->mVectorToAssemble, p_indices, b_surf_elem);
00194 ++neumann_iterator;
00195 }
00196 }
00197
00198 HeartEventHandler::EndEvent(HeartEventHandler::NEUMANN_BCS);
00199 }
00200
00201
00202 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM, unsigned PROBLEM_DIM>
00203 void AbstractFeSurfaceIntegralAssembler<ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM>::AssembleOnSurfaceElement(
00204 const BoundaryElement<ELEMENT_DIM-1,SPACE_DIM>& rSurfaceElement,
00205 c_vector<double, PROBLEM_DIM*ELEMENT_DIM>& rBSurfElem)
00206 {
00207 c_vector<double, SPACE_DIM> weighted_direction;
00208 double jacobian_determinant;
00209 mpMesh->GetWeightedDirectionForBoundaryElement(rSurfaceElement.GetIndex(), weighted_direction, jacobian_determinant);
00210
00211 rBSurfElem.clear();
00212
00213
00214 c_vector<double, ELEMENT_DIM> phi;
00215
00216
00217 for (unsigned quad_index=0; quad_index<mpSurfaceQuadRule->GetNumQuadPoints(); quad_index++)
00218 {
00219 const ChastePoint<ELEMENT_DIM-1>& quad_point = mpSurfaceQuadRule->rGetQuadPoint(quad_index);
00220
00221 SurfaceBasisFunction::ComputeBasisFunctions(quad_point, phi);
00222
00224
00226
00227
00228 ChastePoint<SPACE_DIM> x(0,0,0);
00229
00230 this->ResetInterpolatedQuantities();
00231 for (unsigned i=0; i<rSurfaceElement.GetNumNodes(); i++)
00232 {
00233 const c_vector<double, SPACE_DIM> node_loc = rSurfaceElement.GetNode(i)->rGetLocation();
00234 x.rGetLocation() += phi(i)*node_loc;
00235
00236
00237 this->IncrementInterpolatedQuantities(phi(i), rSurfaceElement.GetNode(i));
00238 }
00239
00240
00242
00244
00245 double wJ = jacobian_determinant * mpSurfaceQuadRule->GetWeight(quad_index);
00247 noalias(rBSurfElem) += ComputeVectorSurfaceTerm(rSurfaceElement, phi, x) * wJ;
00248 }
00249 }
00250
00251 #endif // ABSTRACTFESURFACENTEGRALASSEMBLER_HPP_