G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsMaterialMatrixContainer.hpp
Go to the documentation of this file.
1
15#pragma once
16
17// #include <gsKLShell/src/gsMaterialMatrixUtils.h>
18// #include <gsKLShell/src/gsMaterialMatrixContainer.h>
20
21using namespace gismo;
22
23namespace gismo
24{
25
26template <class T>
28{
29 m_container.resize(size);
30 // To do: initialize with null pointers
31}
32
33 // gsMaterialMatrixContainer(const gsMaterialMatrixContainer & other)
34 // {
35 // // for (index_t k=0; k!=other.m_container.size(); k++)
36 // // add(memory::make_unique(other.m_container.at(k)));
37 // m_container = give(other.m_container);
38 // }
39
40template <class T>
42{
43 // freeAll(m_container);
44}
45template <class T>
47{
48 m_container.push_back( memory::make_shared(mat.clone().release()) );
49}
50
51template <class T>
53{
54 m_container.push_back( memory::make_shared_not_owned(mat) );
55}
56
57template <class T>
59{
60 m_container[i] = memory::make_shared(mat.clone().release());
61}
62
63template <class T>
65{
66 m_container[i] = memory::make_shared_not_owned(mat);
67}
68
69template <class T>
70void gsMaterialMatrixContainer<T>::set(const index_t i, const typename gsMaterialMatrixBase<T>::Ptr mat)
71{
72 m_container[i] = mat;
73}
74
75template <class T>
77{
78 return m_container.at(k).get();
79}
80
81template <class T>
82std::ostream & gsMaterialMatrixContainer<T>::print(std::ostream &os) const
83{
84 os << "Material container with " << m_container.size() << " materials.\n";
85 return os;
86}
87
88template <class T>
90{
91 m_container.clear();
92}
93
94
95namespace internal
96{
100template<class T>
101class gsXml< gsMaterialMatrixContainer<T> >
102{
103private:
104 gsXml() { }
105 typedef gsMaterialMatrixContainer<T> Object;
106
107public:
108 GSXML_COMMON_FUNCTIONS(gsMaterialMatrixContainer<T>);
109 static std::string tag () { return "MaterialMatrixContainer"; }
110 static std::string type () { return ""; }
111
112 GSXML_GET_POINTER(Object);
113
114 static void get_into(gsXmlNode * node,Object & obj)
115 {
116 const int size = atoi(node->first_attribute("size")->value());
117
118 // Read material inventory
119 int count = countByTag("MaterialMatrix", node);
120 std::vector<typename gsMaterialMatrixBase<T>::Ptr> mat(count);
121 for (gsXmlNode * child = node->first_node("MaterialMatrix"); child; child =
122 child->next_sibling("MaterialMatrix"))
123 {
124 const int i = atoi(child->first_attribute("index")->value());
125 mat[i] = memory::make_shared(gsXml<gsMaterialMatrixBase<T>>::get(child));
126 }
127
129 for (gsXmlNode * child = node->first_node("group"); child;
130 child = child->next_sibling("group"))
131 {
132 const int mIndex = atoi(child->first_attribute("material")->value());
133 std::istringstream group_str;
134 group_str.str( child->value() );
135
136 for(int patch; ( gsGetInt(group_str,patch)); )
137 obj.set(patch,mat[mIndex]);
138 }
139
140 }
141
142 static gsXmlNode * put (const Object & /* obj */,
143 gsXmlTree & /* data */)
144 {
145 GISMO_ERROR("Writing gsMaterialMatrixContainer to Xml is not implemented");
146 // gsWarn<<"Writing gsMaterialMatrixContainer to Xml is not implemented\n";
147 // gsXmlNode * result;
148 // return result;
149 // return putMaterialMatrixToXml< Object >( obj,data );
150 }
151};
152}
153
154} // end namespace
This class defines the base class for material matrices.
Definition gsMaterialMatrixBase.h:33
memory::shared_ptr< gsMaterialMatrixBase > Ptr
Shared pointer for gsGeometry.
Definition gsMaterialMatrixBase.h:41
This class serves as the evaluator of material matrices, based on gsMaterialMatrixBase.
Definition gsMaterialMatrixContainer.h:34
gsMaterialMatrixContainer(index_t size=0)
Constructor.
Definition gsMaterialMatrixContainer.hpp:27
void set(const index_t i, const gsMaterialMatrixBase< T > &mat)
Set a material matrix by copying argument.
Definition gsMaterialMatrixContainer.hpp:58
void add(const gsMaterialMatrixBase< T > &mat)
Add a material matrix by copying argument.
Definition gsMaterialMatrixContainer.hpp:46
void clear()
Clear all function pointers.
Definition gsMaterialMatrixContainer.hpp:89
#define GISMO_ERROR(message)
Definition gsDebug.h:118
int countByTag(const std::string &tag, gsXmlNode *root)
Definition gsXml.cpp:81
shared_ptr< T > make_shared_not_owned(const T *x)
Creates a shared pointer which does not eventually delete the underlying raw pointer....
Definition gsMemory.h:189
shared_ptr< T > make_shared(T *x)
Definition gsMemory.h:181
The G+Smo namespace, containing all definitions for the library.