OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
load.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 "load.h"
36 #include "verbose.h"
37 #include "timestep.h"
38 #include "function.h"
39 #include "dynamicinputrecord.h"
40 
41 namespace oofem {
42 Load :: Load(int i, Domain *aDomain) :
43  GeneralBoundaryCondition(i, aDomain), componentArray(), dofExcludeMask(), reference(false)
44 {
45  timeFunction = 0;
46 }
47 
48 
49 const FloatArray &
51 {
52  return componentArray;
53 }
54 
55 
56 void
57 Load :: computeValues(FloatArray &answer, TimeStep *tStep, const FloatArray &coords, const IntArray &dofids, ValueModeType mode)
58 {
60 #if 1
61  if ( this->dofs.giveSize() == 0 ) {
62  this->computeValueAt(answer, tStep, coords, mode);
63  return;
64  }
65 #endif
66 
67  FloatArray loaded_dofs;
68  this->computeValueAt(loaded_dofs, tStep, coords, mode);
69 
70  answer.resize(dofids.giveSize());
71  answer.zero();
72  for ( int i = 0; i < dofids.giveSize(); ++i ) {
73  int index = this->dofs.findFirstIndexOf(dofids[i]);
74  if ( index > 0 ) {
75  answer[i] = loaded_dofs.at(index);
76  }
77  }
78 }
79 
80 
81 void
83 // Returns an array, the load induced at tStep by the receiver.
84 {
85  double factor;
86 
87  factor = this->giveTimeFunction()->evaluate(tStep, mode);
88  answer = componentArray;
89  answer.times(factor);
90 
91  if ( !isImposed(tStep) ) {
92  answer.zero();
93  }
94 }
95 
96 
99 {
100  IRResultType result; // Required by IR_GIVE_FIELD macro
101 
102 # ifdef VERBOSE
103  // VERBOSE_PRINT1 ("Instanciating load ",number)
104 # endif
105 
107 
108  int size = componentArray.giveSize();
109  dofExcludeMask.resize(size);
112  if ( dofExcludeMask.giveSize() != size ) {
113  OOFEM_WARNING("dofExcludeMask and componentArray size mismatch");
114  return IRRT_BAD_FORMAT;
115  } else {
116  for ( int i = 1; i <= size; i++ ) {
117  if ( dofExcludeMask.at(i) ) {
118  componentArray.at(i) = 0.0;
119  }
120  }
121  }
122 
124 
126 }
127 
128 
130 {
133  if ( !this->dofExcludeMask.containsOnlyZeroes() ) {
135  }
136  if ( this->reference ) input.setField(_IFT_Load_reference);
137 }
138 
139 
140 int
142 {
143  if ( ( indx > 0 ) && ( indx <= dofExcludeMask.giveSize() ) ) {
144  return dofExcludeMask.at(indx);
145  } else {
146  OOFEM_ERROR("dof index out of range");
147  }
148 
149  return 0;
150 }
151 
152 
153 void
154 Load :: scale(double s)
155 {
156  this->componentArray.times(s);
157  this->reference = false;
158 }
159 
160 } // end namespace oofem
virtual bool isImposed(TimeStep *tStep)
Returns nonzero if receiver representing BC is imposed at given time, otherwise returns zero...
void setField(int item, InputFieldType id)
#define _IFT_Load_reference
Definition: load.h:48
Class and object Domain.
Definition: domain.h:115
FloatArray componentArray
Components of boundary condition.
Definition: load.h:85
bool reference
Definition: load.h:100
void zero()
Sets all component to zero.
Definition: intarray.C:52
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
Load(int n, Domain *d)
Constructor.
Definition: load.C:42
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Definition: load.C:98
virtual void computeValueAt(FloatArray &answer, TimeStep *tStep, const FloatArray &coords, ValueModeType mode)=0
Computes components values of load at given point - global coordinates (coordinates given)...
virtual bool hasField(InputFieldType id)=0
Returns true if record contains field identified by idString keyword.
virtual void computeComponentArrayAt(FloatArray &answer, TimeStep *tStep, ValueModeType mode)
Computes boundary condition value - its components values at given time.
Definition: load.C:82
double evaluate(TimeStep *tStep, ValueModeType mode)
Returns the value of load time function at given time.
Definition: function.C:55
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
bool containsOnlyZeroes() const
Checks if receiver is all zero.
Definition: intarray.C:172
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
virtual void computeValues(FloatArray &answer, TimeStep *tStep, const FloatArray &coords, const IntArray &dofids, ValueModeType mode)
Computes components values for specified dof ids.
Definition: load.C:57
#define _IFT_Load_dofexcludemask
Definition: load.h:47
#define OOFEM_ERROR(...)
Definition: error.h:61
int timeFunction
Associated load time function.
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
Definition: load.C:129
IntArray dofs
Dofs that b.c. is applied to (relevant for Dirichlet type b.c.s).
Abstract base class for all boundary conditions of problem.
void resize(int n)
Checks size of receiver towards requested bounds.
Definition: intarray.C:124
const FloatArray & giveComponentArray() const
Definition: load.C:50
Initializes the variable VERBOSE, in order to get a few intermediate messages on screen: beginning an...
Class representing vector of real numbers.
Definition: floatarray.h:82
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
Class representing the general Input Record.
Definition: inputrecord.h:101
int isDofExcluded(int index)
Returns the value of dofExcludeMask corresponding to given index.
Definition: load.C:141
IntArray dofExcludeMask
The load is specified for all dofs of object to which is associated.
Definition: load.h:96
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
Class representing the a dynamic Input Record.
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
#define _IFT_Load_components
Definition: load.h:46
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
int giveSize() const
Definition: intarray.h:203
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.
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
#define OOFEM_WARNING(...)
Definition: error.h:62
Class representing solution step.
Definition: timestep.h:80
virtual void scale(double s)
Scales the receiver according to given value.
Definition: load.C:154
int findFirstIndexOf(int value) const
Finds index of first occurrence of given value in array.
Definition: intarray.C:331
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:29 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011