OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
fracturemanager.C
Go to the documentation of this file.
1 /*
2  *
3  * ##### ##### ###### ###### ### ###
4  * ## ## ## ## ## ## ## ### ##
5  * ## ## ## ## #### #### ## # ##
6  * ## ## ## ## ## ## ## ##
7  * ## ## ## ## ## ## ## ##
8  * ##### ##### ## ###### ## ##
9  *
10  *
11  * OOFEM : Object Oriented Finite Element Code
12  *
13  * Copyright (C) 1993 - 2013 Borek Patzak
14  *
15  *
16  *
17  * Czech Technical University, Faculty of Civil Engineering,
18  * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28  * Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free Software
32  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33  */
34 
35 #include "fracturemanager.h"
36 #include "inputrecord.h"
37 #include "intarray.h"
38 #include "floatarray.h"
39 #include "domain.h"
40 #include "cltypes.h"
41 #include "datareader.h"
42 #include "datastream.h"
43 #include "contextioerr.h"
44 #include "xfem/xfemmanager.h"
45 #include "classfactory.h"
46 #include "element.h"
47 
48 
49 namespace oofem {
51 
52 
53 //===================================================
54 // Fracture Manager
55 //===================================================
57 {
58  this->domain = domain;
59  this->updateFlag = false;
60 }
61 
63 
64 void
66 
67 
68 
70 {
71  // Read number of failure criterias to evaluate
72  IRResultType result; // Required by IR_GIVE_FIELD macro
73 
74  int numCriterias;
76  this->criteriaList.resize(numCriterias);
77  bool verbose = false;
79 
80 #define VERBOSE
81 
82 
83  return IRRT_OK;
84 }
85 
86 
88 {
89  IRResultType result; // Required by IR_GIVE_FIELD macro
90  std :: string name;
91 
92  // Create and initialize all failure criterias
93  for ( int i = 1; i <= ( int ) this->criteriaList.size(); i++ ) {
95  result = mir->giveRecordKeywordField(name);
96 
97  if ( result != IRRT_OK ) {
98  IR_IOERR("", mir, result);
99  }
100 
101  FailureCriteria *failCriteria = classFactory.createFailureCriteria(name.c_str(), i, this);
102  if ( !failCriteria ) {
103  OOFEM_ERROR( "unknown failure criteria (%s)", name.c_str() );
104  return 0;
105  }
106  failCriteria->initializeFrom(mir);
107 
108  // Case: One status per element
109  if ( failCriteria->giveType() == ELLocal ) { // if ELLocal, allocate one failure criteria for each element - should be per gp
110  int numEl = this->domain->giveNumberOfElements();
111  failCriteria->list.resize(numEl);
112  for ( int j = 1; j <= numEl; j++ ) {
113  Element *el = domain->giveElement(j);
114  FailureCriteriaStatus *fcs = failCriteria->CreateStatus(el, failCriteria);
115  failCriteria->list.at(j - 1) = fcs;
116  }
117  } else if ( failCriteria->giveType() == IPLocal ) {
118  OOFEM_ERROR("IPLocal criteria not supported yet");
119  } else if ( failCriteria->giveType() == Nonlocal ) {
120  OOFEM_ERROR("Nonlocal criteria not supported yet");
121  } else {
122  OOFEM_ERROR("Unknown failure criteria");
123  }
124 
125  this->criteriaList.at(i - 1) = failCriteria;
126  }
127 
128  return 1;
129 }
130 
131 
132 void
134 {
135  this->setUpdateFlag(false);
136  this->evaluateFailureCriterias(tStep);
137 }
138 
139 
140 
141 void
143 {
144  // Go through all the failure criterias. These in turn keep track of the failure criteria statuses
145  // which are responsible for their own evaluation
146 
147  for ( int i = 1; i <= ( int ) this->criteriaList.size(); i++ ) {
148 #ifdef VERBOSE
149  printf("\n Evaluating failure criteria %i \n", i);
150 #endif
151  FailureCriteria *failCrit = this->criteriaList.at(i - 1);
152  if ( failCrit->giveType() == ELLocal ) {
153  for ( int j = 1; j <= ( int ) failCrit->list.size(); j++ ) {
154 #ifdef VERBOSE
155  printf("\n Evaluating for element %i \n", j);
156 #endif
157  FailureCriteriaStatus *fcStatus = failCrit->list.at(j - 1);
158  failCrit->computeFailureCriteriaQuantities(fcStatus, tStep);
159 
160  this->setUpdateFlag( failCrit->evaluateFailureCriteria(fcStatus) );
161  }
162  } else if ( failCrit->giveType() == Nonlocal ) {
163  OOFEM_ERROR("Nonlocal criteria not supported yet");
164  } else {
165  OOFEM_ERROR("Unknown failure criteria");
166  }
167  }
168 }
169 
170 
171 void
173 {
174  if ( this->giveUpdateFlag() ) {
175  XfemManager *xMan = this->giveDomain()->giveXfemManager();
176  EnrichmentItem *ei;
177 
178  for ( int k = 1; k <= xMan->giveNumberOfEnrichmentItems(); k++ ) {
179 #ifdef VERBOSE
180  printf("\n Updating geometry of enrichment item %i ", k);
181 #endif
182  ei = xMan->giveEnrichmentItem(k);
183 
184  for ( int i = 1; i <= ( int ) this->criteriaList.size(); i++ ) {
185 #ifdef VERBOSE
186  printf("based on failure criteria %i \n", i);
187 #endif
188  FailureCriteria *failCrit = this->criteriaList.at(i - 1);
189 
190  for ( int j = 1; j <= ( int ) failCrit->list.size(); j++ ) { // each criteria (often each element)
191 #ifdef VERBOSE
192  printf("\n Element %i ", j);
193 #endif
194  FailureCriteriaStatus *fcStatus = failCrit->list.at(j - 1);
195  ei->updateGeometry(fcStatus, tStep);
196  }
197  }
198  }
199  }
200 }
201 
202 
203 
204 
205 
206 //===================================================
207 // Failure Criterias
208 //===================================================
209 #if 1
210 
211 
212 
213 bool
215 {
216  Element *el = fcStatus->el;
217 
218  // If the quantity cannot be evaluated ask element for implementation through an interface
219  if ( !this->evaluateFCQuantities(el, tStep) ) {
220  FailureModuleElementInterface *fmInterface =
222 
223  if ( fmInterface ) { // if element supports the failure module interface
224  fmInterface->computeFailureCriteriaQuantities(fcStatus, tStep); // compute quantities
225  }
226  }
227 
228  return true;
229 }
230 
231 
232 // DamagedNeighborLayered
233 bool
235 {
236  // Go through all the layers and compare against threshold value
237  DamagedNeighborLayeredStatus *status = dynamic_cast< DamagedNeighborLayeredStatus * >(fcStatus);
238  bool criteriaFulfilled = false;
239  status->failedFlags.resize( status->layerDamageValues.giveSize() );
240  for ( int i = 1; i <= ( int ) status->failedFlags.size(); i++ ) { // if there are several quantities like interfaces
241  status->failedFlags.at(i - 1) = false;
242  if ( status->layerDamageValues.at(i) > this->DamageThreshold ) {
243  status->failedFlags.at(i - 1) = true;
244  criteriaFulfilled = true;
245  }
246  }
247  return criteriaFulfilled;
248 };
249 
250 
251 
252 
254 {
255  //IRResultType result; // Required by IR_GIVE_FIELD macro
256 
257  return IRRT_OK;
258 }
259 
260 
262 {
263  IRResultType result; // Required by IR_GIVE_FIELD macro
264 
265  // Read damage threshold value
267 
268  this->setType(ELLocal);
269 
270  return IRRT_OK;
271 }
272 
273 #endif
274 
275 
276 
277 //===================================================
278 // Failure Criteria Status
279 //===================================================
281 {
282  //IRResultType result; // Required by IR_GIVE_FIELD macro
283 
284  return IRRT_OK;
285 }
286 } // end namespace oofem
virtual FailureCriteriaStatus * CreateStatus(Element *el, FailureCriteria *failCrit) const =0
Abstract class representing entity, which is included in the FE model using one (or more) global func...
Class and object Domain.
Definition: domain.h:115
virtual bool evaluateFailureCriteria(FailureCriteriaStatus *fcStatus)=0
#define _IFT_DamagedNeighborLayered_DamageThreshold
virtual bool evaluateFailureCriteria(FailureCriteriaStatus *fcStatus)
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
#define _IFT_FracManager_numcriterias
#define _IFT_FracManager_verbose
void evaluateFailureCriterias(TimeStep *tStep)
Abstract base class for all finite elements.
Definition: element.h:145
FailureCriteria * createFailureCriteria(const char *name, int num, FractureManager *fracManager)
Definition: classfactory.C:364
virtual void updateGeometry(FailureCriteriaStatus *fc, TimeStep *tStep)
This class manages the fracture mechanics part.
std::vector< FailureCriteriaStatus * > list
Class representing the abstraction for input data source.
Definition: datareader.h:50
int giveNumberOfElements() const
Returns number of elements in domain.
Definition: domain.h:434
XfemManager * giveXfemManager()
Definition: domain.C:375
virtual void computeFailureCriteriaQuantities(FailureCriteriaStatus *fc, TimeStep *tStep)
int giveNumberOfEnrichmentItems() const
Definition: xfemmanager.h:185
Element * giveElement(int n)
Service for accessing particular domain fe element.
Definition: domain.C:160
void evaluateYourself(TimeStep *tStep)
void updateXFEM(TimeStep *tStep)
virtual IRResultType giveRecordKeywordField(std::string &answer, int &value)=0
Reads the record id field (type of record) and its corresponding number.
#define OOFEM_ERROR(...)
Definition: error.h:61
REGISTER_FailureCriteria(DamagedNeighborLayered)
std::vector< FailureCriteria * > criteriaList
virtual IRResultType initializeFrom(InputRecord *ir)
virtual InputRecord * giveInputRecord(InputRecordType irType, int recordId)=0
Returns input record corresponding to given InputRecordType value and its record_id.
virtual IRResultType initializeFrom(InputRecord *ir)
void setUpdateFlag(bool flag)
#define IR_IOERR(__keyword, __ir, __result)
Macro simplifying the error reporting.
Definition: inputrecord.h:60
This class manages the xfem part.
Definition: xfemmanager.h:109
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
Class representing the general Input Record.
Definition: inputrecord.h:101
FailureCriteriaType giveType()
virtual Interface * giveInterface(InterfaceType t)
Interface requesting service.
Definition: femcmpnn.h:179
EnrichmentItem * giveEnrichmentItem(int n)
Definition: xfemmanager.h:184
ClassFactory & classFactory
Definition: classfactory.C:59
virtual IRResultType initializeFrom(InputRecord *ir)
~FractureManager()
Destructor.
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
the oofem namespace is to define a context or scope in which all oofem names are defined.
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
int instanciateYourself(DataReader &dr)
std::vector< bool > failedFlags
Class representing solution step.
Definition: timestep.h:80
virtual bool computeFailureCriteriaQuantities(FailureCriteriaStatus *fcStatus, TimeStep *tStep)
IRResultType initializeFrom(InputRecord *ir)

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:28 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011