|
224 | 224 | """
|
225 | 225 | $SIGNATURES
|
226 | 226 |
|
227 |
| -Return full dictionary of PPEs in a variable, recommended to rather use CRUD: [`getPPE`](@ref), |
| 227 | +Return full dictionary of PPEs in a variable, recommended to rather use CRUD: [`getPPE`](@ref), |
228 | 228 | """
|
229 | 229 | getVariablePPEDict(vari::VariableDataLevel1) = getPPEDict(vari)
|
230 | 230 |
|
@@ -361,34 +361,37 @@ addVariableSolverData!(dfg::AbstractDFG, sourceVariable::DFGVariable, solvekey::
|
361 | 361 | """
|
362 | 362 | $(SIGNATURES)
|
363 | 363 | Update variable solver data if it exists, otherwise add it.
|
364 |
| -""" |
365 |
| -function updateVariableSolverData!(dfg::AbstractDFG, variablekey::Symbol, vnd::VariableNodeData, solvekey::Symbol=:default)::VariableNodeData |
| 364 | +Notes: |
| 365 | +- `useDeepcopy=true` to copy solver data and keep separate memory. |
| 366 | +""" |
| 367 | +function updateVariableSolverData!(dfg::AbstractDFG, |
| 368 | + variablekey::Symbol, |
| 369 | + vnd::VariableNodeData, |
| 370 | + solvekey::Symbol=:default, |
| 371 | + useDeepcopy::Bool=true )::VariableNodeData |
| 372 | + # |
366 | 373 | #This is basically just setSolverData
|
367 | 374 | var = getVariable(dfg, variablekey)
|
368 | 375 | if !haskey(var.solverDataDict, solvekey)
|
369 | 376 | @warn "VariableNodeData '$(solvekey)' does not exist, adding"
|
370 | 377 | end
|
371 | 378 | #for InMemoryDFGTypes, cloud would update here
|
372 |
| - var.solverDataDict[solvekey] = vnd |
| 379 | + var.solverDataDict[solvekey] = useDeepcopy ? deepcopy(vnd) : vnd |
373 | 380 | return vnd
|
374 | 381 | end
|
375 | 382 |
|
376 |
| -""" |
377 |
| - $(SIGNATURES) |
378 |
| -Update variable solver data if it exists, otherwise add it. |
379 |
| -NOTE: Copies the solver data. |
380 |
| -""" |
381 |
| -updateVariableSolverData!(dfg::AbstractDFG, sourceVariable::DFGVariable, solvekey::Symbol=:default) = |
382 |
| - updateVariableSolverData!(dfg, sourceVariable.label, deepcopy(getSolverData(sourceVariable, solvekey)), solvekey) |
| 383 | +updateVariableSolverData!(dfg::AbstractDFG, |
| 384 | + sourceVariable::DFGVariable, |
| 385 | + solvekey::Symbol=:default, useDeepcopy::Bool=true) = |
| 386 | + updateVariableSolverData!(dfg, sourceVariable.label, getSolverData(sourceVariable, solvekey), solvekey, useDeepcopy) |
383 | 387 |
|
384 |
| -""" |
385 |
| - $(SIGNATURES) |
386 |
| -Update variable solver data if it exists, otherwise add it. |
387 |
| -""" |
388 |
| -function updateVariableSolverData!(dfg::AbstractDFG, sourceVariables::Vector{<:DFGVariable}, solvekey::Symbol=:default) |
| 388 | +function updateVariableSolverData!(dfg::AbstractDFG, |
| 389 | + sourceVariables::Vector{<:DFGVariable}, |
| 390 | + solvekey::Symbol=:default, |
| 391 | + useDeepcopy::Bool=true ) |
389 | 392 | #I think cloud would do this in bulk for speed
|
390 | 393 | for var in sourceVariables
|
391 |
| - updateVariableSolverData!(dfg, var.label, getSolverData(var, solvekey), solvekey) |
| 394 | + updateVariableSolverData!(dfg, var.label, getSolverData(var, solvekey), solvekey, useDeepcopy) |
392 | 395 | end
|
393 | 396 | end
|
394 | 397 |
|
|
0 commit comments