OOFEM 3.0
Loading...
Searching...
No Matches
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 - 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 "gausspoint.h"
37#include "contextioerr.h"
38#include "floatarrayf.h"
39#include "floatmatrixf.h"
40#include "datastream.h"
41
42namespace oofem {
43
44TransportMaterialStatus :: TransportMaterialStatus(GaussPoint *g) :
46{ }
47
48void TransportMaterialStatus :: printOutputAt(FILE *File, TimeStep *tStep) const
49{
50 MaterialStatus :: printOutputAt(File, tStep);
51
52 fprintf(File, " state %.4e", field);
53
54 fprintf(File, " flow");
55 for ( auto &flow : flux ) {
56 fprintf( File, " %.4e", flow );
57 }
58
59 fprintf(File, "\n");
60}
61
62
63void
64TransportMaterialStatus :: updateYourself(TimeStep *tStep)
65{
66 MaterialStatus :: updateYourself(tStep);
70}
71
72
73void
74TransportMaterialStatus :: initTempStatus()
75{
76 MaterialStatus :: initTempStatus();
80}
81
82
83void
84TransportMaterialStatus :: saveContext(DataStream &stream, ContextMode mode)
85{
86 MaterialStatus :: saveContext(stream, mode);
87
89 if ( ( iores = gradient.storeYourself(stream) ) != CIO_OK ) {
90 THROW_CIOERR(iores);
91 }
92
93 if ( stream.read(field) ) {
95 }
96
97 if ( ( iores = flux.storeYourself(stream) ) != CIO_OK ) {
98 THROW_CIOERR(iores);
99 }
100}
101
102
103void
104TransportMaterialStatus :: restoreContext(DataStream &stream, ContextMode mode)
105{
106 MaterialStatus :: restoreContext(stream, mode);
107
109 if ( ( iores = gradient.restoreYourself(stream) ) != CIO_OK ) {
110 THROW_CIOERR(iores);
111 }
112 if ( !stream.read(field) ) {
114 }
115 if ( ( iores = flux.restoreYourself(stream) ) != CIO_OK ) {
116 THROW_CIOERR(iores);
117 }
118}
119
120
121
122HeMoTransportMaterialStatus :: HeMoTransportMaterialStatus(GaussPoint *g) :
124{ }
125
126
127void
128HeMoTransportMaterialStatus :: printOutputAt(FILE *File, TimeStep *tStep) const
129{
130 MaterialStatus :: printOutputAt(File, tStep);
131
132 fprintf(File, " temperature %.4e", temperature);
133
134 fprintf(File, " t_flux");
135 for ( auto &flow : t_flux ) {
136 fprintf( File, " %.4e", flow );
137 }
138
139 fprintf(File, " humidity %.4e", humidity);
140
141 fprintf(File, " h_flux");
142 for ( auto &flow : h_flux ) {
143 fprintf( File, " %.4e", flow );
144 }
145
146 fprintf(File, "\n");
147}
148
149
150void
151HeMoTransportMaterialStatus :: updateYourself(TimeStep *tStep)
152{
153 MaterialStatus :: updateYourself(tStep);
154
158
162}
163
164
165void
166HeMoTransportMaterialStatus :: initTempStatus()
167{
168 MaterialStatus :: initTempStatus();
169
173
177}
178
179
180void
181HeMoTransportMaterialStatus :: saveContext(DataStream &stream, ContextMode mode)
182{
183 MaterialStatus :: saveContext(stream, mode);
184
186 if ( ( iores = t_gradient.storeYourself(stream) ) != CIO_OK ) {
187 THROW_CIOERR(iores);
188 }
189
190 if ( stream.read(temperature) ) {
192 }
193
194 if ( ( iores = t_flux.storeYourself(stream) ) != CIO_OK ) {
195 THROW_CIOERR(iores);
196 }
197
198 if ( ( iores = h_gradient.storeYourself(stream) ) != CIO_OK ) {
199 THROW_CIOERR(iores);
200 }
201
202 if ( stream.read(humidity) ) {
204 }
205
206 if ( ( iores = h_flux.storeYourself(stream) ) != CIO_OK ) {
207 THROW_CIOERR(iores);
208 }
209}
210
211
212void
213HeMoTransportMaterialStatus :: restoreContext(DataStream &stream, ContextMode mode)
214{
215 MaterialStatus :: restoreContext(stream, mode);
216
218 if ( ( iores = t_gradient.restoreYourself(stream) ) != CIO_OK ) {
219 THROW_CIOERR(iores);
220 }
221 if ( !stream.read(temperature) ) {
223 }
224 if ( ( iores = t_flux.restoreYourself(stream) ) != CIO_OK ) {
225 THROW_CIOERR(iores);
226 }
227
228 if ( ( iores = h_gradient.restoreYourself(stream) ) != CIO_OK ) {
229 THROW_CIOERR(iores);
230 }
231 if ( !stream.read(humidity) ) {
233 }
234 if ( ( iores = h_flux.restoreYourself(stream) ) != CIO_OK ) {
235 THROW_CIOERR(iores);
236 }
237}
238
239
240
241void
242TransportMaterial :: updateInternalState(const FloatArray &stateVec, GaussPoint *gp, TimeStep *)
243{
244 if ( stateVec.giveSize() == 1 ) {
245 auto ms = static_cast< TransportMaterialStatus * >( this->giveStatus(gp) );
246 if ( ms ) {
247 ms->setTempField(stateVec[0]);
248 }
249 } else if ( stateVec.giveSize() == 2 ) {
250 auto ms = static_cast< HeMoTransportMaterialStatus * >( this->giveStatus(gp) );
251 if ( ms ) {
252 ms->setTempTemperature(stateVec[0]);
253 ms->setTempHumidity(stateVec[1]);
254 }
255 }
256}
257
258
259void
260TransportMaterial :: giveFluxVector(FloatArray &answer, GaussPoint *gp, const FloatArray &grad, const FloatArray &field, TimeStep *tStep) const
261{
262 if ( field.giveSize() == 1 ) {
263 if ( grad.giveSize() == 3 ) {
264 answer = computeFlux3D(grad, field[0], gp, tStep);
265 } else if ( grad.giveSize() == 2 ) {
266 answer = computeFlux2D(grad, field[0], gp, tStep);
267 } else {
268 answer = computeFlux1D(grad, field[0], gp, tStep);
269 }
270 } else {
271 // Has to be a HeMo-model:
272 double t = field.at(1);
273 double h = field.at(2);
274
275 int size = grad.giveSize() / 2;
276 FloatArrayF<3> grad_w, grad_t;
277 for (int i = 0; i < size; ++i) {
278 grad_t[i] = grad[i];
279 }
280 for (int i = 0; i < size; ++i) {
281 grad_w[i] = grad[i+size];
282 }
283
284 auto grads = computeHeMoFlux3D(grad_t, grad_w, t, h, gp, tStep);
285
286 answer.resize(size * 2);
287 for (int i = 0; i < size; ++i) {
288 answer[i] = grads.first[i];
289 }
290
291 for (int i = 0; i < size; ++i) {
292 answer[i+size] = grads.second[i];
293 }
294 }
295}
296
297void
298TransportMaterial :: giveCharacteristicMatrix(FloatMatrix &answer, MatResponseMode mode, GaussPoint *gp, TimeStep *tStep) const
299{
300 MaterialMode mmode = gp->giveMaterialMode();
301 if ( mmode == _3dHeat || mmode == _3dMTLattice ) {
302 answer = computeTangent3D(mode, gp, tStep);
303 } else if ( mmode == _2dHeat || mmode == _2dMTLattice ) {
304 answer = computeTangent2D(mode, gp, tStep);
305 } else if ( mmode == _1dHeat ) {
306 answer = computeTangent1D(mode, gp, tStep);
307 } else if ( mmode == _3dHeMo ) {
308 answer = computeTangent3D(mode, gp, tStep);
309 } else if ( mmode == _2dHeMo ) {
310 answer = computeTangent2D(mode, gp, tStep);
311 } else if ( mmode == _1dHeMo ) {
312 answer = computeTangent1D(mode, gp, tStep);
313 }
314}
315
316
318TransportMaterial :: computeFlux3D(const FloatArrayF<3> &grad, double field, GaussPoint *gp, TimeStep *tStep) const
319{
320 OOFEM_ERROR("Method not overloaded");
321}
322
323
325TransportMaterial :: computeFlux2D(const FloatArrayF<2> &grad, double field, GaussPoint *gp, TimeStep *tStep) const
326{
327 auto ans = this->computeFlux3D({grad[0], grad[1], 0.}, field, gp, tStep);
328 return {ans[0], ans[1]};
329}
330
331
333TransportMaterial :: computeFlux1D(const FloatArrayF<1> &grad, double field, GaussPoint *gp, TimeStep *tStep) const
334{
335 auto ans = this->computeFlux3D({grad[0], 0., 0.}, field, gp, tStep);
336 return {ans[0]};
337}
338
339
340std::pair<FloatArrayF<3>, FloatArrayF<3>>
341TransportMaterial :: computeHeMoFlux3D(const FloatArrayF<3> &grad_t, const FloatArrayF<3> &grad_w, double t, double h, GaussPoint *gp, TimeStep *tStep) const
342{
343 OOFEM_ERROR("Method is only validfor heat+moisture coupled materials.");
344}
345
346std::pair<FloatArrayF<2>, FloatArrayF<2>>
347TransportMaterial :: computeHeMoFlux2D(const FloatArrayF<2> &grad_t, const FloatArrayF<2> &grad_w, double t, double h, GaussPoint *gp, TimeStep *tStep) const
348{
349 auto grads = computeHeMoFlux3D({grad_t[0], grad_t[1], 0.}, {grad_w[0], grad_w[1], 0.}, t, h, gp, tStep);
350 return {{grads.first[0], grads.first[1]}, {grads.second[0], grads.second[1]}};
351}
352
353
354std::pair<FloatArrayF<1>, FloatArrayF<1>>
355TransportMaterial :: computeHeMoFlux1D(const FloatArrayF<1> &grad_t, const FloatArrayF<1> &grad_w, double t, double h, GaussPoint *gp, TimeStep *tStep) const
356{
357 auto grads = computeHeMoFlux3D({grad_t[0], 0., 0.}, {grad_w[0], 0., 0.}, t, h, gp, tStep);
358 return {{grads.first[0]}, {grads.second[0]}};
359}
360
361
363TransportMaterial :: computeTangent2D(MatResponseMode mode, GaussPoint *gp, TimeStep *tStep) const
364{
365 auto x = this->computeTangent3D(mode, gp, tStep);
366 return {
367 x(0, 0), x(1, 0),
368 x(0, 1), x(1, 1),
369 };
370}
371
372
374TransportMaterial :: computeTangent1D(MatResponseMode mode, GaussPoint *gp, TimeStep *tStep) const
375{
376 auto x = this->computeTangent3D(mode, gp, tStep);
377 return {x(0, 0)};
378}
379
380
381
382int
383TransportMaterial :: giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
384// IST_Humidity must be overriden!
385{
386 TransportMaterialStatus *ms = static_cast< TransportMaterialStatus * >( this->giveStatus(gp) );
387 if ( type == IST_Temperature || type == IST_MassConcentration_1 || type == IST_Humidity ) {
388 answer = FloatArray{ms->giveField()};
389 return 1;
390 } else if ( type == IST_TemperatureFlow ) {
391 TransportElement *transpElem = static_cast< TransportElement * >( gp->giveElement() );
392 transpElem->computeFlow(answer, gp, tStep);
393 return 1;
394 } else if ( type == IST_Velocity ) {
395 answer = ms->giveFlux();
396 answer.resizeWithValues(3);
397 return 1;
398 } else if ( type == IST_PressureGradient ) {
399 answer = ms->giveGradient();
400 answer.resizeWithValues(3);
401 return 1;
402 } else if ( type == IST_Density ) {
403 answer = FloatArray{ this->give('d', gp) };
404 return 1;
405 } else if ( type == IST_HeatCapacity ) {
406 answer = FloatArray{ this->give('c', gp) };
407 return 1;
408 } else if ( type == IST_ThermalConductivityIsotropic ) {
409 answer = FloatArray{ this->give('k', gp) };
410 return 1;
411 } else if ( type == IST_Maturity ) {
412 answer = FloatArray{ ms->giveMaturity() };
413 return 1;
414 } else if ( type == IST_InternalSource ) {
415 if(hasInternalSource()){
416 computeInternalSourceVector(answer, gp, tStep, VM_Total);
417 } else {
418 answer.resize(1);
419 answer.zero();
420 }
421 return 1;
422 }
423
424 return Material :: giveIPValue(answer, gp, type, tStep);
425}
426} // end namespace oofem
virtual int read(int *data, std::size_t count)=0
Reads count integer values into array pointed by data.
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
void resizeWithValues(Index s, std::size_t allocChunk=0)
Definition floatarray.C:103
void zero()
Zeroes all coefficients of receiver.
Definition floatarray.C:683
MaterialMode giveMaterialMode()
Returns corresponding material mode of receiver.
Definition gausspoint.h:190
Element * giveElement()
Returns corresponding element to receiver.
Definition gausspoint.h:187
FloatArrayF< 3 > h_gradient
Humidity gradient.
FloatArrayF< 3 > t_gradient
Temperature gradient.
FloatArrayF< 3 > t_flux
Heat flux.
FloatArrayF< 3 > temp_t_flux
Temp heat flux.
FloatArrayF< 3 > temp_h_flux
Temp humidity flux.
FloatArrayF< 3 > temp_h_gradient
Temp humidity gradient.
FloatArrayF< 3 > h_flux
Humidity flux.
FloatArrayF< 3 > temp_t_gradient
Temp temperature gradient.
double temp_temperature
Temp temperature.
MaterialStatus(GaussPoint *g)
Definition matstatus.h:91
virtual MaterialStatus * giveStatus(GaussPoint *gp) const
Definition material.C:206
virtual double give(int aProperty, GaussPoint *gp) const
Definition material.C:51
virtual void computeFlow(FloatArray &answer, GaussPoint *gp, TimeStep *tStep)
double giveField() const
Return last field.
FloatArrayF< 3 > temp_gradient
Temp. Gradient.
double field
General field (temperature, concentration, etc.).
const FloatArrayF< 3 > & giveGradient() const
Return last gradient.
const FloatArrayF< 3 > & giveFlux() const
Returns last flux.
FloatArrayF< 3 > temp_flux
Vector containing the last computed flux.
FloatArrayF< 3 > gradient
General gradient.
FloatArrayF< 3 > flux
General flux (energy flux, mass flow, etc.).
double temp_field
Temp. Primary field.
double giveMaturity() const
Returns maturity.
virtual FloatArrayF< 3 > computeFlux3D(const FloatArrayF< 3 > &grad, double field, GaussPoint *gp, TimeStep *tStep) const
FloatMatrixF< 2, 2 > computeTangent2D(MatResponseMode mode, GaussPoint *gp, TimeStep *tStep) const
virtual std::pair< FloatArrayF< 3 >, FloatArrayF< 3 > > computeHeMoFlux3D(const FloatArrayF< 3 > &grad_t, const FloatArrayF< 3 > &grad_w, double t, double h, GaussPoint *gp, TimeStep *tStep) const
virtual void computeInternalSourceVector(FloatArray &val, GaussPoint *gp, TimeStep *tStep, ValueModeType mode) const
virtual FloatMatrixF< 3, 3 > computeTangent3D(MatResponseMode mode, GaussPoint *gp, TimeStep *tStep) const =0
FloatMatrixF< 1, 1 > computeTangent1D(MatResponseMode mode, GaussPoint *gp, TimeStep *tStep) const
FloatArrayF< 1 > computeFlux1D(const FloatArrayF< 1 > &grad, double field, GaussPoint *gp, TimeStep *tStep) const
virtual bool hasInternalSource() const
FloatArrayF< 2 > computeFlux2D(const FloatArrayF< 2 > &grad, double field, GaussPoint *gp, TimeStep *tStep) const
#define THROW_CIOERR(e)
#define OOFEM_ERROR(...)
Definition error.h:79
long ContextMode
Definition contextmode.h:43
@ 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