Thyra Version of the Day
Loading...
Searching...
No Matches
Frequently Asked Questions (FAQ) about Thyra Software

Outline

Questions about the smart pointer class Teuchos::RCP

Q: What are RCP objects and why are they important?

A:The class Teuchos::RCP implements a form of reference counting which, through the magic of smart pointers in C++, allows objects to be created and used without much concern for when and where they should be deleted. It is a form of garbage collection but is not as general or fail- safe as in languages with built in garbage collection. For more information see:

"http://trilinos.sandia.gov/RefCountPtrBeginnersGuideSAND.pdf and click on: <tt>Teuchos::RCP</tt> @subsection thyra_faq_rcp_everywhere_sec Q: Should my code use RCP's everywhere? <b>A:</b> You should only use RCP to wrap objects where a persisting relationship is being formed or maintained. For non-persisting relationships, use raw C++ references and pointers. For more information see the main body and Appendix D of the document: http://software.sandia.gov/Trilinos/RefCountPtrBeginnersGuideSAND.pdf @section thyra_faq_itfc_sec Questions about Fundamental Thyra Operator/Vector Interfaces @subsection thyra_faq_why_helper_funcs_sec Q: Why is Thyra written with so many non-member helper functions instead of member functions? In many standard C++ classes students are told that the beauty of OOP is that functions and data can be put together into classes to combine the operations with the data on which they operate. Is this not correct? <b>A:</b> Generally member functions should only be used over non-member functions when direct access to private or protected data for functions is required. By minimizing the amount of code that can access non-public data you greatly simplify maintenance. See Item 44 in "C++ Coding Standards" by Sutter and Alexandrescu for a discussion of this topic. @subsection thyra_faq_Scalar_sec Q: Where is the Scalar class, and how do I use it to replace my underlying data-type, e.g. double, in my ANA? <b>A:</b> The 'Scalar' class is in a template argument in all of the core Thyra interface code. The goal of this template argument is to allow many abstract numerical algorithms to be written in a general form to support a number of different scalar types (e.g. real, complex, extended precision etc.). While the interfaces, the composite classes, and many of the concrete implementations are fully templated some are not and can only support one scalar type (e.g. see the Epetra/Thyra adapters). See the <tt>sillyCgSolve()</tt> and <tt>sillyPowerMethod()</tt> examples for how this templating is used. @subsection thyra_faq_creating_vecs_multivecs_sec Q: How do I create a Thyra::VectorBase or Thyra::MultiVectorBase object? The member functions Thyra::VectorSpaceBase::createMember() and Thyra::VectorSpaceBase::createMembers() are protected and can not be called by client code. <b>A:</b> You must use the non-member functions <tt>Thyra::createMember()</tt> and <tt>Thyra::createMembers()</tt> described \ref Thyra_Op_Vec_createMember_grp "here" and also used in the examples sillyCgSolve() and sillyModifiedGramSchmidt().