@@ -133,113 +133,18 @@ bool SIMFiniteDefEl<Dim>::parse (const tinyxml2::XMLElement* elem)
133133
134134 Material * defaultMat = nullptr ;
135135
136- const tinyxml2 ::XMLElement * child = elem -> FirstChildElement ();
137- for (; child ; child = child -> NextSiblingElement ())
136+ for ( const tinyxml2 ::XMLElement * child = elem -> FirstChildElement ();
137+ child ; child = child -> NextSiblingElement ())
138138
139- if (! strcasecmp ( child -> Value (), "isotropic" ) )
139+ if (Material * mat = this -> parseMaterial ( child ); mat )
140140 {
141- int code = this -> parseMaterialSet (child ,mDat .size ());
142- IFEM ::cout <<"\tMaterial code " << code ;
143-
144- int mVer = -1 ;
145- if (utl ::getAttribute (child ,"version" ,mVer ))
146- IFEM ::cout <<" (" << mVer <<"):" ;
147- else
148- IFEM ::cout <<":" ;
149-
150- if (mVer >= 0 && nlo .form >= SIM ::UPDATED_LAGRANGE )
151- mDat .push_back (new NeoHookeMaterial (mVer ));
152- else if (Dim ::dimension == 2 )
153- mDat .push_back (new LinIsotropic (!Elastic ::planeStrain ,
154- Elastic ::axiSymmetry ));
141+ if (nlo .form >= SIM ::UPDATED_LAGRANGE && mat -> isLinear ())
142+ mDat .push_back (new LinearMaterial (mat ));
155143 else
156- mDat .push_back (new LinIsotropic ());
157-
158- mDat .back ()-> parse (child );
159- IFEM ::cout << std ::endl ;
160-
161- if (mVer < 0 && nlo .form >= SIM ::UPDATED_LAGRANGE )
162- mDat .back () = new LinearMaterial (mDat .back ());
163-
164- if (!defaultMat || code == 0 ) defaultMat = mDat .back ();
165- }
166-
167- else if (!strcasecmp (child -> Value (),"druckerprager" ))
168- {
169- int code = this -> parseMaterialSet (child ,mDat .size ());
170- IFEM ::cout <<"\tMaterial code " << code ;
171-
172- mDat .push_back (new DruckerPrager (Dim ::dimension ,
173- !Elastic ::planeStrain ,
174- Elastic ::axiSymmetry ));
175- mDat .back ()-> parse (child );
176- IFEM ::cout << std ::endl ;
177-
178- if (nlo .form >= SIM ::UPDATED_LAGRANGE )
179- mDat .back () = new LinearMaterial (mDat .back ());
144+ mDat .push_back (mat );
180145
181- if (!defaultMat || code == 0 ) defaultMat = mDat .back ();
182- }
183- else if (!strcasecmp (child -> Value (),"plastic" ))
184- {
185- int code = this -> parseMaterialSet (child ,mDat .size ());
186-
187- RealArray pMAT ;
188- ScalarFunc * hfunc = nullptr ;
189- const tinyxml2 ::XMLElement * gchild = child -> FirstChildElement ();
190- for (; gchild ; gchild = gchild -> NextSiblingElement ())
191- if (strcasecmp (gchild -> Value (),"hardeningcurve" ))
192- {
193- std ::string value (gchild -> Value ());
194- char * cval = strtok (const_cast < char * > (value .c_str ())," " );
195- for (; cval ; cval = strtok (nullptr ," " ))
196- pMAT .push_back (atof (cval ));
197- }
198- else if (gchild -> FirstChild ())
199- {
200- // An isotropic hardening function is specified
201- IFEM ::cout <<" Hardening: " ;
202- std ::string type ("expression" );
203- utl ::getAttribute (gchild ,"type" ,type );
204- hfunc = utl ::parseTimeFunc (gchild -> FirstChild ()-> Value (),type );
205- }
206-
207- if (pMAT .size () < 11 ) pMAT .resize (11 ,0.0 );
208- utl ::getAttribute (child ,"Bmod" ,pMAT [0 ]);
209- utl ::getAttribute (child ,"Emod" ,pMAT [0 ]);
210- utl ::getAttribute (child ,"E" ,pMAT [0 ]);
211- utl ::getAttribute (child ,"Smod" ,pMAT [1 ]);
212- utl ::getAttribute (child ,"nu" ,pMAT [1 ]);
213- utl ::getAttribute (child ,"rho" ,pMAT [3 ]);
214- utl ::getAttribute (child ,"Hiso" ,pMAT [4 ]);
215- utl ::getAttribute (child ,"Hkin" ,pMAT [5 ]);
216- utl ::getAttribute (child ,"yield" ,pMAT [6 ]);
217- utl ::getAttribute (child ,"Y0" ,pMAT [7 ]);
218- utl ::getAttribute (child ,"Yinf" ,pMAT [8 ]);
219- utl ::getAttribute (child ,"beta" ,pMAT [9 ]);
220- utl ::getAttribute (child ,"istrt" ,pMAT [10 ]);
221- int iYield = static_cast < int > (pMAT [6 ]);
222- if (iYield == 4 )
223- {
224- utl ::getAttribute (child ,"A" ,pMAT [7 ]);
225- utl ::getAttribute (child ,"B" ,pMAT [8 ]);
226- utl ::getAttribute (child ,"n" ,pMAT [9 ]);
227- }
228- else if (iYield == 6 )
229- {
230- if (pMAT .size () < 13 ) pMAT .resize (13 ,0.0 );
231- utl ::getAttribute (child ,"Q1" ,pMAT [8 ]);
232- utl ::getAttribute (child ,"C1" ,pMAT [9 ]);
233- utl ::getAttribute (child ,"Q2" ,pMAT [11 ]);
234- utl ::getAttribute (child ,"C2" ,pMAT [12 ]);
235- }
236- mDat .push_back (new PlasticMaterial (pMAT ,hfunc ));
237-
238- IFEM ::cout <<"\tMaterial code " << code <<":" ;
239- for (double v : pMAT ) IFEM ::cout <<" " << v ;
240- IFEM ::cout << std ::endl ;
241-
242- if (!defaultMat || code == 0 ) defaultMat = mDat .back ();
146+ if (!defaultMat )
147+ defaultMat = mDat .back ();
243148 }
244149
245150 else if (!strcasecmp (child -> Value (),"contact" ))
@@ -264,6 +169,108 @@ bool SIMFiniteDefEl<Dim>::parse (const tinyxml2::XMLElement* elem)
264169}
265170
266171
172+ template < class Dim > Material *
173+ SIMFiniteDefEl < Dim > ::parseMaterial (const tinyxml2 ::XMLElement * elem )
174+ {
175+ Material * mat = nullptr ;
176+
177+ if (!strcasecmp (elem -> Value (),"isotropic" ))
178+ {
179+ int code = this -> parseMaterialSet (elem ,mDat .size ());
180+ IFEM ::cout <<"\tMaterial code " << code ;
181+
182+ int mVer = -1 ;
183+ if (utl ::getAttribute (elem ,"version" ,mVer ))
184+ IFEM ::cout <<" (" << mVer <<"):" ;
185+ else
186+ IFEM ::cout <<":" ;
187+
188+ if (mVer >= 0 && nlo .form >= SIM ::UPDATED_LAGRANGE )
189+ mat = new NeoHookeMaterial (mVer );
190+ else if (Dim ::dimension == 2 )
191+ mat = new LinIsotropic (!Elastic ::planeStrain ,Elastic ::axiSymmetry );
192+ else
193+ mat = new LinIsotropic ();
194+
195+ mat -> parse (elem );
196+ IFEM ::cout << std ::endl ;
197+ }
198+
199+ else if (!strcasecmp (elem -> Value (),"druckerprager" ))
200+ {
201+ int code = this -> parseMaterialSet (elem ,mDat .size ());
202+ IFEM ::cout <<"\tMaterial code " << code <<":" ;
203+
204+ mat = new DruckerPrager (Dim ::dimension ,
205+ !Elastic ::planeStrain ,Elastic ::axiSymmetry );
206+ mat -> parse (elem );
207+ IFEM ::cout << std ::endl ;
208+ }
209+
210+ else if (!strcasecmp (elem -> Value (),"plastic" ))
211+ {
212+ RealArray pMAT ;
213+ ScalarFunc * hfunc = nullptr ;
214+ for (const tinyxml2 ::XMLElement * child = elem -> FirstChildElement ();
215+ child ; child = child -> NextSiblingElement ())
216+ if (strcasecmp (child -> Value (),"hardeningcurve" ))
217+ {
218+ std ::string value (child -> Value ());
219+ char * cval = strtok (const_cast < char * > (value .c_str ())," " );
220+ for (; cval ; cval = strtok (nullptr ," " ))
221+ pMAT .push_back (atof (cval ));
222+ }
223+ else if (child -> FirstChild ())
224+ {
225+ // An isotropic hardening function is specified
226+ IFEM ::cout <<" Hardening: " ;
227+ std ::string type ("expression" );
228+ utl ::getAttribute (child ,"type" ,type );
229+ hfunc = utl ::parseTimeFunc (child -> FirstChild ()-> Value (),type );
230+ }
231+
232+ if (pMAT .size () < 11 ) pMAT .resize (11 ,0.0 );
233+ utl ::getAttribute (elem ,"Bmod" ,pMAT [0 ]);
234+ utl ::getAttribute (elem ,"Emod" ,pMAT [0 ]);
235+ utl ::getAttribute (elem ,"E" ,pMAT [0 ]);
236+ utl ::getAttribute (elem ,"Smod" ,pMAT [1 ]);
237+ utl ::getAttribute (elem ,"nu" ,pMAT [1 ]);
238+ utl ::getAttribute (elem ,"rho" ,pMAT [3 ]);
239+ utl ::getAttribute (elem ,"Hiso" ,pMAT [4 ]);
240+ utl ::getAttribute (elem ,"Hkin" ,pMAT [5 ]);
241+ utl ::getAttribute (elem ,"yield" ,pMAT [6 ]);
242+ utl ::getAttribute (elem ,"Y0" ,pMAT [7 ]);
243+ utl ::getAttribute (elem ,"Yinf" ,pMAT [8 ]);
244+ utl ::getAttribute (elem ,"beta" ,pMAT [9 ]);
245+ utl ::getAttribute (elem ,"istrt" ,pMAT [10 ]);
246+ int iYield = static_cast < int > (pMAT [6 ]);
247+ if (iYield == 4 )
248+ {
249+ utl ::getAttribute (elem ,"A" ,pMAT [7 ]);
250+ utl ::getAttribute (elem ,"B" ,pMAT [8 ]);
251+ utl ::getAttribute (elem ,"n" ,pMAT [9 ]);
252+ }
253+ else if (iYield == 6 )
254+ {
255+ if (pMAT .size () < 13 ) pMAT .resize (13 ,0.0 );
256+ utl ::getAttribute (elem ,"Q1" ,pMAT [8 ]);
257+ utl ::getAttribute (elem ,"C1" ,pMAT [9 ]);
258+ utl ::getAttribute (elem ,"Q2" ,pMAT [11 ]);
259+ utl ::getAttribute (elem ,"C2" ,pMAT [12 ]);
260+ }
261+
262+ int code = this -> parseMaterialSet (elem ,mDat .size ());
263+ IFEM ::cout <<"\tMaterial code " << code <<":" ;
264+ for (double v : pMAT ) IFEM ::cout <<" " << v ;
265+ IFEM ::cout << std ::endl ;
266+
267+ mat = new PlasticMaterial (pMAT ,hfunc );
268+ }
269+
270+ return mat ;
271+ }
272+
273+
267274template < class Dim >
268275ElasticBase * SIMFiniteDefEl < Dim > ::getIntegrand ()
269276{
@@ -288,10 +295,13 @@ bool SIMFiniteDefEl<Dim>::preprocessB ()
288295
289296 if (std ::find_if (mDat .begin (), mDat .end (), [](const Material * mat )
290297 { return mat -> isHistoryDependent (); }) != mDat .end ())
291- for (const SIMoptions ::ProjectionMap ::value_type & proj : Dim ::opt .project )
292- if (proj .first != SIMoptions ::CGL2_INT )
298+ if (SIMoptions ::ProjectionMap ::const_iterator pit =
299+ std ::find_if (Dim ::opt .project .begin (), Dim ::opt .project .end (),
300+ [](const SIMoptions ::ProjectionMap ::value_type & prj )
301+ { return prj .first != SIMoptions ::CGL2_INT ; });
302+ pit != Dim ::opt .project .end ())
293303 {
294- std ::cerr <<"\n *** Invalid projection method (" << proj . first <<")."
304+ std ::cerr <<"\n *** Invalid projection method (" << pit -> first <<")."
295305 <<"\n Only CGL2 (version 2) works for history dependent"
296306 <<" materials.\n Rerun with <projection type=\"gl2\">"
297307 <<" (or command-line option -gl2) instead." << std ::endl ;
0 commit comments