PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
Loading...
Searching...
No Matches
AnalyticalSolutions.h
Go to the documentation of this file.
1#ifndef ANALYTICALSOLUTIONS_H
2#define ANALYTICALSOLUTIONS_H
3
4#include <petscpf.h>
5#include <petscdmswarm.h>
6#include <stdlib.h>
7#include <time.h>
8#include <math.h>
9#include <petsctime.h>
10#include <petscdmcomposite.h>
11
12// Include additional headers
13#include "variables.h" // Shared type definitions
14#include "ParticleSwarm.h" // Particle swarm functions
15#include "walkingsearch.h" // Particle location functions
16#include "grid.h" // Grid functions
17#include "logging.h" // Logging macros
18#include "io.h" // Data Input and Output functions
19#include "setup.h" // Setup Module required for array allocation and deallocation
20#include "interpolation.h" // All the different interpolation routines required
21
22/**
23 * @brief Sets the grid domain and resolution for analytical solution cases.
24 *
25 * @details This function is called when `eulerianSource` is "analytical". It is responsible for
26 * automatically configuring the grid based on the chosen `AnalyticalSolutionType`.
27 *
28 * @par TGV3D Multi-Block Decomposition
29 * If the analytical solution is "TGV3D", this function automatically decomposes the
30 * required `[0, 2*PI]` physical domain among the available blocks.
31 * - **Single Block (`nblk=1`):** The single block is assigned the full `[0, 2*PI]` domain.
32 * - **Multiple Blocks (`nblk>1`):** It requires that the number of blocks be a **perfect square**
33 * (e.g., 4, 9, 16). It then arranges the blocks in a `sqrt(nblk)` by `sqrt(nblk)` grid in the
34 * X-Y plane, partitioning the `[0, 2*PI]` domain in X and Y accordingly. The Z domain for all
35 * blocks remains `[0, 2*PI]`. If `nblk` is not a perfect square, the simulation is aborted
36 * with an error.
37 *
38 * After setting the domain bounds, it proceeds to read the grid resolution options
39 * (`-im`, `-jm`, `-km`) from the command line for the specific block.
40 *
41 * @param user Pointer to the `UserCtx` for a specific block. The function will
42 * populate the geometric fields (`IM`, `JM`, `KM`, `Min_X`, `Max_X`, etc.)
43 * within this struct.
44 * @return PetscErrorCode 0 on success, or a PETSc error code on failure.
45 */
46PetscErrorCode SetAnalyticalGridInfo(UserCtx *user);
47
48#undef __FUNCT__
49#define __FUNCT__ "AnalyticalSolutionEngine"
50/**
51 * @brief Dispatches to the appropriate analytical solution function based on simulation settings.
52 *
53 * This function acts as a router. It reads the `AnalyticalSolutionType` from the
54 * simulation context and calls the corresponding private implementation function
55 * (e.g., for Taylor-Green Vortex, lid-driven cavity, etc.). This design keeps
56 * the main simulation code clean and makes it easy to add new analytical test cases.
57 *
58 * @param simCtx The main simulation context, containing configuration and state.
59 * @return PetscErrorCode 0 on success.
60 */
61PetscErrorCode AnalyticalSolutionEngine(SimCtx *simCtx);
62
63/**
64@brief Applies the analytical solution to particle velocity vector.
65
66@details Dispatcher function that calls the appropriate analytical solution based on
67 simCtx->AnalyticalSolutionType. Supports multiple solution types.
68
69@param tempVec The PETSc Vec containing particle positions which will be used to store velocities.
70@param simCtx The simulation context.
71@return PetscErrorCode Returns 0 on success.
72*/
73PetscErrorCode SetAnalyticalSolutionForParticles(Vec tempVec, SimCtx *simCtx);
74
75#endif // ANALYTICALSOLUTIONS_H
PetscErrorCode AnalyticalSolutionEngine(SimCtx *simCtx)
Dispatches to the appropriate analytical solution function based on simulation settings.
PetscErrorCode SetAnalyticalSolutionForParticles(Vec tempVec, SimCtx *simCtx)
Applies the analytical solution to particle velocity vector.
PetscErrorCode SetAnalyticalGridInfo(UserCtx *user)
Sets the grid domain and resolution for analytical solution cases.
Header file for Particle Swarm management functions.
Public interface for grid, solver, and metric setup routines.
Public interface for data input/output routines.
Logging utilities and macros for PETSc-based applications.
Main header file for a complex fluid dynamics solver.
The master context for the entire simulation.
Definition variables.h:585
User-defined context containing data specific to a single computational grid level.
Definition variables.h:728
Header file for particle location functions using the walking search algorithm.