OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
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 - 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; 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 
35 #include "../sm/Quasicontinuum/geometrygenerator.h"
36 #include <stdlib.h>
37 #include <time.h>
38 
39 
40 namespace oofem {
42 
43 // Constructor.
44 { }
45 
47 // Destructor
48 { }
49 
52 {
53  IRResultType result; // Required by IR_GIVE_FIELD macro
54 
59 
60 
61  //...
62 
63  // check input format
64 #ifdef DEBUG
65  /*
66  * if ( ) {
67  * OOFEM_ERROR("invalid format of ... ??? ");
68  * }
69  */
70 #endif
71 
72  return IRRT_OK;
73 }
74 
75 void
77 {
78  /*
79  * int NumOfParticles, NumOfIterations, NumOfItOnePar = 1;
80  * std::srand(std::time(0)); // randomize
81  * FloatArray coords(3);
82  * // minimal and maximal coordinates
83  * double x1= ??? ... x2 y1 y2 z1 z2
84  * //nog=1; tnog=1; % pocet generaci je na zacatku
85  * while (NumOfParticles<maxNumOfParticles) {
86  * coords.at(1) = ((double) std::rand() / (RAND_MAX))*(x2-x1) + x1;
87  * coords.at(1) = ((double) std::rand() / (RAND_MAX))*(x2-x1) + x1;
88  * coords.at(1) = ((double) std::rand() / (RAND_MAX))*(x2-x1) + x1;
89  *
90  * if ( CheckDistances(ParticleRadius, coords, n) ) {
91  * // add this particle
92  *
93  * }
94  *
95  * if () {
96  * // reached maximal number of iteration of one particles
97  *
98  * }
99  * // reached maximal number of all iteration
100  * if () {
101  *
102  * }
103  *
104  * }
105  *
106  *
107  * x = x1 + (x2-x1).*rand(1,1);
108  * y = y1 + (y2-y1).*rand(1,1);
109  * z = z1 + (z2-z1).*rand(1,1);
110  *
111  * % check zaroven upravuje geometrii do zuzeni
112  * OK = CheckDistances(x, y, z, R, n, particles, quadtree, x1, x2, y1, y2, z1, z2, nod);
113  * if(OK)
114  * particles(n+1,1) = x;
115  * particles(n+1,2) = y;
116  * particles(n+1,3) = z;
117  * quadtree = addParticleInQuadTree(x, y, n+1, quadtree, x1, x2, y1, y2, nod );
118  * //n=n+1;
119  * //nog=1; % castice se pridala - lokalni citac generaci se nuluje
120  * NumOfParticles++;
121  * nog=1;
122  * end
123  * nog=nog+1; tnog=tnog+1;
124  * if (nog>=maxnog) % prekrocen pocet generaci pro prijeti jedne castice
125  * fprintf('v %d krocich vygenerovano:\n%d z %d castic\n', tnog, n, nop);
126  * fprintf('dosazen maximalni pocet %d generaci pro prijeti jedne castice\n', maxnog);
127  * break
128  *
129  * elseif (tnog>=tmaxnog) % prekrocet celkovy pocet generaci
130  * fprintf('v %d krocich vygenerovano:\n%d z %d castic\n', tnog, n, nop);
131  * fprintf('dosazen maximalni celkovy pocet %d generaci\n', tmaxnog);
132  * break
133  * elseif (n>=nop) % dosazen pozadovany pocet castic
134  * fprintf('v %d krocich vygenerovano vsech %d pozadovanych castic\n', tnog, n);
135  * end
136  * % kontrolni vypis
137  * if (floor(tnog/1000)*1000==tnog) % vypisuj kazdou 1000.
138  * fprintf(' aktualni pocet generaci: %d, vygenerovano %d castic\n', tnog, n);
139  * end
140  */
141 }
142 
143 bool
145 // retunrs true if the distance of particle with coords from first n particles is greater or equal than R
146 {
147  if ( n == 0 ) {
148  return true;
149  }
150  if ( (unsigned int) n > Particles.size() ) {
151  n = Particles.size();
152  }
153 
154  double R2 = R * R;
155  for ( int i = 1; i <= n; i++ ) {
156  double distance2 = coords.distance_square(Particles [ i - 1 ]);
157  if ( distance2 < R2 ) {
158  return false;
159  }
160  }
161 
162  return false;
163 }
164 
165 
166 void
168 {}
169 
172 {
173  //IRResultType result; // Required by IR_GIVE_FIELD macro
174  return IRRT_OK;
175 
176 }
177 
178 void
180 {}
181 
182 
183 void
185 {}
186 } // end namespace oofem
#define _IFT_GeometryGenerator_particleRadius
#define _IFT_GeometryGenerator_numOfItOnePar
IRResultType initializeLinkGenerator(InputRecord *ir)
#define _IFT_GeometryGenerator_numOfParticles
double distance_square(const FloatArray &iP1, const FloatArray &iP2, double &oXi, double &oXiUnbounded) const
Definition: floatarray.C:499
bool CheckDistances(double R, FloatArray coords, int n)
Class representing vector of real numbers.
Definition: floatarray.h:82
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
Class representing the general Input Record.
Definition: inputrecord.h:101
IRResultType initializeParticleGenerator(InputRecord *ir)
#define _IFT_GeometryGenerator_numOfIterations
the oofem namespace is to define a context or scope in which all oofem names are defined.
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
std::vector< FloatArray > Particles

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:28 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011