OOFEM 3.0
Loading...
Searching...
No Matches
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 - 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
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#include "gausspoint.h"
44
45namespace oofem {
47
48int
49TwoFluidMaterial :: checkConsistency()
50{
51 return this->giveMaterial(0)->checkConsistency() &&
52 this->giveMaterial(1)->checkConsistency();
53}
54
55
56void
57TwoFluidMaterial :: initializeFrom(InputRecord &ir)
58{
60 if ( this->slaveMaterial.giveSize() != 2 ) {
61 throw ValueInputException(ir, _IFT_TwoFluidMaterial_mat, "mat array should have two values");
62 }
63}
64
65
66void
67TwoFluidMaterial :: giveInputRecord(DynamicInputRecord &input)
68{
69 FluidDynamicMaterial :: giveInputRecord(input);
71}
72
73
74double
75TwoFluidMaterial :: giveEffectiveViscosity(GaussPoint *gp, TimeStep *tStep) const
76{
77 TwoFluidMaterialStatus *status = static_cast< TwoFluidMaterialStatus * >( this->giveStatus(gp) );
78 double vof = this->giveTempVOF(gp);
79 return ( 1.0 - vof ) * giveMaterial(0)->giveEffectiveViscosity(status->giveSlaveGaussPoint0(), tStep) +
80 vof *giveMaterial(1)->giveEffectiveViscosity(status->giveSlaveGaussPoint1(), tStep);
81}
82
83
84double
85TwoFluidMaterial :: give(int aProperty, GaussPoint *gp) const
86{
87 TwoFluidMaterialStatus *status = static_cast< TwoFluidMaterialStatus * >( this->giveStatus(gp) );
88 double vof = this->giveTempVOF(gp);
89 return ( 1.0 - vof ) * giveMaterial(0)->give( aProperty, status->giveSlaveGaussPoint0() ) +
90 vof *giveMaterial(1)->give( aProperty, status->giveSlaveGaussPoint1() );
91}
92
93int
94TwoFluidMaterial :: giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
95{
96 TwoFluidMaterialStatus *status = static_cast< TwoFluidMaterialStatus * >( this->giveStatus(gp) );
97 double vof = this->giveTempVOF(gp);
98 FloatArray tmp;
99 int ret = giveMaterial(0)->giveIPValue(answer, status->giveSlaveGaussPoint0(), type, tStep);
100 answer.times(1.0 - vof);
101 ret = ret && giveMaterial(1)->giveIPValue(tmp, status->giveSlaveGaussPoint1(), type, tStep);
102 answer.add(vof, tmp);
103 return ret;
104}
105
106
107std::unique_ptr<MaterialStatus>
108TwoFluidMaterial :: CreateStatus(GaussPoint *gp) const
109{
110 std::array<Material*, 2> slaveMaterial({this->giveMaterial(0), this->giveMaterial(1)});
111 return std::make_unique<TwoFluidMaterialStatus>(gp, slaveMaterial);
112}
113
115TwoFluidMaterial :: giveMaterial(int i) const
116{
117 return static_cast< FluidDynamicMaterial * >( domain->giveMaterial( slaveMaterial[i] ) );
118}
119
121TwoFluidMaterial :: computeDeviatoricStress3D(const FloatArrayF<6> &eps, GaussPoint *gp, TimeStep *tStep) const
122{
123 double vof = this->giveTempVOF(gp);
124 TwoFluidMaterialStatus *status = static_cast< TwoFluidMaterialStatus * >( this->giveStatus(gp) );
125
126 auto v0 = this->giveMaterial(0)->computeDeviatoricStress3D(eps, status->giveSlaveGaussPoint0(), tStep);
127 auto v1 = this->giveMaterial(1)->computeDeviatoricStress3D(eps, status->giveSlaveGaussPoint1(), tStep);
128
129 auto stress = (1.0 - vof) * v0 + vof * v1;
130
132 status->letDeviatoricStressVectorBe(stress);
133
134 return stress;
135}
136
138TwoFluidMaterial :: computeTangent3D(MatResponseMode mode, GaussPoint *gp, TimeStep *tStep) const
139{
140 double vof = this->giveTempVOF(gp);
141 TwoFluidMaterialStatus *status = static_cast< TwoFluidMaterialStatus * >( this->giveStatus(gp) );
142
143 auto a0 = this->giveMaterial(0)->computeTangent3D(mode, status->giveSlaveGaussPoint0(), tStep);
144 auto a1 = this->giveMaterial(1)->computeTangent3D(mode, status->giveSlaveGaussPoint1(), tStep);
145
146 return (1.0 - vof) * a0 + vof * a1;
147}
148
149double
150TwoFluidMaterial :: giveTempVOF(GaussPoint *gp) const
151{
152 FloatArray vof(2);
153 MaterialInterface *mi = domain->giveEngngModel()->giveMaterialInterface( domain->giveNumber() );
154 if ( mi ) {
156
157 if ( ( vof.at(1) < 0. ) || ( vof.at(1) > 1.0 ) ) {
158 OOFEM_ERROR("vof value out of range (vof=%lf)", vof.at(1));
159 }
160
161 return vof.at(1);
162 } else {
163 return 0.0;
164 }
165}
166
167
168
169
170TwoFluidMaterialStatus :: TwoFluidMaterialStatus(GaussPoint *gp, const std::array<Material*, 2> &slaveMaterial) :
172 slaveGps{{{nullptr, 0, 0., gp->giveMaterialMode()}, {nullptr, 0, 0., gp->giveMaterialMode()}}}
173{
174 for ( int i = 0; i < 2; ++i ) slaveGps[i].setMaterialStatus( slaveMaterial[i]->CreateStatus( &slaveGps[i] ) );
175}
176
177
178void
179TwoFluidMaterialStatus :: printOutputAt(FILE *file, TimeStep *tStep) const
180{
181 for ( auto &gp : slaveGps ) gp.giveMaterialStatus()->printOutputAt(file, tStep);
182}
183
184
185void
186TwoFluidMaterialStatus :: updateYourself(TimeStep *tStep)
187{
188 FluidDynamicMaterialStatus :: updateYourself(tStep);
189 for ( auto &gp : slaveGps ) gp.giveMaterialStatus()->updateYourself(tStep);
190}
191
192
193void
194TwoFluidMaterialStatus :: initTempStatus()
195{
196 FluidDynamicMaterialStatus :: initTempStatus();
197 for ( auto &gp : slaveGps ) static_cast< MaterialStatus * >( gp.giveMaterialStatus() )->initTempStatus();
198}
199
200
201void
202TwoFluidMaterialStatus :: saveContext(DataStream &stream, ContextMode mode)
203{
204 for ( auto &gp : slaveGps ) gp.giveMaterialStatus()->saveContext(stream, mode);
205}
206
207
208void
209TwoFluidMaterialStatus :: restoreContext(DataStream &stream, ContextMode mode)
210{
211 for ( auto &gp : slaveGps ) gp.giveMaterialStatus()->restoreContext(stream, mode);
212}
213} // end namespace oofem
#define REGISTER_Material(class)
void setField(int item, InputFieldType id)
Domain * domain
Link to domain object, useful for communicating with other FEM components.
Definition femcmpnn.h:79
int giveNumber() const
Definition femcmpnn.h:104
double & at(Index i)
Definition floatarray.h:202
void add(const FloatArray &src)
Definition floatarray.C:218
void times(double s)
Definition floatarray.C:834
FluidDynamicMaterialStatus(GaussPoint *g)
Constructor - creates new TransportMaterialStatus with number n, belonging to domain d and integratio...
void letDeviatoricStrainRateVectorBe(const FloatArrayF< 6 > &v)
void letDeviatoricStressVectorBe(const FloatArrayF< 6 > &v)
Element * giveElement()
Returns corresponding element to receiver.
Definition gausspoint.h:187
GaussPoint * gp
Associated integration point.
virtual void giveElementMaterialMixture(FloatArray &answer, int ielem)=0
virtual void initTempStatus()
Definition matstatus.h:99
virtual MaterialStatus * giveStatus(GaussPoint *gp) const
Definition material.C:206
std::array< GaussPoint, 2 > slaveGps
FluidDynamicMaterial * giveMaterial(int i) const
double giveTempVOF(GaussPoint *gp) const
#define OOFEM_ERROR(...)
Definition error.h:79
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
long ContextMode
Definition contextmode.h:43
#define _IFT_TwoFluidMaterial_mat

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