36 #ifndef CONTINUUMMECHANICSNEUMANNBCSASSEMBLER_HPP_
37 #define CONTINUUMMECHANICSNEUMANNBCSASSEMBLER_HPP_
39 #include "AbstractFeAssemblerInterface.hpp"
40 #include "AbstractTetrahedralMesh.hpp"
41 #include "QuadraticMesh.hpp"
42 #include "DistributedQuadraticMesh.hpp"
43 #include "LinearBasisFunction.hpp"
44 #include "QuadraticBasisFunction.hpp"
45 #include "ReplicatableVector.hpp"
46 #include "DistributedVector.hpp"
48 #include "PetscVecTools.hpp"
49 #include "PetscMatTools.hpp"
50 #include "GaussianQuadratureRule.hpp"
51 #include "ContinuumMechanicsProblemDefinition.hpp"
69 template<
unsigned DIM>
114 c_vector<double, STENCIL_SIZE>& rBElem,
115 unsigned boundaryConditionIndex);
129 assert(pProblemDefinition);
135 if(p_quad_mesh == NULL && p_distributed_quad_mesh == NULL)
137 EXCEPTION(
"Continuum mechanics solvers require a quadratic mesh");
155 template<
unsigned DIM>
158 if(this->mVectorToAssemble==NULL)
160 EXCEPTION(
"Vector to be assembled has not been set");
165 EXCEPTION(
"Vector provided to be assembled has size " <<
PetscVecTools::GetSize(this->mVectorToAssemble) <<
", not expected size of " << (DIM+1)*mpMesh->GetNumNodes() <<
" ((dim+1)*num_nodes)");
169 if (this->mZeroVectorBeforeAssembly)
175 if (mpProblemDefinition->GetTractionBoundaryConditionType() != NO_TRACTIONS)
177 c_vector<double, STENCIL_SIZE> b_elem = zero_vector<double>(STENCIL_SIZE);
179 for (
unsigned bc_index=0; bc_index<mpProblemDefinition->rGetTractionBoundaryElements().size(); bc_index++)
181 BoundaryElement<DIM-1,DIM>& r_boundary_element = *(mpProblemDefinition->rGetTractionBoundaryElements()[bc_index]);
182 AssembleOnBoundaryElement(r_boundary_element, b_elem, bc_index);
184 unsigned p_indices[STENCIL_SIZE];
185 for (
unsigned i=0; i<NUM_NODES_PER_ELEMENT; i++)
187 for (
unsigned j=0; j<DIM; j++)
189 p_indices[DIM*i+j] = (DIM+1)*r_boundary_element.GetNodeGlobalIndex(i) + j;
194 for (
unsigned i=0; i<DIM ; i++)
196 p_indices[DIM*NUM_NODES_PER_ELEMENT + i] = (DIM+1)*r_boundary_element.GetNodeGlobalIndex(i)+DIM;
199 PetscVecTools::AddMultipleValues<STENCIL_SIZE>(this->mVectorToAssemble, p_indices, b_elem);
206 template<
unsigned DIM>
208 c_vector<double,STENCIL_SIZE>& rBelem,
209 unsigned boundaryConditionIndex)
213 c_vector<double, DIM> weighted_direction;
214 double jacobian_determinant;
215 mpMesh->GetWeightedDirectionForBoundaryElement(rBoundaryElement.
GetIndex(), weighted_direction, jacobian_determinant);
217 c_vector<double,NUM_NODES_PER_ELEMENT> phi;
219 for (
unsigned quad_index=0; quad_index<mpQuadRule->GetNumQuadPoints(); quad_index++)
221 double wJ = jacobian_determinant * mpQuadRule->GetWeight(quad_index);
222 const ChastePoint<DIM-1>& quad_point = mpQuadRule->rGetQuadPoint(quad_index);
225 c_vector<double,DIM> traction = zero_vector<double>(DIM);
226 switch (mpProblemDefinition->GetTractionBoundaryConditionType())
228 case ELEMENTWISE_TRACTION:
230 traction = mpProblemDefinition->rGetElementwiseTractions()[boundaryConditionIndex];
238 for (
unsigned index=0; index<NUM_NODES_PER_ELEMENT*DIM; index++)
240 unsigned spatial_dim = index%DIM;
241 unsigned node_index = (index-spatial_dim)/DIM;
243 assert(node_index < NUM_NODES_PER_ELEMENT);
245 rBelem(index) += traction(spatial_dim) * phi(node_index) * wJ;
251 #endif // CONTINUUMMECHANICSNEUMANNBCSASSEMBLER_HPP_
void AssembleOnBoundaryElement(BoundaryElement< DIM-1, DIM > &rElement, c_vector< double, STENCIL_SIZE > &rBElem, unsigned boundaryConditionIndex)
static const unsigned PRESSURE_BLOCK_SIZE_ELEMENTAL
GaussianQuadratureRule< DIM-1 > * mpQuadRule
#define EXCEPTION(message)
AbstractTetrahedralMesh< DIM, DIM > * mpMesh
static const unsigned STENCIL_SIZE
static void ComputeBasisFunctions(const ChastePoint< ELEMENT_DIM > &rPoint, c_vector< double,(ELEMENT_DIM+1)*(ELEMENT_DIM+2)/2 > &rReturnValue)
virtual ~ContinuumMechanicsNeumannBcsAssembler()
static const unsigned NUM_VERTICES_PER_ELEMENT
ContinuumMechanicsNeumannBcsAssembler(AbstractTetrahedralMesh< DIM, DIM > *pMesh, ContinuumMechanicsProblemDefinition< DIM > *pProblemDefinition)
unsigned GetIndex() const
static const unsigned NUM_NODES_PER_ELEMENT
ContinuumMechanicsProblemDefinition< DIM > * mpProblemDefinition
static const unsigned SPATIAL_BLOCK_SIZE_ELEMENTAL