StandardAVI.h DG++. More...
#include <StandardAVI.h>
Public Types | |
enum | BCImposedType { ZERO, ONE, TWO } |
type of boundary conditions imposed ZERO means no boundary conditions More... | |
typedef double(* | BCFunc )(int, int, double) |
function used for obtaining value of boundary conditions | |
Public Member Functions | |
StandardAVI (const LocalToGlobalMap &L2G, const DResidue &MyRes, const VecDouble &MassVec, size_t globalIdx, const MatBool &IFlag, const MatDouble &IVal, const double delta, const double time) | |
StandardAVI constructor designed to handle integration of an individual element. | |
StandardAVI (const LocalToGlobalMap &L2G, const DResidue &MyRes, const VecDouble &MassVec, size_t globalIdx, const std::vector< std::vector< BCImposedType > > &IType, const std::vector< BCFunc > &bcfunc_vec, const double delta, const double time) | |
StandardAVI constructor designed to handle integration of an individual element. | |
StandardAVI (const StandardAVI &that) | |
Copy constructor. | |
virtual StandardAVI * | clone () const |
double | getTimeStep () const |
returns time step for the Element | |
double | getTimeStamp () const |
returns the last update time for this element | |
bool | setTimeStamp (double timeval) |
set the last update time. | |
virtual double | getNextTimeStamp () const |
Returns the next time at which the force field will be updated. | |
virtual void | incTimeStamp () |
increment the time stamp | |
virtual const DResidue & | getOperation () const |
size_t | getFieldDof (size_t fieldnumber) const |
Returns the number of degrees of freedom per field used for the computation . | |
const std::vector< size_t > & | getFields () const |
Returns the field numbers used whose degrees of freedom participate in the force field computation. | |
const ElementGeometry & | getGeometry () const |
returns the element geometry | |
const Element & | getElement () const |
returns the element | |
bool | getForceField (const MatDouble &argval, MatDouble &forcefield) const |
Updates the force field through the operation Stresswork class. | |
size_t | getGlobalIndex (void) const |
Returns the global element index for the AVI object. | |
virtual void | computeLocalTvec (MatDouble &tnew) const |
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 |
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 | 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 |
update of the given forcefield. | |
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 |
Gathers the values needed from the global arrays to perform the force field computation. | |
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 |
Assembles the updated values in the global array, including the latest time of update of the degrees of freedom in the object. | |
Protected Member Functions | |
virtual void | setTimeStep (double epsilon=1.0) |
Sets the time step for the element based upon the element geometry and sound speed. | |
virtual void | computeDeltaV (const MatDouble &funcval, MatDouble &DeltaV) const |
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 |
Imposed values of the degrees of freedom and its time derivative. | |
void | roundTimeStep (double min_ts) |
Option to round the time step in order to address round-off error. | |
Private Member Functions | |
StandardAVI & | operator= (const StandardAVI &that) |
void | init (const LocalToGlobalMap &L2G, const VecDouble &MassVec) |
void | setDiagVals (const VecDouble &MassVec, const LocalToGlobalMap &L2G, const GlobalElementIndex &elem_index) |
This function sets the Mass Matrix diagonal values for the element after they have been computed using DiagonalMassForSW and place into the petsc vector MassVec. | |
void | setBCs (const MatBool &IFlag, const MatDouble &IVal) |
set the boundary conditions on the local element | |
Private Attributes | |
const DResidue & | operation |
MatDouble | MMdiag |
size_t | globalIdx |
std::vector< BCFunc > | avi_bc_func |
std::vector< std::vector < BCImposedType > > | imposedTypes |
MatBool | imposedFlags |
MatDouble | imposedValues |
size_t | nfields |
double | delta |
double | timeStamp |
double | timeStep |
StandardAVI.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. StandardAVI class implementation of AVI base class
typedef double(* StandardAVI::BCFunc)(int, int, double) |
function used for obtaining value of boundary conditions
StandardAVI::StandardAVI | ( | const LocalToGlobalMap & | L2G, | |
const DResidue & | MyRes, | |||
const VecDouble & | MassVec, | |||
size_t | globalIdx, | |||
const MatBool & | IFlag, | |||
const MatDouble & | IVal, | |||
const double | delta, | |||
const double | time | |||
) | [inline] |
StandardAVI constructor designed to handle integration of an individual element.
L2G | local to global map for access to Petsc vectors | |
MyRes | ref to a Stresswork for this element | |
MassVec | ref to the assembled mass vector for the mesh | |
globalIdx | is the Element's unique global index | |
IFlag | is a ref to the Boundary values indicator | |
IVal | is a ref to the actual values of boundary conditions, if IFlag is not false | |
delta | is a double that is used as a safety factor in computing the times step for an element | |
time | allows the AVI object's time to be set to some value |
StandardAVI::StandardAVI | ( | const LocalToGlobalMap & | L2G, | |
const DResidue & | MyRes, | |||
const VecDouble & | MassVec, | |||
size_t | globalIdx, | |||
const std::vector< std::vector< BCImposedType > > & | IType, | |||
const std::vector< BCFunc > & | bcfunc_vec, | |||
const double | delta, | |||
const double | time | |||
) | [inline] |
StandardAVI constructor designed to handle integration of an individual element.
MyRes | ref to a Stresswork for this element | |
MassVec | ref to the assembled mass vector for the mesh | |
L2G | local to global map for access to Petsc vectors | |
globalIdx | is the Element's unique global index | |
IType | is a vector containing types of imposed boundary conditons |
bcfunc_vec | is a vector of function pointers used to obtain the value of boundary conditions | |
delta | is a double that is used as a safety factor in computing the times step for an element | |
time | allows the AVI object's time to be set to some value |
StandardAVI::StandardAVI | ( | const StandardAVI & | that | ) | [inline] |
Copy constructor.
bool StandardAVI::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 [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]
Implements AVI.
virtual StandardAVI* StandardAVI::clone | ( | ) | const [inline, virtual] |
Implements AVI.
void StandardAVI::computeDeltaV | ( | const MatDouble & | funcval, | |
MatDouble & | DeltaV | |||
) | const [protected, 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 ![]() ![]() |
Implements AVI.
void StandardAVI::computeLocalTvec | ( | MatDouble & | tnew | ) | const [virtual] |
write the updated time vector into the argument provided value filled in is the one obtained from getNextTimeStamp ()
Implements AVI.
bool StandardAVI::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 [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.
Implements AVI.
const Element& StandardAVI::getElement | ( | ) | const [inline, virtual] |
returns the element
Implements AVI.
size_t StandardAVI::getFieldDof | ( | size_t | fieldnumber | ) | const [inline, 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.
Implements AVI.
const std::vector<size_t>& StandardAVI::getFields | ( | ) | const [inline, 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.
Implements AVI.
bool StandardAVI::getForceField | ( | const MatDouble & | argval, | |
MatDouble & | forcefield | |||
) | const [inline, virtual] |
Updates the force field through the operation Stresswork class.
Implements AVI.
const ElementGeometry& StandardAVI::getGeometry | ( | ) | const [inline, virtual] |
returns the element geometry
Implements AVI.
size_t StandardAVI::getGlobalIndex | ( | void | ) | const [inline, virtual] |
bool StandardAVI::getImposedValues | ( | const GlobalElementIndex & | ElementIndex, | |
const LocalToGlobalMap & | L2G, | |||
size_t | field, | |||
size_t | dof, | |||
double & | qvalue, | |||
double & | vvalue | |||
) | const [protected, 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.
Implements AVI.
virtual double StandardAVI::getNextTimeStamp | ( | ) | const [inline, virtual] |
Returns the next time at which the force field will be updated.
Implements AVI.
double StandardAVI::getTimeStamp | ( | ) | const [inline, virtual] |
returns the last update time for this element
Implements AVI.
double StandardAVI::getTimeStep | ( | ) | const [inline, virtual] |
virtual void StandardAVI::incTimeStamp | ( | ) | [inline, virtual] |
increment the time stamp
Implements AVI.
void StandardAVI::init | ( | const LocalToGlobalMap & | L2G, | |
const VecDouble & | MassVec | |||
) | [inline, private] |
StandardAVI& StandardAVI::operator= | ( | const StandardAVI & | that | ) | [inline, private] |
void StandardAVI::roundTimeStep | ( | double | min_ts | ) | [inline, protected] |
Option to round the time step in order to address round-off error.
Not currently used
min_ts | -- the smallest time step in mesh. Every time step will be rounded to a value 3 significant digits smaller than the min_ts |
set the boundary conditions on the local element
IFlag | is set to true for each bc that is imposed |
IVal | is set to value for each bc that is imposed |
void StandardAVI::setDiagVals | ( | const VecDouble & | MassVec, | |
const LocalToGlobalMap & | L2G, | |||
const GlobalElementIndex & | elem_index | |||
) | [private] |
This function sets the Mass Matrix diagonal values for the element after they have been computed using DiagonalMassForSW and place into the petsc vector MassVec.
MassVec | -- input in the form of petsc vector computed using DiagonalMassForSW | |
L2G | -- localtoglobal map for petsc vectors | |
elem_index | -- needed for proper indexing into the L2G map contains the element index locally |
bool StandardAVI::setTimeStamp | ( | double | timeval | ) | [inline, virtual] |
set the last update time.
Returns true upon success.
timeval | value of the last update time |
Implements AVI.
virtual void StandardAVI::setTimeStep | ( | double | epsilon = 1.0 |
) | [inline, protected, virtual] |
Sets the time step for the element based upon the element geometry and sound speed.
The safety factor, delta, is set during the construction of the AVI object. The optional parameter, epsilon, allows the time step to be adjusted further.
epsilon,: | optional parameter which allows the time step to be set to a fraction of its normal value. |
Implements AVI.
bool StandardAVI::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 [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 |
Implements AVI.
bool StandardAVI::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 [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.
Implements AVI.
std::vector<BCFunc> StandardAVI::avi_bc_func [private] |
double StandardAVI::delta [private] |
size_t StandardAVI::globalIdx [private] |
MatBool StandardAVI::imposedFlags [private] |
std::vector<std::vector<BCImposedType> > StandardAVI::imposedTypes [private] |
MatDouble StandardAVI::imposedValues [private] |
MatDouble StandardAVI::MMdiag [private] |
size_t StandardAVI::nfields [private] |
const DResidue& StandardAVI::operation [private] |
double StandardAVI::timeStamp [private] |
double StandardAVI::timeStep [private] |