OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
function.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 "function.h"
36 #include "timestep.h"
37 #include "error.h"
38 #include "domain.h"
39 #include "gausspoint.h"
40 
41 namespace oofem {
43  FEMComponent(n, d)
44 { this->parameterType=0; }
45 
46 double
48 {
49  if(this->giveDomain()->giveElement(this->giveNumber())!=NULL)
50  return 1.;
51  return 0.;
52 }
53 
54 double
56 {
57  if ( mode == VM_Total ) {
58  return this->evaluateAtTime( tStep->giveIntrinsicTime() );
59  } else if ( mode == VM_Velocity ) {
60  return this->evaluateVelocityAtTime( tStep->giveIntrinsicTime() );
61  } else if ( mode == VM_Acceleration ) {
62  return this->evaluateAccelerationAtTime( tStep->giveIntrinsicTime() );
63  } else if ( mode == VM_Incremental ) {
64  return this->evaluateAtTime( tStep->giveTargetTime() ) - this->evaluateAtTime( tStep->giveTargetTime() - tStep->giveTimeIncrement() );
65  } else if (mode == VM_Intermediate) {
66  return this->evaluateAtTime( tStep->giveIntrinsicTime() );
67  } else {
68  OOFEM_ERROR("unsupported mode(%d)", mode);
69  }
70 
71  return 0.;
72 }
73 
74 
75 double
77 {
78  FloatArray v;
79  this->evaluate(v, {{"t",t}});
80  if ( v.giveSize() != 1 ) {
81  OOFEM_ERROR("Function doesn't return scalar results.");
82  }
83  return v.at(1);
84 }
85 
86 
87 void
88 Function :: evaluate(FloatArray &answer, const std :: map< std :: string, FunctionArgument > &valDict, GaussPoint *gp, double param)
89 {
90  if(this->parameterType==0)
91  {
92  auto it = valDict.find("t");
93  if ( it == valDict.end() )
94  {
95  OOFEM_ERROR("Missing necessary argument \"t\"");
96  }else{
97  answer = FloatArray{this->evaluateAtTime(it->second.val0)};
98  }
99  }
100  else if(this->parameterType==1)
101  {
102  answer = FloatArray{this->evaluateAtTime(param)};
103  }
104  else
105  OOFEM_ERROR("Unknown parameter type %d",parameterType);
106 }
107 
108 double
109 Function :: evaluate(const std :: map< std :: string, FunctionArgument > &valDict)
110 {
111  FloatArray ans;
112  this->evaluate(ans, valDict);
113  if ( ans.giveSize() != 1 ) {
114  OOFEM_ERROR("Function does not return scalar value");
115  }
116  return ans[0];
117 }
118 
119 } // end namespace oofem
virtual double evaluateAccelerationAtTime(double t)=0
Returns the second time derivative of the function at given time.
Class and object Domain.
Definition: domain.h:115
double giveFunctionParameter(int paramID)
Definition: function.C:47
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
ValueModeType
Type representing the mode of UnknownType or CharType, or similar types.
Definition: valuemodetype.h:78
Function(int n, Domain *d)
Constructor.
Definition: function.C:42
double giveTargetTime()
Returns target time.
Definition: timestep.h:146
double evaluate(TimeStep *tStep, ValueModeType mode)
Returns the value of load time function at given time.
Definition: function.C:55
double giveTimeIncrement()
Returns solution step associated time increment.
Definition: timestep.h:150
#define OOFEM_ERROR(...)
Definition: error.h:61
double giveIntrinsicTime()
Returns intrinsic time, e.g. time in which constitutive model is evaluated.
Definition: timestep.h:148
virtual double evaluateVelocityAtTime(double t)=0
Returns the first time derivative of the function at given time.
Class representing vector of real numbers.
Definition: floatarray.h:82
Domain * giveDomain() const
Definition: femcmpnn.h:100
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
the oofem namespace is to define a context or scope in which all oofem names are defined.
int giveNumber() const
Definition: femcmpnn.h:107
int parameterType
Definition: function.h:92
virtual double evaluateAtTime(double t)
Returns the value of the function at given time.
Definition: function.C:76
Class representing integration point in finite element program.
Definition: gausspoint.h:93
Class representing solution step.
Definition: timestep.h:80
The top abstract class of all classes constituting the finite element mesh.
Definition: femcmpnn.h:76

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