Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions brc-interpolation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,10 @@ void barycentric_node_interpolation(const Param& param, Variables &var,
double_vec *new_dppressure = new double_vec(n);
interpolate_field(brc, el, old_connectivity, *var.dppressure, *new_dppressure, n);

#ifdef USEMMG
double_vec *new_init_elem_size_n = new double_vec(var.nnode);
interpolate_field(brc, el, old_connectivity, *var.init_elem_size_n, *new_init_elem_size_n, n);
#endif

#pragma acc wait

Expand All @@ -291,8 +293,10 @@ void barycentric_node_interpolation(const Param& param, Variables &var,
delete var.dppressure;
var.dppressure = new_dppressure;

#ifdef USEMMG
delete var.init_elem_size_n;
var.init_elem_size_n = new_init_elem_size_n;
#endif

#pragma acc wait

Expand Down
7 changes: 6 additions & 1 deletion dynearthsol.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void init_var(const Param& param, Variables& var)
var.func_time.output_time = 0;
var.func_time.remesh_time = 0;
var.func_time.start_time = get_nanoseconds();
var.init_elem_size_n = new double_vec(0);

for (int i=0;i<nbdrytypes;++i)
var.bfacets[i] = new int_pair_vec;
Expand Down Expand Up @@ -185,7 +186,9 @@ void init(const Param& param, Variables& var)
var.dt = compute_dt(param, var); // Global-velocity scaling needs dt before compute_mass.
compute_mass(param, var, var.max_vbc_val, *var.volume_n, *var.mass, *var.tmass, *var.hmass, *var.ymass, *var.tmp_result);

#ifdef USEMMG
initialize_elem_size_n(var, *var.init_elem_size_n);
#endif

compute_shape_fn(var, *var.shpdx, *var.shpdy, *var.shpdz);

Expand Down Expand Up @@ -302,6 +305,7 @@ void restart(const Param& param, Variables& var)
}

allocate_variables(param, var);
var.init_elem_size_n->resize(var.nnode);
Comment on lines 307 to +308
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In restart(), init_elem_size_n is resized unconditionally. In non-MMG builds this can allocate a large per-node array that is never used (and contradicts the goal of avoiding init_elem_size_n allocation when USEMMG is off). Guard this resize behind USEMMG (and only resize when you will actually read/populate the array).

Suggested change
allocate_variables(param, var);
var.init_elem_size_n->resize(var.nnode);
allocate_variables(param, var);
#ifdef USEMMG
var.init_elem_size_n->resize(var.nnode);
#endif

Copilot uses AI. Check for mistakes.

create_top_elems(var);
create_surface_info(param,var,var.surfinfo);
Expand All @@ -327,8 +331,9 @@ void restart(const Param& param, Variables& var)
bin_save.read_array(*var.ppressure, "pore pressure");

bin_chkpt.read_array(*var.surfinfo.edvacc_surf, "dv surface acc");
#ifdef USEMMG
bin_chkpt.read_array(*var.init_elem_size_n, "init_elem_size_n");
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restart will currently fail (BinaryInput/HDF5Input exits) if the checkpoint was produced by an older build that doesn't contain the new "init_elem_size_n" dataset. Use bin_chkpt.has_array("init_elem_size_n") before reading, and provide a fallback when missing (e.g., initialize_elem_size_n(...) under USEMMG after volumes are available, or initialize to a safe default).

Suggested change
bin_chkpt.read_array(*var.init_elem_size_n, "init_elem_size_n");
if (bin_chkpt.has_array("init_elem_size_n"))
bin_chkpt.read_array(*var.init_elem_size_n, "init_elem_size_n");
else {
for (std::size_t i = 0; i < var.init_elem_size_n->size(); ++i)
(*var.init_elem_size_n)[i] = 0;
}

Copilot uses AI. Check for mistakes.

#endif
if (param.mat.is_plane_strain)
bin_chkpt.read_array(*var.stressyy, "stressyy");
}
Expand Down
1 change: 0 additions & 1 deletion fields.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ void allocate_variables(const Param &param, Variables& var)
var.temperature = new double_vec(n);
var.ppressure = new double_vec(n);
var.dppressure = new double_vec(n);
var.init_elem_size_n = new double_vec(n);
var.coord0 = new array_t(n);
var.plstrain = new double_vec(e);
var.delta_plstrain = new double_vec(e);
Expand Down
4 changes: 4 additions & 0 deletions input.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ static void declare_parameters(po::options_description &cfg,
"Factor multiplied to param.mesh.resolution to set the minimum element size\n")
("mesh.mmg_hausd_factor", po::value<double>(&p.mesh.mmg_hausd_factor)->default_value(0.01),
"Factor multiplied to param.mesh.resolution to set the Hausdorff distance between original and remeshed surfaces.\n")
("mesh.mmg_init_coarsening_factor", po::value<double>(&p.mesh.mmg_init_coarsening_factor)->default_value(10.0),
"Coarsening factor for the two-stage TetGen+MMG init mesh. TetGen creates a mesh "
"with element volumes scaled by factor^NDIMS; MMG then refines to target resolution. "
"Higher values = smaller coarse mesh = faster TetGen but more MMG work. Default: 10.")
;

cfg.add_options()
Expand Down
Loading
Loading