OOFEM 3.0
Loading...
Searching...
No Matches
delaunaytriangle.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 - 2025 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
35#include "delaunaytriangle.h"
36#include "dofmanager.h"
37#include "math.h"
38#include "octreelocalizert.h"
40#include "mathfem.h"
41
42namespace oofem {
43DelaunayTriangle :: DelaunayTriangle(Domain *d, int node1, int node2, int node3) :
44 domain(d),
45 nodes(3),
46
47 circumCircle(3),
48 validFlag(true)
49{
50 nodes.at(1) = node1;
51 nodes.at(2) = node2;
52 nodes.at(3) = node3;
53
55}
56
57DelaunayTriangle :: ~DelaunayTriangle()
58{
59}
60
61void
62DelaunayTriangle :: setCircumCircle(double x, double y, double r)
63{
64 this->circumCircle.at(1) = x;
65 this->circumCircle.at(2) = y;
66 this->circumCircle.at(3) = r;
67}
68
69double
70DelaunayTriangle :: giveDistanceToCenter(const FloatArray &coords)
71{
72 double x = coords.at(1);
73 double y = coords.at(2);
74
75 double xC = giveXCenterCoordinate();
76 double yC = giveYCenterCoordinate();
77
78 return ( sqrt( ( xC - x ) * ( xC - x ) + ( yC - y ) * ( yC - y ) ) );
79}
80
81void
82DelaunayTriangle :: computeCircumcircle()
83{
84 double x1, x2, x3;
85 double y1, y2, y3;
86
87 double a, bx, by, c;
88
89 DofManager *dmanA, *dmanB, *dmanC;
90
91 dmanA = domain->giveDofManager( giveNode(1) );
92 x1 = dmanA->giveCoordinate(1);
93 y1 = dmanA->giveCoordinate(2);
94
95 dmanB = domain->giveDofManager( giveNode(2) );
96 x2 = dmanB->giveCoordinate(1);
97 y2 = dmanB->giveCoordinate(2);
98
99 dmanC = domain->giveDofManager( giveNode(3) );
100 x3 = dmanC->giveCoordinate(1);
101 y3 = dmanC->giveCoordinate(2);
102
103 a = x1 * y2 + y1 * x3 + x2 * y3 - 1.0 * ( x1 * y3 + y1 * x2 + y2 * x3 );
104 bx = -1.0 * ( ( ( x1 * x1 + y1 * y1 ) * y2 + y1 * ( x3 * x3 + y3 * y3 ) + ( x2 * x2 + y2 * y2 ) * y3 )
105 - 1.0 * ( ( x1 * x1 + y1 * y1 ) * y3 + y1 * ( x2 * x2 + y2 * y2 ) + y2 * ( x3 * x3 + y3 * y3 ) ) );
106 by = ( ( ( x1 * x1 + y1 * y1 ) * x2 + x1 * ( x3 * x3 + y3 * y3 ) + ( x2 * x2 + y2 * y2 ) * x3 )
107 - 1.0 * ( ( x1 * x1 + y1 * y1 ) * x3 + x1 * ( x2 * x2 + y2 * y2 ) + x2 * ( x3 * x3 + y3 * y3 ) ) );
108 c = ( ( ( x1 * x1 + y1 * y1 ) * x2 * y3 + x1 * y2 * ( x3 * x3 + y3 * y3 ) + y1 * ( x2 * x2 + y2 * y2 ) * x3 )
109 - 1.0 * ( ( x1 * x1 + y1 * y1 ) * y2 * x3 + x1 * ( x2 * x2 + y2 * y2 ) * y3 + y1 * x2 * ( x3 * x3 + y3 * y3 ) ) );
110
111 double xCenterCoordinate = ( -1.0 * bx / ( 2 * a ) );
112 double yCenterCoordinate = ( -1.0 * by / ( 2 * a ) );
113 double absA = a < 0 ? -1.0 * a : a;
114
115 double radius = ( ( sqrt(bx * bx + by * by + 4.0 * a * c) ) / ( 2.0 * absA ) );
116
117 setCircumCircle(xCenterCoordinate, yCenterCoordinate, radius);
118}
119
120std :: list< LocalInsertionData< DelaunayTriangle * > > *
121DelaunayTriangle :: giveListOfCellsAndPosition()
122{
124}
125
126double
127DelaunayTriangle :: giveShortestEdgeLength()
128{
129 double length1 = giveEdgeLength(1, 2);
130 double length2 = giveEdgeLength(2, 3);
131 double length3 = giveEdgeLength(3, 1);
132 return min( length1, min(length2, length3) );
133}
134
135double
136DelaunayTriangle :: giveEdgeLength(int nodeA, int nodeB)
137{
138 DofManager *dmanA = domain->giveDofManager( giveNode(nodeA) );
139 DofManager *dmanB = domain->giveDofManager( giveNode(nodeB) );
140
141 return distance(dmanA->giveCoordinates(), dmanB->giveCoordinates());
142}
143} // end namespace oofem
144
IntArray nodes
Nodes defining the triangle.
FloatArray circumCircle
Parameters of the circumscribed circle: coordinates of center (x,y) and its radius.
double giveYCenterCoordinate() const
Gives the y coordinate of the center of the circumscribed circle.
Domain * domain
Domain where the nodes are defined.
void setCircumCircle(double x, double y, double r)
Sets up the parameters of the calculated circumscribed circle.
double giveEdgeLength(int nodeA, int nodeB)
Gives the length of the edge between two nodes.
std ::list< LocalInsertionData< DelaunayTriangle * > > listOfCellsContainedInAndPosition
In order to allow fast search in octree, every triangle stores list of octree cells where its circums...
double giveXCenterCoordinate() const
Gives the x coordinate of the center of the circumscribed circle.
bool validFlag
Flag for Delaunay property.
int giveNode(int i)
Gives the i-node of the triangle.
void computeCircumcircle()
Calculates the parameters of the circumscribed circle.
double giveCoordinate(int i) const
Definition dofmanager.h:383
const FloatArray & giveCoordinates() const
Definition dofmanager.h:390
double & at(Index i)
Definition floatarray.h:202
FloatArrayF< N > min(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
double distance(const FloatArray &x, const FloatArray &y)

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011