Skip to content
Snippets Groups Projects

[REFACTOR] Updated wing design and c++ modularization doc and added new documentation for airfoils and endnode + placeholder for pyavl- and pyavlunicadopackage

Merged Christopher Ruwisch requested to merge refactor/different_libs_docs into main
Compare and
10 files
+ 480
139
Compare changes
  • Side-by-side
  • Inline

Files

# The `Airfoils` library
**Description:**
This file is part of UNICADO. It implements the `Airfoils` class which manages airfoil data stored in files. The class provides functionality to load airfoil files from a specified directory, print the available airfoils, retrieve airfoil polygon data, and copy airfoil files to a target directory.
---
## Class: Airfoils
### Overview
- **Purpose:** Manages airfoil data by loading airfoil files from a directory and providing methods to interact with them.
- **Key Responsibilities:**
- Load airfoil data from a given directory.
- Maintain a collection (`available_airfoils`) that maps airfoil names to their file paths.
- Provide methods to print, retrieve, and copy airfoil data.
---
### Constructor
#### `Airfoils(const std::filesystem::path& path_to_airfoil_directory)`
- **Description:** Initializes the `Airfoils` object by loading airfoil files from the provided directory.
- **Parameters:**
- `path_to_airfoil_directory`: Filesystem path to the directory containing airfoil files.
- **Behavior:**
- Checks if the provided directory exists.
- If not, throws an error using `throwError` with a formatted message.
- Calls the private method `add_directory_airfoils(path_to_airfoil_directory)` to populate the `available_airfoils` map.
---
### Public Methods
#### `void print_available_airfoils()`
- **Description:** Prints the list of available airfoils with their names and file paths.
- **Behavior:**
- Iterates over the `available_airfoils` map and prints each entry using formatted output.
- Uses `std::cout` or a runtime logging stream (`myRuntimeInfo->out`) if available.
---
#### `geom2::Polygon_2 get_airfoil(const std::string& airfoil)`
- **Description:** Retrieves the polygon data of the specified airfoil.
- **Parameters:**
- `airfoil`: Name of the airfoil.
- **Return:**
- A `geom2::Polygon_2` object representing the airfoil's polygon data.
- **Behavior:**
- Searches for the airfoil in the `available_airfoils` map.
- If the airfoil is not found, throws an error.
- Otherwise, reads and returns the airfoil data using `geom2::io::read_airfoil`.
---
#### `void copy_available_airfoil(const std::string& airfoil, const std::filesystem::path& target_directory)`
- **Description:** Copies the specified airfoil file to a target directory.
- **Parameters:**
- `airfoil`: Name of the airfoil.
- `target_directory`: Filesystem path to the destination directory.
- **Behavior:**
- Checks if the target directory exists; if not, throws an error.
- Validates that the airfoil is available in the `available_airfoils` map; if not, throws an error.
- Compares the absolute paths of the source (airfoil file) and the target directory.
- If they are the same, logs that the copying is skipped.
- Attempts to copy the airfoil file using `std::filesystem::copy` with the `update_existing` option.
- Catches any exceptions during copying and rethrows them using `throwError`.
---
### Private Methods
#### `void add_directory_airfoils(const std::filesystem::path& path_to_airfoil_directory)`
- **Description:** Adds all airfoil files from the specified directory to the `available_airfoils` map.
- **Parameters:**
- `path_to_airfoil_directory`: Filesystem path to the directory containing airfoil files.
- **Behavior:**
- Verifies that the directory exists; if not, throws an error.
- Iterates over each entry in the directory using `std::filesystem::directory_iterator`.
- For each entry, calls the private method `add_airfoil(entry.path())`.
---
#### `void add_airfoil(const std::filesystem::path& airfoil_path)`
- **Description:** Adds a single airfoil file to the `available_airfoils` map.
- **Parameters:**
- `airfoil_path`: Filesystem path to the airfoil file.
- **Behavior:**
- Checks if the file exists; if not, throws an error.
- Verifies that the path is a regular file and has a `.dat` extension.
- Extracts the airfoil name (using the filename's stem) and inserts it into the `available_airfoils` map.
---
Loading