Contributing

We encourage contributions to the library. Contributing to G+Smo is very profitable for both the contributor and the library.

We keep a page of ideas of possible contributions, where you could find one that is of your interest to implement. Nevertheless, you are mostly welcome to send your ideas to the mailing list (Subscribe) or join us in the IRC channel #G+Smo on Freenode.

Feedback

Post build and test reports to https://cdash.ricam.oeaw.ac.at.

This is done by

$ make Experimental

Code style and formatting

  • Use only spaces, no tabs for indentation.
  • Use 4 spaces per indentation level.
  • Open bracket (iteration, switch, function, etc) at flush left position.
  • No indentation inside the namespace, except for a sub-namespace.
  • No indentation for access modifiers (public, private, etc) inside classes.

Sample code

We use the following convention regarding filenames.

There are the following four types of files in G+Smo.

  • gsFilename.h file should contain function declarations, Doxygen documentation and, possibly, definitions of very short inline functions;
    /** @file ... */
    #pragma once
    #include <gsWhereIFindIt/gsWhateverINeed.h>
    
    namespace gismo
    {
    /**
       \brief Here say what this class is and does..
    */
    class GISMO_EXPORT gsMyClass
    {
    public:
        /// Prints "Hello, World!".
        void helloWorld();
    
        /// Returns true.
        inline bool returnTrue()
        { return true; }
    };
    
    /**
       \brief Here say what this class is and does..
    
        \tparam dim The dimention
    */
    template<unsigned dim>
    gsMyTemplatedClass
    {
        /// Function templated w.r.t. dim
        void functionDependingOnDim();
    };
    }// namespace gismo
    
    #ifndef GISMO_BUILD_LIB
    #include GISMO_HPP_HEADER(gsFilename.hpp)
    #endif
    
  • gsFilename.cpp file contains the definitions (i.e., the bodies) of the non-templated functions declared in gsFilename.h;
    /** @file ... */
    #include <gsWhereIFindIt/gsWhateverINeed.h>
    #include <gsMyFolder/gsFilename.h>
    
    namespace gismo
    {
    void gsMyClass::helloWorld()
    {
        std::cout << "Hello, World!" << std::endl;
    }
    }// namespace gismo
    
  • gsFilename.hpp file contains the definitions of the templated functions declared in the gsFilename.h;
    #include <gsMyFolder/gsFilename.h> // Only for syntax highlighting in Qtcreator, as during compilation, this file is included by the gsFilename.h
    namespace gismo
    {
    template<unsigned dim>
    gsMyTemplatedClass<dim>::functionDependingOnDim()
    {
        // code depending on dim
    }
    } // namespace gismo
    
  • gsFilename_.cpp file consists of explicit template instantiations, that are explorted to the dynamic library. This is done by a macro so that it is platform independent.
    /** @file ... */
    #include <gsWhereIFindIt/gsWhateverINeed.h>
    #include <gsMyFolder/gsFilename.hpp>
    namespace gismo
    {
        CLASS_TEMPLATE_INST gsMyTemplatedClass<1> ;
        CLASS_TEMPLATE_INST gsMyTemplatedClass<2> ;
        // ...
    } // namespace gismo
    

Pitfalls

If your non-templated class has definitions in the gsMyClass.cpp file, you need to export it to allow the users call its public functions. This you do by adding GISMO_EXPORT in gsMyClass.h:

class GISMO_EXPORT gsMyClass
{
void helloWorld();
// etc., as before
};

If you forget, you get linking error undefined reference to gismo::gsMyClass::myFunction() which is quite hard to figure out in these circumstances.

For templated functions, this keyword is not needed. However, if the templated class is partitioned in gsMyClass.h and gsMyClass.hpp files, an exported instance has to be added, this is the gsMyClass_.cpp file. In this situation the instantization and exporting is done by

#include <gsCore/gsTemplateTools.h>
#include <gsMyModule/gsMyClass.h>
#include <gsMyModule/gsMyClass.hpp>

namespace gismo {
CLASS_TEMPLATE_INST gsMyClass<real_t> ;
}

The export attribute is now hidden in CLASS_TEMPLATE_INST.

namespace gismo
{

template<class T, class KnotVectorType >
class gsBSplineBasis : public gsBasis<T>
{
public:
    typedef gsBasis<T> Base;

public:

    gsBSplineBasis() : Base() 
    { 

    }

    gsBSplineBasis( const KnotVectorType & KV, int p) : m_p(p), m_knots(KV)
    { 
        if( ! check()  )
            gsWarn << "Warning: Insconsistent "<< *this<< "\n";

        m_knots.set_degree(p); 
    }
}; //end class

}// end namespace gismo

Open the Text Editor options. (Tools / Options / Text Editor). Expand "All Languages" and then click "Tabs". Set the "Tab size" to 4 and check "Insert spaces". Click OK.

  • Style settings for emacs: Put this into your .emacs file:
    (defun gismo-indent-setup ()
      (setq c-default-style "bsd"
            c-basic-offset   4
            c++-basic-offset 4
            c-indent-level   4
            c++-indent-level 4
            tab-width        4
            inline-open      0
            indent-tabs-mode nil
            substatement-open 0
    	)
      (c-set-offset 'innamespace '0)
      (c-set-offset 'member-init-intro '0)
      (c-set-offset 'inline-open '0)
    )
    
    (add-hook 'c-mode-hook          'gismo-indent-setup)
    (add-hook 'c++-mode-hook        'gismo-indent-setup)
    
    
  • Style setting for vim: Put this into your .vimrc file:
    set expandtab
    set shiftwidth=4
    set softtabstop=4
    
Last modified 22 months ago Last modified on 2016-02-03T10:37:50+01:00