You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Functionspace::Element view onto a PETSC vector, as provided by the
element_type FunctionSpace::element( Vector<value_type> const& vec, int blockIdStart = 0 );
element_ptrtype FunctionSpace::elementPtr( Vector<value_type> const& vec, int blockIdStart = 0 );
functions (functionspace.hpp:5285 and functionspace.hpp:5315 resp.), explicitly break const-ness invariance by const_casting the input Vector<value_type> const& vec to VectorPetsc<value_type> *.
This can notably trigger PETSC crash (Incorrect object state) if such view is accessed within a PETSC::VecLockReadPush context, which is for example the case when assembling SNES residuals in the TOOLBOXES, which eventually ends-up calling the provided Feel ModelAlgebraicFactory::updateResidual function through PETSC::SNESComputeFunction (via __feel_petsc_snes_residual), which enforces read-only access to the "X" (input) vector (at least from PETSC v3.18 on).
Note that the element view on the "X" (currentSolution) vector is actually often hidden in the ModelContext used, for example when retrieving auto const& u = mctx.field( FieldTag::velocity(this), "velocity" ); in the FluidMechanics toolbox, which actually retrieves the current velocity vector through the modelFields as a view auto field_u = this->fieldVelocity().functionSpace()->elementPtr( *sol, rowStartInVector+this->startSubBlockSpaceIndex("velocity") ); (c.f. fluidmechanics.hpp:2050).
The text was updated successfully, but these errors were encountered:
Functionspace::Element
view onto a PETSC vector, as provided by thefunctions (
functionspace.hpp:5285
andfunctionspace.hpp:5315
resp.), explicitly break const-ness invariance byconst_cast
ing the inputVector<value_type> const& vec
toVectorPetsc<value_type> *
.This can notably trigger PETSC crash (Incorrect object state) if such view is accessed within a
PETSC::VecLockReadPush
context, which is for example the case when assembling SNES residuals in the TOOLBOXES, which eventually ends-up calling the provided FeelModelAlgebraicFactory::updateResidual
function throughPETSC::SNESComputeFunction
(via__feel_petsc_snes_residual
), which enforces read-only access to the "X" (input) vector (at least from PETSC v3.18 on).Note that the element view on the "X" (currentSolution) vector is actually often hidden in the
ModelContext
used, for example when retrievingauto const& u = mctx.field( FieldTag::velocity(this), "velocity" );
in theFluidMechanics
toolbox, which actually retrieves the current velocity vector through themodelFields
as a viewauto field_u = this->fieldVelocity().functionSpace()->elementPtr( *sol, rowStartInVector+this->startSubBlockSpaceIndex("velocity") );
(c.f.fluidmechanics.hpp:2050
).The text was updated successfully, but these errors were encountered: