OOFEM 3.0
Loading...
Searching...
No Matches
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 - 2025 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
49namespace oofem {
51
52
53//===================================================
54// Fracture Manager
55//===================================================
56FractureManager :: FractureManager(Domain *domain)
57{
58 this->domain = domain;
59 this->updateFlag = false;
60}
61
62FractureManager :: ~FractureManager() { }
63
64void
65FractureManager :: clear() { }
66
67
68
69void FractureManager :: initializeFrom(InputRecord &ir)
70{
71 // Read number of failure criterias to evaluate
72 int numCriterias;
74 this->criteriaList.resize(numCriterias);
75 bool verbose = false;
77}
78
79
80int FractureManager :: instanciateYourself(DataReader &dr)
81{
82 std :: string name;
83
84 // Create and initialize all failure criterias
85 for ( int i = 1; i <= ( int ) this->criteriaList.size(); i++ ) {
86 auto &mir = dr.giveInputRecord(DataReader :: IR_failCritRec, i);
87 mir.giveRecordKeywordField(name);
88
89 auto failCriteria = classFactory.createFailureCriteria(name.c_str(), i, this);
90 if ( !failCriteria ) {
91 OOFEM_ERROR( "unknown failure criteria (%s)", name.c_str() );
92 return 0;
93 }
94 failCriteria->initializeFrom(mir);
95
96 // Case: One status per element
97 if ( failCriteria->giveType() == ELLocal ) { // if ELLocal, allocate one failure criteria for each element - should be per gp
98 int numEl = this->domain->giveNumberOfElements();
99 failCriteria->list.resize(numEl);
100 for ( int j = 1; j <= numEl; j++ ) {
101 Element *el = domain->giveElement(j);
102 FailureCriteriaStatus *fcs = failCriteria->CreateStatus(el);
103 failCriteria->list.at(j - 1) = fcs;
104 }
105 } else if ( failCriteria->giveType() == IPLocal ) {
106 OOFEM_ERROR("IPLocal criteria not supported yet");
107 } else if ( failCriteria->giveType() == Nonlocal ) {
108 OOFEM_ERROR("Nonlocal criteria not supported yet");
109 } else {
110 OOFEM_ERROR("Unknown failure criteria");
111 }
112
113 this->criteriaList.at(i - 1) = std::move(failCriteria);
114 }
115
116 return 1;
117}
118
119
120void
121FractureManager :: evaluateYourself(TimeStep *tStep)
122{
123 this->setUpdateFlag(false);
124 this->evaluateFailureCriterias(tStep);
125}
126
127
128
129void
130FractureManager :: evaluateFailureCriterias(TimeStep *tStep)
131{
132 // Go through all the failure criterias. These in turn keep track of the failure criteria statuses
133 // which are responsible for their own evaluation
134
135 for ( int i = 1; i <= ( int ) this->criteriaList.size(); i++ ) {
136#ifdef VERBOSE
137 printf("\n Evaluating failure criteria %i \n", i);
138#endif
139 auto &failCrit = this->criteriaList.at(i - 1);
140 if ( failCrit->giveType() == ELLocal ) {
141 for ( int j = 1; j <= ( int ) failCrit->list.size(); j++ ) {
142#ifdef VERBOSE
143 printf("\n Evaluating for element %i \n", j);
144#endif
145 FailureCriteriaStatus *fcStatus = failCrit->list.at(j - 1);
146 failCrit->computeFailureCriteriaQuantities(fcStatus, tStep);
147
148 this->setUpdateFlag( failCrit->evaluateFailureCriteria(fcStatus) );
149 }
150 } else if ( failCrit->giveType() == Nonlocal ) {
151 OOFEM_ERROR("Nonlocal criteria not supported yet");
152 } else {
153 OOFEM_ERROR("Unknown failure criteria");
154 }
155 }
156}
157
158
159void
160FractureManager :: updateXFEM(TimeStep *tStep)
161{
162 if ( this->giveUpdateFlag() ) {
163 XfemManager *xMan = this->giveDomain()->giveXfemManager();
164 EnrichmentItem *ei;
165
166 for ( int k = 1; k <= xMan->giveNumberOfEnrichmentItems(); k++ ) {
167#ifdef VERBOSE
168 printf("\n Updating geometry of enrichment item %i ", k);
169#endif
170 ei = xMan->giveEnrichmentItem(k);
171
172 for ( int i = 1; i <= ( int ) this->criteriaList.size(); i++ ) {
173#ifdef VERBOSE
174 printf("based on failure criteria %i \n", i);
175#endif
176 auto &failCrit = this->criteriaList.at(i - 1);
177
178 for ( int j = 1; j <= ( int ) failCrit->list.size(); j++ ) { // each criteria (often each element)
179#ifdef VERBOSE
180 printf("\n Element %i ", j);
181#endif
182 FailureCriteriaStatus *fcStatus = failCrit->list.at(j - 1);
183 ei->updateGeometry(fcStatus, tStep);
184 }
185 }
186 }
187 }
188}
189
190
191
192
193
194//===================================================
195// Failure Criterias
196//===================================================
197#if 1
198
199
200
201bool
202FailureCriteria :: computeFailureCriteriaQuantities(FailureCriteriaStatus *fcStatus, TimeStep *tStep)
203{
204 Element *el = fcStatus->el;
205
206 // If the quantity cannot be evaluated ask element for implementation through an interface
207 if ( !this->evaluateFCQuantities(el, tStep) ) {
208 FailureModuleElementInterface *fmInterface =
210
211 if ( fmInterface ) { // if element supports the failure module interface
212 fmInterface->computeFailureCriteriaQuantities(fcStatus, tStep); // compute quantities
213 }
214 }
215
216 return true;
217}
218
219
220// DamagedNeighborLayered
221bool
222DamagedNeighborLayered :: evaluateFailureCriteria(FailureCriteriaStatus *fcStatus)
223{
224 // Go through all the layers and compare against threshold value
225 DamagedNeighborLayeredStatus *status = dynamic_cast< DamagedNeighborLayeredStatus * >(fcStatus);
226 bool criteriaFulfilled = false;
227 status->failedFlags.resize( status->layerDamageValues.giveSize() );
228 for ( int i = 1; i <= ( int ) status->failedFlags.size(); i++ ) { // if there are several quantities like interfaces
229 status->failedFlags.at(i - 1) = false;
230 if ( status->layerDamageValues.at(i) > this->DamageThreshold ) {
231 status->failedFlags.at(i - 1) = true;
232 criteriaFulfilled = true;
233 }
234 }
235 return criteriaFulfilled;
236};
237
238
239
240
241void FailureCriteria :: initializeFrom(InputRecord &ir)
242{
243}
244
245
246void DamagedNeighborLayered :: initializeFrom(InputRecord &ir)
247{
248 // Read damage threshold value
250
251 this->setType(ELLocal);
252}
253
254#endif
255
256
257
258//===================================================
259// Failure Criteria Status
260//===================================================
261void FailureCriteriaStatus :: initializeFrom(InputRecord &ir)
262{
263}
264} // end namespace oofem
#define REGISTER_FailureCriteria(class)
virtual InputRecord & giveInputRecord(InputRecordType irType, int recordId)=0
virtual void updateGeometry(FailureCriteriaStatus *fc, TimeStep *tStep)
virtual Interface * giveInterface(InterfaceType t)
Definition femcmpnn.h:181
std ::vector< bool > failedFlags
void setType(FailureCriteriaType _type)
virtual bool evaluateFCQuantities(Element *el, TimeStep *tStep)
virtual void computeFailureCriteriaQuantities(FailureCriteriaStatus *fc, TimeStep *tStep)
double & at(Index i)
Definition floatarray.h:202
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
void evaluateFailureCriterias(TimeStep *tStep)
void setUpdateFlag(bool flag)
std::vector< std::unique_ptr< FailureCriteria > > criteriaList
virtual void giveRecordKeywordField(std ::string &answer, int &value)=0
Reads the record id field (type of record) and its corresponding number.
EnrichmentItem * giveEnrichmentItem(int n)
int giveNumberOfEnrichmentItems() const
#define OOFEM_ERROR(...)
Definition error.h:79
#define _IFT_DamagedNeighborLayered_DamageThreshold
#define _IFT_FracManager_verbose
#define _IFT_FracManager_numcriterias
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
ClassFactory & classFactory
@ FailureModuleElementInterfaceType

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011