9.2
general documentation
cs_mesh_adaptive_refinement.h
Go to the documentation of this file.
1#ifndef CS_MESH_ADAPTIVE_REFINEMENT_H
2#define CS_MESH_ADAPTIVE_REFINEMENT_H
3
4/*============================================================================
5 * Adaptive Mesh refinement.
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2026 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------*/
29
30/*----------------------------------------------------------------------------
31 * Local headers
32 *----------------------------------------------------------------------------*/
33
34#include "base/cs_base.h"
36#include "mesh/cs_mesh.h"
37
38/*============================================================================
39 * Macro definitions
40 *============================================================================*/
41
42/*============================================================================
43 * Type definitions
44 *============================================================================*/
45
46/*----------------------------------------------------------------------------
47 * Function pointer for the refinement criteria computation of the adaptive
48 * mesh refinement algorithm.
49 *
50 * Note: if the input pointer is non-NULL, it must point to valid data
51 * when the selection function is called, so either:
52 * - that value or structure should not be temporary (i.e. local);
53 * - when a single integer identifier is needed, the input pointer can be
54 * set to that value instead of an actual address;
55 *
56 * parameters:
57 * input <-- pointer to optional (untyped) value or structure.
58 * vals --> pointer to refinement indicator
59 *----------------------------------------------------------------------------*/
60
61typedef void
62(cs_amr_indicator_t) (const void *input,
63 int *vals);
64
65/*----------------------------------------------------------------------------
66 * Function pointer for field reallocation and interpolation when refining.
67 *
68 * parameters:
69 * m <-- pointer to the mesh
70 * location <-- fields location
71 * n_i_elts <-- old number of elements
72 * o2n_idx <-- old to new element index
73 * new_idx <-- Newly created elements index (interior faces) or nullptr
74 * o_cog <-- old mesh cells center of gravity
75 * n_cog <-- new mesh cells center of gravity
76 *----------------------------------------------------------------------------*/
77
78typedef void
80 int location_id,
81 const cs_lnum_t n_i_elts,
82 const cs_lnum_t o2n_idx[],
83 const cs_lnum_t new_idx[],
84 const cs_real_3_t o_cog[],
85 const cs_real_3_t n_cog[],
86 const cs_real_t measure[]);
87
88/*----------------------------------------------------------------------------
89 * Function pointer for field reallocation and interpolation when coarsening.
90 *
91 * parameters:
92 * m <-- pointer to the mesh
93 * location <-- fields location
94 * n_i_elts <-- old number of elements
95 * n2o_idx <-- new to old index
96 * n2o <-- new to old values
97 * measure <-- elements measure (volume for cells, surface for faces, NULL
98 for vertices
99 *----------------------------------------------------------------------------*/
100
101typedef void
103 int location_id,
104 const cs_lnum_t n_i_elts,
105 const cs_lnum_t n2o_idx[],
106 const cs_lnum_t n2o[],
107 const cs_real_t measure[],
108 const cs_lnum_t i_face_map[]);
109
110/*----------------------------------------------------------------------------
111 * Structure containing general information on the adaptive meshing process
112 *----------------------------------------------------------------------------*/
113
114typedef struct {
115
116 bool is_set;
123 const void *indic_input;
128
131
146
147/*=============================================================================
148 * Static global variables
149 *============================================================================*/
150
152
153/*=============================================================================
154 * Public function prototypes
155 *============================================================================*/
156
157/*----------------------------------------------------------------------------*/
158/*
159 * \brief Activation and Initializing af the global AMR strcture
160 *
161 * \param[in] n_layers number of layers of refinement around user criteria
162 * \param[in] ts_interval time_step interval between adaptation steps
163 * \param[in] indic_func user function marking cells that should be refined
164 * \param[in] indic_input input for indic_func or nullptr
165 * \param[in] load_balance activate load balancing post mesh adaptation
166 */
167/*----------------------------------------------------------------------------*/
168
169void
171 int n_freq,
172 cs_amr_indicator_t *indic_func,
173 const void *indic_input,
174 int interpolation,
175 bool load_balance);
176
177/*----------------------------------------------------------------------------*/
178/*
179 * \brief Compute field gradients when necessary (for fields interpolation)
180 */
181/*----------------------------------------------------------------------------*/
182
183void
185
186/*----------------------------------------------------------------------------*/
187/*
188 * \brief Free field gradients.
189 */
190/*----------------------------------------------------------------------------*/
191
192void
194
195
196void
198
199/*----------------------------------------------------------------------------*/
200
201#endif /* CS_MESH_ADAPTIVE_REFINEMENT_H */
Definition: cs_time_control.h:92
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:349
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
void() cs_amr_indicator_t(const void *input, int *vals)
Definition: cs_mesh_adaptive_refinement.h:62
void cs_adaptive_refinement_define(int n_layers, int n_freq, cs_amr_indicator_t *indic_func, const void *indic_input, int interpolation, bool load_balance)
Activation and Initializing af the global AMR structure.
Definition: cs_mesh_adaptive_refinement.cpp:1244
void cs_adaptive_refinement_update_gradients(void)
Compute field gradients when necessary (for fields interpolation)
Definition: cs_mesh_adaptive_refinement.cpp:1299
cs_amr_info_t * cs_glob_amr_info
Definition: cs_mesh_adaptive_refinement.cpp:117
void cs_adaptive_refinement_free_gradients(void)
Free field gradients.
Definition: cs_mesh_adaptive_refinement.cpp:1372
void() cs_amr_refinement_interpolation_t(cs_mesh_t *mesh, int location_id, const cs_lnum_t n_i_elts, const cs_lnum_t o2n_idx[], const cs_lnum_t new_idx[], const cs_real_3_t o_cog[], const cs_real_3_t n_cog[], const cs_real_t measure[])
Definition: cs_mesh_adaptive_refinement.h:79
void() cs_amr_coarsening_interpolation_t(cs_mesh_t *mesh, int location_id, const cs_lnum_t n_i_elts, const cs_lnum_t n2o_idx[], const cs_lnum_t n2o[], const cs_real_t measure[], const cs_lnum_t i_face_map[])
Definition: cs_mesh_adaptive_refinement.h:102
void cs_adaptive_refinement_step(void)
Perform a refinement / coarsening step.
Definition: cs_mesh_adaptive_refinement.cpp:1390
Definition: mesh.f90:26
Definition: cs_mesh_adaptive_refinement.h:114
const void * indic_input
Definition: cs_mesh_adaptive_refinement.h:123
int interpolation
Definition: cs_mesh_adaptive_refinement.h:132
bool is_set
Definition: cs_mesh_adaptive_refinement.h:116
int * indic_cells
Definition: cs_mesh_adaptive_refinement.h:138
cs_time_control_t time_control
Definition: cs_mesh_adaptive_refinement.h:119
cs_amr_indicator_t * indic_func
Definition: cs_mesh_adaptive_refinement.h:121
cs_amr_refinement_interpolation_t * fields_interp_refinement_func
Definition: cs_mesh_adaptive_refinement.h:127
bool load_balance
Definition: cs_mesh_adaptive_refinement.h:143
int n_layers
Definition: cs_mesh_adaptive_refinement.h:117
cs_amr_coarsening_interpolation_t * fields_interp_coarsening_func
Definition: cs_mesh_adaptive_refinement.h:130
Definition: cs_mesh.h:85