Deleted move constructors and inability to change objects post-initialization

11 views
Skip to first unread message

Lucas Myers

unread,
Jun 23, 2022, 3:49:18 PM6/23/22
to deal.II User Group
Hi everyone,

Is there any way to initialize a Simulation object (akin to the StepX objects found in the tutorials) in a method and then return it via std::move()? Or, barring that, is there a way to reinitialize an FESystem member variable to have a different degree?

In the former case I run into the problem that both the DoFHandler and SparseMatrix objects have no move constructor defined, and in the latter case that FESystem has no `reinit` function nor any way (that I know of) of reassigning the FESystem member variable to a new FESystem instance. Are there fundamental reasons why these operations are not implemented, or is this just an uncommon use case?

For context I'm trying to deserialize a Simulation object in some method, but that either requires deserializing the degree and then constructing the object (in the method), or constructing the object outside the method, then changing the fe degree within the deserialize method.

Hope the question's clear, and thanks so much for the help,
Lucas

Wolfgang Bangerth

unread,
Jun 24, 2022, 1:11:14 AM6/24/22
to dea...@googlegroups.com

Lucas,

> Is there any way to initialize a Simulation object (akin to the StepX objects
> found in the tutorials) in a method and then return it via std::move()? Or,
> barring that, is there a way to reinitialize an FESystem member variable to
> have a different degree?
>
> In the former case I run into the problem that both the DoFHandler and
> SparseMatrix objects have no move constructor defined, and in the latter case
> that FESystem has no `reinit` function nor any way (that I know of) of
> reassigning the FESystem member variable to a new FESystem instance. Are there
> fundamental reasons why these operations are not implemented, or is this just
> an uncommon use case?

It's an uncommon case, and so nobody has implemented it. These sorts of large,
global objects are not generally created by factory functions, and so not
commonly copied or moved. The easy way around this in your case is to let the
factory function create a std::unique_ptr<Simulator<dim>> which you can move
without actually touching the Simulator object.

The same applies to FESystem objects.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Reply all
Reply to author
Forward
0 new messages