Add Simple method to make deepcopies
Closed this issue · 3 comments
MicahGale commented
Is your feature request related to a problem? Please describe.
It's quite common to use an existing object as a "template" for a new one. For instance, when discretizing a cell into smaller ones for zone depletions it would be helpful to make copies of the cell, its surfaces, and material.
Describe the solution you'd like
Add a clone
method to all objects.
So you can do:
new_cell = cell.clone()
instead of:
import copy
new_cell = copy.deepcopy(cell)
Describe alternatives you've considered
Currently the recommended method is copy.deepcopy
Additional context
See openmc.Cell.clone
tjlaboss commented
This will be useful.
Some questions on the mechanics to consider:
- How deep should the deepcopy clones go? For instance, cloning a
Material
should copy thematerial_components
, and it shouldn't copy the_problem
. - Should cloning automatically link to a
Materials
instance and to anMCNP_Problem
? - Does the clone automatically get assigned a new number? Will it use
append_renumber()
,request_number(*args)
, etc.?
MicahGale commented
I think generally:
- Everything but the
_problem
should be cloned. MCNP_Object
instances should automatically be linked to the same problem I think.- When copying
MCNP_Problem
all of its children should be linked to it.