OOFEM 3.0
Loading...
Searching...
No Matches
initialcondition.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
35#include "initialcondition.h"
36#include "inputrecord.h"
37#include "cltypes.h"
38#include "function.h"
39#include "engngm.h"
40#include "timestep.h"
41
42namespace oofem {
43double InitialCondition :: give(ValueModeType type, const FloatArray& coords)
44// Returns the prescribed value of the kinematic unknown 'u'.
45{
46 if (this->mode == 0) {
47 char u;
49 if ( this->hasConditionOn(u) ) {
50 return initialValueDictionary.at(u);
51 } else {
52 return 0.;
53 }
54 } else if (this->mode == 1) {
55 int size = coords.giveSize();
56 double x = (size > 0) ? coords.at(1) : 0.0;
57 double y = (size > 1) ? coords.at(2) : 0.0;
58 double z = (size > 2) ? coords.at(3) : 0.0;
59 switch (type)
60 {
61 case VM_Total:
62 return this->valueExpr.eval( { { "x", x }, {"y", y}, {"z",z} }, this->giveDomain() );
63 break;
64 case VM_Velocity:
65 return this->velocityExpr.eval( { { "x", x }, {"y", y}, {"z",z} }, this->giveDomain() );
66 break;
67 case VM_Acceleration:
68 return this->accelerationExpr.eval( { { "x", x }, {"y", y}, {"z",z} }, this->giveDomain() );
69 break;
70 default:
71 return 0.0;
72 }
73 } else if (this->mode == 2) {
74 if (!this->externalFField) {
75 this->externalFField = this->giveDomain()->giveEngngModel()->giveContext()->giveFieldManager()->giveField(this->fFieldType);
76 }
77 FloatArray answer;
78 this->externalFField->evaluateAt(answer, coords, type, this->domain->giveEngngModel()->giveSolutionStepWhenIcApply());
79 return answer.at(1);
80 } else {
81 OOFEM_ERROR("Invalid mode");
82 return 0.0;
83 }
84}
85
86
87int InitialCondition :: hasConditionOn(int u)
88// Returns True if the receiver submits the unknown 'u' to an initial
89// condition, else returns False.
90{
91 if (this->mode == 0) {
92 return ( initialValueDictionary.includes(u) );
93 } else {
94 return true;
95 }
96}
97
98
99int InitialCondition :: hasConditionOn(ValueModeType type)
100// Returns True if the receiver submits the unknown 'u' to an initial
101// condition, else returns False.
102{
103 if (this->mode == 0) {
104 char u = cltypesGiveUnknownTypeModeKey(type);
105 return ( initialValueDictionary.includes(u) );
106 } else {
107 return true;
108 }
109}
110
111void InitialCondition :: printYourself()
112// Prints the receiver on screen.
113{
114 printf("Initial condition %d\ninitial values :\n", number);
115 initialValueDictionary.printYourself();
116}
117
118
119void
120InitialCondition :: initializeFrom(InputRecord &ir)
121// Sets up the dictionary where the receiver stores the conditions it
122// imposes.
123{
125 // compatibility with old input files
127 this->mode = 0;
128 } else if ( ir.hasField(_IFT_InitialCondition_f) ) {
129 this->mode = 1;
130 // new input file format
131 valueExpr.setValue(0.0);
133 velocityExpr.setValue(0.0);
136 }
137 accelerationExpr.setValue(0.0);
140 }
141 } else if ( ir.hasField(_IFT_InitialCondition_field) ) {
142 this->mode = 2;
143 int val;
145 this->fFieldType = static_cast<FieldType>(val);
146 } else {
147 OOFEM_ERROR("Invalid mode");
148 }
149
150 int val = 0;
152 valType = ( bcValType ) val;
153
155 this->set = 0;
157 this->dofIDs.clear();
159}
160
161
162void
163InitialCondition :: scale(ValueModeType type, double s)
164{
165 if (this->mode == 0) {
166 if ( this->hasConditionOn(type) ) {
167 initialValueDictionary.at(type) *= s;
168 }
169 } else {
170 OOFEM_ERROR ("Not suported");
171 }
172}
173
174} // end namespace oofem
Domain * giveDomain() const
Definition femcmpnn.h:97
Domain * domain
Link to domain object, useful for communicating with other FEM components.
Definition femcmpnn.h:79
int number
Component number.
Definition femcmpnn.h:77
double & at(Index i)
Definition floatarray.h:202
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
int mode
flag indicating compatibility (initialValueDictionary) mode (0 uses initialValueDictionary,...
ScalarFunction accelerationExpr
bcValType valType
Physical meaning of bc value.
Dictionary initialValueDictionary
Dictionary of initial (constant) values (deprecated).
IntArray dofIDs
List of dof ids that IC is applied to.
virtual bool hasField(InputFieldType id)=0
Returns true if record contains field identified by idString keyword.
#define OOFEM_ERROR(...)
Definition error.h:79
#define _IFT_InitialCondition_field
#define _IFT_InitialCondition_f
#define _IFT_InitialCondition_d2fdt2
#define _IFT_InitialCondition_conditions
#define _IFT_InitialCondition_valType
#define _IFT_InitialCondition_dofs
#define _IFT_InitialCondition_dfdt
#define _IFT_InitialCondition_set
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
FieldType
Physical type of field.
Definition field.h:64
char cltypesGiveUnknownTypeModeKey(ValueModeType mode)
Definition cltypes.C:57
bcValType
Type determining the type of general boundary condition.
Definition bcvaltype.h:40

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