OOFEM 3.0
Loading...
Searching...
No Matches
lobattoir.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 "lobattoir.h"
36#include "gausspoint.h"
37#include "floatarray.h"
38#include "mathfem.h"
39
40namespace oofem {
41LobattoIntegrationRule :: LobattoIntegrationRule(int n, Element *e,
42 int startIndx, int endIndx, bool dynamic) :
43 IntegrationRule(n, e, startIndx, endIndx, dynamic) { }
44
45LobattoIntegrationRule :: LobattoIntegrationRule(int n, Element *e) :
46 IntegrationRule(n, e) { }
47
48LobattoIntegrationRule :: ~LobattoIntegrationRule()
49{ }
50
51
52int
53LobattoIntegrationRule :: SetUpPointsOnLine(int nPoints, MaterialMode mode)
54{
55 FloatArray coords_xi, weights;
56 this->giveLineCoordsAndWeights(nPoints, coords_xi, weights);
57 this->gaussPoints.resize( nPoints );
58
59 for ( int i = 1; i <= nPoints; i++ ) {
60 this->gaussPoints [ i - 1 ] = new GaussPoint(this, i, Vec1(coords_xi.at(i)), weights.at ( i ), mode);
61 }
62
63 this->intdomain = _Line;
64 return this->giveNumberOfIntegrationPoints();
65}
66
67
68int
69LobattoIntegrationRule :: SetUpPointsOnSquare(int nPoints, MaterialMode mode)
70//GaussIntegrationRule :: SetUpPointsOnSquare(int nPoints_xi1, int nPoints_xi2, MaterialMode mode)
71{
72 int nPoints_xi1 = ( int ) floor( sqrt( double ( nPoints ) ) );
73 int nPoints_xi2 = nPoints_xi1;
74 FloatArray coords_xi1, weights1, coords_xi2, weights2;
75 this->giveLineCoordsAndWeights(nPoints_xi1, coords_xi1, weights1);
76 this->giveLineCoordsAndWeights(nPoints_xi2, coords_xi2, weights2);
77 this->gaussPoints.resize( nPoints_xi1 * nPoints_xi2 );
78 int count = 0;
79 for ( int i = 1; i <= nPoints_xi1; i++ ) {
80 for ( int j = 1; j <= nPoints_xi2; j++ ) {
81 count++;
82 this->gaussPoints [ count - 1 ] = new GaussPoint(this, count, Vec2(coords_xi1.at(i), coords_xi2.at(j)),
83 weights1.at ( i ) *weights2.at ( j ), mode);
84 }
85 }
86
87 this->intdomain = _Square;
88 return this->giveNumberOfIntegrationPoints();
89}
90
91
92int
93LobattoIntegrationRule :: SetUpPointsOnCube(int nPoints, MaterialMode mode)
94//GaussIntegrationRule :: SetUpPointsOnCube(int nPoints_xi1, int nPoints_xi2, int nPoints_xi3, MaterialMode mode)
95{
96 int nPoints_xi1 = ( int ) floor(cbrt( double ( nPoints ) ) + 0.5);
97 int nPoints_xi2 = nPoints_xi1;
98 int nPoints_xi3 = nPoints_xi1;
99 FloatArray coords_xi1, weights1, coords_xi2, weights2, coords_xi3, weights3;
100 this->giveLineCoordsAndWeights(nPoints_xi1, coords_xi1, weights1);
101 this->giveLineCoordsAndWeights(nPoints_xi2, coords_xi2, weights2);
102 this->giveLineCoordsAndWeights(nPoints_xi3, coords_xi3, weights3);
103 this->gaussPoints.resize( nPoints_xi1 * nPoints_xi2 * nPoints_xi3 );
104 int count = 0;
105 for ( int i = 1; i <= nPoints_xi1; i++ ) {
106 for ( int j = 1; j <= nPoints_xi2; j++ ) {
107 for ( int k = 1; k <= nPoints_xi3; k++ ) {
108 count++;
109 this->gaussPoints [ count - 1 ] = new GaussPoint(this, count, Vec3(coords_xi1.at(i), coords_xi2.at(j), coords_xi3.at(k)),
110 weights1.at ( i ) *weights2.at ( j ) *weights3.at ( k ), mode);
111 }
112 }
113 }
114
115 this->intdomain = _Cube;
116 return this->giveNumberOfIntegrationPoints();
117}
118
119
120int
121LobattoIntegrationRule :: SetUpPointsOnTriangle(int nPoints, MaterialMode mode)
122{
123 OOFEM_ERROR("unsupported number of IPs (%d)", nPoints);
124}
125
126
127
128int
129LobattoIntegrationRule :: getRequiredNumberOfIntegrationPoints(integrationDomain dType,
130 int approxOrder)
131{
132 int requiredNIP;
133
134 switch ( dType ) {
135 case _Line:
136 if ( approxOrder <= 1 ) {
137 return 1;
138 }
139
140 requiredNIP = ( int ) ceil( ( ( double ) approxOrder + 3.0 ) / 2. );
141 if ( requiredNIP > 6 ) {
142 return -1;
143 }
144
145 return requiredNIP;
146
147 default:
148 OOFEM_ERROR("unknown integrationDomain");
149 }
150 // return -1;
151}
152
153
154void
155LobattoIntegrationRule :: giveLineCoordsAndWeights(int nPoints, FloatArray &coords_xi, FloatArray &weights)
156// Create arrays of coordinates and weights for Lobatto Integration Points of a line with 'nPoints' integrationpoints
157{
158 switch ( nPoints ) {
159 case 1:
160 coords_xi = Vec1(0.0);
161 weights = Vec1(2.0);
162 break;
163
164 case 2:
165 coords_xi = Vec2(-1.0, 1.0);
166 weights = Vec2(1.0, 1.0);
167 break;
168
169 case 3:
170 coords_xi = Vec3(-1.0, 0.0, 1.0);
171 weights = Vec3(0.333333333333333, 1.333333333333333, 0.333333333333333);
172 break;
173
174 case 4:
175 coords_xi = Vec4(-1.0,
176 -0.447213595499958,
177 0.447213595499958,
178 1.0);
179 weights = Vec4( 0.166666666666667,
180 0.833333333333333,
181 0.833333333333333,
182 0.166666666666667);
183 break;
184
185 case 5:
186 coords_xi = Vec5(-1.0,
187 -0.654653670707977,
188 0.0,
189 0.654653670707977,
190 1.0);
191 weights = Vec5( 0.1,
192 0.544444444444444,
193 0.711111111111111,
194 0.544444444444444,
195 0.1);
196 break;
197
198 default:
199 coords_xi = Vec6(-1.0,
200 -0.765055323929465,
201 -0.285231516480645,
202 0.285231516480645,
203 0.765055323929465,
204 1.0);
205 weights = Vec6( 0.066666666666667,
206 0.378474956297847,
207 0.554858377035486,
208 0.554858377035486,
209 0.378474956297847,
210 0.066666666666667);
211 if ( nPoints > 6 ) {
212 OOFEM_LOG_WARNING("Unsupported number of IPs (%d) for LobattoIR, using 6 ips instead.", nPoints);
213 }
214 break;
215 }
216}
217} // end namespace oofem
double & at(Index i)
Definition floatarray.h:202
int giveNumberOfIntegrationPoints() const
std::vector< GaussPoint * > gaussPoints
Array containing integration points.
integrationDomain intdomain
Integration domain.
IntegrationRule(int n, Element *e, int startIndx, int endIndx, bool dynamic)
static void giveLineCoordsAndWeights(int nPoints, FloatArray &coords_xi, FloatArray &weights)
Definition lobattoir.C:155
#define OOFEM_ERROR(...)
Definition error.h:79
#define OOFEM_LOG_WARNING(...)
Definition logger.h:139
static FloatArray Vec2(const double &a, const double &b)
Definition floatarray.h:606
double cbrt(double x)
Returns the cubic root of x.
Definition mathfem.h:122
static FloatArray Vec6(const double &a, const double &b, const double &c, const double &d, const double &e, const double &f)
Definition floatarray.h:610
static FloatArray Vec5(const double &a, const double &b, const double &c, const double &d, const double &e)
Definition floatarray.h:609
static FloatArray Vec4(const double &a, const double &b, const double &c, const double &d)
Definition floatarray.h:608
static FloatArray Vec1(const double &a)
Definition floatarray.h:605
static FloatArray Vec3(const double &a, const double &b, const double &c)
Definition floatarray.h:607

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