Skip to content

Integrating CFD HOWL with Other CFD Solvers

RayanDhib edited this page Oct 7, 2024 · 2 revisions

CFD-HOWL is a standalone, modular library designed to be solver-agnostic and adaptable to different proprietary CFD data formats. The library can be extended to work with new CFD solvers by making minimal changes to specific functions.

Why Direct Access to Raw Data is Necessary

To preserve high-order accuracy and access detailed solution states, CFD-HOWL works directly with the proprietary formats of the CFD solvers. Using already exported data in formats like .vtu or .plt would lose essential information about solution points within elements, as these formats typically store only interpolated or post-processed data. Therefore, direct access to raw, high-order solution data before it is exported ensures that the conversion maintains fidelity and accuracy.

How to Integrate Your CFD Solver with CFD-HOWL

To use CFD-HOWL with another CFD solver, you need to modify two key functions in the ./writer/input_data.py script:

  • read_input_data(filename): This function extracts the nodes, element connectivity, and state variables from the input file. To integrate CFD-HOWL with your CFD solver, modify this function to read your solver’s proprietary format and return the necessary data in the expected format.

  • get_data_info(metadata, filename): This function extracts metadata, such as solution order, number of dimensions, number of elements, and element type. Modify this function to retrieve the necessary information from your solver’s data format.

Steps for Integration:

  1. Modify input_data.py:

    • Adapt the read_input_data() and get_data_info() functions to handle your CFD solver's input format.

    Function Details:

    • read_input_data(filename):

      • Purpose: Extracts the nodes, element connectivity, solution data, and metadata from the input file.
      • Expected Return Value: A tuple containing:
        • Nodes: A list of nodal coordinates, where each entry is a coordinate vector [x, y, z] or [x, y] for 2D meshes.

        • Connectivity: A table representing the connectivity of elements, where each row contains the indices of nodes that form an element.

        • Solution Data: A nested array that contains the solution values for each element in the mesh. It has the following structure: (number of elements, number of solution points per element, number of variables).

          Specifically:

          • Elements: Represents each element in the mesh.
          • Solution Points: For each element, multiple solution points are stored, representing locations where the solution is evaluated within the element.
          • Variables: At each solution point, a set of physical variables is stored (e.g., rho, rhoU, rhoV, rhoE).

          The resulting data structure is effectively a three-dimensional array, where:

          • The first dimension indexes the element.
          • The second dimension indexes the solution points within that element.
          • The third dimension contains the values of each physical variable at the corresponding solution point.
        • Metadata: A dictionary providing additional information required for further processing, such as solution order, number of elements, and other format-specific metadata.

    • get_data_info(metadata, filename):

      • Purpose: Extracts the mesh and solution parameters from the metadata provided by the read_input_data() function.
      • Expected Return Value: A tuple containing:
        • Dimension (dim): The number of dimensions of the mesh (e.g., 2 for 2D or 3 for 3D).
        • Number of Equations (nbEqs): The number of governing equations solved in the CFD simulation.
        • Geometric Order (geoOrder): The geometric order of the mesh elements (e.g., linear or quadratic).
        • Solution Order (solOrder): The polynomial order used for the solution representation.
        • Number of Elements (nbElem): The total number of elements in the mesh.
        • Element Type (elem_type): The type of element used in the mesh (e.g., quadrilateral, triangular).

    Example Modification:

    # Example of adding a new format
    elif extension == "newformat1":
        return read_newformat1(filename)
  2. Create a Custom Configuration File:

    • Create a new configuration file similar to config_COOLFluiD.json or config_PyFR.json, specifying:
      • The filename: Path to your input file.
      • The output_filename: Path where the output CGNS file will be saved.
      • The var_names: Names of the state variables provided by your solver (e.g., density, momentum components, energy).
  3. Update config.json:

    • Modify config.json to reference your newly created configuration file:
    {
        "active_config": "./config/your_custom_config.json"
    }
  4. Run CFD-HOWL:

    • You can run CFD-HOWL either directly with Python:
    python main.py
    • Or by using Docker:
    docker run -it --rm \
     -v $(pwd)/examples:/app/examples \
     -v $(pwd)/config:/app/config \
     cfd-howl