Debian Codegraph @

src/atlas/meshgenerator/detail/MeshGeneratorInterface.cc

raw
1 /*
2 * (C) Copyright 2013 ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence Version 2.0
5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 * In applying this licence, ECMWF does not waive the privileges and immunities
7 * granted to it by virtue of its status as an intergovernmental organisation
8 * nor does it submit to any jurisdiction.
9 */
10
11 #include "atlas/meshgenerator/detail/MeshGeneratorInterface.h"
12 #include "atlas/grid/Distribution.h"
13 #include "atlas/grid/Grid.h"
14 #include "atlas/grid/Partitioner.h"
15 #include "atlas/mesh/Mesh.h"
16 #include "atlas/meshgenerator.h"
17 #include "atlas/meshgenerator/detail/MeshGeneratorImpl.h"
18 #include "atlas/runtime/Exception.h"
19
20 using atlas::Mesh;
21
22 namespace atlas {
23 namespace meshgenerator {
24
25 //----------------------------------------------------------------------------------------------------------------------
26
27 extern "C" {
28
29 void atlas__MeshGenerator__delete(MeshGenerator::Implementation* This) {
30 ATLAS_ASSERT(This != nullptr, "Cannot access uninitialisd atlas_MeshGenerator");
31 delete This;
32 }
33
34 const MeshGenerator::Implementation* atlas__MeshGenerator__create_noconfig(const char* name) {
35 const MeshGenerator::Implementation* meshgenerator(nullptr);
36 {
37 MeshGenerator m(std::string{name});
38 meshgenerator = m.get();
39 meshgenerator->attach();
40 }
41 meshgenerator->detach();
42 return meshgenerator;
43 }
44
45 const MeshGenerator::Implementation* atlas__MeshGenerator__create(const char* name,
46 const eckit::Parametrisation* config) {
47 const MeshGenerator::Implementation* meshgenerator(nullptr);
48 ATLAS_ASSERT(config);
49 {
50 MeshGenerator m(std::string(name), *config);
51 meshgenerator = m.get();
52 meshgenerator->attach();
53 }
54 meshgenerator->detach();
55 return meshgenerator;
56 }
57
58 Mesh::Implementation* atlas__MeshGenerator__generate__grid_griddist(
59 const MeshGenerator::Implementation* This, const Grid::Implementation* grid,
60 const grid::Distribution::Implementation* distribution) {
61 ATLAS_ASSERT(This != nullptr, "Cannot access uninitialisd atlas_MeshGenerator");
62 ATLAS_ASSERT(grid != nullptr, "Cannot access uninitialisd atlas_Grid");
63 ATLAS_ASSERT(distribution != nullptr, "Cannot access uninitialisd atlas_GridDistribution");
64
65 Mesh::Implementation* m;
66 {
67 Mesh mesh = This->generate(Grid(grid), grid::Distribution(distribution));
68 mesh.get()->attach();
69 m = mesh.get();
70 }
71 m->detach();
72 return m;
73 }
74
75 Mesh::Implementation* atlas__MeshGenerator__generate__grid(const MeshGenerator::Implementation* This,
76 const Grid::Implementation* grid) {
77 ATLAS_ASSERT(This != nullptr, "Cannot access uninitialisd atlas_MeshGenerator");
78 ATLAS_ASSERT(grid != nullptr, "Cannot access uninitialisd atlas_Grid");
79 Mesh::Implementation* m;
80 {
81 Mesh mesh = This->generate(Grid(grid));
82 ;
83 mesh.get()->attach();
84 m = mesh.get();
85 }
86 m->detach();
87 return m;
88 }
89
90 Mesh::Implementation* atlas__MeshGenerator__generate__grid_partitioner(
91 const MeshGenerator::Implementation* This, const Grid::Implementation* grid,
92 const grid::Partitioner::Implementation* partitioner) {
93 ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_MeshGenerator");
94 ATLAS_ASSERT(grid != nullptr, "Cannot access uninitialised atlas_Grid");
95 ATLAS_ASSERT(partitioner != nullptr, "Cannot access uninitialised atlas_Partitioner");
96
97 Mesh::Implementation* m;
98 {
99 Mesh mesh = This->generate(Grid(grid), grid::Partitioner(partitioner));
100 mesh.get()->attach();
101 m = mesh.get();
102 }
103 m->detach();
104 return m;
105 }
106 } // extern "C"
107
108 //----------------------------------------------------------------------------------------------------------------------
109
110 } // namespace meshgenerator
111
112 //----------------------------------------------------------------------------------------------------------------------
113
114 } // namespace atlas