### Install Doxygen and Graphviz on Ubuntu Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/Doxygen/README.org Installs the necessary packages for building Doxygen documentation on Ubuntu GNU/Linux systems. ```bash sudo apt-get install doxygen graphviz ``` -------------------------------- ### Documenting Namespaces in Header Files Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Illustrates documenting a namespace by referencing the header file where it is defined, using the 'Foam' namespace as an example documented in 'foamVersion.H'. ```C++ namespace 'Foam' is documented in the foamVersion.H file ``` -------------------------------- ### Doxygen Example with Verbatim and Code Blocks Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Demonstrates the use of Doxygen tags like 'InClass' and 'Description', along with embedded verbatim and code blocks for illustrating input files and code loops. ```C++ InClass Foam::myClass Description Implements the read and writing of files. An example input file: \verbatim patchName { type patchType; refValue 100; value uniform 1; } \endverbatim Within the implementation, a loop over all patches is done: \code forAll(patches, patchi) { ... // some operation } \endcode ``` -------------------------------- ### Documentation comment structure Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Provides an example of the structure for documentation comments, using tags like 'Class' and 'Description'. The first paragraph after 'Description' is the brief description. ```C++ Class Foam::myClass Description A class for specifying the documentation style. ``` -------------------------------- ### APA Style Reference Example Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Provides an example of how to format references in the 'Description' section of class header files using the APA style, as seen in the kEpsilon turbulence model documentation. ```text Description Standard k-epsilon turbulence model for incompressible and compressible flows including rapid distortion theory (RDT) based compression term. Reference: \verbatim Standard model: Launder, B. E., & Spalding, D. B. (1972). Lectures in mathematical models of turbulence. Launder, B. E., & Spalding, D. B. (1974). The numerical computation of turbulent flows. Computer methods in applied mechanics and engineering, 3(2), 269-289. ``` -------------------------------- ### Doxygen Brief and Detailed Description in Header Files Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Use special comment syntax in header files for Doxygen documentation. Text starting with '//-' becomes the brief description, and subsequent lines form the detailed description. ```C++ //- A function which returns a thing // This is a detailed description of the function // which processes stuff and returns other stuff // depending on things. thing function(stuff1, stuff2); ``` -------------------------------- ### Doxygen List Entries in Header Files Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Format list entries in Doxygen comments using '- ' or '-# ' for numbered lists. Ensure there is a blank line after the brief description before starting the list. ```C++ //- Compare triFaces // Returns: // - 0: different // - +1: identical // - -1: same face, but different orientation static inline int compare(const triFace&, const triFace&); ``` ```C++ //- Compare triFaces returning 0, +1 or -1 // // - 0: different // - +1: identical // - -1: same face, but different orientation static inline int compare(const triFace&, const triFace&); ``` -------------------------------- ### Stream Output Formatting Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Align stream output operators (<<) for consistent formatting. Use four spaces after the start of the stream. ```c++ Info<< ... os << ... ``` -------------------------------- ### Open Doxygen Index File in Firefox Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/Doxygen/README.org Opens the generated index.html file in the Firefox browser to view the OpenFOAM source code documentation. Assumes Firefox is installed and the html directory is accessible. ```bash firefox html/index.html ``` -------------------------------- ### Incorrect assignment split (function on new line) Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Illustrates an incorrect assignment split where the function call starts on a new line without proper indentation. Ensure consistent indentation. ```C++ variableName = longClassName.longFunctionName ( longArgument1, longArgument2 ); ``` -------------------------------- ### Standard for loop Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Demonstrates the standard for loop syntax. Use this for simple iterative loops. ```C++ for (i = 0; i < maxI; i++) { code; } ``` -------------------------------- ### Run All Make Script for Doxygen Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/Doxygen/README.org Executes the Allwmake script in the Doxygen directory to build the HTML documentation. The output will be located in the html subdirectory. ```bash ./Allwmake ``` -------------------------------- ### forAll macro usage Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Demonstrates the correct usage of the forAll macro for iterating over containers. Ensure no space between 'forAll' and the opening parenthesis. ```C++ forAll( ``` -------------------------------- ### Set Library and Include Directories Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Configures directories for linking libraries and including headers, utilizing environment variables for paths. ```cmake LINK_DIRECTORIES( $ENV{FOAM_LIBBIN} $ENV{FOAM_EXT_LIBBIN} $ENV{PV_PLUGIN_PATH} ) INCLUDE_DIRECTORIES( $ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude $ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude ${PROJECT_SOURCE_DIR}/../vtkPVblockMesh ${PROJECT_SOURCE_DIR}/vtk ) ``` -------------------------------- ### Documenting Classes in Header Files Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Use 'Class' and 'Namespace' tags in header files to document classes. The 'Description' block then applies to the class itself. ```C++ InClass Foam::myClass Description Implements the read and writing of files. ``` -------------------------------- ### Splitting long function signature (second split) Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Demonstrates how to split a long function signature a second time, splitting at the function name and aligning subsequent parts to the left. ```C++ const Foam::longReturnTypeName& Foam::veryveryveryverylongClassName:: veryveryveryverylongFunctionName const ``` -------------------------------- ### Splitting mathematical formulae over multiple lines Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Demonstrates how to split complex mathematical formulae across lines, keeping the operator on the lower line and indenting subsequent parts. ```C++ variableName = a*(a + b) *exp(c/d) *(k + t); ``` -------------------------------- ### Link Libraries for ParaView Versions < 5.5 Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Links necessary libraries for building the plugin when ParaView version is less than 5.5. ```cmake IF(${ParaView_VERSION} VERSION_LESS 5.5) TARGET_LINK_LIBRARIES( ${TARGET_NAME} LINK_PUBLIC vtkPVFoam finiteVolume OpenFOAM LINK_PRIVATE pqApplicationComponents ) ELSEIF(${ParaView_VERSION} VERSION_LESS 5.7) # Assume QT version 5 if it hasn't been defined IF(NOT PARAVIEW_QT_MAJOR_VERSION) set(PARAVIEW_QT_MAJOR_VERSION 5) ENDIF() # Paraview-5.5.x and higher needs QT libraries listed in the link command # in order for the headers to be available TARGET_LINK_LIBRARIES( ${TARGET_NAME} LINK_PUBLIC vtkPVFoam finiteVolume OpenFOAM Qt${PARAVIEW_QT_MAJOR_VERSION}::Core Qt${PARAVIEW_QT_MAJOR_VERSION}::Gui LINK_PRIVATE pqApplicationComponents ) ELSE() # Assume QT version 5 if it hasn't been defined IF(NOT PARAVIEW_QT_MAJOR_VERSION) set(PARAVIEW_QT_MAJOR_VERSION 5) ENDIF() # Paraview-5.5.x and higher needs QT libraries listed in the link command # in order for the headers to be available TARGET_LINK_LIBRARIES( ${TARGET_NAME} LINK_PUBLIC vtkPVFoam finiteVolume OpenFOAM Qt${PARAVIEW_QT_MAJOR_VERSION}::Core Qt${PARAVIEW_QT_MAJOR_VERSION}::Gui LINK_PRIVATE ParaView::pqApplicationComponents ) ENDIF() ``` -------------------------------- ### Link Libraries for Plugin (ParaView < 5.5) Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Links necessary libraries for the plugin when ParaView version is less than 5.5. ```cmake IF(${ParaView_VERSION} VERSION_LESS 5.5) TARGET_LINK_LIBRARIES( ${TARGET_NAME} LINK_PUBLIC vtkPVblockMesh OpenFOAM LINK_PRIVATE pqApplicationComponents ) ELSEIF(${ParaView_VERSION} VERSION_LESS 5.7) # Assume QT version 5 if it hasn't been defined IF(NOT PARAVIEW_QT_MAJOR_VERSION) set(PARAVIEW_QT_MAJOR_VERSION 5) ENDIF() # Paraview-5.5.x and higher needs QT libraries listed in the link command # in order for the headers to be available TARGET_LINK_LIBRARIES( ${TARGET_NAME} LINK_PUBLIC vtkPVblockMesh OpenFOAM Qt${PARAVIEW_QT_MAJOR_VERSION}::Core Qt${PARAVIEW_QT_MAJOR_VERSION}::Gui LINK_PRIVATE pqApplicationComponents ) ELSE() # Assume QT version 5 if it hasn't been defined IF(NOT PARAVIEW_QT_MAJOR_VERSION) set(PARAVIEW_QT_MAJOR_VERSION 5) ENDIF() # Paraview-5.5.x and higher needs QT libraries listed in the link command # in order for the headers to be available TARGET_LINK_LIBRARIES( ${TARGET_NAME} LINK_PUBLIC vtkPVblockMesh OpenFOAM Qt${PARAVIEW_QT_MAJOR_VERSION}::Core Qt${PARAVIEW_QT_MAJOR_VERSION}::Gui LINK_PRIVATE ParaView::pqApplicationComponents ) ENDIF() ``` -------------------------------- ### Include ParaView Use File for Older Versions Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Includes the ParaView use file for ParaView versions 5.7.x and lower. ```cmake IF(${ParaView_VERSION} VERSION_LESS 5.7) # ParaView-5.7.x and lower requires the paraview include file INCLUDE(${PARAVIEW_USE_FILE}) ENDIF() ``` -------------------------------- ### Documenting Namespaces within Classes Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Shows how to document a namespace when it is contained within a class, specifically for the 'Foam::functionEntries' namespace within the 'Foam::functionEntry' class. ```C++ documented namespace 'Foam::functionEntries' within the class 'Foam::functionEntry' ``` -------------------------------- ### Compact for loop (discouraged) Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Illustrates a compact for loop syntax that is discouraged due to potential readability issues. Avoid this style. ```C++ for(i = 0; i < maxI; i++) { code; } ``` -------------------------------- ### Generate Doxygen Header, Footer, and Stylesheet Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/Doxygen/README.org Generates the HTML header, footer, and custom stylesheet files required for Doxygen documentation customization. Ensure you are in the correct directory. ```bash doxygen -w html header.html footer.html customdoxygen.css ``` -------------------------------- ### Multi-line for loop Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Shows an alternative for loop syntax where components are placed on separate lines. This can improve readability for complex loop conditions. ```C++ for ( i = 0; i < maxI; i++ ) { code; } ``` -------------------------------- ### Splitting logical tests over several lines Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Illustrates the preferred method for splitting logical tests across multiple lines, outdenting the operator to align the next condition. ```C++ if ( a == true && b == c ) ``` -------------------------------- ### Set Include Directories Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Specifies directories for header file searching during compilation. ```cmake INCLUDE_DIRECTORIES( $ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude $ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude $ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude ${PROJECT_SOURCE_DIR}/../vtkPVFoam ${PROJECT_SOURCE_DIR}/vtk ) ``` -------------------------------- ### Splitting formulae with extra parentheses Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Shows an alternative for splitting formulae using extra parentheses for enhanced readability, with operators on lower lines and indented content. ```C++ variableName = ( a*(a + b) *exp(c/d) *(k + t) ); ``` -------------------------------- ### Set Link Directories Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Specifies directories where libraries should be searched for linking. ```cmake LINK_DIRECTORIES( $ENV{FOAM_LIBBIN} $ENV{FOAM_EXT_LIBBIN} $ENV{PV_PLUGIN_PATH} ) ``` -------------------------------- ### Splitting function signature over multiple lines Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Demonstrates the preferred method for splitting long function signatures across multiple lines. The return type and function name are aligned to the left. ```C++ const Foam::longReturnTypeName& Foam::longClassName::longFunctionName const ``` -------------------------------- ### Handle ParaView Version for Target Name Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Sets the target name based on the ParaView version. Versions prior to 5.7 prepend 'lib'. ```cmake IF(${ParaView_VERSION} VERSION_LESS 5.7) # ParaView-5.7.x and lower will prepend "lib" to the target name SET(TARGET_NAME PVblockMeshReader_SM) ELSE() SET(TARGET_NAME libPVblockMeshReader_SM) ENDIF() ``` -------------------------------- ### Set Plugin Output Directory Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Configures the output directory for the plugin's library file. ```cmake SET_TARGET_PROPERTIES( ${TARGET_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "$ENV{PV_PLUGIN_PATH}" ) ``` -------------------------------- ### Add Compiler Definitions Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Adds preprocessor definitions for the compiler, including C++ standard and OpenFOAM specific flags. ```cmake ADD_DEFINITIONS( -std=c++17 -DWM_$ENV{WM_PRECISION_OPTION} -DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE} ) ``` -------------------------------- ### Add ParaView Plugin (Older Versions) Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Adds the ParaView plugin using ADD_PARAVIEW_PLUGIN for versions prior to 5.7. ```cmake IF(${ParaView_VERSION} VERSION_LESS 5.7) ADD_PARAVIEW_PLUGIN( ${TARGET_NAME} "1.0" SERVER_MANAGER_XML PVblockMeshReader_SM.xml SERVER_MANAGER_SOURCES vtk/vtkPVblockMeshReader.cxx ) ELSE() # Paraview-5.7.x and higher builds the vtk module separately PARAVIEW_ADD_PLUGIN( ${TARGET_NAME} VERSION "1.0" SERVER_MANAGER_XML PVblockMeshReader_SM.xml MODULES PVblockMeshReader_VTK MODULE_FILES "vtk/vtk.module" ) ENDIF() ``` -------------------------------- ### Find ParaView Package Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Locates the ParaView package, which is required for building the plugin. ```cmake FIND_PACKAGE(ParaView REQUIRED) ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Specifies the minimum required CMake version and sets the project name for the build. ```cmake CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) PROJECT(PVblockMeshReader) ``` -------------------------------- ### Splitting assignment with multi-line arguments Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Illustrates splitting a long assignment where the function call has multiple arguments, requiring further line breaks. ```C++ variableName = longClassName.longFunctionName ( longArgument1, longArgument2 ); ``` -------------------------------- ### forAll macro with space (discouraged) Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Shows the discouraged usage of the forAll macro with a space between 'forAll' and the opening parenthesis. Avoid this style. ```C++ forAll ( ``` -------------------------------- ### Variable Initialization using Assignment Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Initialize variables using assignment with the '&' operator for const references, not direct initialization in parentheses. ```C++ const className& variableName = otherClass.data(); ``` -------------------------------- ### Fully Scoped Namespace in Source Files Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org In source files, fully scope function names instead of opening/closing namespaces. This avoids clutter and ensures clarity. ```C++ Foam::returnType Foam::className::functionName() ``` -------------------------------- ### Documenting Under-Documented Classes with Namespace Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org When a class is not yet fully documented, use its namespace-qualified name for the description to aid in later identification. This ensures Doxygen correctly associates the documentation. ```C++ Class Foam::myUnderDocumentedClass Description Foam::myUnderDocumentedClass ``` -------------------------------- ### Add ParaView Plugin for Older Versions Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Adds a ParaView plugin using ADD_PARAVIEW_PLUGIN for versions prior to 5.7. ```cmake IF(${ParaView_VERSION} VERSION_LESS 5.7) ADD_PARAVIEW_PLUGIN( ${TARGET_NAME} "1.0" SERVER_MANAGER_XML PVFoamReader_SM.xml SERVER_MANAGER_SOURCES vtk/vtkPVFoamReader.cxx ) ELSE() # Paraview-5.7.x and higher builds the vtk module separately PARAVIEW_ADD_PLUGIN( ${TARGET_NAME} VERSION "1.0" SERVER_MANAGER_XML PVFoamReader_SM.xml MODULES PVFoamReader_VTK MODULE_FILES "vtk/vtk.module" ) ENDIF() ``` -------------------------------- ### Warning Message Formatting Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Format warning messages with stream output aligned. Ensure the '<<' symbol is correctly positioned. ```C++ WarningInFunction << "Warning message" ``` -------------------------------- ### Accessing a Cell Zone by Name Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/mesh/conversion/fluentMeshToFoam/README.txt Demonstrates how to access a specific cell zone from the mesh object using its name. This is useful for retrieving and manipulating zone data. ```cpp const labelList& thisCellZone = mesh.cellZones()["thisZoneName"]; ``` -------------------------------- ### Set Library Output Directory for PVFoamReader VTK Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtk/CMakeLists.txt Configures the library output directory for the 'PVFoamReader_VTK' target to the environment variable PV_PLUGIN_PATH. ```cmake SET( PVFoamReader_VTK PROPERTIES LIBRARY_OUTPUT_DIRECTORY "$ENV{PV_PLUGIN_PATH}" ) ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Specifies the minimum required CMake version and defines the project name for the PVFoamReader. ```cmake CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) PROJECT(PVFoamReader) ``` -------------------------------- ### Link Libraries for PVFoamReader VTK Target Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtk/CMakeLists.txt Specifies the public and private libraries to link against for the 'PVFoamReader_VTK' target, including VTK, OpenFOAM, and Qt components. ```cmake TARGET_LINK_LIBRARIES( PVFoamReader_VTK LINK_PUBLIC vtkPVFoam finiteVolume OpenFOAM Qt${PARAVIEW_QT_MAJOR_VERSION}::Core Qt${PARAVIEW_QT_MAJOR_VERSION}::Gui LINK_PRIVATE ParaView::pqApplicationComponents ) ``` -------------------------------- ### Link Libraries for PVblockMeshReader VTK Target Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtk/CMakeLists.txt Links public and private libraries required by the PVblockMeshReader VTK target, including VTK, OpenFOAM, and Qt components. ```cmake TARGET_LINK_LIBRARIES( PVblockMeshReader_VTK LINK_PUBLIC vtkPVblockMesh OpenFOAM Qt${PARAVIEW_QT_MAJOR_VERSION}::Core Qt${PARAVIEW_QT_MAJOR_VERSION}::Gui LINK_PRIVATE ParaView::pqApplicationComponents ) ``` -------------------------------- ### Set Target Properties for PVblockMeshReader VTK Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtk/CMakeLists.txt Sets the library output directory for the PVblockMeshReader VTK target to the plugin path environment variable. ```cmake SET_TARGET_PROPERTIES( PVblockMeshReader_VTK PROPERTIES LIBRARY_OUTPUT_DIRECTORY "$ENV{PV_PLUGIN_PATH}" ) ``` -------------------------------- ### Set Default Paraview Qt Major Version Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtk/CMakeLists.txt Ensures PARAVIEW_QT_MAJOR_VERSION is set to 5 if it is not already defined. ```cmake IF(NOT PARAVIEW_QT_MAJOR_VERSION) set(PARAVIEW_QT_MAJOR_VERSION 5) ENDIF() ``` -------------------------------- ### Incorrect function signature split (scope on new line) Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Shows an incorrect way to split function signatures by placing the scope resolution operator '::' on a new line. Avoid this formatting. ```C++ const Foam::longReturnTypeName& Foam::longClassName:: longFunctionName const ``` -------------------------------- ### Incorrect function signature split (indentation) Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Shows an incorrect way to split function signatures, with improper indentation. Avoid indenting the function name and arguments excessively. ```C++ const Foam::longReturnTypeName& Foam::longClassName::longFunctionName const ``` -------------------------------- ### Define VTK Module for PVblockMeshReader Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtk/CMakeLists.txt Defines the VTK module for PVblockMeshReader, specifying its classes. ```cmake VTK_MODULE_ADD_MODULE(PVblockMeshReader_VTK CLASSES vtkPVblockMeshReader) ``` -------------------------------- ### Add VTK Module for PVFoamReader Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtk/CMakeLists.txt Adds a VTK module named 'PVFoamReader_VTK_CLASSES' for the 'vtkPVFoamReader' component. ```cmake VTK_MODULE_ADD_MODULE(PVFoamReader_VTK CLASSES vtkPVFoamReader) ``` -------------------------------- ### Class Declaration Header Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Use a centered header for class declarations. Ensure the header format is consistent. ```C++ /*---------------------------------------------------------------------------*\ Class exampleClass Declaration \*---------------------------------------------------------------------------*/ ``` -------------------------------- ### Nested Namespaces in Source Files Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org When multiple levels of namespaces are involved, they can be used in source files to prevent excessive prefixing, with closing namespace comments. ```C++ namespace Foam { namespace compressible { namespace RASModels { ... } // End namespace RASModels } // End namespace compressible } // End namespace Foam ``` -------------------------------- ### Operator spacing in comparison and logical operations Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Specifies spacing for comparison and logical operators. Use spaces around all comparison operators and logical AND/OR. ```C++ a = b, a != b a < b, a > b, a >= b, a <= b a || b, a && b ``` -------------------------------- ### forAllIter macro with comma in type (fails) Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Illustrates a case where the forAllIter macro fails due to a comma within the iterated object's type. This highlights a limitation of these macros. ```C++ forAllIter(HashTable>, foo, iter) ``` -------------------------------- ### Nested Doxygen Lists in Header Files Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Nested lists can be used in Doxygen comments for detailed explanations. Ensure proper indentation and list item markers. ```C++ //- Search for \em name // in the following hierarchy: // -# personal settings: // - ~/.OpenFOAM/\/ // for version-specific files // - ~/.OpenFOAM/ // for version-independent files // -# site-wide settings: // - $WM_PROJECT_INST_DIR/site/\/etc/ // for version-specific files // - $WM_PROJECT_INST_DIR/site/etc/ // for version-independent files // -# shipped settings: // - $WM_PROJECT_DIR/etc/ // // \return the full path name or fileName() if the name cannot be found // Optionally abort if the file cannot be found fileName findEtcFile(const fileName&, bool mandatory=false); ``` -------------------------------- ### Incorrect function signature split (const on new line) Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Illustrates another incorrect method for splitting function signatures, where 'const' is placed on its own line. Keep 'const' with the function name and arguments. ```C++ const Foam::longReturnTypeName& Foam::longClassName::longFunctionName const ``` -------------------------------- ### Standard If Statement Formatting Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Use braces for all code blocks within if statements, even for single lines. The condition can be placed on the same line or wrapped for readability if long. ```C++ if (condition) { code; } ``` ```C++ if ( long condition ) { code; } ``` -------------------------------- ### Set Target Name Based on ParaView Version Source: https://github.com/openfoam/openfoam-dev/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Determines the target library name based on the ParaView version. Older versions prepend 'lib'. ```cmake IF(${ParaView_VERSION} VERSION_LESS 5.7) # ParaView-5.7.x and lower will prepend "lib" to the target name SET(TARGET_NAME PVFoamReader_SM) ELSE() SET(TARGET_NAME libPVFoamReader_SM) ENDIF() ``` -------------------------------- ### Incorrect assignment split (operator on new line) Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Shows an incorrect way to split assignment statements, placing the assignment operator '=' on a new line. The operator should remain on the first line. ```C++ variableName = longClassName.longFunctionName(longArgument); ``` -------------------------------- ### Splitting assignment with long function call Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Shows the preferred way to split a long assignment statement, indenting the right-hand side after the equals sign. ```C++ variableName = longClassName.longFunctionName(longArgument); ``` -------------------------------- ### Operator spacing in arithmetic and bitwise operations Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Defines the preferred spacing around arithmetic and bitwise operators. Use spaces around '+' and '-' but not around '*' and '/'. ```C++ a + b, a - b a*b, a/b a & b, a ^ b ``` -------------------------------- ### Doxygen Comment for Destructor Source: https://github.com/openfoam/openfoam-dev/blob/master/doc/codingStyleGuide.org Use a standard Doxygen comment for destructors, similar to other functions. ```C++ //- Destructor ~className(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.