Skip to content

Commit babff94

Browse files
authored
Merge pull request #3268 from jwpeterson/avoid_new_dbc
We can just use DirichletBoundary objects, no need to use new/delete
2 parents c5a8342 + 7280702 commit babff94

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

src/systems/diff_system.C

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void DifferentiableSystem::add_dot_var_dirichlet_bcs( unsigned int var_idx,
242242
// We need to cache the DBCs to be added so that we add them
243243
// after looping over the existing DBCs. Otherwise, we're polluting
244244
// the thing we're looping over.
245-
std::vector<DirichletBoundary *> new_dbcs;
245+
std::vector<DirichletBoundary> new_dbcs;
246246

247247
for (const auto & dbc : *all_dbcs)
248248
{
@@ -278,29 +278,15 @@ void DifferentiableSystem::add_dot_var_dirichlet_bcs( unsigned int var_idx,
278278
libmesh_error_msg("Could not find valid boundary function!");
279279

280280
libmesh_error_msg_if(is_time_evolving_bc, "Cannot currently support time-dependent Dirichlet BC for dot variables!");
281+
libmesh_error_msg_if(!dbc->f, "Expected valid DirichletBoundary function");
281282

282-
283-
DirichletBoundary * new_dbc;
284-
285-
if (dbc->f)
286-
{
287-
ZeroFunction<Number> zf;
288-
289-
new_dbc = new DirichletBoundary(dbc->b, vars_to_add, zf);
290-
}
291-
else
292-
libmesh_error();
293-
294-
new_dbcs.push_back(new_dbc);
283+
new_dbcs.emplace_back(dbc->b, vars_to_add, ZeroFunction<Number>());
295284
}
296285
}
297286

298-
// Let the DofMap make its own deep copy of the DirichletBC objects and delete our copy.
287+
// Let the DofMap make its own deep copy of the DirichletBC objects
299288
for (const auto & dbc : new_dbcs)
300-
{
301-
this->get_dof_map().add_dirichlet_boundary(*dbc);
302-
delete dbc;
303-
}
289+
this->get_dof_map().add_dirichlet_boundary(dbc);
304290

305291
} // if (all_dbcs)
306292
}

0 commit comments

Comments
 (0)