PICurv
0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
Loading...
Searching...
No Matches
include
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
* Grid resolution (`IM/JM/KM`) is expected to be pre-populated in `user`
39
* before this function is called.
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
*/
46
PetscErrorCode
SetAnalyticalGridInfo
(
UserCtx
*user);
47
48
/**
49
* @brief Reports whether an analytical type requires custom geometry/decomposition logic.
50
*
51
* Analytical types returning PETSC_TRUE are expected to route through
52
* `SetAnalyticalGridInfo`. Types returning PETSC_FALSE should use the standard
53
* programmatic grid parser fallback.
54
*
55
* @param analytical_type Analytical solution type string.
56
* @return PETSC_TRUE if custom geometry is required, PETSC_FALSE otherwise.
57
*/
58
PetscBool
AnalyticalTypeRequiresCustomGeometry
(
const
char
*analytical_type);
59
60
#undef __FUNCT__
61
#define __FUNCT__ "AnalyticalSolutionEngine"
62
/**
63
* @brief Dispatches to the appropriate analytical solution function based on simulation settings.
64
*
65
* This function acts as a router. It reads the `AnalyticalSolutionType` from the
66
* simulation context and calls the corresponding private implementation function
67
* (e.g., for Taylor-Green Vortex, lid-driven cavity, etc.). This design keeps
68
* the main simulation code clean and makes it easy to add new analytical test cases.
69
*
70
* @param simCtx The main simulation context, containing configuration and state.
71
* @return PetscErrorCode 0 on success.
72
*/
73
PetscErrorCode
AnalyticalSolutionEngine
(
SimCtx
*simCtx);
74
75
/**
76
@brief Applies the analytical solution to particle velocity vector.
77
78
@details Dispatcher function that calls the appropriate analytical solution based on
79
simCtx->AnalyticalSolutionType. Supports multiple solution types.
80
81
@param tempVec The PETSc Vec containing particle positions which will be used to store velocities.
82
@param simCtx The simulation context.
83
@return PetscErrorCode Returns 0 on success.
84
*/
85
PetscErrorCode
SetAnalyticalSolutionForParticles
(Vec tempVec,
SimCtx
*simCtx);
86
87
#endif
// ANALYTICALSOLUTIONS_H
AnalyticalSolutionEngine
PetscErrorCode AnalyticalSolutionEngine(SimCtx *simCtx)
Dispatches to the appropriate analytical solution function based on simulation settings.
Definition
AnalyticalSolutions.c:179
AnalyticalTypeRequiresCustomGeometry
PetscBool AnalyticalTypeRequiresCustomGeometry(const char *analytical_type)
Reports whether an analytical type requires custom geometry/decomposition logic.
Definition
AnalyticalSolutions.c:38
SetAnalyticalSolutionForParticles
PetscErrorCode SetAnalyticalSolutionForParticles(Vec tempVec, SimCtx *simCtx)
Applies the analytical solution to particle velocity vector.
Definition
AnalyticalSolutions.c:485
SetAnalyticalGridInfo
PetscErrorCode SetAnalyticalGridInfo(UserCtx *user)
Sets the grid domain and resolution for analytical solution cases.
Definition
AnalyticalSolutions.c:70
ParticleSwarm.h
Header file for Particle Swarm management functions.
grid.h
Public interface for grid, solver, and metric setup routines.
interpolation.h
io.h
Public interface for data input/output routines.
logging.h
Logging utilities and macros for PETSc-based applications.
setup.h
variables.h
Main header file for a complex fluid dynamics solver.
SimCtx
The master context for the entire simulation.
Definition
variables.h:589
UserCtx
User-defined context containing data specific to a single computational grid level.
Definition
variables.h:733
walkingsearch.h
Header file for particle location functions using the walking search algorithm.
Generated by
1.9.8