OOFEM 3.0
Loading...
Searching...
No Matches
expressionfield.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
36#include "field.h"
37#include "expressionfield.h"
38#include "floatarray.h"
39#include "timestep.h"
40#include "parser.h"
41
42namespace oofem {
44
45
47ExpressionField :: ExpressionField(void) : Field(FieldType::FT_Unknown)
48{
49}
50
51void ExpressionField :: initializeFrom(InputRecord &ir)
52{
53 IR_GIVE_FIELD(ir, this->expression, "f");
54 int val;
55 IR_GIVE_FIELD(ir, val, "type");
56 this->type = static_cast<FieldType>(val);
57}
58
59
60int ExpressionField :: evaluateAt(FloatArray &answer, const FloatArray &coords, ValueModeType mode, TimeStep *tStep)
61{
62 if (mode == VM_Total) {
63 Parser p;
64 int err;
65 p.setVariableValue("x", 0, coords.at(1));
66 p.setVariableValue("y", 0, (coords.giveSize()>1)?coords.at(2):0);
67 p.setVariableValue("z", 0, (coords.giveSize()>2)?coords.at(3):0);
68 p.setVariableValue("t", 0, tStep->giveIntrinsicTime());
69 p.eval(this->expression.c_str(), answer, "f", err); // evaluate the expression; return value of "f" array
70 return (err==0);
71 } else {
72 OOFEM_ERROR("Unsupported mode");
73 return 1;
74 }
75}
76
77int ExpressionField :: evaluateAt(FloatArray &answer, DofManager *dman, ValueModeType mode, TimeStep *tStep)
78{
79 OOFEM_ERROR("Not implemented");
80 return 1;
81}
82
83
84
85} // end namespace oofem
#define REGISTER_Field(class)
std::string expression
Name of python module containing evaluating function function.
Field(FieldType b=FieldType::FT_Unknown)
Definition field.h:95
FieldType type
Definition field.h:88
double & at(Index i)
Definition floatarray.h:202
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
void setVariableValue(const char *name, int indx, double value)
Definition parser.C:470
double eval(const char *string, int &err)
Definition parser.C:419
double giveIntrinsicTime()
Returns intrinsic time, e.g. time in which constitutive model is evaluated.
Definition timestep.h:166
#define OOFEM_ERROR(...)
Definition error.h:79
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
FieldType
Physical type of field.
Definition field.h:64

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