ElementalOperation.h DG++. More...
#include <ElementalOperation.h>
Public Member Functions | |
Residue () | |
virtual | ~Residue () |
Residue (const Residue &NewEl) | |
virtual Residue * | clone () const =0 |
virtual const std::vector < size_t > & | getFields () const =0 |
Returns the fields used for the computation of the residue . | |
virtual size_t | getFieldDof (size_t fieldnumber) const =0 |
Returns the number of degrees of freedom per field used for the computation of the residue . | |
virtual bool | getVal (const MatDouble &argval, MatDouble &funcval) const =0 |
Returns the value of the residue given the values of the fields. | |
virtual const Element & | getElement () const =0 |
virtual const SimpleMaterial & | getMaterial () const =0 |
Static Public Member Functions | |
static bool | assemble (std::vector< Residue * > &ResArray, const LocalToGlobalMap &L2G, const VecDouble &Dofs, VecDouble &ResVec) |
assemble Residual Vector |
ElementalOperation.h DG++.
Created by Adrian Lew on 10/25/06.
Copyright (c) 2006 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. Computes a residue on an element A Residue object computes the values of a vector function of some or all the fields in the element, with the distinguishing feature that there is one component of the function per degree of freedom of the participating fields.
A Residue object contains two concepts:
1) A procedure to compute the value of the function
2) A pointer to the element over which to compute it
Each residue acts then as a container of a pointer to an element object, and an operation to perform on that object. In this way the same element can be used for several operation in a single computation (The alternative of adding more layers of inheritance to the element classes makes the last possibility very clumsy).
Additionally, operation that need higher-levels of specialization, such as special classes of elements, can perform type-checking in their own implementation.
The class residue is in fact very similar to a general container, in the sense that the object it points to does not need to be an element but can be any object that permits the computation of the function and can use the (field, dof) notation to label the inputs and outputs.
The precise fields to be utilized in the computation of the operation may vary from element type to element type, hence these will generally be specified.
More precisely, a residual is a function
where is the a-th degree of freedom of the f-th participating field in the function. A total of K of the element fields participate as arguments in the function. The f-th participating field has a total of
degrees of freedom. The coefficient of the force "f" runs from 0 to K-1, and "a" ia the degree of freedom index that ranges from 0 to
.
We need to specify specify which field in the element will represent the f-th participating field in the function F. For instance, the field number 2 in the element can be used as the first argument of F, i.e., as participating field number 0.
Residue::Residue | ( | ) | [inline] |
virtual Residue::~Residue | ( | ) | [inline, virtual] |
Residue::Residue | ( | const Residue & | NewEl | ) | [inline] |
bool Residue::assemble | ( | std::vector< Residue * > & | ResArray, | |
const LocalToGlobalMap & | L2G, | |||
const VecDouble & | Dofs, | |||
VecDouble & | ResVec | |||
) | [static] |
assemble Residual Vector
Assembles the contributions from an Array of residual objects ResArray into ResVec. The contribution from each ResArray, ResArray[e], is mapped into ResVec with a LocalToGlobalMap.
ResArray | Array of residue objects | |
L2G | LocalToGlobalMap | |
Dofs | PetscVector with values of degrees of freedom | |
ResVec | Pointer to a PetscVector where to assemble the residues. ResVec is zeroed in assemble |
This is precisely what's done:
1) assemble input gathered as
argval[f][a] = Dofs[L2G(f,a)]
2) Computation of the local residue funcval as ResArray[i]->getVal(argval, funcval)
3) assemble output gathered as
ResVec[L2G(f,a)] += funcval[f][a]
Behavior:
Successful assembly returns true, unsuccessful false
virtual Residue* Residue::clone | ( | ) | const [pure virtual] |
Implemented in DiagonalMassForSW, DResidue, and StressWork.
virtual const Element& Residue::getElement | ( | ) | const [pure virtual] |
Implemented in BaseResidue.
virtual size_t Residue::getFieldDof | ( | size_t | fieldnumber | ) | const [pure virtual] |
Returns the number of degrees of freedom per field used for the computation of the residue
.
getFieldDof(fieldnum) returns the number of deegrees of freedom in the participating fieldo number "fieldnumber". The argument fieldnumber begins from zero.
The number of different values of "a" in is then computed with field getFieldDof(f)
Implemented in BaseResidue.
virtual const std::vector<size_t>& Residue::getFields | ( | ) | const [pure virtual] |
Returns the fields used for the computation of the residue
.
getFields()[i] returns the field number beginning from zero.
The variable is then computed with field getFields()[f] in the element.
Implemented in BaseResidue.
virtual const SimpleMaterial& Residue::getMaterial | ( | ) | const [pure virtual] |
Implemented in BaseResidue.
Returns the value of the residue given the values of the fields.
argval | vector of vector<double> containing the values of the degrees of freedom for each field. argval[f][a] contains the value of degree of freedom "a" for participating field "f". | |
funcval | It returns a vector< vector<double> > with the values of each component of the residual function. We have that ![]() |
The function returns true if successful, false otherwise.
Implemented in DiagonalMassForSW, and StressWork.