Skip to content
Merged
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
16 changes: 8 additions & 8 deletions lib/data_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,8 @@ bool DataState::SetNewMeshAndSolution(DataState new_state,
{
ResetMeshAndSolution(new_state, vs);

internal.grid_f = std::move(new_state.internal.grid_f);
internal.mesh = std::move(new_state.internal.mesh);
internal.quad_f = std::move(new_state.internal.quad_f);
internal.mesh_quad = std::move(new_state.internal.mesh_quad);
// do not move 'sol' vector as it is updated directly
internal = std::move(new_state.internal);

return true;
}
Expand All @@ -593,8 +591,9 @@ void DataState::ResetMeshAndSolution(DataState &ss, VisualizationScene* vs)
{
VisualizationSceneSolution *vss =
dynamic_cast<VisualizationSceneSolution *>(vs);
ss.grid_f->GetNodalValues(ss.sol);
vss->NewMeshAndSolution(ss.mesh.get(), ss.mesh_quad.get(), &ss.sol,
// use the local vector as pointer is invalid after the move
ss.grid_f->GetNodalValues(sol);
vss->NewMeshAndSolution(ss.mesh.get(), ss.mesh_quad.get(), &sol,
ss.grid_f.get());
}
else
Expand All @@ -610,8 +609,9 @@ void DataState::ResetMeshAndSolution(DataState &ss, VisualizationScene* vs)
{
VisualizationSceneSolution3d *vss =
dynamic_cast<VisualizationSceneSolution3d *>(vs);
ss.grid_f->GetNodalValues(ss.sol);
vss->NewMeshAndSolution(ss.mesh.get(), ss.mesh_quad.get(), &ss.sol,
// use the local vector as pointer is invalid after the move
ss.grid_f->GetNodalValues(sol);
vss->NewMeshAndSolution(ss.mesh.get(), ss.mesh_quad.get(), &sol,
ss.grid_f.get());
}
else
Expand Down
12 changes: 6 additions & 6 deletions lib/data_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ struct DataState
void SetGridFunctionSolution(int component = -1);
void SetQuadFunctionSolution(int component = -1);

/// Updates the given VisualizationScene pointer with the new data
/// of the given DataState object.
/// @note: Use with caution when the update is compatible
/// @see SetNewMeshAndSolution()
void ResetMeshAndSolution(DataState &ss, VisualizationScene* vs);

public:
mfem::Vector sol, solu, solv, solw, normals;
const std::unique_ptr<mfem::Mesh> &mesh{internal.mesh};
Expand Down Expand Up @@ -168,12 +174,6 @@ struct DataState
/// updated.
bool SetNewMeshAndSolution(DataState new_state,
VisualizationScene* vs);

/// Updates the given VisualizationScene pointer with the new data
/// of the given DataState object.
/// @note: Use with caution when the update is compatible
/// @see SetNewMeshAndSolution()
static void ResetMeshAndSolution(DataState &ss, VisualizationScene* vs);
};

#endif // GLVIS_DATA_STATE_HPP
Loading