OOFEM 3.0
Loading...
Searching...
No Matches
geometrygenerator.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; eitherc
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 <stdlib.h>
37#include <time.h>
38
39
40namespace oofem {
41GeometryGenerator :: GeometryGenerator()
42
43// Constructor.
44{ }
45
46GeometryGenerator :: ~GeometryGenerator()
47// Destructor
48{ }
49
50void
51GeometryGenerator :: initializeParticleGenerator(InputRecord &ir)
52{
57
58 //...
59
60 // check input format
61#ifdef DEBUG
62 /*
63 * if ( ) {
64 * OOFEM_ERROR("invalid format of ... ??? ");
65 * }
66 */
67#endif
68}
69
70void
71GeometryGenerator :: generateParticles()
72{
73 /*
74 * int NumOfParticles, NumOfIterations, NumOfItOnePar = 1;
75 * std::srand(std::time(0)); // randomize
76 * FloatArray coords(3);
77 * // minimal and maximal coordinates
78 * double x1= ??? ... x2 y1 y2 z1 z2
79 * //nog=1; tnog=1; % pocet generaci je na zacatku
80 * while (NumOfParticles<maxNumOfParticles) {
81 * coords.at(1) = ((double) std::rand() / (RAND_MAX))*(x2-x1) + x1;
82 * coords.at(1) = ((double) std::rand() / (RAND_MAX))*(x2-x1) + x1;
83 * coords.at(1) = ((double) std::rand() / (RAND_MAX))*(x2-x1) + x1;
84 *
85 * if ( CheckDistances(ParticleRadius, coords, n) ) {
86 * // add this particle
87 *
88 * }
89 *
90 * if () {
91 * // reached maximal number of iteration of one particles
92 *
93 * }
94 * // reached maximal number of all iteration
95 * if () {
96 *
97 * }
98 *
99 * }
100 *
101 *
102 * x = x1 + (x2-x1).*rand(1,1);
103 * y = y1 + (y2-y1).*rand(1,1);
104 * z = z1 + (z2-z1).*rand(1,1);
105 *
106 * % check zaroven upravuje geometrii do zuzeni
107 * OK = CheckDistances(x, y, z, R, n, particles, quadtree, x1, x2, y1, y2, z1, z2, nod);
108 * if(OK)
109 * particles(n+1,1) = x;
110 * particles(n+1,2) = y;
111 * particles(n+1,3) = z;
112 * quadtree = addParticleInQuadTree(x, y, n+1, quadtree, x1, x2, y1, y2, nod );
113 * //n=n+1;
114 * //nog=1; % castice se pridala - lokalni citac generaci se nuluje
115 * NumOfParticles++;
116 * nog=1;
117 * end
118 * nog=nog+1; tnog=tnog+1;
119 * if (nog>=maxnog) % prekrocen pocet generaci pro prijeti jedne castice
120 * fprintf('v %d krocich vygenerovano:\n%d z %d castic\n', tnog, n, nop);
121 * fprintf('dosazen maximalni pocet %d generaci pro prijeti jedne castice\n', maxnog);
122 * break
123 *
124 * elseif (tnog>=tmaxnog) % prekrocet celkovy pocet generaci
125 * fprintf('v %d krocich vygenerovano:\n%d z %d castic\n', tnog, n, nop);
126 * fprintf('dosazen maximalni celkovy pocet %d generaci\n', tmaxnog);
127 * break
128 * elseif (n>=nop) % dosazen pozadovany pocet castic
129 * fprintf('v %d krocich vygenerovano vsech %d pozadovanych castic\n', tnog, n);
130 * end
131 * % kontrolni vypis
132 * if (floor(tnog/1000)*1000==tnog) % vypisuj kazdou 1000.
133 * fprintf(' aktualni pocet generaci: %d, vygenerovano %d castic\n', tnog, n);
134 * end
135 */
136}
137
138bool
139GeometryGenerator :: CheckDistances(double R, FloatArray coords, int n)
140// retunrs true if the distance of particle with coords from first n particles is greater or equal than R
141{
142 if ( n == 0 ) {
143 return true;
144 }
145 if ( (unsigned int) n > Particles.size() ) {
146 n = Particles.size();
147 }
148
149 double R2 = R * R;
150 for ( int i = 1; i <= n; i++ ) {
151 double distance2 = distance_square(coords, Particles [ i - 1 ]);
152 if ( distance2 < R2 ) {
153 return false;
154 }
155 }
156
157 return false;
158}
159
160
161void
162GeometryGenerator :: loadParticles()
163{}
164
165void
166GeometryGenerator :: initializeLinkGenerator(InputRecord &ir)
167{
168}
169
170void
171GeometryGenerator :: generateLinks()
172{}
173
174
175void
176GeometryGenerator :: loadLinks()
177{}
178} // end namespace oofem
std::vector< FloatArray > Particles
#define _IFT_GeometryGenerator_particleRadius
#define _IFT_GeometryGenerator_numOfItOnePar
#define _IFT_GeometryGenerator_numOfParticles
#define _IFT_GeometryGenerator_numOfIterations
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
double distance_square(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