@@ -24,7 +24,7 @@ cfg['library_dirs'] = dolfin_pc['library_dirs']
2424
2525using namespace dolfin ;
2626
27- // Base case for all divergence computations.
27+ // Base case for all divergence computations.
2828// Compute divergence of vector field u.
2929void cr_divergence (Function& divu, const Function& u)
3030{
@@ -36,7 +36,7 @@ void cr_divergence(Function& divu, const Function& u)
3636 std::shared_ptr<const GenericVector> U = u.vector ();
3737 std::shared_ptr<GenericVector> DIVU = divu.vector ();
3838
39- // Figure out about the local dofs of DG0
39+ // Figure out about the local dofs of DG0
4040 std::pair<std::size_t , std::size_t >
4141 first_last_dof = DG0_dofmap->ownership_range ();
4242 std::size_t first_dof = first_last_dof.first ;
@@ -48,7 +48,7 @@ void cr_divergence(Function& divu, const Function& u)
4848
4949 // Get topological dimension so that we know what Facet is
5050 const Mesh mesh = *u.function_space ()->mesh ();
51- std::size_t tdim = mesh.topology ().dim ();
51+ std::size_t tdim = mesh.topology ().dim ();
5252 // Get the info on length of u and gdim for the dot product
5353 std::size_t gdim = mesh.geometry ().dim ();
5454 std::size_t udim = u.value_dimension (0 ); // Rank 1!
@@ -65,10 +65,10 @@ void cr_divergence(Function& divu, const Function& u)
6565 {
6666 Point cell_mp = cell->midpoint ();
6767 double cell_volume = cell->volume ();
68-
68+
6969 // Dofs of CR on all facets of the cell, global order
7070 auto facets_dofs = CR1_dofmap->cell_dofs (cell->index ());
71-
71+
7272 double cell_integral = 0 ;
7373 std::size_t local_facet_index = 0 ;
7474 for (FacetIterator facet (*cell); !facet.end (); ++facet)
@@ -79,7 +79,7 @@ void cr_divergence(Function& divu, const Function& u)
7979 else if (tdim == 3 )
8080 facet_measure = Face (mesh, facet->index ()).area ();
8181 // Tdim 1 will not happen because CR is not defined there
82-
82+
8383 Point facet_normal = facet->normal ();
8484
8585 // Flip the normal if it is not outer already
@@ -115,7 +115,7 @@ void cr_divergence(Function& divu, const Function& u)
115115void cr_divergence2 (Function& divu, const Function& u,
116116 const FunctionSpace& DGscalar, const FunctionSpace& CRvector)
117117{
118- // Divu scalar from u vector
118+ // Divu scalar from u vector
119119 std::size_t u_rank = u.value_rank ();
120120 std::size_t divu_rank = divu.value_rank ();
121121 if ((divu_rank == 0 ) and (u_rank == 1 ))
@@ -139,10 +139,10 @@ void cr_divergence2(Function& divu, const Function& u,
139139 std::shared_ptr<const GenericVector> U = u.vector ();
140140 std::shared_ptr<GenericVector> DIVU = divu.vector ();
141141
142- // Get dofmaps
142+ // Get dofmaps
143143 std::shared_ptr<const FunctionSpace> DGvector = divu.function_space ();
144144 std::shared_ptr<const FunctionSpace> CRtensor = u.function_space ();
145-
145+
146146 std::size_t len_divu = divu.value_dimension (0 );
147147 // With scalar U can be extracted only once
148148 std::vector<double > U_values;
@@ -163,7 +163,7 @@ void cr_divergence2(Function& divu, const Function& u,
163163 CRi_rows = CRvector[i]->dofmap ()->dofs ();
164164 std::size_t m = CRi_rows.size ();
165165 U_i->zero ();
166- U_i->set (U_values.data (), m, CRi_rows.data ());
166+ U_i->set (U_values.data (), m, CRi_rows.data ());
167167 U_i->apply (" insert" );
168168 }
169169 // For tensor, U_i represents T_ij, (T_i0, T_i1, T_i2)
@@ -183,7 +183,7 @@ void cr_divergence2(Function& divu, const Function& u,
183183 std::vector<dolfin::la_index>
184184 CRj_rows = CRvector[j]->dofmap ()->dofs ();
185185
186- U_i->set (U_values.data (), m, CRj_rows.data ());
186+ U_i->set (U_values.data (), m, CRj_rows.data ());
187187 U_i->apply (" insert" );
188188 }
189189 }
@@ -197,22 +197,22 @@ void cr_divergence2(Function& divu, const Function& u,
197197 std::size_t m = DGi_rows.size ();
198198 std::vector<double > DIVU_i_values;
199199 DIVU_i->get_local (DIVU_i_values);
200- DIVU->set (DIVU_i_values.data (), m, DGi_rows.data ());
200+ DIVU->set (DIVU_i_values.data (), m, DGi_rows.data ());
201201 DIVU->apply (" insert" );
202202 }
203203 }
204204}
205- // Base case for all divergence computations.
205+ // Base case for all divergence computations.
206206// Compute divergence of vector field u.
207207void cr_divergence_matrix (GenericMatrix& M, GenericMatrix& A,
208- const FunctionSpace& DGscalar,
208+ const FunctionSpace& DGscalar,
209209 const FunctionSpace& CRvector)
210210{
211211 std::shared_ptr<const GenericDofMap>
212212 CR1_dofmap = CRvector.dofmap (),
213213 DG0_dofmap = DGscalar.dofmap ();
214214
215- // Figure out about the local dofs of DG0
215+ // Figure out about the local dofs of DG0
216216 std::pair<std::size_t , std::size_t >
217217 first_last_dof = DG0_dofmap->ownership_range ();
218218 std::size_t first_dof = first_last_dof.first ;
@@ -221,25 +221,25 @@ void cr_divergence_matrix(GenericMatrix& M, GenericMatrix& A,
221221
222222 // Get topological dimension so that we know what Facet is
223223 const Mesh mesh = *DGscalar.mesh ();
224- std::size_t tdim = mesh.topology ().dim ();
224+ std::size_t tdim = mesh.topology ().dim ();
225225 std::size_t gdim = mesh.geometry ().dim ();
226-
226+
227227 std::vector<std::size_t > columns;
228228 std::vector<double > values;
229-
229+
230230 // Fill the values
231231 for (CellIterator cell (mesh); !cell.end (); ++cell)
232232 {
233233 auto dg_dofs = DG0_dofmap->cell_dofs (cell->index ());
234234 // There is only one DG0 dof per cell
235235 dolfin::la_index cell_dof = dg_dofs[0 ];
236-
236+
237237 Point cell_mp = cell->midpoint ();
238238 double cell_volume = cell->volume ();
239- std::size_t local_facet_index = 0 ;
240-
239+ std::size_t local_facet_index = 0 ;
240+
241241 auto cr_dofs = CR1_dofmap->cell_dofs (cell->index ());
242-
242+
243243 for (FacetIterator facet (*cell); !facet.end (); ++facet)
244244 {
245245 double facet_measure=0 ;
@@ -248,23 +248,23 @@ void cr_divergence_matrix(GenericMatrix& M, GenericMatrix& A,
248248 else if (tdim == 3 )
249249 facet_measure = Face (mesh, facet->index ()).area ();
250250 // Tdim 1 will not happen because CR is not defined there
251-
251+
252252 Point facet_normal = facet->normal ();
253253
254254 // Flip the normal if it is not outer already
255255 Point facet_mp = facet->midpoint ();
256256 double sign = (facet_normal.dot (facet_mp - cell_mp) > 0.0 ) ? 1.0 : -1.0 ;
257257 facet_normal *= (sign*facet_measure/cell_volume);
258-
258+
259259 // Dofs of CR on the facet, local order
260260 std::vector<std::size_t > facet_dofs;
261261 CR1_dofmap->tabulate_facet_dofs (facet_dofs, local_facet_index);
262-
262+
263263 for (std::size_t j = 0 ; j < facet_dofs.size (); j++)
264- {
264+ {
265265 columns.push_back (cr_dofs[facet_dofs[j]]);
266266 values.push_back (facet_normal[j]);
267- }
267+ }
268268 local_facet_index += 1 ;
269269 }
270270 M.setrow (cell_dof, columns, values);
@@ -275,7 +275,6 @@ void cr_divergence_matrix(GenericMatrix& M, GenericMatrix& A,
275275 // std::shared_ptr<GenericMatrix> Cp = MatMatMult(M, A);
276276 // return Cp;
277277}
278-
279278namespace py = pybind11;
280279
281280PYBIND11_MODULE (cr_divergence, m)
@@ -299,4 +298,3 @@ PYBIND11_MODULE(cr_divergence, m)
299298 cr_divergence_matrix (M, A, _U, _V);
300299 });
301300}
302-
0 commit comments