OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
transportmaterial.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 "transportmaterial.h"
36 #include "gausspoint.h"
37 #include "contextioerr.h"
38 
39 namespace oofem {
40 void
42 {
43  this->temp_gradient = std :: move(grad);
44 }
45 
46 void
48 {
49  this->temp_field = std :: move(newField);
50 }
51 
52 void
54 {
55  this->temp_flux = std :: move(w);
56 }
57 
58 void
60 {
61  TransportMaterialStatus *ms = static_cast< TransportMaterialStatus * >( this->giveStatus(gp) );
62  if ( ms ) {
63  ms->letTempStateVectorBe(stateVec);
64  }
65 }
66 
67 
70 { }
71 
73 // Print the state variable and the flow vector on the data file.
74 {
75  FloatArray flowVec;
76  TransportElement *transpElem = static_cast< TransportElement * >( gp->giveElement() );
77 
79 
80  fprintf(File, " state");
81 
82  for ( auto &val : field ) {
83  fprintf( File, " %.4e", val );
84  }
85 
86  transpElem->computeFlow(flowVec, gp, tStep);
87 
88  fprintf(File, " flow");
89  for ( auto &flow : flowVec ) {
90  fprintf( File, " %.4e", flow );
91  }
92 
93  fprintf(File, "\n");
94 }
95 
96 
97 void
99 // Performs end-of-step updates.
100 {
103  field = temp_field;
104  flux = temp_flux;
105 }
106 
107 
108 void
110 //
111 // initialize record at the beginning of new load step
112 //
113 {
116  temp_field = field;
117  temp_flux = flux;
118 }
119 
120 
123 //
124 // saves full ms context (saves state variables, that completely describe
125 // current state)
126 {
127  contextIOResultType iores;
128 
129  if ( ( iores = MaterialStatus :: saveContext(stream, mode, obj) ) != CIO_OK ) {
130  THROW_CIOERR(iores);
131  }
132 
133  if ( ( iores = gradient.storeYourself(stream) ) != CIO_OK ) {
134  THROW_CIOERR(iores);
135  }
136 
137  if ( ( iores = field.storeYourself(stream) ) != CIO_OK ) {
138  THROW_CIOERR(iores);
139  }
140 
141  if ( ( iores = flux.storeYourself(stream) ) != CIO_OK ) {
142  THROW_CIOERR(iores);
143  }
144 
145  return CIO_OK;
146 }
147 
148 
151 //
152 // restores full material context (saves state variables, that completely describe
153 // current state)
154 //
155 {
156  contextIOResultType iores;
157 
158  if ( ( iores = MaterialStatus :: restoreContext(stream, mode, obj) ) != CIO_OK ) {
159  THROW_CIOERR(iores);
160  }
161 
162  if ( ( iores = gradient.restoreYourself(stream) ) != CIO_OK ) {
163  THROW_CIOERR(iores);
164  }
165  if ( ( iores = field.restoreYourself(stream) ) != CIO_OK ) {
166  THROW_CIOERR(iores);
167  }
168  if ( ( iores = flux.restoreYourself(stream) ) != CIO_OK ) {
169  THROW_CIOERR(iores);
170  }
171 
172  return CIO_OK;
173 }
174 
175 
176 int
178 // IST_Humidity must be overriden!
179 {
180  TransportMaterialStatus *ms = static_cast< TransportMaterialStatus * >( this->giveStatus(gp) );
181  if ( type == IST_Temperature || type == IST_MassConcentration_1 || type == IST_Humidity ) {
182  const FloatArray &vec = ms->giveField();
183 // answer = FloatArray{vec.at( ( type == IST_Temperature ) ? 1 : 2 ) };
184  answer = FloatArray{vec.at( 1 ) };
185  return 1;
186  } else if ( type == IST_TemperatureFlow ) {
187  TransportElement *transpElem = static_cast< TransportElement * >( gp->giveElement() );
188  transpElem->computeFlow(answer, gp, tStep);
189  return 1;
190  } else if ( type == IST_Velocity ) {
191  answer = ms->giveFlux();
192  answer.resizeWithValues(3);
193  return 1;
194  } else if ( type == IST_PressureGradient ) {
195  answer = ms->giveGradient();
196  answer.resizeWithValues(3);
197  return 1;
198  } else if ( type == IST_Density ) {
199  answer = FloatArray{ this->give('d', gp) };
200  return 1;
201  } else if ( type == IST_HeatCapacity ) {
202  answer = FloatArray{ this->give('c', gp) };
203  return 1;
204  } else if ( type == IST_ThermalConductivityIsotropic ) {
205  answer = FloatArray{ this->give('k', gp) };
206  return 1;
207  } else if ( type == IST_Maturity ) {
208  answer = FloatArray{ ms->giveMaturity() };
209  return 1;
210  }
211  return Material :: giveIPValue(answer, gp, type, tStep);
212 }
213 } // end namespace oofem
InternalStateType
Type representing the physical meaning of element or constitutive model internal variable.
virtual void updateYourself(TimeStep *)
Update equilibrium history variables according to temp-variables.
Definition: matstatus.h:108
virtual void updateYourself(TimeStep *tStep)
Update equilibrium history variables according to temp-variables.
FloatArray flux
Vector containing the last equilibrated flux. The physical meaning corresponds to energy flux...
FloatArray gradient
Vector containing the last equilibrated gradient. It is the spatial gradient of the field...
GaussPoint * gp
Associated integration point.
Class and object Domain.
Definition: domain.h:115
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
Definition: datastream.h:54
contextIOResultType storeYourself(DataStream &stream) const
Definition: floatarray.C:872
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
double giveMaturity()
Returns maturity.
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 void printOutputAt(FILE *file, TimeStep *tStep)
Print receiver&#39;s output to given stream.
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
FloatArray temp_flux
Vector containing the last computed flux.
This class implements a transport material status information.
virtual void initTempStatus()
Initializes the temporary internal variables, describing the current state according to previously re...
#define THROW_CIOERR(e)
Definition: contextioerr.h:61
TransportMaterialStatus(int n, Domain *d, GaussPoint *g)
Constructor - creates new TransportMaterialStatus with number n, belonging to domain d and Integratio...
const FloatArray & giveFlux()
Returns last flux.
virtual void initTempStatus()
Initializes the temporary internal variables, describing the current state according to previously re...
Definition: matstatus.h:103
const FloatArray & giveField()
Return last field.
This abstract class represent a general base element class for transport problems.
FloatArray field
Vector containing the last equilibrated field. The physical meaning corresponds to temperature...
virtual void computeFlow(FloatArray &answer, GaussPoint *gp, TimeStep *tStep)
Computes a flow vector in an integration point.
contextIOResultType restoreYourself(DataStream &stream)
Definition: floatarray.C:895
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
void setTempField(FloatArray newField)
Set field.
void resizeWithValues(int s, int allocChunk=0)
Checks size of receiver towards requested bounds.
Definition: floatarray.C:615
virtual void updateInternalState(const FloatArray &state, GaussPoint *gp, TimeStep *tStep)
Updates internal state of material according to new state vector.
FloatArray temp_gradient
Vector containing the last used gradient.
void setTempGradient(FloatArray grad)
Set gradient.
Abstract base class representing a material status information.
Definition: matstatus.h:84
double maturity
A scalar containing maturity (integration of temperature over time)
Class representing vector of real numbers.
Definition: floatarray.h:82
void setTempFlux(FloatArray w)
Set flux.
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Definition: contextmode.h:43
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
Definition: femcmpnn.C:64
FloatArray temp_field
Vector containing the last used field.
the oofem namespace is to define a context or scope in which all oofem names are defined.
virtual void printOutputAt(FILE *file, TimeStep *tStep)
Print receiver&#39;s output to given stream.
Definition: matstatus.h:97
void letTempStateVectorBe(FloatArray v)
Class representing integration point in finite element program.
Definition: gausspoint.h:93
Class representing solution step.
Definition: timestep.h:80
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
Returns the integration point corresponding value in Reduced form.
Definition: material.C:142
const FloatArray & giveGradient()
Return last gradient.

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