TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Coarsen_Operator_K.h
1/****************************************************************************
2* Copyright (c) 2025, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Coarsen_Operator_K_included
17#define Coarsen_Operator_K_included
18
19#include <Coarsen_Operator_base.h>
20#include <TRUSTTab.h>
21
22// Coarsen the "fine" mesh in the k direction with provided arbitrary coarse
23// mesh node positions.
25{
26 Declare_instanciable(Coarsen_Operator_K);
27public:
28 inline void initialize_grid_data(const Grid_Level_Data_double& fine, Grid_Level_Data_double& coarse, int additional_k_layers) override
29 {
30 initialize_grid_data_(fine, coarse, additional_k_layers);
31 }
32 inline void initialize_grid_data(const Grid_Level_Data_float& fine, Grid_Level_Data_float& coarse, int additional_k_layers) override
33 {
34 initialize_grid_data_(fine, coarse, additional_k_layers);
35 }
36 // Compute values on coarse mesh from values on fine mesh
37 inline void coarsen(const IJK_Field_double& fine, IJK_Field_double& coarse, int compute_weighted_average = 0) const override
38 {
39 coarsen_(fine, coarse, compute_weighted_average);
40 }
41 inline void coarsen(const IJK_Field_float& fine, IJK_Field_float& coarse, int compute_weighted_average = 0) const override
42 {
43 coarsen_(fine, coarse, compute_weighted_average);
44 }
45
46 // Interpolate values on coarse mesh to fine mesh and substract them from existing values
47 inline void interpolate_sub_shiftk(const IJK_Field_double& coarse, IJK_Field_double& fine, const int kshift) const override
48 {
49 interpolate_sub_shiftk_(coarse, fine, kshift);
50 }
51 inline void interpolate_sub_shiftk(const IJK_Field_float& coarse, IJK_Field_float& fine, const int kshift) const override
52 {
53 interpolate_sub_shiftk_(coarse, fine, kshift);
54 }
55
56protected:
57 void ajouter_param(Param& param) override;
58 // File containing the k coordinates of the coarse grid
60 ArrOfDouble z_coord_all_;
61
62 // Fine/coarse intersection data for the global mesh (size is nk_tot)
65 ArrOfDouble avg_coefficients_;
66
67 // src_dest_index_local_ contains couples of intersecting cell indices from the coarse and fine meshes:
68 // arrays contain local indices for the part on this processor
69 // Column 0: index of k layer in fine grid
70 // Column 1: index of k layer in coarse grid
72 // For each line n in src_dest_index_, coefficient to apply to the fine value to add to the coarse value:
73 // Sum for src_dest_index_(n,0)==i (for all coarse cells crossing fine cell i) of coarsen_coefficients_[n] is equal to 1:
75 // Sum for src_dest_index_(n,1)==i (for all fine cells crossing coarse cell i) of coarsen_coefficients_[n] is equal to 1:
77
78private:
79
80 //ToDo: temporary workaround as virtual templates are not possible...
81 // when suppressing mix precision multigrid, move the template on the class
82 template<typename _TYPE_>
83 void initialize_grid_data_(const Grid_Level_Data_template<_TYPE_>& fine, Grid_Level_Data_template<_TYPE_>& coarse,
84 int additional_k_layers);
85
86 template <typename _TYPE_, typename _TYPE_ARRAY_>
87 void coarsen_(const IJK_Field_template<_TYPE_,_TYPE_ARRAY_>& fine, IJK_Field_template<_TYPE_,_TYPE_ARRAY_>& coarse, int compute_weighted_average = 0) const;
88
89 template <typename _TYPE_, typename _TYPE_ARRAY_>
90 void interpolate_sub_shiftk_(const IJK_Field_template<_TYPE_,_TYPE_ARRAY_>& coarse, IJK_Field_template<_TYPE_,_TYPE_ARRAY_>& fine, const int kshift) const;
91
92};
93
94#include <Coarsen_Operator_K.tpp>
95
96#endif
void coarsen(const IJK_Field_double &fine, IJK_Field_double &coarse, int compute_weighted_average=0) const override
ArrOfDouble coarsen_coefficients_local_
void interpolate_sub_shiftk(const IJK_Field_float &coarse, IJK_Field_float &fine, const int kshift) const override
void ajouter_param(Param &param) override
void coarsen(const IJK_Field_float &fine, IJK_Field_float &coarse, int compute_weighted_average=0) const override
void initialize_grid_data(const Grid_Level_Data_double &fine, Grid_Level_Data_double &coarse, int additional_k_layers) override
ArrOfDouble avg_coefficients_
void initialize_grid_data(const Grid_Level_Data_float &fine, Grid_Level_Data_float &coarse, int additional_k_layers) override
ArrOfDouble avg_coefficients_local_
ArrOfDouble coarsen_coefficients_
void interpolate_sub_shiftk(const IJK_Field_double &coarse, IJK_Field_double &fine, const int kshift) const override
: This class is an IJK_Field_local with parallel informations.
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112