Skip to content

Commit 190b5b1

Browse files
authored
Debug ci fix (chaos-polymtl#1247)
Description There were some asserts being thrown in debug mode. These asserts were all warrented. They were cuased by the following: 1- std::shared_ptr cannot be created from a nullptr. Since the sharp edge in the tracer relies on this mechanism to assess if there is or not a shape, this was highly problematic. @oguevremont we will need to look more into this and refactor this more cleanly in the next month. I have made a solution using regular pointers which is fine, but relying on nullptr is not very nice in my opinion 2- There was an std::vector that was not used correctly in the find cell around flat mechanism 3- In the restart for sharp edge, the order of the checks was not done in the right order which violated the size issue. Solution Fixed all of those bugs. Testing Debug tests should pass now. Former-commit-id: b255a9e
1 parent 18d34a5 commit 190b5b1

File tree

9 files changed

+47
-51
lines changed

9 files changed

+47
-51
lines changed

include/solvers/multiphysics_interface.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,14 +567,16 @@ class MultiphysicsInterface
567567
/**
568568
* @brief Request immersed solid signed distance function
569569
*/
570-
std::shared_ptr<Function<dim>>
570+
Function<dim> *
571571
get_immersed_solid_signed_distance_function();
572572

573573
/**
574574
* @brief Share immersed solid signed distance function
575+
*
576+
* @param function The immersed solid signed distance function
575577
*/
576578
void
577-
set_immersed_solid_signed_distance_function(std::shared_ptr<Function<dim>>);
579+
set_immersed_solid_signed_distance_function(Function<dim> *function);
578580

579581
/**
580582
* @brief Request the previous solutions of a given physics
@@ -921,7 +923,7 @@ class MultiphysicsInterface
921923
GlobalVectorType *reynolds_stress_solutions;
922924

923925
// Immersed solid signed distance function to be used by auxiliary physics
924-
std::shared_ptr<Function<dim>> immersed_solid_signed_distance_function;
926+
Function<dim> *immersed_solid_signed_distance_function;
925927

926928
// past (minus 1) solution
927929
std::map<PhysicsID, GlobalVectorType *> physics_solutions_m1;

include/solvers/tracer.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,6 @@ class Tracer : public AuxiliaryPhysics<dim, GlobalVectorType>
432432
AffineConstraints<double> zero_constraints;
433433
TrilinosWrappers::SparseMatrix system_matrix;
434434

435-
// Immersed solid signed distance function with immersed solid solver
436-
std::shared_ptr<Function<dim>> immersed_solid_signed_distance_function;
437-
438435
// Previous solutions vectors
439436
std::vector<GlobalVectorType> previous_solutions;
440437

include/solvers/tracer_scratch_data.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,16 @@ class TracerScratchData
159159
auto &fe_tracer = this->fe_values_tracer.get_fe();
160160

161161
source_function->value_list(quadrature_points, source);
162+
162163
if (properties_manager.field_is_required(field::levelset))
163-
levelset_function->value_list(quadrature_points, sdf_values);
164+
{
165+
Assert(
166+
levelset_function != nullptr,
167+
ExcMessage(
168+
"Levelset function is required for tracer assembly, but the level set function is a nullptr"));
169+
170+
levelset_function->value_list(quadrature_points, sdf_values);
171+
}
164172

165173
if (dim == 2)
166174
this->cell_size =

source/core/lethe_grid_tools.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,6 @@ LetheGridTools::cell_cut_by_flat(
870870
if (condition_B2)
871871
{
872872
bool condition_C2 = false;
873-
manifold_points.clear();
874873
for (const auto face : cell->face_indices())
875874
{
876875
auto face_iter = cell->face(face);

source/fem-dem/fluid_dynamics_sharp.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ FluidDynamicsSharp<dim>::define_particles()
817817
combined_shapes =
818818
std::make_shared<CompositeShape<dim>>(all_shapes, Point<dim>(), Point<3>());
819819
this->multiphysics->set_immersed_solid_signed_distance_function(
820-
combined_shapes);
820+
&(*combined_shapes));
821821
}
822822

823823

@@ -4341,15 +4341,15 @@ FluidDynamicsSharp<dim>::read_checkpoint()
43414341
std::map<std::string, std::vector<double>> restart_data;
43424342
fill_vectors_from_file(restart_data, filename);
43434343

4344-
// Implement the data in the particles.
4344+
// Implement the data in the particles.
43454345
if constexpr (dim == 2)
43464346
{
43474347
unsigned int row = 0;
43484348
for (unsigned int p_i = 0; p_i < particles.size(); ++p_i)
43494349
{
43504350
unsigned int j = 0;
4351-
while (restart_data["ID"][row] == p_i and
4352-
row < restart_data["ID"].size())
4351+
while (row < restart_data["ID"].size() &&
4352+
restart_data["ID"][row] == p_i)
43534353
{
43544354
if (j == 0)
43554355
{
@@ -4415,8 +4415,8 @@ FluidDynamicsSharp<dim>::read_checkpoint()
44154415
for (unsigned int p_i = 0; p_i < particles.size(); ++p_i)
44164416
{
44174417
unsigned int j = 0;
4418-
while (restart_data["ID"][row] == p_i and
4419-
row < restart_data["ID"].size())
4418+
while (row < restart_data["ID"].size() &&
4419+
restart_data["ID"][row] == p_i)
44204420
{
44214421
if (j == 0)
44224422
{

source/solvers/multiphysics_interface.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,20 @@ MultiphysicsInterface<dim>::get_projected_phase_fraction_gradient_dof_handler()
217217
}
218218

219219
template <int dim>
220-
std::shared_ptr<Function<dim>>
220+
Function<dim> *
221221
MultiphysicsInterface<dim>::get_immersed_solid_signed_distance_function()
222222
{
223223
// This pointer is also used to check if an immersed boundary solid method is
224224
// being used, depending on whether the pointer is assigned.
225-
return this->immersed_solid_signed_distance_function;
225+
return immersed_solid_signed_distance_function;
226226
}
227227

228228
template <int dim>
229229
void
230230
MultiphysicsInterface<dim>::set_immersed_solid_signed_distance_function(
231-
std::shared_ptr<Function<dim>> function)
231+
Function<dim> *function)
232232
{
233-
this->immersed_solid_signed_distance_function = function;
233+
immersed_solid_signed_distance_function = function;
234234
}
235235

236236
template <int dim>

source/solvers/tracer.cc

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ Tracer<dim>::assemble_system_matrix()
5151
this->system_matrix = 0;
5252
setup_assemblers();
5353

54-
// We get the immersed function, which is null when no immersed solids are
55-
// involved.
56-
immersed_solid_signed_distance_function =
57-
this->multiphysics->get_immersed_solid_signed_distance_function();
54+
// Update the source term time
55+
simulation_parameters.source_term.tracer_source->set_time(
56+
simulation_control->get_current_time());
5857

5958
const DoFHandler<dim> *dof_handler_fluid =
6059
multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
@@ -89,14 +88,13 @@ Tracer<dim>::assemble_local_system_matrix(
8988
if (!cell->is_locally_owned())
9089
return;
9190

92-
auto source_term = simulation_parameters.source_term.tracer_source;
93-
source_term->set_time(simulation_control->get_current_time());
9491

95-
scratch_data.reinit(cell,
96-
this->evaluation_point,
97-
this->previous_solutions,
98-
&(*source_term),
99-
&(*immersed_solid_signed_distance_function));
92+
scratch_data.reinit(
93+
cell,
94+
this->evaluation_point,
95+
this->previous_solutions,
96+
&(*simulation_parameters.source_term.tracer_source),
97+
&(*this->multiphysics->get_immersed_solid_signed_distance_function()));
10098

10199
const DoFHandler<dim> *dof_handler_fluid =
102100
multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
@@ -193,10 +191,9 @@ Tracer<dim>::assemble_system_rhs()
193191
this->system_rhs = 0;
194192
setup_assemblers();
195193

196-
// We get the immersed function, which is null when no immersed solids are
197-
// involved
198-
immersed_solid_signed_distance_function =
199-
this->multiphysics->get_immersed_solid_signed_distance_function();
194+
// Update the source term time
195+
simulation_parameters.source_term.tracer_source->set_time(
196+
simulation_control->get_current_time());
200197

201198
const DoFHandler<dim> *dof_handler_fluid =
202199
multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
@@ -234,11 +231,12 @@ Tracer<dim>::assemble_local_system_rhs(
234231
auto source_term = simulation_parameters.source_term.tracer_source;
235232
source_term->set_time(simulation_control->get_current_time());
236233

237-
scratch_data.reinit(cell,
238-
this->evaluation_point,
239-
this->previous_solutions,
240-
&(*source_term),
241-
&(*immersed_solid_signed_distance_function));
234+
scratch_data.reinit(
235+
cell,
236+
this->evaluation_point,
237+
this->previous_solutions,
238+
&(*source_term),
239+
(this->multiphysics->get_immersed_solid_signed_distance_function()));
242240

243241
const DoFHandler<dim> *dof_handler_fluid =
244242
multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
@@ -650,11 +648,9 @@ Tracer<dim>::postprocess_tracer_flow_rate(const VectorType &current_solution_fd)
650648
n_q_points_face));
651649
face_quadrature_points =
652650
fe_face_values_tracer.get_quadrature_points();
653-
immersed_solid_signed_distance_function =
654-
this->multiphysics
655-
->get_immersed_solid_signed_distance_function();
656-
this->immersed_solid_signed_distance_function->value_list(
657-
face_quadrature_points, levelset_values);
651+
this->multiphysics
652+
->get_immersed_solid_signed_distance_function()
653+
->value_list(face_quadrature_points, levelset_values);
658654
set_field_vector(field::levelset,
659655
levelset_values,
660656
fields);

tests/core/lethe_grid_tool_mesh_cut_by_flat_2.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,10 @@ test()
111111
<< std::endl;
112112
}
113113

114-
// Printing the final position for all the vertices
115-
116-
#if (DEAL_II_VERSION_MAJOR < 10 && DEAL_II_VERSION_MINOR < 4)
117-
Legacy::DataOut<2> data_out;
118-
Legacy::DataOut<1, DoFHandler<1, 2>> flat_data_out;
119-
#else
114+
// Printing the final position for all the vertices
120115
DataOut<2> data_out;
121116
DataOut<1, 2> flat_data_out;
122-
#endif
117+
123118
data_out.attach_dof_handler(dof_handler);
124119
data_out.add_data_vector(subdomain, "subdomain");
125120
data_out.build_patches();

tests/tests.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include <deal.II/base/config.h>
2222

23-
#include <deal.II/base/cuda.h>
2423
#include <deal.II/base/exceptions.h>
2524
#include <deal.II/base/job_identifier.h>
2625
#include <deal.II/base/logstream.h>

0 commit comments

Comments
 (0)