Skip to content

Commit

Permalink
Merge pull request #69 from peterrum/EvaluationFlags
Browse files Browse the repository at this point in the history
Use EvaluationFlags
  • Loading branch information
peterrum authored Jun 30, 2022
2 parents a80bb7d + ddae116 commit b65df32
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 71 deletions.
2 changes: 1 addition & 1 deletion applications/periodic_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ PeriodicChannelProblem<dim>::local_compute_force(
{
vel_values.submit_value(force, q);
}
vel_values.integrate(true, false);
vel_values.integrate(EvaluationFlags::values);
vel_values.distribute_local_to_global(dst);
}
}
Expand Down
4 changes: 2 additions & 2 deletions include/adaflo/sharp_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ class FrontTrackingSolver : public SharpInterfaceSolver
navier_stokes_solver.get_matrix().begin_densities(cell)[q]);
phi.submit_value(force, q);
}
phi.integrate_scatter(true, false, vec);
phi.integrate_scatter(EvaluationFlags::values, vec);
}
},
navier_stokes_solver.user_rhs.block(0),
Expand Down Expand Up @@ -1040,7 +1040,7 @@ class MixedLevelSetSolver : public SharpInterfaceSolver
navier_stokes_solver.get_matrix().begin_densities(cell)[q]);
phi.submit_value(force, q);
}
phi.integrate_scatter(true, false, vec);
phi.integrate_scatter(EvaluationFlags::values, vec);
}
},
navier_stokes_solver.user_rhs.block(0),
Expand Down
6 changes: 3 additions & 3 deletions include/adaflo/sharp_interface_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -1008,13 +1008,13 @@ compute_force_vector_regularized(const MatrixFree<dim, double> &matrix_free,
{
level_set.reinit(cell);
level_set.read_dof_values_plain(level_set_as_heaviside);
level_set.evaluate(false, true);
level_set.evaluate(EvaluationFlags::gradients);

surface_tension.reinit(cell);

curvature.reinit(cell);
curvature.read_dof_values_plain(curvature_solution);
curvature.evaluate(true, false);
curvature.evaluate(EvaluationFlags::values);

for (unsigned int q_index = 0; q_index < surface_tension.n_q_points; ++q_index)
{
Expand All @@ -1023,7 +1023,7 @@ compute_force_vector_regularized(const MatrixFree<dim, double> &matrix_free,
curvature.get_value(q_index),
q_index);
}
surface_tension.integrate_scatter(true, false, force_rhs);
surface_tension.integrate_scatter(EvaluationFlags::values, force_rhs);
}
},
force_rhs,
Expand Down
14 changes: 7 additions & 7 deletions source/level_set_okz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,13 @@ LevelSetOKZSolver<dim>::local_projection_matrix(
for (unsigned int j = 0; j < phi.dofs_per_cell; ++j)
phi.begin_dof_values()[j] = VectorizedArray<double>();
phi.begin_dof_values()[i] = 1.;
phi.evaluate(true, true);
phi.evaluate(EvaluationFlags::values | EvaluationFlags::gradients);
for (unsigned int q = 0; q < phi.n_q_points; ++q)
{
phi.submit_value(phi.get_value(q), q);
phi.submit_gradient(phi.get_gradient(q) * damping, q);
}
phi.integrate(true, true);
phi.integrate(EvaluationFlags::values | EvaluationFlags::gradients);
for (unsigned int v = 0; v < data.n_active_entries_per_cell_batch(cell); ++v)
for (unsigned int j = 0; j < phi.dofs_per_cell; ++j)
scratch.matrices[v](phi.get_shape_info().lexicographic_numbering[j],
Expand Down Expand Up @@ -353,7 +353,7 @@ LevelSetOKZSolver<dim>::local_compute_force(
vector_t *densities = this->navier_stokes.get_matrix().begin_densities(cell);
vector_t *viscosities =
this->navier_stokes.get_matrix().begin_viscosities(cell);
ls_values.evaluate(true, false);
ls_values.evaluate(EvaluationFlags::values);
for (unsigned int q = 0; q < ls_values.n_q_points; ++q)
{
densities[q] = this->parameters.density +
Expand All @@ -374,14 +374,14 @@ LevelSetOKZSolver<dim>::local_compute_force(
ls_values.get_dof_value(j);
pre_values.submit_dof_value(projected_value, i);
}
pre_values.evaluate(false, true);
pre_values.evaluate(EvaluationFlags::gradients);
}
else
ls_values.evaluate(false, true);
ls_values.evaluate(EvaluationFlags::gradients);

// evaluate curvature and level set gradient
curv_values.read_dof_values_plain(this->solution.block(1));
curv_values.evaluate(true, false);
curv_values.evaluate(EvaluationFlags::values);

// evaluate surface tension force and gravity force
for (unsigned int q = 0; q < curv_values.n_q_points; ++q)
Expand All @@ -402,7 +402,7 @@ LevelSetOKZSolver<dim>::local_compute_force(

vel_values.submit_value(force, q);
}
vel_values.integrate(true, false);
vel_values.integrate(EvaluationFlags::values);

vel_values.distribute_local_to_global(dst);
}
Expand Down
27 changes: 18 additions & 9 deletions source/level_set_okz_advance_concentration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ LevelSetOKZSolverAdvanceConcentration<dim>::local_advance_concentration(
&evaluated_convection[cell * ls_values.n_q_points];
ls_values.reinit(cell);

ls_values.gather_evaluate(src, true, true);
ls_values.gather_evaluate(src,
EvaluationFlags::values | EvaluationFlags::gradients);

for (unsigned int q = 0; q < ls_values.n_q_points; ++q)
{
Expand All @@ -246,7 +247,11 @@ LevelSetOKZSolverAdvanceConcentration<dim>::local_advance_concentration(
if (this->parameters.convection_stabilization)
ls_values.submit_gradient(artificial_viscosities[cell] * ls_grad, q);
}
ls_values.integrate_scatter(true, this->parameters.convection_stabilization, dst);
ls_values.integrate_scatter(EvaluationFlags::values |
(this->parameters.convection_stabilization ?
EvaluationFlags::gradients :
EvaluationFlags::nothing),
dst);
}
}

Expand Down Expand Up @@ -327,12 +332,12 @@ LevelSetOKZSolverAdvanceConcentration<dim>::local_advance_concentration_rhs(
ls_values_old.read_dof_values_plain(this->solution_old);
ls_values_old_old.read_dof_values_plain(this->solution_old_old);

vel_values.evaluate(true, false);
vel_values_old.evaluate(true, false);
vel_values_old_old.evaluate(true, false);
ls_values.evaluate(true, true);
ls_values_old.evaluate(true, true);
ls_values_old_old.evaluate(true, true);
vel_values.evaluate(EvaluationFlags::values);
vel_values_old.evaluate(EvaluationFlags::values);
vel_values_old_old.evaluate(EvaluationFlags::values);
ls_values.evaluate(EvaluationFlags::values | EvaluationFlags::gradients);
ls_values_old.evaluate(EvaluationFlags::values | EvaluationFlags::gradients);
ls_values_old_old.evaluate(EvaluationFlags::values | EvaluationFlags::gradients);

if (this->parameters.convection_stabilization)
{
Expand Down Expand Up @@ -381,7 +386,11 @@ LevelSetOKZSolverAdvanceConcentration<dim>::local_advance_concentration_rhs(
ls_values.submit_gradient(-artificial_viscosities[cell] * ls_grad, q);
velocities[q] = vel_values.get_value(q);
}
ls_values.integrate_scatter(true, this->parameters.convection_stabilization, dst);
ls_values.integrate_scatter(EvaluationFlags::values |
(this->parameters.convection_stabilization ?
EvaluationFlags::gradients :
EvaluationFlags::nothing),
dst);
}
}

Expand Down
14 changes: 10 additions & 4 deletions source/level_set_okz_compute_curvature.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ LevelSetOKZSolverComputeCurvature<dim>::local_compute_curvature(
phi.read_dof_values(src);
// If diffusion_setting is true a damping term is added to the weak form
// i.e. diffusion_setting=1 => diffusion_setting%2 == 1 is true.
phi.evaluate(diffusion_setting < 2, diffusion_setting % 2 == 1);
phi.evaluate(
((diffusion_setting < 2) ? EvaluationFlags::values : EvaluationFlags::nothing) |
((diffusion_setting % 2 == 1) ? EvaluationFlags::gradients :
EvaluationFlags::nothing));
const VectorizedArray<double> damping =
diffusion_setting % 2 == 1 ?
Utilities::fixed_power<2>(
Expand All @@ -117,7 +120,10 @@ LevelSetOKZSolverComputeCurvature<dim>::local_compute_curvature(
if (diffusion_setting % 2 == 1)
phi.submit_gradient(phi.get_gradient(q) * damping, q);
}
phi.integrate(diffusion_setting < 2, diffusion_setting % 2 == 1);
phi.integrate(
((diffusion_setting < 2) ? EvaluationFlags::values : EvaluationFlags::nothing) |
((diffusion_setting % 2 == 1) ? EvaluationFlags::gradients :
EvaluationFlags::nothing));
phi.distribute_local_to_global(dst);
}
}
Expand Down Expand Up @@ -239,10 +245,10 @@ LevelSetOKZSolverComputeCurvature<dim>::local_compute_curvature_rhs(

if (all_zero == false)
{
normal_values.evaluate(false, true, false);
normal_values.evaluate(EvaluationFlags::gradients);
for (unsigned int q = 0; q < normal_values.n_q_points; ++q)
curv_values.submit_value(-get_divergence(normal_values, q), q);
curv_values.integrate(true, false);
curv_values.integrate(EvaluationFlags::values);
curv_values.distribute_local_to_global(dst);
}
}
Expand Down
8 changes: 4 additions & 4 deletions source/level_set_okz_compute_normal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ LevelSetOKZSolverComputeNormal<dim>::local_compute_normal(
{
phi.reinit(cell);
phi.read_dof_values(src);
phi.evaluate(true, true);
phi.evaluate(EvaluationFlags::values | EvaluationFlags::gradients);
const VectorizedArray<Number> damping =
Number(parameters.damping_scale_factor) *
Utilities::fixed_power<2>(
Expand All @@ -111,7 +111,7 @@ LevelSetOKZSolverComputeNormal<dim>::local_compute_normal(
phi.submit_value(phi.get_value(q), q);
phi.submit_gradient(phi.get_gradient(q) * damping, q);
}
phi.integrate(true, true);
phi.integrate(EvaluationFlags::values | EvaluationFlags::gradients);
phi.distribute_local_to_global(dst);
}
}
Expand Down Expand Up @@ -143,12 +143,12 @@ LevelSetOKZSolverComputeNormal<dim>::local_compute_normal_rhs(
ls_values.reinit(cell);

ls_values.read_dof_values_plain(this->level_set_solution);
ls_values.evaluate(false, true, false);
ls_values.evaluate(EvaluationFlags::gradients);

for (unsigned int q = 0; q < normal_values.n_q_points; ++q)
normal_values.submit_value(ls_values.get_gradient(q), q);

normal_values.integrate(true, false);
normal_values.integrate(EvaluationFlags::values);
normal_values.distribute_local_to_global(dst);
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/level_set_okz_preconditioner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ initialize_projection_matrix(
for (unsigned int j = 0; j < phi.dofs_per_cell; ++j) \
phi.begin_dof_values()[j] = VectorizedArray<double>(); \
phi.begin_dof_values()[i] = 1.; \
phi.evaluate(true, true); \
phi.evaluate(EvaluationFlags::values | EvaluationFlags::gradients); \
for (unsigned int q = 0; q < phi.n_q_points; ++q) \
{ \
phi.submit_value(phi.get_value(q), q); \
phi.submit_gradient(phi.get_gradient(q) * damping, q); \
} \
phi.integrate(true, true); \
phi.integrate(EvaluationFlags::values | EvaluationFlags::gradients); \
for (unsigned int v = 0; v < data.n_active_entries_per_cell_batch(cell); ++v) \
for (unsigned int j = 0; j < phi.dofs_per_cell; ++j) \
scratch.matrices[v](phi.get_shape_info().lexicographic_numbering[j], \
Expand Down
10 changes: 5 additions & 5 deletions source/level_set_okz_reinitialization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ LevelSetOKZSolverReinitialization<dim>::local_reinitialize(
{
phi.reinit(cell);
phi.read_dof_values(src);
phi.evaluate(true, true, false);
phi.evaluate(EvaluationFlags::values | EvaluationFlags::gradients);

VectorizedArray<double> cell_diameter = this->cell_diameters[cell];
VectorizedArray<double> diffusion =
Expand All @@ -99,7 +99,7 @@ LevelSetOKZSolverReinitialization<dim>::local_reinitialize(
phi.submit_gradient(phi.get_gradient(q) * diffusion, q);
}

phi.integrate(true, true);
phi.integrate(EvaluationFlags::values | EvaluationFlags::gradients);
phi.distribute_local_to_global(dst);
}
}
Expand Down Expand Up @@ -148,11 +148,11 @@ LevelSetOKZSolverReinitialization<dim>::local_reinitialize_rhs(
{
phi.reinit(cell);
phi.read_dof_values_plain(this->solution);
phi.evaluate(true, true, false);
phi.evaluate(EvaluationFlags::values | EvaluationFlags::gradients);

normals.reinit(cell);
normals.read_dof_values_plain(this->normal_vector_field);
normals.evaluate(true, false, false);
normals.evaluate(EvaluationFlags::values);

VectorizedArray<double> cell_diameter = this->cell_diameters[cell];
VectorizedArray<double> diffusion =
Expand Down Expand Up @@ -182,7 +182,7 @@ LevelSetOKZSolverReinitialization<dim>::local_reinitialize_rhs(
phi.submit_gradient(-diffusion * phi.get_gradient(q), q);
}

phi.integrate(false, true);
phi.integrate(EvaluationFlags::gradients);
phi.distribute_local_to_global(dst);
}
}
Expand Down
Loading

0 comments on commit b65df32

Please sign in to comment.