KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
variable_indexing_python.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Pooyan Dadvand
11 // Riccardo Rossi
12 //
13 
14 #pragma once
15 
16 // System includes
17 #include <pybind11/pybind11.h>
18 
19 // External includes
20 
21 // Project includes
22 #include "includes/define_python.h"
23 
24 namespace Kratos::Python
25 {
26 
27 namespace py = pybind11;
30 
34 
38 
42 
46 
48 
50 template<class TContainerType, class TVariableType>
51 class VariableIndexingPython //: public def_visitor<VariableIndexingPython<TContainerType, TVariableType> >
52 {
53 public:
56 
59 
63 
66 
69 
72 
76 
80 
81  template <class TClassType>
82  void visit(TClassType& ThisClass) const
83  {
84  ThisClass
91  //.def("__delitem__", &DataValueContainerDeleteValue)
92  //.def("Erase", &DataValueContainerDeleteValue)
93  ;
94  }
95 
99 
103 
107 
111 
113 private:
116 
120 
124 
128 
129  static void DataValueContainerSetValue(TContainerType& rData, TVariableType const& rV, typename TVariableType::Type const& rValue)
130  {
131  rData.SetValue(rV, rValue);
132  }
133 
134  static typename TVariableType::Type DataValueContainerGetValue(TContainerType const& rData, TVariableType const& rV)
135  {
136  return rData.GetValue(rV);
137  }
138 
139  inline
140  static typename TVariableType::Type const& DataValueContainerGetReference(TContainerType const& rData, TVariableType const& rV)
141  {
142  return rData.GetValue(rV);
143  }
144 
145  //static void DataValueContainerDeleteValue(TContainerType& rData, TVariableType const& rV)
146  //{
147  // rData.Erase(rV);
148  //}
149 
150  static bool DataValueContainerHas(TContainerType const& rData, TVariableType const& rV)
151  {
152  return rData.Has(rV);
153  }
154 
158 
159 
163 
164 
168 
170  VariableIndexingPython& operator=(const VariableIndexingPython& rOther);
171 
173 
174 }; // Class VariableIndexingPython
175 
177 
180 
184 
186 
187 } // namespace Kratos::Python.
188 
189 
Short class definition.
Definition: variable_indexing_python.h:52
VariableIndexingPython(const VariableIndexingPython &rOther)
Copy constructor.
virtual ~VariableIndexingPython()
Destructor.
Definition: variable_indexing_python.h:71
KRATOS_CLASS_POINTER_DEFINITION(VariableIndexingPython)
Pointer definition of VariableIndexingPython.
void visit(TClassType &ThisClass) const
Definition: variable_indexing_python.h:82
VariableIndexingPython()
Default constructor.
Definition: variable_indexing_python.h:65
Definition: add_distributed_sparse_matrices_to_python.cpp:28