#include <FEM.h>
Inheritance diagram for FEM::

Public Types | |
| enum | FieldAverage_type { ARITHMETIC = 0, HARMONIC = 1 } |
| enum | Smoothing_type { GLOBAL_LS = 0, MOVING_LS = 1 } |
Public Methods | |
| FEM () | |
| virtual | ~FEM () |
| virtual void | makeSystem (DegFreeFE &dof, LinEqAdmFE &lineq, bool compute_A=true, bool compute_RHS=true, bool only_safe_nopt=true) |
| virtual void | calcElmMatVec (int e, ElmMatVec &elmat, FiniteElement &fe) |
| virtual void | numItgOverElm (ElmMatVec &elmat, FiniteElement &fe) |
| virtual void | integrands (ElmMatVec &elmat, const FiniteElement &fe) |
| virtual void | numItgOverSide (int side, int boind, ElmMatVec &elmat, FiniteElement &fe) |
| virtual void | integrands4side (int side, int boind, ElmMatVec &elmat, const FiniteElement &fe) |
| void | detach () |
| virtual void | derivedQuantitiesAtItgPt (VecSimple(NUMT) &quantities, const FiniteElement &fe) |
| void | makeMassMatrix (GridFE &grid, Matrix(NUMT) &mm, bool row_sum, int ndof_perr_node=1, Field *scalar_field=NULL) |
| void | makeSystem (DegFreeFE &dof, ElmMatVecCalc &emv, IntegrandCalc *integrand, LinEqAdmFE &lineq, bool compute_A=true, bool compute_RHS=true) |
| void | makeSystem (DegFreeFE &dof, ElmMatVecCalc &emv, IntegrandCalc *integrand, Matrix(NUMT) &mt) |
| void | makeSystem (DegFreeFE &dof, Matrix(NUMT) &mt) |
| void | makeSystem (DegFreeFE &dof, Matrix(NUMT) &mt, Vector(NUMT) &vc) |
| void | makeSystem (DegFreeFE &dof, ElmMatVecCalc &emv, IntegrandCalc *integrand, Vector(NUMT) &vc) |
| void | makeSystem (DegFreeFE &dof, Vector(NUMT) &vc) |
| virtual void | numItgOverElm (ElmMatVec &elmat, FiniteElement &fe, IntegrandCalc &integrand) |
| virtual void | numItgOverSide (int side, int boind, ElmMatVec &elmat, FiniteElement &fe, IntegrandCalc &integrand) |
| void | attachMassMatrix (MatDiag(NUMT) &mass_matrix) |
| void | makeFlux (FieldsFE &flux, const FieldFE &f, Field &k, real c=-1.0, enum Smoothing_type method=GLOBAL_LS, real t=DUMMY) |
| void | makeFlux (FieldsFE &flux, const FieldFE &f, enum Smoothing_type method=GLOBAL_LS, real t=DUMMY) |
| virtual NUMT | k (const FiniteElement &fe, real t=DUMMY) |
| void | smoothFields (FieldsFE &smooth_field, const FieldsFEatItgPt &some_field, enum Smoothing_type method=GLOBAL_LS) |
| void | smoothFields (FieldsFE &smooth_field, const FieldsPiWisConst &piecewise_constant_field) |
| void | smoothField (FieldFE &smooth_field, const Field &some_field) |
| void | smoothField (FieldFE &smooth_field, IntegrandCalc &rhs_integrand, int relative_itg_order=-1) |
| void | smoothDerivative (FieldFE &df_dir, int dir, const FieldFE &f) |
| void | smoothGradient (FieldsFE &gradf, const FieldFE &f) |
| void | makeGradient (FieldsFEatItgPt &gradf, const FieldFE &f) |
| void | makeGradient (FieldsPiWisConst &gradf, const FieldFE &f) |
| void | makeGradient (FieldPiWisConst &gradf_norm, const FieldFE &f) |
| void | smoothMultipleFields (FieldsFE &collection, Matrix(NUMT) &mass_matrix) |
| virtual void | integrand4smoothing (FiniteElement &fe, MatSimple(NUMT) &contributions) |
| void | smoothField (FieldFE &smooth_field, Matrix(NUMT) &mass_matrix, Field &some_field) |
| void | smoothFields (FieldsFE &smooth_field, Matrix(NUMT) &mass_matrix, FieldsPiWisConst &piecewise_constant_field) |
| void | smoothFields (FieldsFE &smooth_field, FieldsPiWisConst &piecewise_constant_field) |
| void | smoothField (FieldFE &smooth_field, Matrix(NUMT) &mass_matrix, IntegrandCalc &rhs_integrand, int relative_itg_order=-1) |
| void | smoothDerivative (FieldFE &df, int dir, Matrix(NUMT) &mass_matrix, FieldFE &f) |
| void | smoothGradient (FieldsFE &df, Matrix(NUMT) &mass_matrix, FieldFE &f) |
| void | makeFlux (FieldsPiWisConst &v, FieldFE &u, real c=1.0, Field *k=NULL, real t=DUMMY) |
| void | makeFlux (FieldsFE &v, FieldFE &u, int method, Matrix(NUMT) *mass_matrix, real c=1.0, Field *k=NULL, real t=DUMMY) |
| void | define (MenuSystem &menu, int level=MAIN) |
| void | scan (MenuSystem &menu) |
| double | getCPUtime4makeSystem () const |
| virtual real | integrands4energyErrorNorm (const FiniteElement &fe) |
| virtual void | evalOwnRefInd (FieldPiWisConst &refinement_field, real &evaluated_error) |
| virtual void | customizeElmDef (ElmDef &elmdef, const String &elm_name) |
| virtual void | fillEssBC () |
| virtual void | mgFillEssBC (SpaceId grid_level=0) |
| virtual void | mgFillEssBC (LinEqVector &x, SpaceId grid_level=0) |
Static Public Methods | |
| void | makeGradientStatic (FieldsPiWisConst &gradient, FieldFE &f) |
| void | makeGradientStatic (FieldPiWisConst &gradient, FieldFE &f) |
| void | defineStatic (MenuSystem &menu, int level=MAIN) |
Static Public Attributes | |
| bool | optimize |
Protected Methods | |
| void | reportCPUtime (const char *algorithm, int verbosity_level=0, const char *comment=NULL) |
| void | checkMassMatrix (GridFE &grid, int ndof_per_node=1) |
| void | solveMassMatrix (const Vector(NUMT) &rhs, Vector(NUMT) &x) |
Protected Attributes | |
| ElmItgRules | itg_rules |
| FiniteElement | finite_elm |
| ElmMatVec | elm_matvec |
| Handle(MatDiag(NUMT)) | mass_mat |
| MovingLS | MLS |
| FieldsFEatItgPt | field_at_pts |
| FieldAverage_type | average_tp |
| CPUclock | cpu |
| double | cpu_time_makeSystem |
NAME: FEM - base class and methods for finite element programming
DESCRIPTION:
Class "FEM" offers the standard finite element algorithms for the assembly loop over the elements, including numerical integration over elements. In addition, class "FEM" offers computation and smoothing of (discontinuous) derivatives of finite element fields. Usually, "FEM" is used in conjuction with a simulator class and serves as base class for the simulator. All the standard finite element algorithms are thereby inherited in the simulator class. These standard algorithms set up the loops and peform all actions that are common to ""all"" problems. The problem dependent parts are defined in virtual functions that are called from these algorithms. Some virtual functions must be implemented in the simulator class (typically the one that defines the integrands in the weak form - otherwise the algorithms do not know which PDE to solve!).
One can apply class "FEM" without knowing the details of the implementation.
Class "FEM" can perform some algorithmic optimizations if the static variable "FEM optimize" is "true" (or "ON"). This can be turned on by the statement "FEM optimize=ON" in the code, preferably in "main", or by the command line argument "--FEM optimize ON". The value of this optimization indicator is written to the logfile ("casename.dp"). The optimizations assumes that standard Diffpack conventions are followed. If you program in a different way, or work with a problem where you have your own special constructions, the optimizations may lead to wrong answers! Therefore, the optimizations are off by default and the user should only turn them on after having verified the code thoroughly.
|
|
|
|
|
|
|
|
A constructor without arguments is available. No further initialization is necessary. The "define" and "scan" functions makes it possible to alter the numerical integration rules using a menu in the standard way. There is also a menu item related to average vs harmonic mean when calculating fluxes. The default menu answers will suffice in many cases. |
|
|
|
|
|
this function allows the user to explicitly attach his own mass matrix. If the function is not called, the various other functions for computing smooth derivatives and fluxes will use an internal mass matrix, which is automatically re-used in later computations (unless the grid changes during a simulation). In practice, many simulators will never have or attach a mass matrix, but rely on "FEM" and its internal mass matrix computations. If the mass matrix is to be used directly in the solver, it is available as the "mass_mat" data member. |
|
|
calculates the element matrix and vector. When the programmer has analytical expressions for the element vector and matrix available, these expressions can simply be inserted in a subclass (simulation class) implementation of "calcElmMatVec". If numerical integration is required, class "FEM" provides a default implementation of "calcElmMatVec" that performs necessary initializations and a call to "numItgOverElement". The latter administrates the numerical integration and samples the integrand by calling a function "integrands" that must be implemented in the simulator class. In cases where a surface integral enters the weak form in addition to the volume integral over the element''s interior, the programmer must implement a local version of "calcElmMatVec". Such an implementation will typically consist of a call to "FEM calcElmMatVec" for performing the integration over the interior of the element and thereafter a loop over the sides of the element is coded. In the loop, one tests if the relevant boundary indicators are set (these indicators mark parts of the boundaries where the surface integral is to be evaluated), and thereafter the "integrands4side" function is called. This is the counterpart to "integrands" and must of course be implemented in the subclass (simulator). The complete weak form is hence defined by "integrands" and "integrands4side". If the programmer needs to compute the element matrix and vector for different weak forms, the "calcElmMatVec" function can be represented as a functor, using class "ElmMatVecCalc". Particularly, a default functor corresponding to the "FEM calcElmMatVec" implementation exists in class "ElmMatVecCalcStd". |
|
|
|
|
|
to be implemented in the derived simulator class if element customization is needed. |
|
|
Reimplemented in PreproLaplace. |
|
|
Reimplemented in PreproLaplace. |
|
|
to be implemented in the derived simulator class if derived quantities are to be computed. Possibly invoked by "FieldsFEatItgPt :: derivedQuantitiesAtItgPt". |
|
|
detach all objects referred by handles in the "FEM" object. |
|
|
to be implemented in the derived simulator class if combined with the Diffpack adaptivity toolbox, and a user-defined refinement criterion is wanted. |
|
|
to be implemented in the derived simulator class, to be called for handling of essential bounday conditions. Reimplemented in PreproLaplace. |
|
|
returns the CPU time used by the "makeSystem" call. |
|
|
to be implemented in the derived simulator class as special ""integrands"" function where the programmer can fill several element vectors at the same time (each element vector corresponds to the "elmat.b" quantity in the standard "integrands" routine). This is used in conjunction with "smoothMultipleFields". |
|
|
to be implemented in the derived simulator class. Its purpose is to compute the contributions to the element matrix and element vector (in terms of an "ElmMatVec" object) for a given element number and integration point (in terms of a "FiniteElement" object). For this purpose the input "FiniteElement" object is used to evaluate basis functions, and derivatives thereof. Reimplemented in PreproLaplace. |
|
|
a function similar to "integrands", but the purpose is to evaluate the contribution (from an integration point in an element) to the energy norm of the error. Hence, one must in this function have access to the primary unknown of the problem and some reference solution (e.g. an exact solution or a fine grid simulation). |
|
|
similar to "integrands", this function can be implemented in the derived simulator class in order to define the integrand in side integrals. Such integrals might be present in the weak formulation of the PDE problem, e.g. representing natural boundary conditions.. |
|
|
given a filled "FiniteElement" object and a time step value "t", this function can be implemented in the derived simulator class in order to define the coefficient "k" in the the "makeFlux" calculations. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
documented under function "smoothField". |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
documented under function "smoothField". |
|
|
|
|
|
|
|
|
generate the mass matrix, lumped by the row-sum technique if "row_sum" is true. Otherwise, one can compute a consistent mass matrix or a lumped mass matrix (if nodal point integration is used; the "itg_rules" variable in class "FEM" controls the type of numerical integration used in "makeMassMatrix"). |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
computes the linear system arising from a finite element method. The function is completely general and calls virtual functions for defining the element matrix and vector. A default version of this virtual function is provided. The default version simply calls a function for numerical integration over the element which again calls a virtual function "integrands" that the programmer must implement in the derived simulator class. If "only_safe_opt" is "false", special optimization might be turned on. The code is then not necessarily valid in all cases. What type of optimizations that are available and their validity will be documented here. Typically, all elements must be of the same type and no surface integrals must appear in the weak form. (We can test that all elements are of the same type, but not if the simulator developer also has a surface integral! The "only_safe_opt" flag must therefore be used with care.) There are several overloaded versions of the "makeSystem" function. Some functions are aimed at computing the coefficient matrix only or the right hand side only. The programmer is encouraged to read the body of the "makeSystem" functions since this will provide all details about the different versions. Some of the versions require particular initializations of the involved data structures and this is explained in comments in the source code. If the user needs to form linear systems corresponding to different weak forms, one can create special ""integrands functors"" upon which special "makeSystem" functions can base the computation. If none of the "makeSystem" functions are appropriate, one can easily make one''s own "makeSystem" in a subclass of "FEM". This might be required to construct an efficient assembly process, taking advantage of special features in the problem. The "makeSystem" functions measures the CPU time spent in the function. This CPU time is written to the logfile (casename.dp) if more than half a second is spent in the "makeSystem" function. Similar CPU time information is provided by "LinEqAdmFE solve" and written on the same line in the logfile. The CPU time is available in an internal (protected) variable that the programmer can use in a derived simulation class if desired. |
|
|
See documentation of one of the overloaded functions. |
|
|
as "fillEssBC, but for use in applications that employ the Diffpack multigrid toolbox. |
|
|
See documentation of one of the overloaded functions. |
|
|
numerical integration over the element. The "FiniteElement" object must be initialized by calling its "refill" function prior to the call to "numItgOverElm." The function evaluates the integrand of the integral by calling the virtual function "integrands". If the integrand is defined by a functor (derived from "IntegrandCalc") rather than a class "FEM" virtual function "integrands", an overloaded version of "numItgOverElm" can handle that case. |
|
|
See documentation of one of the overloaded functions. |
|
|
numerical integration over the side (surface) of an element. Contrary to "numItgOverElm" the "FiniteElement" object is automatically refilled for the current side ("refill4side") inside "numItgOverSide." (However, "refill" must be called, but that is usually performed prior to a "numItgOverElm" call which normally preceeds the computation of the side integral). An overloaded version can handle the case where the integrand in the side (surface) integral is defined in terms of an "IntegrandCalc" functor. |
|
|
|
|
|
Reimplemented in PreproLaplace. |
|
|
See documentation of one of the overloaded functions. |
|
|
documented under function "smoothField". |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
This documentation is common for the smoothing functions "smoothField", "makeGradient", "makeFlux", "smoothDerivative", "smoothGradient": Enable computation and smoothing of derivatives of finite element fields. "makeFlux" is an all-round function that is sufficient for most users. See the description of "makeFlux" below. The most fundamental "smoothField" function runs the least squares method on a system where a "IntegrandCalc" functor defines the right-hand side, i.e. the field to be smoothed. An assembly process over the elements is set up, the mass matrix is computed if it is not computed before or attached by the user, and the resulting system is solved. Other versions of "smoothField" offer more user-friendly interfaces in that they take ordinary Diffpack field objects as input and define the corresponding functor for the right-hand side in the least squares system. Of particular interest is the function that takes a "FieldsFEatItgPt" object, usually containing derivatives at reduced Gauss points in the elements, and runs the least squares process on this collection of discrete values. The "smoothField" functions are usually used for smoothing 'derivatives'. Direct computation of derivatives are offered by the functions "smoothDerivative" (smooth derivative in one direction), "makeGradient" (all derivatives, but no smoothing) and "smoothGradient" (computes all directional derivatives and smooths the result). We also refer to class "FieldsFEatItgPt" for functionality concerning computation of derivatives (this functionality is much used in the "FEM" functions as well). Two "makeGradient" functions represent the gradient of a field in terms of piecewise constant fields. When using multilinear or linear elements this is a natural representation of derivatives. For higher order elements these functions first computes the derivatives at the reduced Gauss points and then assign the average of these point values to the element value in a "Field(s)PiWisConst" field. The "FieldsPiWisConst" field can be plotted directly by the "SimRes2mtv plotmtvVector" function or it can be smoothed by "FEM smoothFields" and then stored as a general finite element vector field and later plotted by any visualization system that handles finite element vector fields. The main function of all functions for smoothing and derivative computation in class "FEM" is "makeFlux". This is a flexible function for computing "c*k*grad(f)", where "c" is scalar parameter (e.g. minus one in many cases, "k" is a coefficient in the expression for the flux, and "f" is finite element field. There are two basic representations of "k", either as a subclass of "Field" or as a virtual function "k" in the solver class. Simple solvers usually apply the virtual function representation (see e.g. class "Elliptic2" in the basic Diffpack documentation), while the field representation might be preferable in more complicated simulators. If one calls the version of "makeFlux" where there is no explicit "k" argument, the virtual "k" function must be implemented in the solver class (otherwise an instructive error message is issued). The "makeFlux" function first computes the derivatives at the optimal points in each element (the reduced Gauss points), using class "FieldsFEatItgPt" functionality. Then these derivatives are multiplied by the "k" values, and then calls a "smoothField" function for smoothing the result. If the "k" field is not given as a parameter, it is taken as unity. Finally, the smoothed field is multiplied by "c". There are two smoothing methods in "makeFlux"; global least squares and moving least squares. The former is most efficient, but the latter has a higher convergence rate and is recommended when high accuracy is important. There is a data member "average_tp" (in clas "FEM") which indicates the type of averaging procedures that should be used in smoothing procedures ("smoothField", "makeFlux" and similar routines). By default, the method gives arithmetic averages, but we have a developed a special method that mimics harmonic means. You can set the arithmetic or harmonic mean option on the menu, or set the "average_tp" variable explicitly in the simulator class (which is normally a subclass of "FEM" if finite element methods are used in the simulator). |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
smooth each scalar component in the supplied vector fields by calls to "smoothFields". |
|
|
See documentation of one of the overloaded functions. |
|
|
documented under function "smoothField". |
|
|
runs the least squares smoothing algorithm for several fields simultaneously. The functions "smoothFields" invokes a smoothing procedure for each component. In other words, the assembly of the right hand side of the resulting linear system will be performed independently for each field (vector component) that is to be smoothed. The "smoothMultipleFields" function has an assembly loop that computes several right hand sides simultaneously. Of course, this requires a special ""integrands"" function where the programmer can fill several element vectors at the same time (each element vector corresponds to the "elmat.b" quantity in the standard "integrands" routine). Instad of sending an "ElmMatVec" object to the ""integrands"" routine, one sends instead a "Mat" object, where each column is an element vector. The function that defines the integrand has the name "integrand4smoothing". The "smoothMultipleFields" function can give significant speed up if the smoothing operations are a time consuming part of a simulation. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|