33class gsXml< gsMaterialMatrixBase<T> >
37 typedef gsMaterialMatrixBase<T> Object;
40 GSXML_COMMON_FUNCTIONS(Object);
41 static std::string tag () {
return "MaterialMatrix"; }
42 static std::string type () {
return ""; }
46 static void get_into(gsXmlNode * node, Object & obj)
52 static Object * get(gsXmlNode * node)
54 GISMO_ASSERT( ( !strcmp( node->name(),
"MaterialMatrix") ),
55 "Something went wrong, was waiting for a MaterialMatrix tag.\n" );
57 gsXmlAttribute * gtype = node->first_attribute(
"type");
60 gsWarn<<
"MaterialMatrix without a type in the xml file\n";
64 const gsXmlAttribute * att_TFT = node->first_attribute(
"TFT");
68 if ((strcmp(
"1", att_TFT->value()) == 0) ||
69 (strcmp(
"true", att_TFT->value()) == 0) ||
70 (strcmp(
"True", att_TFT->value()) == 0) )
74 std::string s = gtype->value() ;
75 Object * tmp = get_impl(node);
78 if ( ( s ==
"Linear2" ) )
79 return new gsMaterialMatrixTFT<2,T,true>(tmp);
80 else if ( ( s ==
"Linear3" ) )
81 return new gsMaterialMatrixTFT<3,T,true>(tmp);
82 else if ( ( s ==
"CompressibleNH2" ) ||
83 ( s ==
"IncompressibleNH2" ) ||
84 ( s ==
"CompressibleNHe2" ) ||
86 ( s ==
"CompressibleMR2" ) ||
87 ( s ==
"IncompressibleMR2" ) ||
88 ( s ==
"CompressibleOG2" ) ||
89 ( s ==
"IncompressibleOG2" ) )
90 return new gsMaterialMatrixTFT<2,T,false>(tmp);
91 else if ( ( s ==
"CompressibleNH3" ) ||
92 ( s ==
"IncompressibleNH3" ) ||
93 ( s ==
"CompressibleNHe3" ) ||
95 ( s ==
"CompressibleMR3" ) ||
96 ( s ==
"IncompressibleMR3" ) ||
97 ( s ==
"CompressibleOG3" ) ||
98 ( s ==
"IncompressibleOG3" ) )
99 return new gsMaterialMatrixTFT<3,T,false>(tmp);
102 gsWarn<<
"Material matrix for TFT model not recognised\n";
110 static Object * get_impl(gsXmlNode * node)
112 GISMO_ASSERT( ( !strcmp( node->name(),
"MaterialMatrix") ),
113 "Something went wrong, was waiting for a MaterialMatrix tag.\n" );
115 gsXmlAttribute * gtype = node->first_attribute(
"type");
118 gsWarn<<
"MaterialMatrix without a type in the xml file\n";
122 std::string s = gtype->value() ;
123 if ( s ==
"Linear2" )
124 return gsXml< gsMaterialMatrixLinear<2,T> >::get(node);
125 if ( s ==
"Linear3" )
126 return gsXml< gsMaterialMatrixLinear<3,T> >::get(node);
128 if ( s ==
"CompressibleNH2" )
129 return gsXml< gsMaterialMatrixNonlinear<2,T,11,true> >::get(node);
130 if ( s ==
"CompressibleNH3" )
131 return gsXml< gsMaterialMatrixNonlinear<3,T,11,true> >::get(node);
132 if ( s ==
"IncompressibleNH2" )
133 return gsXml< gsMaterialMatrixNonlinear<2,T,11,false> >::get(node);
134 if ( s ==
"IncompressibleNH3" )
135 return gsXml< gsMaterialMatrixNonlinear<3,T,11,false> >::get(node);
137 if ( s ==
"CompressibleNHe2" )
138 return gsXml< gsMaterialMatrixNonlinear<2,T,12,true> >::get(node);
139 if ( s ==
"CompressibleNHe3" )
140 return gsXml< gsMaterialMatrixNonlinear<3,T,12,true> >::get(node);
146 if ( s ==
"CompressibleMR2" )
147 return gsXml< gsMaterialMatrixNonlinear<2,T,13,true> >::get(node);
148 if ( s ==
"CompressibleMR3" )
149 return gsXml< gsMaterialMatrixNonlinear<3,T,13,true> >::get(node);
150 if ( s ==
"IncompressibleMR2" )
151 return gsXml< gsMaterialMatrixNonlinear<2,T,13,false> >::get(node);
152 if ( s ==
"IncompressibleMR3" )
153 return gsXml< gsMaterialMatrixNonlinear<3,T,13,false> >::get(node);
155 if ( s ==
"CompressibleOG2" )
156 return gsXml< gsMaterialMatrixNonlinear<2,T,34,true> >::get(node);
157 if ( s ==
"CompressibleOG3" )
158 return gsXml< gsMaterialMatrixNonlinear<3,T,34,true> >::get(node);
159 if ( s ==
"IncompressibleOG2" )
160 return gsXml< gsMaterialMatrixNonlinear<2,T,34,false> >::get(node);
161 if ( s ==
"IncompressibleOG3" )
162 return gsXml< gsMaterialMatrixNonlinear<3,T,34,false> >::get(node);
164 gsWarn<<
"gsMaterialMatrixBase: get<MaterialMatrixBase<T>>: No known MaterialMatrix \""<<s<<
"\". Error.\n";
168 static gsXmlNode * put (
const Object & obj,
171 const Object * ptr = & obj;
172 if (
dynamic_cast<const gsMaterialMatrixTFT<2,T,true> *
>( ptr )
174 dynamic_cast<const gsMaterialMatrixTFT<3,T,true> *
>( ptr )
176 dynamic_cast<const gsMaterialMatrixTFT<2,T,false> *
>( ptr )
178 dynamic_cast<const gsMaterialMatrixTFT<3,T,false> *
>( ptr )
181 gsXmlNode * tmp = put_impl(ptr->material(),data);
186 return put_impl(ptr,data);
189 static gsXmlNode * put_impl (
const Object * obj,
192 if (
const gsMaterialMatrixLinear<2,T> * mm =
193 dynamic_cast<const gsMaterialMatrixLinear<2,T> *
>( obj ) )
194 return gsXml< gsMaterialMatrixLinear<2,T> >::put(*mm,data);
195 if (
const gsMaterialMatrixLinear<3,T> * mm =
196 dynamic_cast<const gsMaterialMatrixLinear<3,T> *
>( obj ) )
197 return gsXml< gsMaterialMatrixLinear<3,T> >::put(*mm,data);
200 if (
const gsMaterialMatrixNonlinear<2,T,11,true> * mm =
201 dynamic_cast<const gsMaterialMatrixNonlinear<2,T,11,true> *
>( obj ) )
202 return gsXml< gsMaterialMatrixNonlinear<2,T,11,true> >::put(*mm,data);
204 if (
const gsMaterialMatrixNonlinear<3,T,11,true> * mm =
205 dynamic_cast<const gsMaterialMatrixNonlinear<3,T,11,true> *
>( obj ) )
206 return gsXml< gsMaterialMatrixNonlinear<3,T,11,true> >::put(*mm,data);
208 if (
const gsMaterialMatrixNonlinear<2,T,11,false> * mm =
209 dynamic_cast<const gsMaterialMatrixNonlinear<2,T,11,false> *
>( obj ) )
210 return gsXml< gsMaterialMatrixNonlinear<2,T,11,false> >::put(*mm,data);
212 if (
const gsMaterialMatrixNonlinear<3,T,11,false> * mm =
213 dynamic_cast<const gsMaterialMatrixNonlinear<3,T,11,false> *
>( obj ) )
214 return gsXml< gsMaterialMatrixNonlinear<3,T,11,false> >::put(*mm,data);
217 if (
const gsMaterialMatrixNonlinear<2,T,12,true> * mm =
218 dynamic_cast<const gsMaterialMatrixNonlinear<2,T,12,true> *
>( obj ) )
219 return gsXml< gsMaterialMatrixNonlinear<2,T,12,true> >::put(*mm,data);
221 if (
const gsMaterialMatrixNonlinear<3,T,12,true> * mm =
222 dynamic_cast<const gsMaterialMatrixNonlinear<3,T,12,true> *
>( obj ) )
223 return gsXml< gsMaterialMatrixNonlinear<3,T,12,true> >::put(*mm,data);
234 if (
const gsMaterialMatrixNonlinear<2,T,13,true> * mm =
235 dynamic_cast<const gsMaterialMatrixNonlinear<2,T,13,true> *
>( obj ) )
236 return gsXml< gsMaterialMatrixNonlinear<2,T,13,true> >::put(*mm,data);
238 if (
const gsMaterialMatrixNonlinear<3,T,13,true> * mm =
239 dynamic_cast<const gsMaterialMatrixNonlinear<3,T,13,true> *
>( obj ) )
240 return gsXml< gsMaterialMatrixNonlinear<3,T,13,true> >::put(*mm,data);
242 if (
const gsMaterialMatrixNonlinear<2,T,13,false> * mm =
243 dynamic_cast<const gsMaterialMatrixNonlinear<2,T,13,false> *
>( obj ) )
244 return gsXml< gsMaterialMatrixNonlinear<2,T,13,false> >::put(*mm,data);
246 if (
const gsMaterialMatrixNonlinear<3,T,13,false> * mm =
247 dynamic_cast<const gsMaterialMatrixNonlinear<3,T,13,false> *
>( obj ) )
248 return gsXml< gsMaterialMatrixNonlinear<3,T,13,false> >::put(*mm,data);
251 if (
const gsMaterialMatrixNonlinear<2,T,34,true> * mm =
252 dynamic_cast<const gsMaterialMatrixNonlinear<2,T,34,true> *
>( obj ) )
253 return gsXml< gsMaterialMatrixNonlinear<2,T,34,true> >::put(*mm,data);
255 if (
const gsMaterialMatrixNonlinear<3,T,34,true> * mm =
256 dynamic_cast<const gsMaterialMatrixNonlinear<3,T,34,true> *
>( obj ) )
257 return gsXml< gsMaterialMatrixNonlinear<3,T,34,true> >::put(*mm,data);
259 if (
const gsMaterialMatrixNonlinear<2,T,34,false> * mm =
260 dynamic_cast<const gsMaterialMatrixNonlinear<2,T,34,false> *
>( obj ) )
261 return gsXml< gsMaterialMatrixNonlinear<2,T,34,false> >::put(*mm,data);
263 if (
const gsMaterialMatrixNonlinear<3,T,34,false> * mm =
264 dynamic_cast<const gsMaterialMatrixNonlinear<3,T,34,false> *
>( obj ) )
265 return gsXml< gsMaterialMatrixNonlinear<3,T,34,false> >::put(*mm,data);
267 gsWarn<<
"gsMaterialMatrixBase: put<MaterialMatrixBase<T>>: No known MaterialMatrix "<< obj <<
"Error.\n";
272template<
class Object>
273Object getMaterialMatrixFromXml ( gsXmlNode * node)
275 typedef typename Object::Scalar_t T;
278 assert ( ( !strcmp( node->name(),
"MaterialMatrix") ) &&
279 ( !strcmp(node->first_attribute(
"type")->value(), gsXml<Object>::type().c_str() ) ) );
281 Object result = Object();
285 tmp = node->first_node(
"Thickness");
287 gsFunctionExpr<T> thickness;
288 gsXml<gsFunctionExpr<T> >::get_into(tmp->first_node(
"Function"), thickness);
289 result.setThickness(thickness);
291 tmp = node->first_node(
"Density");
292 gsFunctionExpr<T> density;
293 bool hasDensity = tmp;
296 gsXml<gsFunctionExpr<T> >::get_into(tmp->first_node(
"Function"), density);
297 result.setDensity(density);
300 gsXmlNode * parNode = node->first_node(
"Parameters");
302 gsFunctionExpr<T> fun;
303 for (gsXmlNode * child = parNode->first_node(
"Function"); child; child =
304 child->next_sibling(
"Function"))
306 const int i = atoi(child->first_attribute(
"index")->value());
307 gsXml<gsFunctionExpr<T> >::get_into(child, fun);
308 result.setParameter(i,fun);
313template<
class Object>
314gsXmlNode * putMaterialMatrixToXml ( Object
const & obj, gsXmlTree & data)
317 typedef typename Object::Scalar_t T;
322 internal::gsXml<Object>::type().c_str(), data) );
324 GISMO_ASSERT(obj.hasThickness(),
"Thickness is not assigned");
326 gsXmlNode * tfun = putFunctionToXml<T>(obj.getThickness(), data, 0);
327 t->append_node(tfun);
329 if (obj.hasDensity())
332 gsXmlNode * rfun = putFunctionToXml<T>(obj.getDensity(), data, 0);
333 r->append_node(rfun);
338 for (
index_t k=0; k!=obj.numParameters(); k++)
340 gsXmlNode * pfun = putFunctionToXml<T>(obj.getParameter(k), data, k);
341 p->append_node(pfun);
#define index_t
Definition gsConfig.h:32
#define gsWarn
Definition gsDebug.h:50
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of FunctionExpr class.
Provides a base class for material matrices.
Provides a container for material matrices for thin shells.
Provides linear material matrices.
Provides hyperelastic material matrices.
Provides linear material matrices.
Provides implementation of generic XML functions.
gsXmlNode * makeNode(const std::string &name, gsXmlTree &data)
Helper to allocate XML node.
Definition gsXml.cpp:54
gsXmlAttribute * makeAttribute(const std::string &name, const std::string &value, gsXmlTree &data)
Helper to allocate XML attribute.
Definition gsXml.cpp:37
The G+Smo namespace, containing all definitions for the library.