### Basic CMake Setup Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Initializes the CMake version and project name. Sets up the ParaView package requirement. ```cmake CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) PROJECT(PVFoamReader) FIND_PACKAGE(ParaView REQUIRED) ``` -------------------------------- ### Install Doxygen and Graphviz Source: https://github.com/openfoam/openfoam-10/blob/master/doc/Doxygen/README.org Installs the required Doxygen and Graphviz packages on Ubuntu GNU/Linux systems using apt-get. ```bash sudo apt-get install doxygen graphviz ``` -------------------------------- ### Doxygen Example with Verbatim and Code Blocks in C++ Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Demonstrates using Doxygen special commands like \verbatim and \code within documentation blocks. Ensure Doxygen commands are correctly formatted. ```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 ``` -------------------------------- ### Documenting Namespaces in C++ Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Examples of documenting namespaces, either explicitly declared or within class definitions. ```C++ documented namespace 'Foam::functionEntries' within the class 'Foam::functionEntry' ``` ```C++ namespace 'Foam' is documented in the foamVersion.H file ``` -------------------------------- ### APA Style Reference Example Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Illustrates the correct formatting for references in the 'Description' section of class header files, following the APA style guide. ```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. ``` -------------------------------- ### Documentation comment tags Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Provides an example of using documentation comment tags like 'Class' and 'Description' for Doxygen pre-filtering. ```C++ Class Foam::myClass Description A class for specifying the documentation style. ``` -------------------------------- ### forAll macro usage Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Demonstrates the correct usage of the forAll macro for iterating over containers. ```C++ forAll( ``` -------------------------------- ### Standard for loop Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Demonstrates the preferred standard for loop syntax in C++. ```C++ for (i = 0; i < maxI; i++) { code; } ``` -------------------------------- ### Run Doxygen Build Script Source: https://github.com/openfoam/openfoam-10/blob/master/doc/Doxygen/README.org Executes the Allwmake script in the Doxygen directory to generate the OpenFOAM source code documentation. The output is placed in the html directory. ```bash ./Allwmake ``` -------------------------------- ### Directory and Definition Configuration Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Configures library search paths, include directories, and compiler definitions for the project. Includes 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 $ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude ${PROJECT_SOURCE_DIR}/../vtkPVFoam ${PROJECT_SOURCE_DIR}/vtk ) ADD_DEFINITIONS( -std=c++14 -DWM_$ENV{WM_PRECISION_OPTION} -DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE} ) ``` -------------------------------- ### Doxygen Brief and Detailed Description in C++ Headers Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Use '//-' for the Doxygen brief description and subsequent lines for the detailed description in header files. Ensure proper spacing for list items. ```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); ``` ```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&); ``` ```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); ``` -------------------------------- ### Open Doxygen Documentation in Firefox Source: https://github.com/openfoam/openfoam-10/blob/master/doc/Doxygen/README.html After generating the documentation, use this command to open the main index file in the Firefox browser. This allows you to view the generated documentation. ```bash firefox $WM_PROJECT_DIR/doc/Doxygen/html/index.html ``` -------------------------------- ### Documenting Class Implementation in C++ Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Use 'InClass' and 'InNamespace' tags in header files for class documentation, and 'InClass' in source files for file-specific documentation. ```C++ InClass Foam::myClass Description Implements the read and writing of files. ``` -------------------------------- ### Set Include Directories Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Specifies directories where the compiler should search for header files. Includes OpenFOAM, OS-specific, and local plugin headers. ```cmake 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 ) ``` -------------------------------- ### Generate Doxygen Header, Footer, and Stylesheet Source: https://github.com/openfoam/openfoam-10/blob/master/doc/Doxygen/README.org Generates the HTML header, footer, and a custom CSS stylesheet for Doxygen documentation. This command should be run from the Doxygen configuration directory. ```bash doxygen -w html header.html footer.html customdoxygen.css ``` -------------------------------- ### Linking Libraries for Plugin Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Links the necessary libraries to the plugin target. Includes version-specific Qt5 libraries for newer ParaView versions. ```cmake # Build the plugin IF(${ParaView_VERSION} VERSION_LESS 5.5) TARGET_LINK_LIBRARIES( ${TARGET_NAME} LINK_PUBLIC vtkPVFoam finiteVolume OpenFOAM ) ELSE() # Paraview-5.5.x and higher needs QT-5 libraries listed in the link command # in order for the headers to be available TARGET_LINK_LIBRARIES( ${TARGET_NAME} LINK_PUBLIC vtkPVFoam finiteVolume OpenFOAM Qt5::Core Qt5::Gui ) ENDIF() ``` -------------------------------- ### Compact for loop (discouraged) Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Illustrates a compact for loop syntax that is discouraged due to potential readability issues. ```C++ for(i = 0; i < maxI; i++) { code; } ``` -------------------------------- ### Multi-line for loop Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Shows an alternative, multi-line for loop syntax for improved readability. ```C++ for ( i = 0; i < maxI; i++ ) { code; } ``` -------------------------------- ### forAll macro (discouraged) Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Shows a discouraged syntax for the forAll macro with a space before the opening parenthesis. ```C++ forAll ( ``` -------------------------------- ### Setting Library Output Directory Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Configures the output directory for the plugin's library to the ParaView plugin path. ```cmake # Set the output library destination to the plugin directory SET_TARGET_PROPERTIES( ${TARGET_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "$ENV{PV_PLUGIN_PATH}" ) ``` -------------------------------- ### Set Link Directories Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Specifies directories where the linker should search for libraries. Includes OpenFOAM and ParaView plugin paths. ```cmake LINK_DIRECTORIES( $ENV{FOAM_LIBBIN} $ENV{FOAM_EXT_LIBBIN} $ENV{PV_PLUGIN_PATH} ) ``` -------------------------------- ### Adding ParaView Plugin with Version Specifics Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Adds the PVFoamReader plugin, with different arguments based on ParaView version. Older versions require GUI resource files. ```cmake # Add the plugin IF(${ParaView_VERSION} VERSION_LESS 4.1) # ParaView-4.0.x and lower requires a GUI_RESOURCE_FILES XML file ADD_PARAVIEW_PLUGIN( ${TARGET_NAME} "1.0" SERVER_MANAGER_XML PVFoamReader_SM.xml SERVER_MANAGER_SOURCES vtk/vtkPVFoamReader.cxx GUI_RESOURCE_FILES PVFoamReader.xml ) ELSEIF(${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() ``` -------------------------------- ### Open Doxygen Documentation in Firefox Source: https://github.com/openfoam/openfoam-10/blob/master/doc/Doxygen/README.org Opens the generated index.html file of the OpenFOAM Doxygen documentation in the Firefox browser. ```bash firefox html/index.html ``` -------------------------------- ### Splitting long function name and class name Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Demonstrates how to split function and class names across multiple lines when they are excessively long. ```C++ const Foam::longReturnTypeName& Foam::veryveryveryverylongClassName:: veryveryveryverylongFunctionName const ``` -------------------------------- ### Splitting function return type and name Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Demonstrates the preferred method for splitting function return types and names across multiple lines for long declarations. ```C++ const Foam::longReturnTypeName& Foam::longClassName::longFunctionName const ``` -------------------------------- ### Add ParaView Plugin for Older Versions (<= 4.0.x) Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Adds the ParaView plugin for versions 4.0.x and lower, requiring a GUI_RESOURCE_FILES XML file. ```cmake IF(${ParaView_VERSION} VERSION_LESS 4.1) # ParaView-4.0.x and lower requires a GUI_RESOURCE_FILES XML file ADD_PARAVIEW_PLUGIN( ${TARGET_NAME} "1.0" SERVER_MANAGER_XML PVblockMeshReader_SM.xml SERVER_MANAGER_SOURCES vtk/vtkPVblockMeshReader.cxx GUI_RESOURCE_FILES PVblockMeshReader.xml ) ELSEIF(${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() ``` -------------------------------- ### Splitting mathematical formulae with extra parentheses Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Illustrates splitting long mathematical formulae using extra parentheses for clarity, with operators on lower lines. ```C++ variableName = ( a*(a + b) *exp(c/d) *(k + t) ); ``` -------------------------------- ### Link Libraries for Older ParaView Versions (< 5.5) Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Links the plugin target to necessary libraries for ParaView versions older than 5.5, including vtkPVblockMesh and OpenFOAM. ```cmake IF(${ParaView_VERSION} VERSION_LESS 5.5) TARGET_LINK_LIBRARIES( ${TARGET_NAME} LINK_PUBLIC vtkPVblockMesh OpenFOAM ) ELSE() # Paraview-5.5.x and higher needs QT-5 libraries listed in the link command # in order for the headers to be available TARGET_LINK_LIBRARIES( ${TARGET_NAME} LINK_PUBLIC vtkPVblockMesh OpenFOAM Qt5::Core Qt5::Gui ) ENDIF() ``` -------------------------------- ### Set Target Properties for PVblockMeshReader Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtk/CMakeLists.txt Configures the 'PVblockMeshReader_VTK' target to place its library output in the directory specified by the PV_PLUGIN_PATH environment variable. This is crucial for plugin discovery. ```cmake SET_TARGET_PROPERTIES( PVblockMeshReader_VTK PROPERTIES LIBRARY_OUTPUT_DIRECTORY "$ENV{PV_PLUGIN_PATH}" ) ``` -------------------------------- ### Include ParaView Use File for Older Versions Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Includes the ParaView use file for versions older than 5.7. This file provides necessary definitions and targets for older ParaView builds. ```cmake IF(${ParaView_VERSION} VERSION_LESS 5.7) # ParaView-5.7.x and lower requires the paraview include file INCLUDE(${PARAVIEW_USE_FILE}) ENDIF() ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Specifies the minimum required CMake version and defines the project name for the build system. ```cmake CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) PROJECT(PVblockMeshReader) ``` -------------------------------- ### Link Libraries for PVFoamReader VTK Target Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtk/CMakeLists.txt Links necessary libraries to the PVFoamReader VTK target, including VTK modules, OpenFOAM, and Qt. ```cmake TARGET_LINK_LIBRARIES( PVFoamReader_VTK LINK_PUBLIC vtkPVFoam finiteVolume OpenFOAM Qt5::Core Qt5::Gui ) ``` -------------------------------- ### Splitting mathematical formulae with operator on lower line Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Shows how to split long mathematical formulae over multiple lines, with the operator placed on the lower line and aligned indentation. ```C++ variableName = a*(a + b) *exp(c/d) *(k + t); ``` -------------------------------- ### Add Preprocessor Definitions Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Adds preprocessor definitions for the C++ standard, precision, and label size, often used for OpenFOAM integration. ```cmake ADD_DEFINITIONS( -std=c++14 -DWM_$ENV{WM_PRECISION_OPTION} -DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE} ) ``` -------------------------------- ### Set Plugin Library Output Directory Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Configures the target properties to set the output directory for the plugin library to the ParaView plugin path. ```cmake SET_TARGET_PROPERTIES( ${TARGET_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "$ENV{PV_PLUGIN_PATH}" ) ``` -------------------------------- ### Splitting logical tests with outdented operator Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Demonstrates splitting logical tests over multiple lines, outdenting the operator for alignment with subsequent variables. ```C++ if ( a == true && b == c ) ``` -------------------------------- ### forAllIter macro with complex type Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Illustrates the use of the forAllIter macro with a complex type, highlighting potential issues with commas in the type definition. ```C++ forAllIter(HashTable>, foo, iter) ``` -------------------------------- ### Find ParaView Package Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Finds the ParaView package, which is required for building the plugin. This makes ParaView's build system targets and variables available. ```cmake FIND_PACKAGE(ParaView REQUIRED) ``` -------------------------------- ### Splitting function return type and name (discouraged - indentation) Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Shows a discouraged way to split function declarations with incorrect indentation. ```C++ const Foam::longReturnTypeName& Foam::longClassName::longFunctionName const ``` -------------------------------- ### Documenting Under-Documented Classes in C++ Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Use the namespace-qualified class name for the description when there's nothing specific to add. This helps in identifying under-documented classes. ```C++ Class Foam::myUnderDocumentedClass Description Foam::myUnderDocumentedClass ``` -------------------------------- ### Accessing Cell Zones in OpenFOAM Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/mesh/conversion/fluentMeshToFoam/README.txt Demonstrates how to access a specific cell zone by its name from the polyMesh object. This is useful for manipulating or querying zone data. ```cpp const labelList& thisCellZone = mesh.cellZones()["thisZoneName"]; ``` -------------------------------- ### Link Libraries for PVblockMeshReader Target Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtk/CMakeLists.txt Specifies the libraries that the 'PVblockMeshReader_VTK' target depends on. It links public libraries including 'vtkPVblockMesh', 'OpenFOAM', and Qt5 modules for core and GUI functionalities. ```cmake TARGET_LINK_LIBRARIES( PVblockMeshReader_VTK LINK_PUBLIC vtkPVblockMesh OpenFOAM Qt5::Core Qt5::Gui ) ``` -------------------------------- ### Splitting long line at assignment operator with function call (discouraged) Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Illustrates a discouraged way to split a line at an assignment operator followed by a function call, with improper alignment. ```C++ variableName = longClassName.longFunctionName ( longArgument1, longArgument2 ); ``` -------------------------------- ### Splitting long line at assignment operator with function call Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Illustrates splitting a long line at an assignment operator, followed by a function call that also requires splitting. ```C++ variableName = longClassName.longFunctionName ( longArgument1, longArgument2 ); ``` -------------------------------- ### Variable Initialization Style in C++ Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Initialize const references using the assignment operator, not parentheses. This applies to referencing data from other class objects. ```C++ const className& variableName = otherClass.data(); ``` ```C++ const className& variableName(otherClass.data()); ``` -------------------------------- ### Set Target Properties for PVFoamReader VTK Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtk/CMakeLists.txt Sets target properties for the PVFoamReader VTK library, specifically its output directory. ```cmake SET_TARGET_PROPERTIES( PVFoamReader_VTK PROPERTIES LIBRARY_OUTPUT_DIRECTORY "$ENV{PV_PLUGIN_PATH}" ) ``` -------------------------------- ### Doxygen Comment for Destructor in C++ Headers Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Use '//-' for the Doxygen brief description when commenting a destructor in header files, followed by the function signature. ```C++ //- Destructor ~className(); ``` -------------------------------- ### Define VTK Module for PVblockMeshReader Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtk/CMakeLists.txt Defines the VTK module 'PVblockMeshReader_VTK_CLASSES' and associates it with the 'vtkPVblockMeshReader' class. This is a standard way to register custom VTK classes. ```cmake VTK_MODULE_ADD_MODULE(PVblockMeshReader_VTK CLASSES vtkPVblockMeshReader) ``` -------------------------------- ### Define VTK Module for PVFoamReader Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtk/CMakeLists.txt Defines the VTK module for PVFoamReader, specifying its classes. ```cmake VTK_MODULE_ADD_MODULE(PVFoamReader_VTK CLASSES vtkPVFoamReader) ``` -------------------------------- ### Splitting long line at assignment operator Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Shows the preferred way to split a long line at an assignment operator, indenting the subsequent code. ```C++ variableName = longClassName.longFunctionName(longArgument); ``` -------------------------------- ### Conditional Statement Formatting in C++ Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Use braces for all conditional statements. Conditions can either be on the same line as 'if' or wrapped onto the next line if long, ensuring a space between 'if' and the opening parenthesis. ```C++ if (condition) { code; } ``` ```C++ if ( long condition ) { code; } ``` ```C++ if(condition) { code; } ``` -------------------------------- ### Splitting function return type and name (discouraged - separate lines) Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Illustrates a discouraged method of splitting function declarations where the const keyword is on its own line. ```C++ const Foam::longReturnTypeName& Foam::longClassName::longFunctionName const ``` -------------------------------- ### Splitting long line at assignment operator (discouraged - no indent) Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Shows a discouraged method of splitting a line at an assignment operator without proper indentation. ```C++ variableName = longClassName.longFunctionName(longArgument); ``` -------------------------------- ### ParaView Version Conditional Logic Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/CMakeLists.txt Adjusts the target name and include file usage based on the ParaView version. Lower versions require specific handling. ```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() IF(${ParaView_VERSION} VERSION_LESS 5.7) # ParaView-5.7.x and lower requires the paraview include file INCLUDE(${PARAVIEW_USE_FILE}) ENDIF() ``` -------------------------------- ### Stream Output Alignment Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Align stream output operators (<<) for consistent formatting. This applies to general stream output and specific warning functions. ```c++ Info<< ... os << ... ``` ```C++ WarningInFunction << "Warning message" ``` -------------------------------- ### Set Target Name Based on ParaView Version Source: https://github.com/openfoam/openfoam-10/blob/master/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/CMakeLists.txt Determines the target name for the plugin based on the ParaView version. Older versions (less than 5.7) prepend 'lib' to the target name. ```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() ``` -------------------------------- ### Splitting function return type and name (discouraged - scope resolution) Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Shows a discouraged way to split function declarations by breaking after the scope resolution operator. ```C++ const Foam::longReturnTypeName& Foam::longClassName:: longFunctionName const ``` -------------------------------- ### Centered Class Declaration Header Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Use a centered header format for class declaration comments. This ensures a consistent and readable structure for class definitions. ```c++ /*---------------------------------------------------------------------------*\ Class exampleClass Declaration *---------------------------------------------------------------------------*/ ``` -------------------------------- ### Fully Scoped Function Name in C++ Source Files Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org In C++ source files, fully scope function names with their namespace and class. Avoid opening and closing namespaces within the same file unless dealing with multiple levels. ```C++ Foam::returnType Foam::className::functionName() ``` ```C++ namespace Foam { namespace compressible { namespace RASModels { ... } // End namespace RASModels } // End namespace compressible } // End namespace Foam ``` -------------------------------- ### Operator spacing for arithmetic and bitwise operations Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Defines the preferred spacing around operators for arithmetic and bitwise operations. ```C++ a + b, a - b a*b, a/b a & b, a ^ b ``` -------------------------------- ### Operator spacing for assignment and comparison operations Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Defines the preferred spacing around operators for assignment and comparison operations. ```C++ a = b, a != b a < b, a > b, a >= b, a <= b ``` -------------------------------- ### Operator spacing for logical operations Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Defines the preferred spacing around operators for logical operations. ```C++ a || b, a && b ``` -------------------------------- ### Avoid Unnecessary Class Section Headers Source: https://github.com/openfoam/openfoam-10/blob/master/doc/codingStyleGuide.org Remove private member function headers if they contain no members to avoid clutter. This applies to 'Check', 'Edit', and 'Write' sections. ```c++ // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // Check // Edit // Write ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.