TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Domaine_PolyMAC_CDO.h
1
2/****************************************************************************
3* Copyright (c) 2023, CEA
4* All rights reserved.
5*
6* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8* 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.
9* 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.
10*
11* 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.
12* 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;
13* 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.
14*
15*****************************************************************************/
16
17#ifndef Domaine_PolyMAC_CDO_included
18#define Domaine_PolyMAC_CDO_included
19
20#include <Echange_global_impose.h>
21#include <Neumann_sortie_libre.h>
22#include <Domaine_Poly_base.h>
23#include <Matrice_Morse_Sym.h>
24#include <Neumann_homogene.h>
25#include <SolveurSys.h>
26#include <Periodique.h>
27#include <Dirichlet.h>
28#include <Symetrie.h>
29
31{
32 Declare_instanciable(Domaine_PolyMAC_CDO);
33public :
34 void discretiser() override;
35 void swap(int, int, int) { }
36 void modifier_pour_Cl(const Conds_lim& ) override;
37 void init_equiv() const override;
38
39 inline const IntTab& arete_faces() const { return arete_faces_; }
40 void calculer_volumes_entrelaces() override;
41 void calculer_h_carre() override;
42
43 inline double dot (const double *a, const double *b, const double *ma = nullptr, const double *mb = nullptr) const { return dot(dimension, a, b, ma, mb); }
44 KOKKOS_INLINE_FUNCTION double dot (const int dim, const double *a, const double *b, const double *ma = nullptr, const double *mb = nullptr) const;
45
46 IntVect cyclic; // cyclic(i) = 1 if poly i is cyclic
47
48 //which optional structures have been initialized
49 mutable std::map<std::string, int> is_init;
50 //first-order interpolations of the velocity vector at elements
51 void init_ve() const;
52 mutable IntTab vedeb, veji; //reconstruction of ve via (veji, veci)[vedeb(e), vedeb(e + 1)[ (faces)
53 mutable DoubleTab veci;
54
55 //curl at faces of a field tangent to edges
56 void init_rf() const;
57 mutable IntTab rfdeb, rfji; //reconstruction of the curl via (rfji, rfci)[rfdeb(f), rfdeb(f + 1)[ (field at edges)
58 mutable DoubleTab rfci;
59
60 //stabilization of a mimetic mass matrix in an element: in PolyMAC_CDO -> m1 or m2
61 inline void ajouter_stabilisation(DoubleTab& M, DoubleTab& N) const;
62 inline int W_stabiliser(DoubleTab& W, DoubleTab& R, DoubleTab& N, int *ctr, double *spectre) const;
63
64 //mimetic matrix of a face field: (normal value at faces) -> (linear integral on broken lines)
65 void init_m2() const;
66 // ToDo switch these arrays to IntVect and DoubleVect:
67 mutable IntTab m2d, m2i, m2j, w2i, w2j; //storage: rows of M_2^e in m2i([m2d(e), m2d(e + 1)[), indices/coeffs of these rows in (m2j/m2c)[m2i(i), m2i(i+1)[
68 mutable DoubleTab m2c, w2c; // with the diagonal coefficient first (facilitates Echange_contact_PolyMAC_CDO)
69 void init_m2solv() const; //to solve m2.v = s
72
73 //first-order interpolation at elements of a field defined by its tangential components at edges (e.g. vorticity)
74 inline void init_we() const;
75 void init_we_2d() const;
76 void init_we_3d() const;
77 mutable IntTab wedeb, weji; //reconstruction of we via (weji, weci)[wedeb(e), wedeb(e + 1)[ (vertices in 2D, edges in 3D)
78 mutable DoubleTab weci;
79
80 //mimetic matrix of an edge field: (tangential value at edges) -> (flux through the union of facets touching the edge)
81 void init_m1() const;
82 void init_m1_2d() const;
83 void init_m1_3d() const;
84 mutable IntTab m1deb, m1ji; //reconstruction of m1 via (m1ji(.,0), m1ci)[m1deb(a), m1deb(a + 1)[ (vertices in 2D, edges in 3D); m1ji(.,1) contains the element index
85 mutable DoubleTab m1ci;
86
87 //std::map to retrieve the (proc, local item) pair associated with a virtual item for mdv_elem_faces
88 void init_virt_ef_map() const;
89 mutable std::map<std::array<int, 2>, int> virt_ef_map;
90
91 //local matrices per element (Hodge operators) for performing interpolations:
92 void M2(const DoubleTab *nu, int e, DoubleTab& m2) const; //normals at faces -> tangentials at dual faces: (nu x_ef.v) = m2 (|f|n_ef.v)
93 void W2(const DoubleTab *nu, int e, DoubleTab& w2) const; //tangentials at dual faces -> normals at faces: (nu |f|n_ef.v) = w2 (x_ef.v)
94
95private:
96 void init_m2_new() const;
97 void init_m2_osqp() const;
98
99 mutable IntTab arete_faces_; //connectivite face -> aretes
100};
101
102/* dot product of two vectors */
103KOKKOS_INLINE_FUNCTION double Domaine_PolyMAC_CDO::dot(const int dim, const double *a, const double *b, const double *ma, const double *mb) const
104{
105 double res = 0;
106 for (int i = 0; i < dim; i++) res += (a[i] - (ma ? ma[i] : 0)) * (b[i] - (mb ? mb[i] : 0));
107 return res;
108}
109
110#endif /* Domaine_PolyMAC_CDO_included */
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
void W2(const DoubleTab *nu, int e, DoubleTab &w2) const
int W_stabiliser(DoubleTab &W, DoubleTab &R, DoubleTab &N, int *ctr, double *spectre) const
double dot(const double *a, const double *b, const double *ma=nullptr, const double *mb=nullptr) const
void ajouter_stabilisation(DoubleTab &M, DoubleTab &N) const
void calculer_volumes_entrelaces() override
const IntTab & arete_faces() const
std::map< std::string, int > is_init
Matrice_Morse_Sym m2mat
void M2(const DoubleTab *nu, int e, DoubleTab &m2) const
void swap(int, int, int)
void init_equiv() const override
std::map< std::array< int, 2 >, int > virt_ef_map
void modifier_pour_Cl(const Conds_lim &) override
void calculer_h_carre() override
class Domaine_Poly_base
Matrice_Morse_Sym class - Represents a sparse symmetric matrix M stored in Morse format.
static int dimension
Definition Objet_U.h:94
class SolveurSys A SolveurSys represents any class
Definition SolveurSys.h:32