OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
randommaterialext.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 "gausspoint.h"
36 #include "inputrecord.h"
37 #include "domain.h"
38 #include "material.h"
39 #include "function.h"
40 #include "randommaterialext.h"
41 #include "dynamicinputrecord.h"
42 
43 namespace oofem {
44 bool
46 {
47  if ( randProperties.includes(key) ) {
48  value = randProperties.at(key);
49  return true;
50  } else {
51  return false;
52  }
53 }
54 
55 void
57 {
58  randProperties.at(key) = value;
59 }
60 
61 
64 {
65  IRResultType result; // Required by IR_GIVE_FIELD macro
66 
67  randVariables.clear();
68  randomVariableGenerators.clear();
70  IR_GIVE_OPTIONAL_FIELD(ir, randomVariableGenerators, _IFT_RandomMaterialExt_randGen);
71 
72  if ( randVariables.giveSize() != randomVariableGenerators.giveSize() ) {
73  OOFEM_WARNING("Incompatible size of randvars and randdist attrs");
74  return IRRT_BAD_FORMAT;
75  }
76 
77  return IRRT_OK;
78 }
79 
80 
81 void
83 {
84  ir.setField(this->randVariables, _IFT_RandomMaterialExt_randVariables);
85  ir.setField(this->randomVariableGenerators, _IFT_RandomMaterialExt_randGen);
86 }
87 
88 
89 bool
91 {
92  RandomMaterialStatusExtensionInterface *interface = dynamic_cast< RandomMaterialStatusExtensionInterface * >
94  return interface->_giveProperty(key, value);
95 }
96 
97 void
99 {
100  // Have to wrap it through the material to ensure that it gets an actual material status (for now at least)
101  int size = randVariables.giveSize();
102  double value;
103  MaterialStatus *matStat = static_cast< MaterialStatus* >( gp->giveMaterialStatus() );
106 
107  for ( int i = 1; i <= size; i++ ) {
108  FloatArray globalCoordinates;
109  if ( gp->giveElement()->computeGlobalCoordinates( globalCoordinates, gp->giveSubPatchCoordinates() ) ) {
110  Function *f = gp->giveElement()->giveDomain()->giveFunction( randomVariableGenerators.at(i) );
111  value = f->evaluate({{"x", globalCoordinates}});
112  status->_setProperty(randVariables.at(i), value);
113  } else {
114  OOFEM_ERROR("computeGlobalCoordinates failed");
115  }
116  }
117 }
118 } // end namespace oofem
void setField(int item, InputFieldType id)
#define _IFT_RandomMaterialExt_randVariables
double & at(int aKey)
Returns the value of the pair which key is aKey.
Definition: dictionary.C:106
const FloatArray & giveSubPatchCoordinates()
Returns local sub-patch coordinates of the receiver.
Definition: gausspoint.h:144
void _setProperty(int key, double value)
Sets the value of random property, identified by a key.
bool includes(int aKey)
Checks if dictionary includes given key.
Definition: dictionary.C:126
bool _giveProperty(int key, double &value)
Returns the value of random property, identified by a key.
Element * giveElement()
Returns corresponding element to receiver.
Definition: gausspoint.h:188
double evaluate(TimeStep *tStep, ValueModeType mode)
Returns the value of load time function at given time.
Definition: function.C:55
#define _IFT_RandomMaterialExt_randGen
void _generateStatusVariables(GaussPoint *) const
Sets up (generates) the variables identified in randVariables array using generators given in randomV...
#define OOFEM_ERROR(...)
Definition: error.h:61
bool give(int key, GaussPoint *gp, double &value)
Returns the property in associated status of given integration point if defined.
Abstract base class for all random constitutive model statuses.
Function * giveFunction(int n)
Service for accessing particular domain load time function.
Definition: domain.C:268
Abstract base class representing a material status information.
Definition: matstatus.h:84
Class representing vector of real numbers.
Definition: floatarray.h:82
Abstract base class representing a function with vector input and output.
Definition: function.h:88
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
IntegrationPointStatus * giveMaterialStatus()
Returns reference to associated material status (NULL if not defined).
Definition: gausspoint.h:205
Class representing the general Input Record.
Definition: inputrecord.h:101
void giveInputRecord(DynamicInputRecord &ir)
virtual Interface * giveInterface(InterfaceType t)
Interface requesting service.
Definition: femcmpnn.h:179
Class representing the a dynamic Input Record.
Domain * giveDomain() const
Definition: femcmpnn.h:100
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
the oofem namespace is to define a context or scope in which all oofem names are defined.
Dictionary randProperties
Dictionary containing material model values.
Class representing integration point in finite element program.
Definition: gausspoint.h:93
#define OOFEM_WARNING(...)
Definition: error.h:62
IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
virtual int computeGlobalCoordinates(FloatArray &answer, const FloatArray &lcoords)
Computes the global coordinates from given element&#39;s local coordinates.
Definition: element.C:1207

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