TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Domaine_dis_cache.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 Domaine_dis_cache_included
17#define Domaine_dis_cache_included
18
19#include <Domaine_forward.h>
20
21#include <TClearable.h>
22#include <memory>
23#include <Nom.h>
24#include <map>
25
28
29/*! @brief Cache of discretized domains. Avoid repeating the discretize operation when not
30 * necessary.
31 *
32 * This is a singleton class.
33 */
34class Domaine_dis_cache : public TClearable
35{
36public:
37 static Domaine_dis_cache& Get_instance();
38 static void Clear();
39
40 static Domaine_dis_base& Build_or_get(const Nom& type, const Domaine& dom, const Discretisation_base * disc=nullptr);
41 static Domaine_dis_base& Build_or_get_poly_post(const Nom& type, const Domaine& dom);
42
43 Domaine_dis_base& build_or_get(const Nom& type, const Domaine& dom, const Discretisation_base * disc=nullptr);
44 Domaine_dis_base& build_or_get_poly_post(const Nom& type, const Domaine& dom);
45
46 void clear() override { cache_.clear(); }
47
48private:
50 /*! The actual cache hodling the true Domaine_dis objects.
51 * Store them as shared_ptr since we need easy duplication, notably for NO_FACE_ discretisations.
52 * See build_or_get() method.
53 */
54 std::map<std::string, OWN_PTR(Domaine_dis_base)> cache_;
55};
56
57#endif
classe Discretisation_base Cette classe represente un schema de discretisation en espace,...
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
Cache of discretized domains. Avoid repeating the discretize operation when not necessary.
static Domaine_dis_cache & Get_instance()
Get the unique instance of the cache.
static Domaine_dis_base & Build_or_get_poly_post(const Nom &type, const Domaine &dom)
static Domaine_dis_base & Build_or_get(const Nom &type, const Domaine &dom, const Discretisation_base *disc=nullptr)
Domaine_dis_base & build_or_get_poly_post(const Nom &type, const Domaine &dom)
void clear() override
static void Clear()
Clear the content of the cache. Useful to exit nicely making sure everything is deallocated.
Domaine_dis_base & build_or_get(const Nom &type, const Domaine &dom, const Discretisation_base *disc=nullptr)
Get a discretized domain from the cache, building it and recording it if not there yet.
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
A small class representing any object with a "clear()" method.
Definition TClearable.h:29