OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
meshqualityerrorestimator.C
Go to the documentation of this file.
1 /*
2  *
3  * ##### ##### ###### ###### ### ###
4  * ## ## ## ## ## ## ## ### ##
5  * ## ## ## ## #### #### ## # ##
6  * ## ## ## ## ## ## ## ##
7  * ## ## ## ## ## ## ## ##
8  * ##### ##### ## ###### ## ##
9  *
10  *
11  * OOFEM : Object Oriented Finite Element Code
12  *
13  * Copyright (C) 1993 - 2013 Borek Patzak
14  *
15  *
16  *
17  * Czech Technical University, Faculty of Civil Engineering,
18  * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28  * Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free Software
32  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33  */
34 
36 #include "element.h"
37 #include "elementgeometrytype.h"
38 #include "mathfem.h"
39 #include "node.h"
40 #include "integrationrule.h"
41 #include "feinterpol.h"
42 #include "gausspoint.h"
43 
44 namespace oofem {
46 {
47  // A good plan would probably be to let the element determines its own quality if they implement some interface.
48  // otherwise use a sane default.
49  double error;
50  FEInterpolation *fei = elem->giveInterpolation();
52  if ( fei && ir ) {
53  error = this->computeJacobianError(* fei, * ir, elem);
54  } else {
55  switch ( elem->giveGeometryType() ) {
56  case EGT_triangle_1:
57  error = this->computeTriangleRadiusError(elem);
58  break;
59  case EGT_triangle_2:
60  error = this->computeTriangleRadiusError(elem);
61  break;
62  default:
63  error = 0.0;
64  break;
65  }
66  }
67  return error;
68 }
69 
71 {
72  // Outside/inside circle radius fraction based for quality measurement.
73  // Zero for a perfect triangle,
74  double a, b, c;
75  FloatArray *c1, *c2, *c3;
76  c1 = elem->giveNode(1)->giveCoordinates();
77  c2 = elem->giveNode(2)->giveCoordinates();
78  c3 = elem->giveNode(3)->giveCoordinates();
79  a = c1->distance(* c2);
80  b = c1->distance(* c3);
81  c = c2->distance(* c3);
82  return a * b * c / ( ( b + c - a ) * ( a + c - b ) * ( a + b - c ) ) - 1.0;
83  // Reciprocal error would be;
84  // (b+c-a)*(a+c-b)*(a+b-c)/(a*b*c - (b+c-a)*(a+c-b)*(a+b-c));
85  // Which is safe except for when all points coincide, i.e. a = b = c = 0
86 }
87 
89 {
90  double min_rcond = 1.0, rcond;
91  FloatMatrix jac;
92 
93  for ( GaussPoint *gp: ir ) {
94  fei.giveJacobianMatrixAt( jac, gp->giveNaturalCoordinates(), FEIElementGeometryWrapper(elem) );
95  rcond = jac.computeReciprocalCondition() * sgn( jac.giveDeterminant() ); // Signed rcond. as inverted mappings are particularly bad.
96  if ( rcond < min_rcond ) {
97  min_rcond = rcond;
98  }
99  }
100  return min_rcond < 1e-6 ? 1e6 : 1.0 / min_rcond; // Cap it to avoid overflow.
101 }
102 
104 {
105  double error = 0.0, temp;
106  for ( auto &elem : this->domain->giveElements() ) {
107  temp = this->giveElementError(unknownET, elem.get(), tStep);
108  if ( temp > error ) {
109  error = temp;
110  }
111  }
112  return error;
113 }
114 
116 {
117  return true;
118 }
119 
121 {
123 }
124 } // end namespace oofem
double giveDeterminant() const
Returns the trace (sum of diagonal components) of the receiver.
Definition: floatmatrix.C:1408
virtual IntegrationRule * giveDefaultIntegrationRulePtr()
Access method for default integration rule.
Definition: element.h:822
Domain * domain
Link to domain object, useful for communicating with other FEM components.
Definition: femcmpnn.h:82
double sgn(double i)
Returns the signum of given value (if value is < 0 returns -1, otherwise returns 1) ...
Definition: mathfem.h:91
Abstract base class for all finite elements.
Definition: element.h:145
EE_ErrorType
Type characterizing different type of element errors.
virtual FEInterpolation * giveInterpolation() const
Definition: element.h:629
double computeReciprocalCondition(char p= '1') const
Computes the conditioning of the receiver.
Definition: floatmatrix.C:1737
Abstract base class representing integration rule.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
virtual double giveElementError(EE_ErrorType type, Element *elem, TimeStep *tStep)
Returns the element error.
double distance(const FloatArray &x) const
Computes the distance between position represented by receiver and position given as parameter...
Definition: floatarray.C:489
Class representing a general abstraction for finite element interpolation class.
Definition: feinterpol.h:132
static double computeJacobianError(FEInterpolation &fei, IntegrationRule &ir, Element *elem)
Computes the error based on the conditioning of the Jacobian.
Wrapper around element definition to provide FEICellGeometry interface.
Definition: feinterpol.h:95
virtual double giveValue(EE_ValueType type, TimeStep *tStep)
Gives the max error from any element in the domain.
virtual int estimateError(EE_ErrorMode mode, TimeStep *tStep)
Empty implementation.
Class representing vector of real numbers.
Definition: floatarray.h:82
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
EE_ErrorMode
Type determining whether temporary or equilibrated variables are used for error evaluation.
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
virtual void giveJacobianMatrixAt(FloatMatrix &jacobianMatrix, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Gives the jacobian matrix at the local coordinates.
Definition: feinterpol.h:232
Class representing the general Input Record.
Definition: inputrecord.h:101
static double computeTriangleRadiusError(Element *elem)
Computes error based on the inscribed triangle/circle ratio.
virtual FloatArray * giveCoordinates()
Definition: node.h:114
EE_ValueType
Type characterizing different type of errors.
std::vector< std::unique_ptr< Element > > & giveElements()
Definition: domain.h:279
virtual Element_Geometry_Type giveGeometryType() const
Returns the element geometry type.
Definition: element.C:1529
the oofem namespace is to define a context or scope in which all oofem names are defined.
Node * giveNode(int i) const
Returns reference to the i-th node of element.
Definition: element.h:610
Class representing integration point in finite element program.
Definition: gausspoint.h:93
Class representing solution step.
Definition: timestep.h:80

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:29 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011