OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
oofem::ScalarFunction Class Reference

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)
 

Detailed Description

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.

Member Enumeration Documentation

anonymous enum
private

Enum value determining the dataValue type.

Enumerator
DV_Undefined 
DV_ValueType 
DV_SimpleExpressionType 
DV_FunctionReferenceType 

Definition at line 72 of file scalarfunction.h.

Constructor & Destructor Documentation

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.

Parameters
valDefines 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.

Parameters
valString 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.

Parameters
valExternal 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.

Member Function Documentation

double oofem::ScalarFunction::eval ( double  time,
Domain d 
) const

Evaluates the receiver (convenience function that directly takes just the time as a parameter).

Parameters
timeTime to evaluate for.
ddomain managing external functions

Definition at line 149 of file scalarfunction.C.

References DV_ValueType, dValue, dvType, and eval().

void oofem::ScalarFunction::setReference ( int  val)

Sets receiver to be a scalar function defined using external function.

Parameters
valExternal 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.

Parameters
valString 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.

Parameters
valDefines 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().

Friends And Related Function Documentation

std :: ostream& operator<< ( std::ostream &  out,
const ScalarFunction s 
)
friend

Definition at line 169 of file scalarfunction.C.

Member Data Documentation

double oofem::ScalarFunction::dValue
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().

std :: string oofem::ScalarFunction::eValue
private

Simple expression (evaluated by internal parser)

Definition at line 67 of file scalarfunction.h.

Referenced by eval(), oofem::operator<<(), and setSimpleExpression().

int oofem::ScalarFunction::fReference
private

Reference to external function.

Definition at line 69 of file scalarfunction.h.

Referenced by eval(), oofem::operator<<(), and setReference().


The documentation for this class was generated from the following files:

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