Diffpack Documentation


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

ScalarScale Class Reference

stores a physical scaling for a scalar quantity. More...

#include <SpaceTimeScale.h>

Inheritance diagram for ScalarScale::

HandleId List of all members.

Public Methods

 ScalarScale (const char *quantity_name=NULL)
 ~ScalarScale ()
void operator= (const ScalarScale &scale)
void attach (Vec(NUMT) &vector)
void attach (NUMT &number)
void attach (Ptv(NUMT) &point)
bool hasAttachedVector ()
bool hasAttachedNumber ()
bool hasAttachedPoint ()
void defaultInit ()
bool defaultScale ()
void define (MenuSystem &menu, int level=MAIN)
void scan (MenuSystem &menu)
virtual void scale ()
virtual void unscale ()

Static Public Methods

void defineStatic (const char *quantity_name, MenuSystem &menu, int level=MAIN)

Public Attributes

String quantity_name
NUMT scale_factor
NUMT scale_reference
bool is_scaled

Detailed Description

stores a physical scaling for a scalar quantity.

NAME: ScalarScale - stores a physical scaling for a scalar quantity

DESCRIPTION:

The "ScalarScale" class offers tools for convenient computations with scaled and unscaled variables. The class contains a definition of the scaling (""stretch"" and ""translation"", referred to as factor and reference quantities) and several utility functions for applying the scaling to numbers or arrays.

The scaling is described in terms of a factor and a reference value according to the formula "p=factor*(q-reference)", where "p" is the new dimensionless parameter, "q" is the physical parameter (usually with a dimension), "reference" is a reference value that is often zero and "factor" is the scaling factor (hence "1/factor" is the scale of the "q" parameter).

The scaling represented by a "ScalarScale" object typically has the following information: 1) definition of the scaling, 2) a name of the variable that is to be scaled (fieldname f.ex.), 3) a pointer to the variable to be scaled, 4) an indicator that is true if the parameter value(s) has been scaled and false otherwise.

The functions of class "ScalarScale" are typically menu functions for easy inititalization of the definition of the scaling, attach functions for setting the internal pointers to the external parameter object to be scaled, and scale/unscale functions for performing the scaling or recover the original values.

To every possibly scaled parameter in a simulator there should be one "ScalarScale" object (with a proper name) that is attached to the parameter. The parameters may be arrays ("Vec" or classes derived from "Vec", like "ArrayGen"), numbers ("real" for example) or fields. When working with stand-alone arrays or numbers, there must be one "ScalarScale" object per variable and the variable must be explicitly attached to the "ScalarScale" object. On the other hand, all scalar fields have a built-in "ScalarScale" object and the data structures in the field are automatically correctly attached to this "ScalarScale" object. (Grids and fields have also an internal pointer to a"SpaceTimeScale" object). The usage of "ScalarScale" for a number/array and a scalar field is hence different. With a number or array the programmer declares a "ScalarScale" object and attaches it to the variable using the "attach" function. With a field the programmer normally declares a "ScalarScale" object, fill it (f.ex. on a menu). After the field is created, the internal "ScalarScale" object in the field is set equal to the programmer''s "ScalarScale" object that was set on the menu.

In the EXAMPLE section a complete program that demonstrate the scaling features in Diffpack is presented. By studying that code, one can se how the "ScalarScale" are used in practice. This example provides the main documentation of the scaling facilities in Diffpack.

"ScalarScale" only applies to numbers or vectors. "Ptv" objects are not yet supported (but can easily be included by declaring a "Ptv(NUMT)* p_parameter" and update it when "a_parameter" and "n_parameter" are updated).


Constructor & Destructor Documentation

ScalarScale::ScalarScale ( const char * quantity_name = NULL )
 

The constructor requires a name of the variable that is to scaled by this "ScalarScale" object. One can omit the name, but if you declare a "ScalarScale" object explicitly, it is recommended to always provide a name. The name is only used for setting up and reading menu items.

Fields that have built-in "ScalarScale" objects, automatically applies the fieldname for the name in the "ScalarScale" object. When the fieldname is modified, the name in the "ScalarScale" object is automatically updated.

ScalarScale::~ScalarScale ( )
 


Member Function Documentation

void ScalarScale::attach ( Ptv(NUMT) & point )
 

See documentation of one of the overloaded functions.

void ScalarScale::attach ( NUMT & number )
 

See documentation of one of the overloaded functions.

void ScalarScale::attach ( Vec(NUMT) & vector )
 

connect the scaling object to an array or a number that is to be scaled. At present, it is not allowed to call both attach functions in the same "ScalarScale" object (that is likely to be an error).

void ScalarScale::defaultInit ( )
 

sets the factor to 1 and the reference value to 0. This function is automatically called at construction time.

bool ScalarScale::defaultScale ( )
 

void ScalarScale::define ( MenuSystem & menu,
int level = MAIN )
 

see function scan

static void ScalarScale::defineStatic ( const char * quantity_name,
MenuSystem & menu,
int level = MAIN ) [static]
 

see function scan

bool ScalarScale::hasAttachedNumber ( ) [inline]
 

bool ScalarScale::hasAttachedPoint ( ) [inline]
 

bool ScalarScale::hasAttachedVector ( ) [inline]
 

void ScalarScale::operator= ( const ScalarScale & scale )
 

copies the information in another "ScalarScale" object. Only the scaling factor and reference is copied (not the name, the state ("is_scaled") or the pointers to the programmers''s data structures).

void ScalarScale::scale ( ) [virtual]
 

scales the scalar parameter given as argument. The internal indicator "is_scaled" is then set to a true value. The "scale" and "unscale" function do not work if "attach" has not been called (in that case the "scale" and "unscale" functions have no parameter to scale).

void ScalarScale::scan ( MenuSystem & menu )
 

standard menu functions for convenient setting of the scaling factor and reference on a menu. Note that the menu item makes use of the name of the "ScalarScale" object (that name should reflect the name of the parameter to be scaled) so it is important to set this name when calling the constructor.

void ScalarScale::unscale ( ) [virtual]
 

inverse function of "scale".


Member Data Documentation

bool ScalarScale::is_scaled
 

String ScalarScale::quantity_name
 

NUMT ScalarScale::scale_factor
 

NUMT ScalarScale::scale_reference
 


The documentation for this class was generated from the following file:
Copyright © 2003 inuTech GmbH. All rights reserved.