2121#include < aspect/simulator/assemblers/stokes_anisotropic_viscosity.h>
2222
2323#include < aspect/gravity_model/interface.h>
24+ #include < aspect/material_model/additional_outputs/anisotropic_viscosity.h>
2425
2526#include < deal.II/base/signaling_nan.h>
2627
@@ -37,9 +38,13 @@ namespace aspect
3738 internal::Assembly::Scratch::StokesPreconditioner<dim> &scratch = dynamic_cast <internal::Assembly::Scratch::StokesPreconditioner<dim>&> (scratch_base);
3839 internal::Assembly::CopyData::StokesPreconditioner<dim> &data = dynamic_cast <internal::Assembly::CopyData::StokesPreconditioner<dim>&> (data_base);
3940
40- std::shared_ptr<const MaterialModel::AnisotropicViscosity<dim>> anisotropic_viscosity =
41+ const std::shared_ptr<const MaterialModel::AnisotropicViscosity<dim>> anisotropic_viscosity =
4142 scratch.material_model_outputs .template get_additional_output_object <MaterialModel::AnisotropicViscosity<dim>>();
4243
44+ Assert (anisotropic_viscosity != nullptr ,
45+ ExcMessage (" This assembler should only be used with material models that provide "
46+ " an anisotropic viscosity tensor, but none was provided." ));
47+
4348 const Introspection<dim> &introspection = this ->introspection ();
4449 const FiniteElement<dim> &fe = this ->get_fe ();
4550 const unsigned int stokes_dofs_per_cell = data.local_dof_indices .size ();
@@ -78,30 +83,16 @@ namespace aspect
7883
7984 const double eta = scratch.material_model_outputs .viscosities [q];
8085 const double one_over_eta = 1 . / eta;
81-
82- const bool use_tensor = (anisotropic_viscosity != nullptr );
83-
84- const SymmetricTensor<4 , dim> &stress_strain_director = (use_tensor)
85- ?
86- anisotropic_viscosity->stress_strain_directors [q]
87- :
88- dealii::identity_tensor<dim>();
89-
90-
91-
86+ const SymmetricTensor<4 , dim> &stress_strain_director = anisotropic_viscosity->stress_strain_directors [q];
9287 const double JxW = scratch.finite_element_values .JxW (q);
9388
9489 for (unsigned int i = 0 ; i < stokes_dofs_per_cell; ++i)
9590 for (unsigned int j = 0 ; j < stokes_dofs_per_cell; ++j)
9691 if (scratch.dof_component_indices [i] ==
9792 scratch.dof_component_indices [j])
98- data.local_matrix (i, j) += ((
99- use_tensor ?
100- 2.0 * eta * (scratch.grads_phi_u [i]
101- * stress_strain_director
102- * scratch.grads_phi_u [j]) :
103- 2.0 * eta * (scratch.grads_phi_u [i]
104- * scratch.grads_phi_u [j]))
93+ data.local_matrix (i, j) += (2.0 * eta * (scratch.grads_phi_u [i]
94+ * stress_strain_director
95+ * scratch.grads_phi_u [j])
10596 + one_over_eta * pressure_scaling
10697 * pressure_scaling
10798 * (scratch.phi_p [i]
@@ -140,6 +131,10 @@ namespace aspect
140131 const std::shared_ptr<const MaterialModel::AnisotropicViscosity<dim>> anisotropic_viscosity =
141132 scratch.material_model_outputs .template get_additional_output_object <MaterialModel::AnisotropicViscosity<dim>>();
142133
134+ Assert (anisotropic_viscosity != nullptr ,
135+ ExcMessage (" This assembler should only be used with material models that provide "
136+ " an anisotropic viscosity tensor, but none was provided." ));
137+
143138 const Introspection<dim> &introspection = this ->introspection ();
144139 const FiniteElement<dim> &fe = this ->get_fe ();
145140 const unsigned int stokes_dofs_per_cell = data.local_dof_indices .size ();
@@ -174,26 +169,15 @@ namespace aspect
174169 }
175170
176171 const double eta_two_thirds = scratch.material_model_outputs .viscosities [q] * 2.0 / 3.0 ;
177-
178- const bool use_tensor = (anisotropic_viscosity != nullptr );
179-
180- const SymmetricTensor<4 , dim> &stress_strain_director = (use_tensor)
181- ?
182- anisotropic_viscosity->stress_strain_directors [q]
183- :
184- dealii::identity_tensor<dim>();
185-
172+ const SymmetricTensor<4 , dim> &stress_strain_director = anisotropic_viscosity->stress_strain_directors [q];
186173 const double JxW = scratch.finite_element_values .JxW (q);
187174
188175 for (unsigned int i = 0 ; i < stokes_dofs_per_cell; ++i)
189176 for (unsigned int j = 0 ; j < stokes_dofs_per_cell; ++j)
190177 if (scratch.dof_component_indices [i] ==
191178 scratch.dof_component_indices [j])
192- data.local_matrix (i, j) += (- (use_tensor ?
193- eta_two_thirds * (scratch.div_phi_u [i] * trace (stress_strain_director * scratch.grads_phi_u [j]))
194- :
195- eta_two_thirds * (scratch.div_phi_u [i] * scratch.div_phi_u [j])
196- ))
179+ data.local_matrix (i, j) += (- eta_two_thirds *
180+ (scratch.div_phi_u [i] * trace (stress_strain_director * scratch.grads_phi_u [j])))
197181 * JxW;
198182 }
199183 }
@@ -212,6 +196,10 @@ namespace aspect
212196 const std::shared_ptr<const MaterialModel::AnisotropicViscosity<dim>> anisotropic_viscosity =
213197 scratch.material_model_outputs .template get_additional_output_object <MaterialModel::AnisotropicViscosity<dim>>();
214198
199+ Assert (anisotropic_viscosity != nullptr ,
200+ ExcMessage (" This assembler should only be used with material models that provide "
201+ " an anisotropic viscosity tensor, but none was provided." ));
202+
215203 const Introspection<dim> &introspection = this ->introspection ();
216204 const FiniteElement<dim> &fe = this ->get_fe ();
217205 const unsigned int stokes_dofs_per_cell = data.local_dof_indices .size ();
@@ -247,13 +235,7 @@ namespace aspect
247235 :
248236 numbers::signaling_nan<double >());
249237
250- const bool use_tensor = (anisotropic_viscosity != nullptr );
251-
252- const SymmetricTensor<4 , dim> &stress_strain_director = (use_tensor)
253- ?
254- anisotropic_viscosity->stress_strain_directors [q]
255- :
256- dealii::identity_tensor<dim>();
238+ const SymmetricTensor<4 , dim> &stress_strain_director = anisotropic_viscosity->stress_strain_directors [q];
257239
258240 const Tensor<1 ,dim>
259241 gravity = this ->get_gravity_model ().gravity_vector (scratch.finite_element_values .quadrature_point (q));
@@ -274,18 +256,15 @@ namespace aspect
274256 if (scratch.rebuild_stokes_matrix )
275257 for (unsigned int j=0 ; j<stokes_dofs_per_cell; ++j)
276258 {
277- data.local_matrix (i,j) += ( (use_tensor ?
278- eta * 2.0 * (scratch.grads_phi_u [i] * stress_strain_director * scratch.grads_phi_u [j])
279- :
280- eta * 2.0 * (scratch.grads_phi_u [i] * scratch.grads_phi_u [j]))
281- // assemble \nabla p as -(p, div v):
282- - (pressure_scaling *
283- scratch.div_phi_u [i] * scratch.phi_p [j])
284- // assemble the term -div(u) as -(div u, q).
285- // Note the negative sign to make this
286- // operator adjoint to the grad p term:
287- - (pressure_scaling *
288- scratch.phi_p [i] * scratch.div_phi_u [j]))
259+ data.local_matrix (i,j) += (eta * 2.0 * (scratch.grads_phi_u [i] * stress_strain_director * scratch.grads_phi_u [j])
260+ // assemble \nabla p as -(p, div v):
261+ - (pressure_scaling *
262+ scratch.div_phi_u [i] * scratch.phi_p [j])
263+ // assemble the term -div(u) as -(div u, q).
264+ // Note the negative sign to make this
265+ // operator adjoint to the grad p term:
266+ - (pressure_scaling *
267+ scratch.phi_p [i] * scratch.div_phi_u [j]))
289268 * JxW;
290269 }
291270 }
@@ -336,6 +315,10 @@ namespace aspect
336315 const std::shared_ptr<const MaterialModel::AnisotropicViscosity<dim>> anisotropic_viscosity =
337316 scratch.material_model_outputs .template get_additional_output_object <MaterialModel::AnisotropicViscosity<dim>>();
338317
318+ Assert (anisotropic_viscosity != nullptr ,
319+ ExcMessage (" This assembler should only be used with material models that provide "
320+ " an anisotropic viscosity tensor, but none was provided." ));
321+
339322 const Introspection<dim> &introspection = this ->introspection ();
340323 const FiniteElement<dim> &fe = this ->get_fe ();
341324 const unsigned int stokes_dofs_per_cell = data.local_dof_indices .size ();
@@ -357,25 +340,14 @@ namespace aspect
357340
358341 // Viscosity scalar
359342 const double eta_two_thirds = scratch.material_model_outputs .viscosities [q] * 2.0 / 3.0 ;
360-
361- const bool use_tensor = (anisotropic_viscosity != nullptr );
362-
363- const SymmetricTensor<4 , dim> &stress_strain_director = (use_tensor)
364- ?
365- anisotropic_viscosity->stress_strain_directors [q]
366- :
367- dealii::identity_tensor<dim>();
368-
343+ const SymmetricTensor<4 , dim> &stress_strain_director = anisotropic_viscosity->stress_strain_directors [q];
369344 const double JxW = scratch.finite_element_values .JxW (q);
370345
371346 for (unsigned int i=0 ; i<stokes_dofs_per_cell; ++i)
372347 for (unsigned int j=0 ; j<stokes_dofs_per_cell; ++j)
373348 {
374- data.local_matrix (i,j) += (- (use_tensor ?
375- eta_two_thirds * (scratch.div_phi_u [i] * trace (stress_strain_director * scratch.grads_phi_u [j]))
376- :
377- eta_two_thirds * (scratch.div_phi_u [i] * scratch.div_phi_u [j])
378- ))
349+ data.local_matrix (i,j) += (-eta_two_thirds * (scratch.div_phi_u [i] * trace (stress_strain_director * scratch.grads_phi_u [j]))
350+ )
379351 * JxW;
380352 }
381353 }
0 commit comments