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.
smart_pointers.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: Riccardo Rossi
11 // Pooyan Dadvand
12 //
13 
14 #pragma once
15 
16 // System includes
17 #include <iostream>
18 #include <utility>
19 #include <memory>
20 
21 // External includes
22 #include "intrusive_ptr/intrusive_ptr.hpp"
23 
24 namespace Kratos {
25 
26 template<class T>
27 using shared_ptr = std::shared_ptr<T>;
28 
29 template<class T>
30 using weak_ptr = std::weak_ptr<T>;
31 
32 template<class T>
33 using unique_ptr = std::unique_ptr<T>;
34 
35 template<typename C, typename...Args>
36 intrusive_ptr<C> make_intrusive(Args &&...args) {
37  return intrusive_ptr<C>(new C(std::forward<Args>(args)...));
38 }
39 template<typename C, typename...Args>
41  return std::make_shared<C>(std::forward<Args>(args)...);
42 }
43 
44 template<typename C, typename...Args>
46  return std::make_unique<C>(std::forward<Args>(args)...);
47 }
48 
49 template<class T>
50 std::ostream& operator <<(std::ostream& rOStream, const Kratos::weak_ptr<T>& rData) {
51 
52  if(!rData.expired())
53  rOStream << *rData.lock().get();
54  else
55  rOStream <<" expired weak_ptr ";
56 
57  return rOStream;
58 }
59 
60 template<class T>
61 std::ostream& operator <<(std::ostream& rOStream, const Kratos::intrusive_ptr<T>& rData) {
62  rOStream << *rData.get();
63  return rOStream;
64 }
65 
66 } // namespace Kratos
67 
68 
69 #define KRATOS_CLASS_POINTER_DEFINITION(a) typedef Kratos::shared_ptr<a > Pointer; \
70 typedef Kratos::shared_ptr<a > SharedPointer; \
71 typedef Kratos::weak_ptr<a > WeakPointer; \
72 typedef Kratos::unique_ptr<a > UniquePointer
73 
74 namespace Kratos {
75 template< class T > class GlobalPointer;
76 }
77 
78 #define KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(a) typedef typename Kratos::intrusive_ptr<a > Pointer; \
79 typedef Kratos::GlobalPointer<a > WeakPointer; \
80 typedef Kratos::unique_ptr<a > UniquePointer; \
81 typename a::Pointer shared_from_this(){ return a::Pointer(this); }
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
intrusive_ptr< C > make_intrusive(Args &&...args)
Definition: smart_pointers.h:36
std::weak_ptr< T > weak_ptr
Definition: smart_pointers.h:30
std::shared_ptr< T > shared_ptr
Definition: smart_pointers.h:27
std::unique_ptr< T > unique_ptr
Definition: smart_pointers.h:33
unique_ptr< C > make_unique(Args &&...args)
Definition: smart_pointers.h:45
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
shared_ptr< C > make_shared(Args &&...args)
Definition: smart_pointers.h:40
args
Definition: generate_gid_list_file.py:37
int C
Definition: generate_hyper_elastic_simo_taylor_neo_hookean.py:27