120 double result_on_element = 0;
127 double jacobian_determinant;
128 c_matrix<double, SPACE_DIM, ELEMENT_DIM> jacobian;
129 c_matrix<double, ELEMENT_DIM, SPACE_DIM> inverse_jacobian;
135 for (
unsigned quad_index=0; quad_index < quad_rule.
GetNumQuadPoints(); quad_index++)
139 c_vector<double, ELEMENT_DIM+1> phi;
141 c_matrix<double, ELEMENT_DIM, ELEMENT_DIM+1> grad_phi;
146 c_vector<double,PROBLEM_DIM> u = zero_vector<double>(PROBLEM_DIM);
147 c_matrix<double,PROBLEM_DIM,SPACE_DIM> grad_u = zero_matrix<double>(PROBLEM_DIM,SPACE_DIM);
149 for (
unsigned i=0; i<num_nodes; i++)
151 const c_vector<double, SPACE_DIM>& r_node_loc = rElement.
GetNode(i)->rGetLocation();
154 x.rGetLocation() += phi(i)*r_node_loc;
158 for (
unsigned index_of_unknown=0; index_of_unknown<PROBLEM_DIM; index_of_unknown++)
163 unsigned index_into_vec = PROBLEM_DIM*node_global_index + index_of_unknown;
165 double u_at_node = mSolutionReplicated[index_into_vec];
166 u(index_of_unknown) += phi(i)*u_at_node;
169 for (
unsigned j=0; j<ELEMENT_DIM; j++)
171 grad_u(index_of_unknown,j) += grad_phi(j,i)*u_at_node;
176 double wJ = jacobian_determinant * quad_rule.
GetWeight(quad_index);
177 result_on_element += GetIntegrand(x, u, grad_u) * wJ;
180 return result_on_element;
186 assert(ELEMENT_DIM == SPACE_DIM);
188 mSolutionReplicated.ReplicatePetscVector(solution);
189 if (mSolutionReplicated.GetSize() != rMesh.
GetNumNodes() * PROBLEM_DIM)
191 EXCEPTION(
"The solution size does not match the mesh");
194 double local_result = 0;
204 local_result += CalculateOnElement(*iter);
211 throw exception_in_integral;
216 MPI_Allreduce(&local_result, &final_result, 1, MPI_DOUBLE, MPI_SUM, PETSC_COMM_WORLD);
virtual double GetIntegrand(ChastePoint< SPACE_DIM > &rX, c_vector< double, PROBLEM_DIM > &rU, c_matrix< double, PROBLEM_DIM, SPACE_DIM > &rGradU)=0
void CalculateInverseJacobian(c_matrix< double, SPACE_DIM, ELEMENT_DIM > &rJacobian, double &rJacobianDeterminant, c_matrix< double, ELEMENT_DIM, SPACE_DIM > &rInverseJacobian)
static void ComputeTransformedBasisFunctionDerivatives(const ChastePoint< ELEMENT_DIM > &rPoint, const c_matrix< double, ELEMENT_DIM, ELEMENT_DIM > &rInverseJacobian, c_matrix< double, ELEMENT_DIM, ELEMENT_DIM+1 > &rReturnValue)