View Issue Details

IDProjectCategoryView StatusLast Update
0002598OpenFOAMBugpublic2017-10-18 16:12
Reporterjacob Assigned Tohenry  
PrioritylowSeverityminorReproducibilityalways
Status closedResolutionno change required 
PlatformGNU/LinuxOSOpenSuSEOS VersionTumbleweed
Summary0002598: lduMatrix does not have a virtual destructor
DescriptionThe class lduMatrix is used as a base class for fvMatrix. As such, it should have a virtual destructor.
Additional InformationAlso, without a virtual destructor (and in absence of any other virtual function) lduMatrix is not considered polymorphic by compilers (or at least by GCC 6.2.0) and hence it cannot be dynamic_cast-ed to fvMatrix. Such a feature is otherwise useful e.g. when accessing the objectRegistry from within a lduMatrix solver.
TagsNo tags attached.

Activities

henry

2017-07-02 16:10

manager   ~0008319

lduMatrix is not polymorphic, does not have any virtual functions and hence does not currently need a virtual destructor. Could you provide a use case for which this would be required? Where is OpenFOAM is this required and causing a problem?

jacob

2017-07-10 14:22

reporter   ~0008376

I provided a use case in "Additional Information": When fvMatrix is derived from lduMatrix, it should be possible to dynamic_cast lduMatrix to fvMatrix. Right now this is not possible, because lduMatrix is not polymorphic. Addition of a virtual destructor would make the class polymorphic.

If this is not desired, I withdraw my suggestion.

henry

2017-07-10 14:37

manager   ~0008377

lduMatrix was not designed to be dynamically up-cast and currently there is no need for this in OpenFOAM nor does it appear to be appropriate.

Under what conditions do you need to up-cast lduMatrix? Wouldn't it be better to provide direct access to the fvMatrix rather than up-casting the lduMatrix?

jacob

2017-10-18 15:36

reporter   ~0008888

I think this issue can be closed, it originates from my misunderstanding of OpenFOAM architecture. No action needed.

Issue History

Date Modified Username Field Change
2017-07-01 12:31 jacob New Issue
2017-07-02 16:10 henry Note Added: 0008319
2017-07-10 14:22 jacob Note Added: 0008376
2017-07-10 14:37 henry Note Added: 0008377
2017-10-18 15:36 jacob Note Added: 0008888
2017-10-18 16:12 henry Assigned To => henry
2017-10-18 16:12 henry Status new => closed
2017-10-18 16:12 henry Resolution open => no change required