OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
twofluidmaterial.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 "twofluidmaterial.h"
36 #include "domain.h"
37 #include "floatmatrix.h"
38 #include "gausspoint.h"
39 #include "engngm.h"
40 #include "materialinterface.h"
41 #include "dynamicinputrecord.h"
42 #include "classfactory.h"
43 
44 namespace oofem {
45 REGISTER_Material(TwoFluidMaterial);
46 
47 int
49 {
50  return this->giveMaterial(0)->checkConsistency() &&
51  this->giveMaterial(1)->checkConsistency();
52 }
53 
54 
57 {
58  IRResultType result; // Required by IR_GIVE_FIELD macro
59 
61  if ( this->slaveMaterial.giveSize() != 2 ) {
62  OOFEM_WARNING("mat array should have two values");
63  return IRRT_BAD_FORMAT;
64  }
65 
66  return IRRT_OK;
67 }
68 
69 
70 void
72 {
75 }
76 
77 
78 double
80 {
81  TwoFluidMaterialStatus *status = static_cast< TwoFluidMaterialStatus * >( this->giveStatus(gp) );
82  double vof = this->giveTempVOF(gp);
83  return ( 1.0 - vof ) * giveMaterial(0)->giveEffectiveViscosity(status->giveSlaveGaussPoint0(), tStep) +
84  vof *giveMaterial(1)->giveEffectiveViscosity(status->giveSlaveGaussPoint1(), tStep);
85 }
86 
87 
88 double
90 {
91  TwoFluidMaterialStatus *status = static_cast< TwoFluidMaterialStatus * >( this->giveStatus(gp) );
92  double vof = this->giveTempVOF(gp);
93  return ( 1.0 - vof ) * giveMaterial(0)->give( aProperty, status->giveSlaveGaussPoint0() ) +
94  vof *giveMaterial(1)->give( aProperty, status->giveSlaveGaussPoint1() );
95 }
96 
97 int
99 {
100  TwoFluidMaterialStatus *status = static_cast< TwoFluidMaterialStatus * >( this->giveStatus(gp) );
101  double vof = this->giveTempVOF(gp);
102  FloatArray tmp;
103  int ret = giveMaterial(0)->giveIPValue(answer, status->giveSlaveGaussPoint0(), type, tStep);
104  answer.times(1.0 - vof);
105  ret = ret && giveMaterial(1)->giveIPValue(tmp, status->giveSlaveGaussPoint1(), type, tStep);
106  answer.add(vof, tmp);
107  return ret;
108 }
109 
110 
113 {
114  return new TwoFluidMaterialStatus(1, this->giveDomain(), gp, this->slaveMaterial);
115 }
116 
119 {
120  return static_cast< FluidDynamicMaterial * >( domain->giveMaterial( slaveMaterial(i) ) );
121 }
122 
123 void
125 {
126  double vof = this->giveTempVOF(gp);
127  FloatArray v0, v1;
128  TwoFluidMaterialStatus *status = static_cast< TwoFluidMaterialStatus * >( this->giveStatus(gp) );
129 
130  this->giveMaterial(0)->computeDeviatoricStressVector(v0, status->giveSlaveGaussPoint0(), eps, tStep);
131  this->giveMaterial(1)->computeDeviatoricStressVector(v1, status->giveSlaveGaussPoint1(), eps, tStep);
132 
133  answer.clear();
134  answer.add(1.0 - vof, v0);
135  answer.add(vof, v1);
136 
137  status->letDeviatoricStrainRateVectorBe(eps);
138  status->letDeviatoricStressVectorBe(answer);
139 }
140 
141 void
143  TimeStep *tStep)
144 {
145  FloatMatrix a0, a1;
146  double vof = this->giveTempVOF(gp);
147  TwoFluidMaterialStatus *status = static_cast< TwoFluidMaterialStatus * >( this->giveStatus(gp) );
148 
149  this->giveMaterial(0)->giveDeviatoricStiffnessMatrix(a0, mode, status->giveSlaveGaussPoint0(), tStep);
150  this->giveMaterial(1)->giveDeviatoricStiffnessMatrix(a1, mode, status->giveSlaveGaussPoint1(), tStep);
151 
152  answer.clear();
153  answer.add(1.0 - vof, a0);
154  answer.add(vof, a1);
155 }
156 
157 double
159 {
160  FloatArray vof(2);
162  if ( mi ) {
164 
165  if ( ( vof.at(1) < 0. ) || ( vof.at(1) > 1.0 ) ) {
166  OOFEM_ERROR("vof value out of range (vof=%lf)", vof.at(1));
167  }
168 
169  return vof.at(1);
170  } else {
171  return 0.0;
172  }
173 }
174 
175 
176 
177 
179  FluidDynamicMaterialStatus(n, d, gp),
180  slaveGp0( new GaussPoint(NULL, 0, FloatArray(), 0., gp->giveMaterialMode()) ),
181  slaveGp1( new GaussPoint(NULL, 0, FloatArray(), 0., gp->giveMaterialMode()) )
182 {
183  this->slaveGp0->setMaterialStatus( domain->giveMaterial( slaveMaterial(0) )->CreateStatus(this->slaveGp0.get()), this->giveNumber() );
184  this->slaveGp1->setMaterialStatus( domain->giveMaterial( slaveMaterial(1) )->CreateStatus(this->slaveGp0.get()), this->giveNumber() );
185 }
186 
187 
188 void
190 {
191  this->giveSlaveGaussPoint0()->giveMaterialStatus()->printOutputAt(file, tStep);
192  this->giveSlaveGaussPoint1()->giveMaterialStatus()->printOutputAt(file, tStep);
193 }
194 
195 
196 void
198 {
202 }
203 
204 
205 void
207 {
209  static_cast< MaterialStatus * >( this->giveSlaveGaussPoint0()->giveMaterialStatus() )->initTempStatus();
210  static_cast< MaterialStatus * >( this->giveSlaveGaussPoint1()->giveMaterialStatus() )->initTempStatus();
211 }
212 
213 
216 {
217  this->giveSlaveGaussPoint0()->giveMaterialStatus()->saveContext(stream, mode, obj);
218  this->giveSlaveGaussPoint1()->giveMaterialStatus()->saveContext(stream, mode, obj);
219  return CIO_OK;
220 }
221 
222 
225 {
226  this->giveSlaveGaussPoint0()->giveMaterialStatus()->restoreContext(stream, mode, obj);
227  this->giveSlaveGaussPoint1()->giveMaterialStatus()->restoreContext(stream, mode, obj);
228  return CIO_OK;
229 }
230 } // end namespace oofem
InternalStateType
Type representing the physical meaning of element or constitutive model internal variable.
void setField(int item, InputFieldType id)
virtual void updateYourself(TimeStep *tStep)
Update equilibrium history variables according to temp-variables.
virtual void updateYourself(TimeStep *)
Update equilibrium history variables according to temp-variables.
Definition: matstatus.h:108
virtual void printOutputAt(FILE *file, TimeStep *tStep)
Print receiver&#39;s output to given stream.
virtual MaterialStatus * CreateStatus(GaussPoint *gp) const
Creates new copy of associated status and inserts it into given integration point.
virtual MaterialStatus * giveStatus(GaussPoint *gp) const
Returns material status of receiver in given integration point.
Definition: material.C:244
virtual int checkConsistency()
Allows programmer to test some internal data, before computation begins.
Definition: material.C:233
Class and object Domain.
Definition: domain.h:115
virtual double giveEffectiveViscosity(GaussPoint *gp, TimeStep *tStep)=0
Gives the effective viscosity for the given integration point.
Abstract base class for all fluid materials.
Domain * domain
Link to domain object, useful for communicating with other FEM components.
Definition: femcmpnn.h:82
virtual void computeDeviatoricStressVector(FloatArray &answer, GaussPoint *gp, const FloatArray &eps, TimeStep *tStep)
Computes the deviatoric stress vector from given strain.
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
Definition: datastream.h:54
virtual void printOutputAt(FILE *file, TimeStep *tStep)
Print receiver&#39;s output to given stream.
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
void clear()
Clears receiver (zero size).
Definition: floatarray.h:206
virtual MaterialInterface * giveMaterialInterface(int n)
Returns material interface representation for given domain.
Definition: engngm.h:351
void letDeviatoricStrainRateVectorBe(FloatArray v)
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
EngngModel * giveEngngModel()
Returns engineering model to which receiver is associated.
Definition: domain.C:433
std::unique_ptr< GaussPoint > slaveGp1
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
Definition: femcmpnn.C:51
Element * giveElement()
Returns corresponding element to receiver.
Definition: gausspoint.h:188
int giveNumber()
Returns domain number.
Definition: domain.h:266
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
Definition: material.C:110
TwoFluidMaterialStatus(int n, Domain *d, GaussPoint *g, const IntArray &slaveMaterial)
Constructor.
Class implementing an array of integers.
Definition: intarray.h:61
MatResponseMode
Describes the character of characteristic material matrix.
virtual void initTempStatus()
Initializes the temporary internal variables, describing the current state according to previously re...
virtual double giveEffectiveViscosity(GaussPoint *gp, TimeStep *tStep)
Gives the effective viscosity for the given integration point.
double giveTempVOF(GaussPoint *gp)
void letDeviatoricStressVectorBe(FloatArray v)
Sets the deviatoric stress.
virtual double give(int aProperty, GaussPoint *gp)
Returns the value of material property &#39;aProperty&#39;.
Definition: material.C:52
FluidDynamicMaterial * giveMaterial(int i) const
virtual void giveElementMaterialMixture(FloatArray &answer, int ielem)=0
Returns volumetric (or other based measure) of relative material contents in given element...
This class implements a transport material status information.
virtual void computeDeviatoricStressVector(FloatArray &stress_dev, double &epsp_vol, GaussPoint *gp, const FloatArray &eps, double pressure, TimeStep *tStep)
Computes the deviatoric stress vector and volumetric strain rate from given deviatoric strain and pre...
Material * giveMaterial(int n)
Service for accessing particular domain material model.
Definition: domain.C:281
#define OOFEM_ERROR(...)
Definition: error.h:61
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
Returns the integration point corresponding value in Reduced form.
Abstract base class representing (moving) material interfaces.
std::unique_ptr< GaussPoint > slaveGp0
Abstract base class representing a material status information.
Definition: matstatus.h:84
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
Returns the integration point corresponding value in Reduced form.
Class representing vector of real numbers.
Definition: floatarray.h:82
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
virtual double give(int aProperty, GaussPoint *gp)
Returns the value of material property &#39;aProperty&#39;.
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
IntegrationPointStatus * giveMaterialStatus()
Returns reference to associated material status (NULL if not defined).
Definition: gausspoint.h:205
virtual void giveDeviatoricStiffnessMatrix(FloatMatrix &answer, MatResponseMode mode, GaussPoint *gp, TimeStep *tStep)
Computes the deviatoric stiffness; .
Class representing the general Input Record.
Definition: inputrecord.h:101
virtual void initTempStatus()
Initializes the temporary internal variables, describing the current state according to previously re...
void add(const FloatMatrix &a)
Adds matrix to the receiver.
Definition: floatmatrix.C:1023
Class representing the a dynamic Input Record.
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
virtual void updateYourself(TimeStep *)
Update equilibrium history variables according to temp-variables.
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Definition: contextmode.h:43
#define new
Domain * giveDomain() const
Definition: femcmpnn.h:100
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
Definition: femcmpnn.C:64
REGISTER_Material(DummyMaterial)
virtual int checkConsistency()
Allows programmer to test some internal data, before computation begins.
int giveSize() const
Definition: intarray.h:203
#define _IFT_TwoFluidMaterial_mat
the oofem namespace is to define a context or scope in which all oofem names are defined.
void clear()
Sets size of receiver to be an empty matrix. It will have zero rows and zero columns size...
Definition: floatmatrix.h:516
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
int giveNumber() const
Definition: femcmpnn.h:107
Class representing integration point in finite element program.
Definition: gausspoint.h:93
#define OOFEM_WARNING(...)
Definition: error.h:62
Class representing solution step.
Definition: timestep.h:80
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
virtual MaterialStatus * CreateStatus(GaussPoint *gp) const
Creates new copy of associated status and inserts it into given integration point.
Definition: material.h:316
virtual void giveDeviatoricStiffnessMatrix(FloatMatrix &answer, MatResponseMode mode, GaussPoint *gp, TimeStep *tStep)=0
Computes the deviatoric stiffness; .

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:32 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011