#include <AVI.h>
Public Member Functions | |
AVI () | |
virtual | ~AVI () |
AVI (const AVI &NewAVI) | |
virtual AVI * | clone () const =0 |
virtual double | getTimeStep () const =0 |
Returns the current value of the time step for the potential. | |
virtual double | getTimeStamp () const =0 |
Returns the last time at which the force field was updated. | |
virtual bool | setTimeStamp (double timeval)=0 |
set the last update time. | |
virtual double | getNextTimeStamp () const =0 |
Returns the next time at which the force field will be updated. | |
virtual void | incTimeStamp ()=0 |
increment the time stamp | |
virtual const std::vector < size_t > & | getFields () const =0 |
Returns the field numbers used whose degrees of freedom participate in the force field computation. | |
virtual size_t | getFieldDof (size_t fieldnumber) const =0 |
Returns the number of degrees of freedom per field used for the computation . | |
virtual size_t | getGlobalIndex (void) const =0 |
Returns the global element index for the AVI object. | |
virtual const DResidue & | getOperation () const =0 |
virtual const Element & | getElement () const =0 |
virtual const ElementGeometry & | getGeometry () const =0 |
virtual void | computeLocalTvec (MatDouble &tnew) const =0 |
write the updated time vector into the argument provided value filled in is the one obtained from getNextTimeStamp () | |
virtual bool | vbInit (const MatDouble &q, const MatDouble &v, const MatDouble &vb, const MatDouble &ti, const MatDouble &tnew, MatDouble &qnew, MatDouble &vbinit, MatDouble &forcefield, MatDouble &funcval, MatDouble &deltaV) const =0 |
Initialization routine to set values at the half time step This function is called only once per element and is called after gather and before update and assemble. | |
virtual bool | getForceField (const MatDouble &argval, MatDouble &forcefield) const =0 |
Computes the value of the force field at a given configuration. | |
virtual bool | update (const MatDouble &q, const MatDouble &v, const MatDouble &vb, const MatDouble &ti, const MatDouble &tnew, MatDouble &qnew, MatDouble &vnew, MatDouble &vbnew, MatDouble &forcefield, MatDouble &funcval, MatDouble &deltaV) const =0 |
update of the given forcefield. | |
virtual bool | gather (const LocalToGlobalMap &L2G, const VecDouble &Qval, const VecDouble &Vval, const VecDouble &Vbval, const VecDouble &Tval, MatDouble &q, MatDouble &v, MatDouble &vb, MatDouble &ti) const =0 |
Gathers the values needed from the global arrays to perform the force field computation. | |
virtual bool | assemble (const LocalToGlobalMap &L2G, const MatDouble &qnew, const MatDouble &vnew, const MatDouble &vbnew, const MatDouble &tnew, VecDouble &Qval, VecDouble &Vval, VecDouble &Vbval, VecDouble &Tval, VecDouble &LUpdate) const =0 |
Assembles the updated values in the global array, including the latest time of update of the degrees of freedom in the object. | |
virtual const std::string | toString () const |
Protected Member Functions | |
virtual void | setTimeStep (double epsilon=1.0)=0 |
virtual void | computeDeltaV (const MatDouble &funcval, MatDouble &DeltaV) const =0 |
Solves the system of equations with the mass matrix for ![]() | |
virtual bool | getImposedValues (const GlobalElementIndex &ElementIndex, const LocalToGlobalMap &L2G, size_t field, size_t dof, double &qvalue, double &vvalue) const =0 |
Imposed values of the degrees of freedom and its time derivative. | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const AVI &avi) |
AVI.h DG++.
Created by Adrian Lew on 9/23/08.
Copyright (c) 2008 Adrian Lew
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. AVI: abstract base class for AVI An AVI object consists of:
1) A force field , where
are degrees of freedom, and
is the force acting on degree of freedom "a".
2) A mass matrix for the degrees of freedom of the potential.
3) A time step
4) The last time at which the force field was updated
5) The last time each degree of freedom was updated
The AVI class assumes that there exists four provided global arrays, accessed through a LocalToGlobalMap:
1) An array Qval with the value of each degree of freedom at its last update,
2) An array Vval with the latest value of the time derivative of the degrees of freedom at its last update, .
3) An array Vbval with the latest value of the time derivative of the degree of freedom at the middle of a time step, .
4) An array Tval with the last time at which a degree of freedom was updated, .
Given ,
and
, the class computes
,
and
for each degree of freedom of the object's force field. It also updates the values of
and the objects latest time.
The update is as follows:
If does not have imposed values
(e.g., Dirichlet bounday conditions), then
1) Compute for each
, where
is the current time of the object.
2) Solve for
, where
is the force on node
by the force field in the object computed with
.
3) Compute
4) Compute
Else, set ,
and
is defined to any value, it is not guaranteed to have any meaning.
The class also has an initialization procedure to compute the initial values of .
Following the convention elsewhere in the code, degrees of freedom are labeled with field number f and degree of freedom number for that field, b. Even thought it is not the most natural numbering in the context of ODEs, it simplifies the communication with the rest of the code. Field and degree of freedom numbers begin from zero.
The class separates the update process into three different functions: gather, update, assemble. In this way more flexibility is provided to be able to work with force fields that depend, perhaps, on sets of internal variables that are not necessarily updated with AVI.
Imposed values need to be provided separately. A virtual procedure is constructed to this end.
AVI::AVI | ( | ) | [inline] |
virtual AVI::~AVI | ( | ) | [inline, virtual] |
AVI::AVI | ( | const AVI & | NewAVI | ) | [inline] |
virtual bool AVI::assemble | ( | const LocalToGlobalMap & | L2G, | |
const MatDouble & | qnew, | |||
const MatDouble & | vnew, | |||
const MatDouble & | vbnew, | |||
const MatDouble & | tnew, | |||
VecDouble & | Qval, | |||
VecDouble & | Vval, | |||
VecDouble & | Vbval, | |||
VecDouble & | Tval, | |||
VecDouble & | LUpdate | |||
) | const [pure virtual] |
Assembles the updated values in the global array, including the latest time of update of the degrees of freedom in the object.
identify its global degrees of freedom. This information is not embedded in the object.
L2G | Local to Global map used to find the values in the Global arrays | |
qnew | local vector with the updated values of the degrees of freedom, ![]() | |
vnew | Upon exit, local vector with the updated values of the time derivatives of the degrees of freedom, ![]() | |
vbnew | Upon exit, local vector with the updated values of the time derivatives at the middle of a time step of the degrees of freedom, ![]() | |
tnew | updated values of time vector | |
Qval | Global array where to assemble the updated values of the degrees of freedom. | |
Vval | Global array where to assemble the time derivatives of the degrees of freedom. | |
Vbval | Global array where to assemble the time derivatives of the degrees of freedom at the middle of the time step. | |
Tval | Global array where to assemble the times at which the degrees of freedom were last updated. | |
LUpdate | Global array to keep track of which element updated the Dof last. This is used to keep Dofs from being updated out of order due to messaging delays. contains the global elem index of the last element to update each Dof. |
For example, Q[L2G.map(ElementIndex,getFields()[f],b)]=q[f][b]
Implemented in StandardAVI.
virtual AVI* AVI::clone | ( | ) | const [pure virtual] |
Implemented in StandardAVI.
virtual void AVI::computeDeltaV | ( | const MatDouble & | funcval, | |
MatDouble & | DeltaV | |||
) | const [protected, pure virtual] |
Solves the system of equations with the mass matrix for .
This is made a virtual function so that, if the mass matrix happens to be diagonal, it is done efficiently.
funcval | values of ![]() ![]() ![]() | |
DeltaV | values of ![]() ![]() |
Implemented in StandardAVI.
virtual void AVI::computeLocalTvec | ( | MatDouble & | tnew | ) | const [pure virtual] |
write the updated time vector into the argument provided value filled in is the one obtained from getNextTimeStamp ()
tnew |
Implemented in StandardAVI.
virtual bool AVI::gather | ( | const LocalToGlobalMap & | L2G, | |
const VecDouble & | Qval, | |||
const VecDouble & | Vval, | |||
const VecDouble & | Vbval, | |||
const VecDouble & | Tval, | |||
MatDouble & | q, | |||
MatDouble & | v, | |||
MatDouble & | vb, | |||
MatDouble & | ti | |||
) | const [pure virtual] |
Gathers the values needed from the global arrays to perform the force field computation.
identify its global degrees of freedom. This information is not embedded in the object.
L2G | Local to Global map used to find the values in the Global arrays | |
Qval | Global array with the last updated values of the degrees of freedom. | |
Vval | Global array with the last updated values of the time derivatives of the degrees of freedom. | |
Vbval | Global array with the last updated values of the time derivatives of the degrees of freedom at the middle of the time step. | |
Tval | Global array with the times at which the degrees of freedom were last updated. | |
q | Upon exit, local vector with the last known values of the degrees of freedom, ![]() | |
v | Upon exit, local vector with the last known values of the time derivatives of the degrees of freedom, ![]() | |
vb | Upon exit, local vector with the last known values of the time derivatives at the middle of a time step of the degrees of freedom, ![]() | |
ti | Upon exit, local vector with the last update time of a the degrees of freedom, ![]() |
For example, q[f][b] = Q[L2G.map(ElementIndex,getFields()[f],b)]
This function uses getImposedValues to fill the imposed values arrays.
Implemented in StandardAVI.
virtual const Element& AVI::getElement | ( | ) | const [pure virtual] |
Implemented in StandardAVI.
virtual size_t AVI::getFieldDof | ( | size_t | fieldnumber | ) | const [pure virtual] |
Returns the number of degrees of freedom per field used for the computation
.
getFieldDof(fieldnum) returns the number of deegrees of freedom in the participating field number "fieldnumber". The argument fieldnumber begins from zero.
Implemented in StandardAVI.
virtual const std::vector<size_t>& AVI::getFields | ( | ) | const [pure virtual] |
Returns the field numbers used whose degrees of freedom participate in the force field computation.
getFields()[i] returns the field number beginning from zero.
If the degree of freedom is indexed with [f][b] locally, then it corresponds to field getFields()[f] in the Global arrays.
Implemented in StandardAVI.
virtual bool AVI::getForceField | ( | const MatDouble & | argval, | |
MatDouble & | forcefield | |||
) | const [pure virtual] |
Computes the value of the force field at a given configuration.
Returns true upon success.
argval | values of the degrees of freedom for the force field of the object. argval[f][a] contains the value of the degree of freedom indexed with field "f" and degree of freedom number in that field "a". | |
forcefield | values of ![]() ![]() |
Implemented in StandardAVI.
virtual const ElementGeometry& AVI::getGeometry | ( | ) | const [pure virtual] |
Implemented in StandardAVI.
virtual size_t AVI::getGlobalIndex | ( | void | ) | const [pure virtual] |
Returns the global element index for the AVI object.
Implemented in StandardAVI.
virtual bool AVI::getImposedValues | ( | const GlobalElementIndex & | ElementIndex, | |
const LocalToGlobalMap & | L2G, | |||
size_t | field, | |||
size_t | dof, | |||
double & | qvalue, | |||
double & | vvalue | |||
) | const [protected, pure virtual] |
Imposed values of the degrees of freedom and its time derivative.
ElementIndex | GlobalElementIndex or index of the force field in the AVI object, used to identify its global degrees of freedom. This information is not embedded in the object. | |
L2G | Local to Global map used to find the values in the Global arrays | |
field | field number for which the imposed values are sought, starting from zero. | |
dof | degree of freedom number within field "field" for which the imposed values are sought, starting from zero. | |
qvalue | upon exit, imposed value of the degree of freedom | |
vvalue | upon exit, imposed value of the time derivative of the degree of freedom |
The values of ElementIndex and L2G are not always needed, but they are included here to provide a general interface.
Implemented in StandardAVI.
virtual double AVI::getNextTimeStamp | ( | ) | const [pure virtual] |
Returns the next time at which the force field will be updated.
Implemented in StandardAVI.
virtual const DResidue& AVI::getOperation | ( | ) | const [pure virtual] |
Implemented in StandardAVI.
virtual double AVI::getTimeStamp | ( | ) | const [pure virtual] |
Returns the last time at which the force field was updated.
Implemented in StandardAVI.
virtual double AVI::getTimeStep | ( | ) | const [pure virtual] |
Returns the current value of the time step for the potential.
Implemented in StandardAVI.
virtual void AVI::incTimeStamp | ( | ) | [pure virtual] |
increment the time stamp
Implemented in StandardAVI.
virtual bool AVI::setTimeStamp | ( | double | timeval | ) | [pure virtual] |
set the last update time.
Returns true upon success.
timeval | value of the last update time |
Implemented in StandardAVI.
virtual void AVI::setTimeStep | ( | double | epsilon = 1.0 |
) | [protected, pure virtual] |
Implemented in StandardAVI.
virtual const std::string AVI::toString | ( | ) | const [inline, virtual] |
virtual bool AVI::update | ( | const MatDouble & | q, | |
const MatDouble & | v, | |||
const MatDouble & | vb, | |||
const MatDouble & | ti, | |||
const MatDouble & | tnew, | |||
MatDouble & | qnew, | |||
MatDouble & | vnew, | |||
MatDouble & | vbnew, | |||
MatDouble & | forcefield, | |||
MatDouble & | funcval, | |||
MatDouble & | deltaV | |||
) | const [pure virtual] |
update of the given forcefield.
It returns the new values for the degrees of freedom and its time derivatives. These need yet to be assembled. Returns true upon success.
The forcefield time is updated. Of course, this does not happen with the last update time of each degree of freedom, which are updated in the assemble part.
In the following vectors, index [f][b] indicates the value for the "b"-th degree of freedom of field "f".
q | vector with the last known values of the degrees of freedom, ![]() | |
v | vector with the last known values of the time derivatives of the degrees of freedom, ![]() | |
vb | vector with the last known values of the time derivatives at the middle of a time step of the degrees of freedom, ![]() | |
ti | vector with the last update time of a the degrees of freedom, ![]() | |
tnew | vector with the updated time of a the degrees of freedom, ![]() | |
qnew | Upon exit, new values of the degrees of freedom, ![]() | |
vnew | Upon exit, new values of the time derivatives of the degrees of freedom, ![]() | |
vbnew | Upon exit, new values of the time derivatives at the middle of a time step of the degrees of freedom, ![]() | |
forcefield | temporary intermediate vector | |
funcval | temporary intermediate vector | |
deltaV | temporary intermediate vector |
Implemented in StandardAVI.
virtual bool AVI::vbInit | ( | const MatDouble & | q, | |
const MatDouble & | v, | |||
const MatDouble & | vb, | |||
const MatDouble & | ti, | |||
const MatDouble & | tnew, | |||
MatDouble & | qnew, | |||
MatDouble & | vbinit, | |||
MatDouble & | forcefield, | |||
MatDouble & | funcval, | |||
MatDouble & | deltaV | |||
) | const [pure virtual] |
Initialization routine to set values at the half time step This function is called only once per element and is called after gather and before update and assemble.
q | used to calculate the velocity at the half step. local vector with the last known values of the degrees of freedom, ![]() | |
v | previous values of the time derivatives of velocity | |
vb | previous values of the time derivatives at the middle of a time step of the degrees of freedom, ![]() | |
ti | local vector with the last update time of a the degrees of freedom, ![]() | |
tnew | updated local time vector |
qnew | updated value of q vector | |
vbinit | initialized value of vb vector | |
forcefield | temporary intermediate vector | |
funcval | temporary intermediate vector | |
deltaV | temporary intermediate vector For example, q[f][b] = Q[L2G.map(ElementIndex,getFields()[f],b)] |
This function uses getImposedValues to fill the imposed values arrays.
Implemented in StandardAVI.
std::ostream& operator<< | ( | std::ostream & | out, | |
const AVI & | avi | |||
) | [friend] |