const double dx = fe.JxW(k) * factor;
for (unsigned int i=0; i<n_dofs; ++i)
- for (unsigned int j=i; j<n_dofs; ++j)
- for (unsigned int d=0; d<n_components; ++d)
- M(i,j) += dx
- * fe.shape_value_component(j,k,d)
+ for (unsigned int d=0; d<n_components; ++d)
+ {
+ M(i,i) += dx
+ * fe.shape_value_component(i,k,d)
* fe.shape_value_component(i,k,d);
+ for (unsigned int j=i+1; j<n_dofs; ++j)
+ {
+ const double Mij = dx
+ * fe.shape_value_component(j,k,d)
+ * fe.shape_value_component(i,k,d);
+ M(i,j) += Mij;
+ M(j,i) += Mij;
+ }
+ }
}
-
- // exploit symmetry
- for (unsigned int i=0; i<n_dofs; ++i)
- for (unsigned int j=i+1; j<n_dofs; ++j)
- M(j,i) = M(i,j);
}
/**
const double dx = fe.JxW(k) * weights[k];
for (unsigned int i=0; i<n_dofs; ++i)
- for (unsigned int j=i; j<n_dofs; ++j)
- for (unsigned int d=0; d<n_components; ++d)
- M(i,j) += dx
- * fe.shape_value_component(j,k,d)
+ for (unsigned int d=0; d<n_components; ++d)
+ {
+ M(i,i) += dx
+ * fe.shape_value_component(i,k,d)
* fe.shape_value_component(i,k,d);
- }
- //exploit symmetry
- for (unsigned int i=0; i<n_dofs; ++i)
- for (unsigned int j=i+1; j<n_dofs; ++j)
- M(j,i) = M(i,j);
+ for (unsigned int j=i+1; j<n_dofs; ++j)
+ {
+ const double Mij = dx
+ * fe.shape_value_component(j,k,d)
+ * fe.shape_value_component(i,k,d);
+ M(i,j) += Mij;
+ M(j,i) += Mij;
+ }
+ }
+ }
}
/**
{
const double dx = fe.JxW(k) * factor;
for (unsigned int i=0; i<n_dofs; ++i)
- {
- for (unsigned int j=i; j<n_dofs; ++j)
- for (unsigned int d=0; d<n_components; ++d)
- M(i,j) += dx *
- (fe.shape_grad_component(j,k,d) * fe.shape_grad_component(i,k,d));
- }
+ for (unsigned int d=0; d<n_components; ++d)
+ {
+ M(i,i) += dx *
+ (fe.shape_grad_component(i,k,d) * fe.shape_grad_component(i,k,d));
+
+ for (unsigned int j=i+1; j<n_dofs; ++j)
+ {
+ const double Mij = dx *
+ (fe.shape_grad_component(j,k,d) * fe.shape_grad_component(i,k,d));
+ M(i,j) += Mij;
+ M(j,i) += Mij;
+ }
+ }
}
- // exploit symmetry
- for (unsigned int i=0; i<n_dofs; ++i)
- for (unsigned int j=i+1; j<n_dofs; ++j)
- M(j,i) = M(i,j);
-
}
/**