OOFEM
2.4
OOFEM.org - Object Oriented Finite Element Solver
|
Implementation of Scalar function. More...
#include <scalarfunction.h>
Public Member Functions | |
ScalarFunction () | |
Creates empty constant scalar function. More... | |
ScalarFunction (double val) | |
Creates constant scalar function defined by given value. More... | |
ScalarFunction (std::string &val) | |
Creates scalar funtion defined by given simple expression. More... | |
ScalarFunction (int val) | |
Constructor of scalar function defined using external function. More... | |
~ScalarFunction () | |
void | setValue (double val) |
Sets receiver to be a constant scalar function defined by given value. More... | |
void | setSimpleExpression (std::string &val) |
Sets receiver to be a scalar funtion defined by given simple expression. More... | |
void | setReference (int val) |
Sets receiver to be a scalar function defined using external function. More... | |
double | eval (const std::map< std::string, FunctionArgument >valDict, Domain *d, GaussPoint *gp=NULL, double param=0.) const |
Evaluates the receiver. More... | |
double | eval (double time, Domain *d) const |
Evaluates the receiver (convenience function that directly takes just the time as a parameter). More... | |
bool | isDefined () const |
True if receiver is defined. More... | |
Private Types | |
enum | { DV_Undefined, DV_ValueType, DV_SimpleExpressionType, DV_FunctionReferenceType } |
Enum value determining the dataValue type. More... | |
Private Attributes | |
double | dValue |
Constant, double value. More... | |
std::string | eValue |
Simple expression (evaluated by internal parser) More... | |
int | fReference |
Reference to external function. More... | |
enum oofem::ScalarFunction:: { ... } | dvType |
Enum value determining the dataValue type. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const ScalarFunction &s) |
Implementation of Scalar function.
The scalar function can be defined as (i) simple double (constant) value, (ii) simple expression, that is evaluated by internal parser and that can depend on any number of variables, which are defined by calling context (time finctions depend on time variable 't', variable loads can depend on spatial position described by 'x', 'y', 'z' values, etc.). (iii) reference to a function, defined in input file and maintained by corresponding Domain.
The sclar functions can replace constant variables in many places. The advantage is that they are naturally supported by input readers (simple values are formatted as usual, simple expressions are enclosed in '$', references to external functions are formatted as , where i is the number of corresponding external function).
Definition at line 62 of file scalarfunction.h.
|
private |
Enum value determining the dataValue type.
Enumerator | |
---|---|
DV_Undefined | |
DV_ValueType | |
DV_SimpleExpressionType | |
DV_FunctionReferenceType |
Definition at line 72 of file scalarfunction.h.
oofem::ScalarFunction::ScalarFunction | ( | ) |
Creates empty constant scalar function.
Definition at line 49 of file scalarfunction.C.
References DV_Undefined, and dvType.
oofem::ScalarFunction::ScalarFunction | ( | double | val | ) |
Creates constant scalar function defined by given value.
val | Defines the constant value |
Definition at line 54 of file scalarfunction.C.
References DV_ValueType, dvType, and setValue().
oofem::ScalarFunction::ScalarFunction | ( | std::string & | val | ) |
Creates scalar funtion defined by given simple expression.
val | String with simple expression |
Definition at line 61 of file scalarfunction.C.
References DV_ValueType, dvType, and setSimpleExpression().
oofem::ScalarFunction::ScalarFunction | ( | int | val | ) |
Constructor of scalar function defined using external function.
val | External function number |
Definition at line 68 of file scalarfunction.C.
References DV_ValueType, dvType, and setReference().
oofem::ScalarFunction::~ScalarFunction | ( | ) |
Definition at line 75 of file scalarfunction.C.
double oofem::ScalarFunction::eval | ( | const std::map< std::string, FunctionArgument > | valDict, |
Domain * | d, | ||
GaussPoint * | gp = NULL , |
||
double | param = 0. |
||
) | const |
Evaluates the receiver.
valDict | map defining input parameters in the form (name, value) pairs |
d | domain managing external functions |
Definition at line 103 of file scalarfunction.C.
References oofem::IntArray::at(), oofem::FloatArray::at(), DV_FunctionReferenceType, DV_SimpleExpressionType, DV_ValueType, dValue, dvType, oofem::Parser::eval(), oofem::Function::evaluate(), eValue, oofem::FunctionArgument::FAT_double, oofem::FunctionArgument::FAT_FloatArray, oofem::FunctionArgument::FAT_int, oofem::FunctionArgument::FAT_IntArray, fReference, oofem::Domain::giveFunction(), oofem::IntArray::giveSize(), oofem::FloatArray::giveSize(), OOFEM_ERROR, oofem::FunctionArgument::type, oofem::FunctionArgument::val0, oofem::FunctionArgument::val1, oofem::FunctionArgument::val2, and oofem::FunctionArgument::val3.
Referenced by eval(), oofem::IsotropicHeatTransferMaterial::give(), oofem::VariableCrossSection::give(), and oofem::BoundaryLoad::giveProperty().
double oofem::ScalarFunction::eval | ( | double | time, |
Domain * | d | ||
) | const |
Evaluates the receiver (convenience function that directly takes just the time as a parameter).
time | Time to evaluate for. |
d | domain managing external functions |
Definition at line 149 of file scalarfunction.C.
References DV_ValueType, dValue, dvType, and eval().
bool oofem::ScalarFunction::isDefined | ( | ) | const |
True if receiver is defined.
Definition at line 161 of file scalarfunction.C.
References DV_Undefined, and dvType.
Referenced by oofem::TransportElement::computeBCSubMtrxAt(), oofem::TransportElement::computeBoundaryEdgeLoadVector(), oofem::TransportElement::computeBoundarySurfaceLoadVector(), oofem::TransportElement::computeEdgeBCSubVectorAt(), oofem::TransportElement::computeSurfaceBCSubVectorAt(), oofem::TransportElement::computeTangentFromEdgeLoad(), oofem::TransportElement::computeTangentFromSurfaceLoad(), oofem::IsotropicHeatTransferMaterial::give(), and oofem::BoundaryLoad::giveProperty().
void oofem::ScalarFunction::setReference | ( | int | val | ) |
Sets receiver to be a scalar function defined using external function.
val | External function number |
Definition at line 95 of file scalarfunction.C.
References DV_FunctionReferenceType, dvType, and fReference.
Referenced by oofem::OOFEMTXTInputRecord::giveField(), and ScalarFunction().
void oofem::ScalarFunction::setSimpleExpression | ( | std::string & | val | ) |
Sets receiver to be a scalar funtion defined by given simple expression.
val | String with simple expression |
Definition at line 87 of file scalarfunction.C.
References DV_SimpleExpressionType, dvType, and eValue.
Referenced by oofem::OOFEMTXTInputRecord::giveField(), and ScalarFunction().
void oofem::ScalarFunction::setValue | ( | double | val | ) |
Sets receiver to be a constant scalar function defined by given value.
val | Defines the constant value |
Definition at line 79 of file scalarfunction.C.
References DV_ValueType, dValue, and dvType.
Referenced by oofem::OOFEMTXTInputRecord::giveField(), oofem::VariableCrossSection::initializeFrom(), and ScalarFunction().
|
friend |
Definition at line 169 of file scalarfunction.C.
|
private |
Constant, double value.
Definition at line 65 of file scalarfunction.h.
Referenced by eval(), oofem::operator<<(), and setValue().
enum { ... } oofem::ScalarFunction::dvType |
Enum value determining the dataValue type.
Referenced by eval(), isDefined(), oofem::operator<<(), ScalarFunction(), setReference(), setSimpleExpression(), and setValue().
|
private |
Simple expression (evaluated by internal parser)
Definition at line 67 of file scalarfunction.h.
Referenced by eval(), oofem::operator<<(), and setSimpleExpression().
|
private |
Reference to external function.
Definition at line 69 of file scalarfunction.h.
Referenced by eval(), oofem::operator<<(), and setReference().