OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
rvestokesflow.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 "rvestokesflow.h"
36 #include "util.h"
37 #include "oofemtxtdatareader.h"
38 #include "../fm/stokesflowvelocityhomogenization.h"
39 #include "engngm.h"
40 #include "contextioerr.h"
41 #include "gausspoint.h"
42 #include "mathfem.h"
43 #include "classfactory.h"
44 
45 #include <cstdio>
46 #include <cstring>
47 #include <sstream>
48 
49 namespace oofem {
50 REGISTER_Material(RVEStokesFlow);
51 
52 int RVEStokesFlow :: n = 1;
53 
54 RVEStokesFlowMaterialStatus :: RVEStokesFlowMaterialStatus(int n, Domain *d, GaussPoint *g, const std :: string &inputfile) :
55  TransportMaterialStatus(n, d, g), oldTangent(true)
56 {
57  OOFEM_LOG_INFO( "************************** Instanciating microproblem from file %s\n", inputfile.c_str() );
58  OOFEMTXTDataReader dr( inputfile.c_str() );
59 
61  dr.finish();
62 
63  if ( dynamic_cast< StokesFlowVelocityHomogenization* >(e) ) {
64  this->rve.reset( dynamic_cast< StokesFlowVelocityHomogenization* >(e) );
65  } else {
66  delete e;
67  OOFEM_ERROR("Unexpected RVE engineering model");
68  }
69 
70  std :: ostringstream name;
71  name << this->rve->giveOutputBaseFileName() << "-gp" << n;
72  if ( this->domain->giveEngngModel()->isParallel() && this->domain->giveEngngModel()->giveNumberOfProcesses() > 1 ) {
73  name << "." << this->domain->giveEngngModel()->giveRank();
74  }
75  this->rve->letOutputBaseFileNameBe( name.str() );
76 
77  this->rve->setProblemScale(microScale);
78  this->rve->checkProblemConsistency();
79  this->rve->initMetaStepAttributes( this->rve->giveMetaStep(1) );
80  this->rve->giveNextStep();
81  this->rve->init();
82 
83  OOFEM_LOG_INFO("************************** Microproblem at %p instanciated \n", rve.get());
84 }
85 
87 {
88 }
89 
90 
92 {
93  TimeStep *rveTStep = this->rve->giveCurrentStep();
94  rveTStep->setNumber( tStep->giveNumber() );
95  rveTStep->setTime( tStep->giveTargetTime() );
96  rveTStep->setTimeIncrement( tStep->giveTimeIncrement() );
97 }
98 
99 void
101 {
103 }
104 
105 void
107 {
110 
111  this->rve->updateYourself(tStep);
112  this->rve->terminate(tStep);
113 }
114 
115 
118 {
119  contextIOResultType iores;
120 
121  if ( ( iores = TransportMaterialStatus :: saveContext(stream, mode, obj) ) != CIO_OK ) {
122  THROW_CIOERR(iores);
123  }
124 
125  return CIO_OK;
126 }
127 
128 
131 {
132  contextIOResultType iores;
133 
134  if ( ( iores = TransportMaterialStatus :: restoreContext(stream, mode, obj) ) != CIO_OK ) {
135  THROW_CIOERR(iores);
136  }
137 
138  return CIO_OK;
139 }
140 
142 { }
143 
145 {
146  IRResultType result;
147 
149 
150  SupressRVEoutput = 0;
151 
153 
154  return IRRT_OK;
155 }
156 
157 
158 int
160 {
161  RVEStokesFlowMaterialStatus *thisMaterialStatus;
162  thisMaterialStatus = static_cast< RVEStokesFlowMaterialStatus * >( this->giveStatus(gp) );
163  FloatMatrix temp;
164  answer.clear();
165 
166  switch ( type ) {
167  case IST_Velocity:
168  answer.copySubVector(thisMaterialStatus->giveFlux(), 1);
169  return 1;
170  case IST_PressureGradient:
171  answer.copySubVector(thisMaterialStatus->giveGradient(), 1);
172  return 1;
173  case IST_TangentNorm:
174  temp = thisMaterialStatus->giveTangentMatrix();
175  answer.resize(1);
176  answer.at(1) = temp.computeFrobeniusNorm();
177  return 1;
178  case IST_Tangent:
179  temp = thisMaterialStatus->giveTangentMatrix();
180  answer.resize(4);
181  answer.at(1) = temp.at(1, 1);
182  answer.at(2) = temp.at(1, 2);
183  answer.at(3) = temp.at(2, 1);
184  answer.at(4) = temp.at(2, 2);
185  return 1;
186  default:
187  return TransportMaterial :: giveIPValue(answer, gp, type, tStep);
188  }
189 
190  return 0;
191 }
192 
193 void
194 RVEStokesFlow :: giveFluxVector(FloatArray &answer, GaussPoint *gp, const FloatArray &grad, const FloatArray &field, TimeStep *tStep)
195 {
196 
197  this->suppressStdout();
198 
199  OOFEM_LOG_DEBUG("\n****** Enter giveFluxVector ********************** Element number %u, Gauss point %u\n",
200  gp->giveElement()->giveGlobalNumber(), gp->giveNumber());
201 
202  RVEStokesFlowMaterialStatus *status = static_cast< RVEStokesFlowMaterialStatus * >( this->giveStatus(gp) );
203  StokesFlowVelocityHomogenization *rveE = status->giveRVE();
204 
205  OOFEM_LOG_DEBUG( "Solve RVE problem for macroscale pressure gradient gradP=[%f, %f, %f]\n ",
206  grad.at(1), grad.at(2), grad.giveSize() == 3 ? grad.at(3) : 0. );
207 
208  // Compute seepage velocity
209  rveE->applyPressureGradient(grad);
210  status->setTimeStep(tStep);
211  rveE->solveYourselfAt(rveE->giveCurrentStep());
212  rveE->computeSeepage(answer, tStep);
213 
214  OOFEM_LOG_DEBUG( "Pressure gradient gradP=[%f %f] yields velocity vector [%f %f]\n", grad.at(1), grad.at(2), answer.at(1), answer.at(2) );
215 
216 
217  status->setTempGradient(grad);
218  status->setTempFlux(answer);
219  status->oldTangent = true;
220 
221  OOFEM_LOG_DEBUG("****** Exit giveFluxVector **************************************** \n");
222 
223  this->enableStdout();
224 }
225 
226 
227 void
229 {
230  this->suppressStdout();
231 
232  OOFEM_LOG_DEBUG("\n****** Enter giveDeviatoricStiffnessMatrix **********************\n");
233 
234  RVEStokesFlowMaterialStatus *status = static_cast< RVEStokesFlowMaterialStatus * >( this->giveStatus(gp) );
235 
236  if ( status->oldTangent ) {
237  // Compute tangent
238  status->giveRVE()->computeTangent(answer, tStep);
239  status->letTempTangentMatrixBe(answer);
240  status->oldTangent = false;
241  } else {
242  answer = status->giveTempTangentMatrix();
243  }
244 
245  OOFEM_LOG_DEBUG("****** Exit giveDeviatoricStiffnessMatrix **************************************** \n");
246 
247  this->enableStdout();
248 }
249 
252 {
253  return new RVEStokesFlowMaterialStatus(n++, this->giveDomain(), gp, this->rveFilename);
254 }
255 
256 void
258 {
259  // if (SupressRVEoutput) {
260  // fgetpos(stdout, &stdoutPos);
261  // stdoutFID=dup(fileno(stdout));
262  // freopen(this->rveLogFilename.c_str(), "a", stdout);
263  // }
264 }
265 
267 {
268  // if (SupressRVEoutput) {
269  // fflush(stdout);
270  // dup2(stdoutFID, fileno(stdout));
271  // close (stdoutFID);
272  // clearerr(stdout);
273  // fsetpos(stdout, &stdoutPos); /* for C9X */
274  // }
275 }
276 
277 }
InternalStateType
Type representing the physical meaning of element or constitutive model internal variable.
virtual void updateYourself(TimeStep *tStep)
Update equilibrium history variables according to temp-variables.
virtual MaterialStatus * giveStatus(GaussPoint *gp) const
Returns material status of receiver in given integration point.
Definition: material.C:244
void copySubVector(const FloatArray &src, int si)
Copy the given vector as sub-vector to receiver.
Definition: floatarray.C:864
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
Class and object Domain.
Definition: domain.h:115
Domain * domain
Link to domain object, useful for communicating with other FEM components.
Definition: femcmpnn.h:82
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
Definition: datastream.h:54
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
int giveGlobalNumber() const
Definition: element.h:1059
const FloatMatrix & giveTempTangentMatrix()
Definition: rvestokesflow.h:78
const FloatMatrix & giveTangentMatrix()
Definition: rvestokesflow.h:77
void clear()
Clears receiver (zero size).
Definition: floatarray.h:206
void letTempTangentMatrixBe(const FloatMatrix &K)
Definition: rvestokesflow.h:79
EngngModel * giveEngngModel()
Returns engineering model to which receiver is associated.
Definition: domain.C:433
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
Returns the integration point corresponding value in Reduced form.
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
Returns the integration point corresponding value in Reduced form.
double giveTargetTime()
Returns target time.
Definition: timestep.h:146
bool isParallel() const
Returns true if receiver in parallel mode.
Definition: engngm.h:1056
void setTime(double newt)
Sets target and intrinsic time to be equal.
Definition: timestep.h:154
void setTimeIncrement(double newDt)
Sets solution step time increment.
Definition: timestep.h:152
int giveNumberOfProcesses() const
Returns the number of collaborating processes.
Definition: engngm.h:1060
Element * giveElement()
Returns corresponding element to receiver.
Definition: gausspoint.h:188
This class implements a transport material status information.
#define OOFEM_LOG_DEBUG(...)
Definition: logger.h:128
MatResponseMode
Describes the character of characteristic material matrix.
virtual MaterialStatus * CreateStatus(GaussPoint *gp) const
Creates new copy of associated status and inserts it into given integration point.
virtual void initTempStatus()
Initializes the temporary internal variables, describing the current state according to previously re...
#define THROW_CIOERR(e)
Definition: contextioerr.h:61
virtual void initTempStatus()
Initializes the temporary internal variables, describing the current state according to previously re...
double giveTimeIncrement()
Returns solution step associated time increment.
Definition: timestep.h:150
void computeSeepage(FloatArray &v, TimeStep *tStep)
Computes the mean velocity and pressure gradient.
EngngModel * InstanciateProblem(DataReader &dr, problemMode mode, int contextFlag, EngngModel *_master, bool parallelFlag)
Instanciates the new problem.
Definition: util.C:45
const FloatArray & giveFlux()
Returns last flux.
int giveNumber()
Returns receiver&#39;s number.
Definition: timestep.h:129
#define OOFEM_LOG_INFO(...)
Definition: logger.h:127
#define _IFT_RVEStokesFlow_supressoutput
Definition: rvestokesflow.h:48
#define OOFEM_ERROR(...)
Definition: error.h:61
Material status class for the RVEStokesFlow class.
Definition: rvestokesflow.h:57
int giveNumber()
Returns number of receiver.
Definition: gausspoint.h:184
RVEStokesFlow(int n, Domain *d)
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
double at(int i, int j) const
Coefficient access function.
Definition: floatmatrix.h:176
virtual void updateYourself(TimeStep *tStep)
Update equilibrium history variables according to temp-variables.
void computeTangent(FloatMatrix &answer, TimeStep *tStep)
Abstract base class representing a material status information.
Definition: matstatus.h:84
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
Class representing vector of real numbers.
Definition: floatarray.h:82
void setTimeStep(TimeStep *tStep)
Definition: rvestokesflow.C:91
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
double computeFrobeniusNorm() const
Computes the Frobenius norm of the receiver.
Definition: floatmatrix.C:1613
virtual void giveFluxVector(FloatArray &answer, GaussPoint *gp, const FloatArray &grad, const FloatArray &field, TimeStep *tStep)
Returns the flux for the field and its gradient.
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
Class for using the stokes flow class as an rve/constitutive model.
Class representing the general Input Record.
Definition: inputrecord.h:101
Abstract base class for all constitutive models for transport problems.
int giveRank() const
Returns domain rank in a group of collaborating processes (0..groupSize-1)
Definition: engngm.h:1058
#define _IFT_RVEStokesFlow_fileName
Definition: rvestokesflow.h:46
RVEStokesFlowMaterialStatus(int n, Domain *d, GaussPoint *g, const std::string &inputfile)
Definition: rvestokesflow.C:54
StokesFlowVelocityHomogenization * giveRVE()
Definition: rvestokesflow.h:81
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Definition: contextmode.h:43
Domain * giveDomain() const
Definition: femcmpnn.h:100
REGISTER_Material(DummyMaterial)
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
virtual TimeStep * giveCurrentStep(bool force=false)
Returns current time step.
Definition: engngm.h:683
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
Class representing the implementation of plain text date reader.
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
virtual void solveYourselfAt(TimeStep *tStep)
Solves problem for given time step.
Definition: stokesflow.C:90
Class representing integration point in finite element program.
Definition: gausspoint.h:93
std::unique_ptr< StokesFlowVelocityHomogenization > rve
Definition: rvestokesflow.h:61
Class representing solution step.
Definition: timestep.h:80
void setNumber(int i)
Set receiver&#39;s number.
Definition: timestep.h:131
const FloatArray & giveGradient()
Return last gradient.
std::string rveFilename
virtual void giveCharacteristicMatrix(FloatMatrix &answer, MatResponseMode, GaussPoint *gp, TimeStep *tStep)
Computes characteristic matrix of receiver in given integration point.
void resize(int s)
Resizes receiver towards requested size.
Definition: floatarray.C:631

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