Skip to content

Commit

Permalink
Address Amishga's review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
oguevremont committed Aug 5, 2024
1 parent 6145e6b commit 4c9b8da
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 77 deletions.
22 changes: 11 additions & 11 deletions applications_tests/lethe-fluid/tracer_flow_rate.output
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ Tracer statistics :
------------------
Tracer flow rates
------------------
Tracer flow rate at the boundaries :
boundary 0 : 8.2
boundary 1 : 0
boundary 2 : 0
boundary 3 : 0
Tracer flow rate at the boundaries:
boundary 0: 8.2
boundary 1: 0
boundary 2: 0
boundary 3: 0

*****************************
Steady iteration: 1/1
*****************************
Tracer statistics :
Tracer statistics :
Min : 1
Max : 1
Average : 1
Std-Dev : 3.37941e-09
------------------
Tracer flow rates
------------------
Tracer flow rate at the boundaries :
boundary 0 : 0.2
boundary 1 : -0.200001
boundary 2 : 9.02388e-10
boundary 3 : 2.18592e-09
Tracer flow rate at the boundaries:
boundary 0: 0.2
boundary 1: -0.200001
boundary 2: 9.02388e-10
boundary 3: 2.18592e-09
2 changes: 1 addition & 1 deletion applications_tests/lethe-fluid/tracer_flow_rate.prm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set dimension = 2

subsection simulation control
set output frequency = 0
set output frequency = 1
end

subsection physical properties
Expand Down
2 changes: 2 additions & 0 deletions include/solvers/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ class Tracer : public AuxiliaryPhysics<dim, GlobalVectorType>
*
* @param current_solution_fd current solution for the fluid dynamics, parsed
* by postprocess
*
* @tparam GlobalVectorType The type of the global vector used for the tracer physics
*/

template <typename GlobalVectorType>
Expand Down
127 changes: 62 additions & 65 deletions source/solvers/tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -612,72 +612,69 @@ Tracer<dim>::postprocess_tracer_flow_rate(const VectorType &current_solution_fd)
end(boundary_conditions_ids),
cell->face(face)->boundary_id());

if (boundary_id != end(boundary_conditions_ids))

unsigned int vector_index =
boundary_id - boundary_conditions_ids.begin();

// Gather tracer information
fe_face_values_tracer.reinit(cell, face);
fe_face_values_tracer.get_function_values(
this->present_solution, tracer_values);
fe_face_values_tracer.get_function_gradients(
this->present_solution, tracer_gradient);

// We update the fields required by the diffusivity
// model
fields.clear();
if (diffusivity_model->depends_on(field::levelset))
{
std::vector<double> levelset_values(n_q_points_face);
fields.insert(
std::pair<field, std::vector<double>>(field::levelset,
n_q_points_face));
face_quadrature_points =
fe_face_values_tracer.get_quadrature_points();
immersed_solid_signed_distance_function =
this->multiphysics
->get_immersed_solid_signed_distance_function();
this->immersed_solid_signed_distance_function->value_list(
face_quadrature_points, levelset_values);
set_field_vector(field::levelset,
levelset_values,
fields);
}

diffusivity_model->vector_value(fields, tracer_diffusivity);

// Get fluid dynamics active cell iterator
typename DoFHandler<dim>::active_cell_iterator cell_fd(
&(*(this->triangulation)),
cell->level(),
cell->index(),
dof_handler_fd);

// Gather fluid dynamics information
fe_face_values_fd.reinit(cell_fd, face);
fe_face_values_fd[velocities].get_function_values(
current_solution_fd, velocity_values);

// Loop on the quadrature points
for (unsigned int q = 0; q < n_q_points_face; q++)
{
unsigned int vector_index =
boundary_id - boundary_conditions_ids.begin();

// Gather tracer information
fe_face_values_tracer.reinit(cell, face);
fe_face_values_tracer.get_function_values(
this->present_solution, tracer_values);
fe_face_values_tracer.get_function_gradients(
this->present_solution, tracer_gradient);

// We update the fields required by the diffusivity
// model
fields.clear();
if (diffusivity_model->depends_on(field::levelset))
{
std::vector<double> levelset_values(n_q_points_face);
fields.insert(std::pair<field, std::vector<double>>(
field::levelset, n_q_points_face));
face_quadrature_points =
fe_face_values_tracer.get_quadrature_points();
immersed_solid_signed_distance_function =
this->multiphysics
->get_immersed_solid_signed_distance_function();
this->immersed_solid_signed_distance_function
->value_list(face_quadrature_points,
levelset_values);
set_field_vector(field::levelset,
levelset_values,
fields);
}

diffusivity_model->vector_value(fields,
tracer_diffusivity);

// Get fluid dynamics active cell iterator
typename DoFHandler<dim>::active_cell_iterator cell_fd(
&(*(this->triangulation)),
cell->level(),
cell->index(),
dof_handler_fd);

// Gather fluid dynamics information
fe_face_values_fd.reinit(cell_fd, face);
fe_face_values_fd[velocities].get_function_values(
current_solution_fd, velocity_values);

// Loop on the quadrature points
for (unsigned int q = 0; q < n_q_points_face; q++)
{
Tensor<1, dim> normal_vector_tracer =
-fe_face_values_tracer.normal_vector(q);

tracer_flow_rate_vector[vector_index] +=
(-tracer_diffusivity[q] * tracer_gradient[q] *
normal_vector_tracer +
tracer_values[q] * velocity_values[q] *
normal_vector_tracer) *
fe_face_values_tracer.JxW(q);
} // end loop on quadrature points
} // end condition face at boundary
} // end loop on faces
} // end face is a boundary face
} // end condition cell at boundary
} // end loop on cells
Tensor<1, dim> normal_vector_tracer =
-fe_face_values_tracer.normal_vector(q);

tracer_flow_rate_vector[vector_index] +=
(-tracer_diffusivity[q] * tracer_gradient[q] *
normal_vector_tracer +
tracer_values[q] * velocity_values[q] *
normal_vector_tracer) *
fe_face_values_tracer.JxW(q);
} // end loop on quadrature points
} // end face is a boundary face
} // end loop on faces
} // end condition cell at boundary
} // end loop on cells


// Sum across all cores
Expand Down

0 comments on commit 4c9b8da

Please sign in to comment.