OOFEM 3.0
Loading...
Searching...
No Matches
binghamfluid2.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
37#include "domain.h"
38#include "floatmatrix.h"
39#include "gausspoint.h"
40#include "engngm.h"
41#include "mathfem.h"
42#include "datastream.h"
43#include "contextioerr.h"
44#include "dynamicinputrecord.h"
45#include "classfactory.h"
46
47#include <cstdlib>
48
49namespace oofem {
50#define BINGHAM_ALT 1
51#define BINGHAM_MIN_SHEAR_RATE 1.e-10
52
55// static bool __dummy_BinghamFluidMaterial2_alt __attribute__((unused)) = GiveClassFactory().registerMaterial("binghamfluid2", matCreator< BinghamFluidMaterial2 > );
57
58BinghamFluidMaterial2 :: BinghamFluidMaterial2(int n, Domain *d) : FluidDynamicMaterial(n, d)
59{ }
60
61
62void
63BinghamFluidMaterial2 :: initializeFrom(InputRecord &ir)
64{
65 FluidDynamicMaterial :: initializeFrom(ir);
66 // we use rather object's member data than to store data into slow
67 // key-val dictionary with lot of memory allocations
70 mu_inf = 1.e6;
74 tau_c = tau_0 * mu_inf / ( mu_inf - mu_0 );
75 //tau_c = tau_0;
76}
77
78
79void
80BinghamFluidMaterial2 :: giveInputRecord(DynamicInputRecord &input)
81{
82 FluidDynamicMaterial :: giveInputRecord(input);
87}
88
89double
90BinghamFluidMaterial2 :: giveEffectiveViscosity(GaussPoint *gp, TimeStep *tStep) const
91{
92 BinghamFluidMaterial2Status *status = static_cast< BinghamFluidMaterial2Status * >( this->giveStatus(gp) );
93 //double temp_tau=status->giveTempDevStressMagnitude();
94 //double temp_gamma=status->giveTempDevStrainMagnitude();
95 //determine actual viscosity
96 //return this->computeActualViscosity(temp_tau, temp_gamma);
97#ifdef BINGHAM_ALT
98 double gamma = status->giveTempDevStrainMagnitude(); //status->giveTempDevStrainMagnitude();
99 return computeActualViscosity(tau_0, gamma);
100
101 #if 0
102 const FloatArray &epsd = status->giveTempDeviatoricStrainVector(); //status->giveTempDeviatoricStrainVector();
103 double gamma2 = gamma * gamma;
104 double dmudg, dgde1, dgde2, dgde3, mu;
105 if ( gamma < BINGHAM_MIN_SHEAR_RATE ) {
106 dmudg = dgde1 = dgde2 = dgde3 = 0.0;
107 mu = computeActualViscosity(tau_0, gamma);
108 } else {
109 dmudg = ( -1.0 ) * tau_0 * ( 1.0 - exp(-this->stressGrowthRate * gamma) ) / gamma2 +
110 tau_0 *this->stressGrowthRate *exp(-this->stressGrowthRate *gamma) / gamma;
111 mu = mu_0 + tau_0 * ( 1. - exp(-this->stressGrowthRate * gamma) ) / gamma;
112
113 dgde1 = 2.0 * fabs( epsd.at(1) ) / gamma;
114 dgde2 = 2.0 * fabs( epsd.at(2) ) / gamma;
115 dgde3 = 1.0 * fabs( epsd.at(3) ) / gamma;
116 }
117
118 return min( min( ( epsd.at(1) * dmudg * dgde1 + mu ), ( epsd.at(2) * dmudg * dgde2 + mu ) ),
119 ( epsd.at(3) * dmudg * dgde3 + mu ) );
120
121 #endif
122
123#else
124 if ( temp_tau < tau_c ) {
125 return mu_inf;
126 } else {
127 return mu_0;
128 }
129
130#endif
131}
132
133
134double
135BinghamFluidMaterial2 :: give(int aProperty, GaussPoint *gp) const
136{
137 if ( aProperty == Viscosity ) {
138 return mu_0;
139 } else if ( aProperty == YieldStress ) {
140 return tau_0;
141 } else {
142 return FluidDynamicMaterial :: give(aProperty, gp);
143 }
144}
145
146
147std::unique_ptr<MaterialStatus>
148BinghamFluidMaterial2 :: CreateStatus(GaussPoint *gp) const
149{
150 return std::make_unique<BinghamFluidMaterial2Status>(gp);
151}
152
153
155BinghamFluidMaterial2 :: computeDeviatoricStress3D(const FloatArrayF<6> &eps, GaussPoint *gp, TimeStep *tStep) const
156{
157 BinghamFluidMaterial2Status *status = static_cast< BinghamFluidMaterial2Status * >( this->giveStatus(gp) );
158
159 // determine actual viscosity
160 auto epsd = this->computeDeviatoricStrain(eps);
161 // determine shear strain magnitude
162 double gamma = this->computeDevStrainMagnitude(epsd);
163
164#ifdef BINGHAM_ALT
165 double nu = computeActualViscosity(tau_0, gamma);
166 auto stress = this->computeDeviatoricStress(epsd, nu);
167 double tau = this->computeDevStressMagnitude(stress);
168
169 //printf ("nu %e gamma %e\n", nu, gamma);
170#else
171 // compute trial state
172 auto stress = this->computeDeviatoricStress(epsd, this->mu_inf);
173 // check if state allowed
174 double tau = this->computeDevStressMagnitude(stress);
175 if ( tau > this->tau_c ) {
176 double nu = this->computeActualViscosity(tau, gamma);
177 auto stress = this->computeDeviatoricStress(stress, epsd, nu);
178 tau = this->computeDevStressMagnitude(stress);
179 }
180
181#endif
182 // update status
184 status->letDeviatoricStressVectorBe(stress);
185 status->letTempDevStrainMagnitudeBe(gamma);
186 status->letTempDevStressMagnitudeBe(tau);
187
188 return stress;
189}
190
192BinghamFluidMaterial2 :: computeTangent3D(MatResponseMode mode, GaussPoint *gp, TimeStep *tStep) const
193{
194 BinghamFluidMaterial2Status *status = static_cast< BinghamFluidMaterial2Status * >( this->giveStatus(gp) );
195 const auto &epsd = status->giveTempDeviatoricStrainVector();
196 double gamma = status->giveTempDevStrainMagnitude();
197
199 double mu;
200 if ( gamma < BINGHAM_MIN_SHEAR_RATE ) {
201 mu = computeActualViscosity(tau_0, gamma);
202 } else {
203 double dmudg = - tau_0 * ( 1.0 - exp(-this->stressGrowthRate * gamma) ) / (gamma * gamma) +
204 tau_0 * this->stressGrowthRate * exp(-this->stressGrowthRate * gamma) / gamma;
205 mu = mu_0 + tau_0 * ( 1. - exp(-this->stressGrowthRate * gamma) ) / gamma;
206
207 FloatArrayF<6> dgde = {
208 2.0 * epsd.at(1) / gamma,
209 2.0 * epsd.at(2) / gamma,
210 2.0 * epsd.at(3) / gamma,
211 1.0 * epsd.at(4) / gamma,
212 1.0 * epsd.at(5) / gamma,
213 1.0 * epsd.at(6) / gamma,
214 };
215
216 for ( int i = 1; i <= 6; i++ ) {
217 d.at(1, i) = std::abs( 2.0 * epsd.at(1) * dmudg * dgde.at(i) );
218 d.at(2, i) = std::abs( 2.0 * epsd.at(2) * dmudg * dgde.at(i) );
219 d.at(3, i) = std::abs( 2.0 * epsd.at(3) * dmudg * dgde.at(i) );
220 d.at(4, i) = std::abs( epsd.at(4) * dmudg * dgde.at(i) );
221 d.at(5, i) = std::abs( epsd.at(5) * dmudg * dgde.at(i) );
222 d.at(6, i) = std::abs( epsd.at(6) * dmudg * dgde.at(i) );
223 }
224 }
225
226 d.at(1, 1) += 2.0 * mu;
227 d.at(2, 2) += 2.0 * mu;
228 d.at(3, 3) += 2.0 * mu;
229 d.at(4, 4) += mu;
230 d.at(5, 5) += mu;
231 d.at(6, 6) += mu;
232 return d;
233}
234
235
236int
237BinghamFluidMaterial2 :: checkConsistency()
238{
239 if ( domain->giveEngngModel()->giveEquationScalingFlag() ) {
240 double scale = domain->giveEngngModel()->giveVariableScale(VST_Density);
241 propertyDictionary.at('d') /= scale;
242
243 scale = domain->giveEngngModel()->giveVariableScale(VST_Viscosity);
244 this->mu_0 /= scale;
245 this->tau_0 /= scale;
246 }
247
248 return 1;
249}
250
251double
252BinghamFluidMaterial2 :: computeActualViscosity(double tau, double shearRate) const
253{
254#ifdef BINGHAM_ALT
255 if ( tau_0 > 0.0 ) {
256 shearRate = max(shearRate, BINGHAM_MIN_SHEAR_RATE);
257 return ( mu_0 + tau_0 * ( 1. - exp(-this->stressGrowthRate * shearRate) ) / shearRate );
258 } else {
259 // newtonian flow
260 return mu_0;
261 }
262
263#else
264 if ( tau <= tau_c ) {
265 return this->mu_inf;
266 } else {
267 return mu_0 + ( tau_0 / shearRate );
268 }
269
270#endif
271}
272
273
274double
275BinghamFluidMaterial2 :: computeDevStrainMagnitude(const FloatArrayF<6> &epsd)
276{
277 double val = 2.0 * ( epsd[0] * epsd[0] + epsd[1] * epsd[1] + epsd[2] * epsd[2] ) +
278 epsd[3] * epsd[3] + epsd[4] * epsd[4] + epsd[5] * epsd[5];
279 return sqrt(val);
280}
281
282double
283BinghamFluidMaterial2 :: computeDevStressMagnitude(const FloatArrayF<6> &sigd)
284{
285 double val = 0.5 * ( sigd[0] * sigd[0] + sigd[1] * sigd[1] + sigd[2] * sigd[2] +
286 2.0 * (sigd[3] * sigd[3] + sigd[4] * sigd[4] + sigd[5] * sigd[5]) );
287 return sqrt(val);
288}
289
291BinghamFluidMaterial2 :: computeDeviatoricStrain(const FloatArrayF<6> &eps)
292{
293 //double ekk=(eps.at(1)+eps.at(2)+eps.at(3))/3.0;
294 double ekk = 0.0;
295 return {
296 eps[0] - ekk,
297 eps[1] - ekk,
298 eps[2] - ekk,
299 eps[3],
300 eps[4],
301 eps[5]
302 };
303}
304
305
307BinghamFluidMaterial2 :: computeDeviatoricStress(const FloatArrayF<6> &deps, double nu)
308{
309 return {
310 2.0 * nu * ( deps[0] ),
311 2.0 * nu * ( deps[1] ),
312 2.0 * nu * ( deps[2] ),
313 deps[3] * nu,
314 deps[4] * nu,
315 deps[5] * nu
316 };
317}
318
319
320BinghamFluidMaterial2Status :: BinghamFluidMaterial2Status(GaussPoint *g) :
322{}
323
324void
325BinghamFluidMaterial2Status :: printOutputAt(FILE *File, TimeStep *tStep) const
326{
327 fprintf(File, " strains ");
328 for ( double e: deviatoricStrainRateVector ) {
329 fprintf( File, " %.4e", e );
330 }
331
332 fprintf(File, "\n deviatoric stresses");
333 for ( double e: deviatoricStressVector ) {
334 fprintf( File, " %.4e", e );
335 }
336
337 fprintf(File, "\n status { gamma %e, tau %e }", devStrainMagnitude, devStressMagnitude);
338
339 fprintf(File, "\n");
340}
341
342void
343BinghamFluidMaterial2Status :: updateYourself(TimeStep *tStep)
344{
345 FluidDynamicMaterialStatus :: updateYourself(tStep);
346
350}
351
352
353void
354BinghamFluidMaterial2Status :: initTempStatus()
355{
356 FluidDynamicMaterialStatus :: initTempStatus();
357
361}
362
363
364void
365BinghamFluidMaterial2Status :: saveContext(DataStream &stream, ContextMode mode)
366{
367 FluidDynamicMaterialStatus :: saveContext(stream, mode);
368
369 if ( !stream.write(devStrainMagnitude) ) {
371 }
372
373 if ( !stream.write(devStressMagnitude) ) {
375 }
376}
377
378
379void
380BinghamFluidMaterial2Status :: restoreContext(DataStream &stream, ContextMode mode)
381{
382 FluidDynamicMaterialStatus :: restoreContext(stream, mode);
383
384 if ( !stream.read(devStrainMagnitude) ) {
386 }
387
388 if ( !stream.read(devStressMagnitude) ) {
390 }
391}
392
393
394#if 0
395void
396BinghamFluidMaterial2 :: __debug(GaussPoint *gp, TimeStep *tStep)
397{
398 BinghamFluidMaterial2Status *status = static_cast< BinghamFluidMaterial2Status * >( this->giveStatus(gp) );
399 const FloatArray &epsd = status->giveTempDeviatoricStrainVector();
400 const FloatArray &sigd = status->giveTempDeviatoricStrainVector()
401 for ( int i = 1; i <= nincr; i++ ) {
402 eps.add(eps_i);
403 computeDeviatoricStressVector(tau, gp, eps, tStep);
404 giveDeviatoricStiffnessMatrix(d, TangentStiffness, gp, tStep);
405 tau_t.beProductOf(d, eps_i);
406 tau_t.add(tau_p);
407 //tau.printYourself();
408 //tau_t.printYourself();
409 //d.printYourself();
410 printf( "%e %e %e %e %e %e %e %e %e\n", eps.at(1), eps.at(2), eps.at(3), tau.at(1), tau.at(2), tau.at(3), tau_t.at(1), tau_t.at(2), tau_t.at(3) );
411 tau_p = tau_t;
412 }
413}
414#endif
415} // end namespace oofem
#define BINGHAM_MIN_SHEAR_RATE
#define _IFT_BinghamFluidMaterial2_mu0
#define BINGHAM_DEFAULT_STRESS_GROWTH_RATE
#define _IFT_BinghamFluidMaterial2_tau0
#define _IFT_BinghamFluidMaterial2_muinf
#define _IFT_BinghamFluidMaterial2_stressGrowthRate
#define REGISTER_Material_Alt(class, altname)
#define REGISTER_Material(class)
double devStressMagnitude
Magnitude of deviatoric stresses.
const FloatArrayF< 6 > & giveTempDeviatoricStrainVector() const
void letTempDevStressMagnitudeBe(double _val)
void letTempDevStrainMagnitudeBe(double _val)
FloatArrayF< 6 > temp_deviatoricStrainVector
Deviatoric stresses and strains (reduced form).
void letTempDeviatoricStrainVectorBe(const FloatArrayF< 6 > &v)
double devStrainMagnitude
Magnitude of deviatoric strains.
static FloatArrayF< 6 > computeDeviatoricStrain(const FloatArrayF< 6 > &eps)
static double computeDevStrainMagnitude(const FloatArrayF< 6 > &epsd)
static FloatArrayF< 6 > computeDeviatoricStress(const FloatArrayF< 6 > &deps, double nu)
double computeActualViscosity(double tau, double shearRate) const
double tau_0
Yield stress.
static double computeDevStressMagnitude(const FloatArrayF< 6 > &sigd)
double stressGrowthRate
Stress growth rate - parameter controlling the shape of regularized model.
virtual int read(int *data, std::size_t count)=0
Reads count integer values into array pointed by data.
virtual int write(const int *data, std::size_t count)=0
Writes count integer values from array pointed by data.
void setField(int item, InputFieldType id)
Domain * domain
Link to domain object, useful for communicating with other FEM components.
Definition femcmpnn.h:79
double & at(Index i)
Definition floatarray.h:202
double at(std::size_t i, std::size_t j) const
FluidDynamicMaterialStatus(GaussPoint *g)
Constructor - creates new TransportMaterialStatus with number n, belonging to domain d and integratio...
FloatArrayF< 6 > deviatoricStrainRateVector
Strain vector in reduced form.
void letDeviatoricStressVectorBe(const FloatArrayF< 6 > &v)
FloatArrayF< 6 > deviatoricStressVector
Stress vector in reduced form.
virtual MaterialStatus * giveStatus(GaussPoint *gp) const
Definition material.C:206
Dictionary propertyDictionary
Definition material.h:107
#define THROW_CIOERR(e)
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
#define Viscosity
Definition matconst.h:79
#define YieldStress
Definition matconst.h:80
long ContextMode
Definition contextmode.h:43
FloatArrayF< N > min(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
@ VST_Viscosity
@ VST_Density
FloatArrayF< N > max(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
@ CIO_IOERR
General IO error.

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