mesh_smoother_vsmoother.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_MESH_SMOOTHER_VSMOOTHER_H
21 #define LIBMESH_MESH_SMOOTHER_VSMOOTHER_H
22 
23 #include "libmesh/libmesh_config.h"
24 #ifdef LIBMESH_ENABLE_VSMOOTHER
25 
26 // Local Includes -----------------------------------
27 #include "libmesh/mesh_smoother.h"
29 
30 // C++ Includes -----------------------------------
31 #include <cstddef>
32 #include <vector>
33 #include <map>
34 
35 namespace libMesh
36 {
37 
38 //jj
39 typedef double * LPDOUBLE;
40 typedef LPDOUBLE * LPLPDOUBLE;
42 typedef void * LPVOID;
43 typedef LPVOID * LPLPVOID;
44 typedef int * LPINT;
45 typedef LPINT * LPLPINT;
46 typedef unsigned int uint;
47 
69 // ------------------------------------------------------------
70 // VariationalMeshSmoother class definition
72 {
73 public:
74 
78  VariationalMeshSmoother(UnstructuredMesh& mesh, const double theta=0.5, const uint miniter=2,
79  const uint maxiter=5, const uint miniterBC=5)
80  :MeshSmoother(mesh),
82  _adapt_data(NULL),
83  _dim(mesh.mesh_dimension()),
84  _miniter(miniter),
85  _maxiter(maxiter),
86  _miniterBC(miniterBC),
87 
90  _theta(theta),
91  _generate_data(false),
92 
93  _area_of_interest(NULL)
94  {}
95 
99  VariationalMeshSmoother(UnstructuredMesh& mesh, std::vector<float>* adapt_data, const double theta=0.5,
100  const uint miniter=2, const uint maxiter=5, const uint miniterBC=5,
101  const double percent_to_move=1)
102  :MeshSmoother(mesh),
103  _percent_to_move(percent_to_move),
104  _adapt_data(adapt_data),
105  _dim(mesh.mesh_dimension()),
106  _miniter(miniter),
107  _maxiter(maxiter),
108  _miniterBC(miniterBC),
109 
110  _metric(uniform),
112  _theta(theta),
113  _generate_data(false),
114 
115  _area_of_interest(NULL)
116  {}
117 
122  VariationalMeshSmoother(UnstructuredMesh& mesh, const UnstructuredMesh* area_of_interest, std::vector<float>* adapt_data,
123  const double theta=0.5, const uint miniter=2, const uint maxiter=5,
124  const uint miniterBC=5, const double percent_to_move=1)
125  :MeshSmoother(mesh),
126  _percent_to_move(percent_to_move),
127  _adapt_data(adapt_data),
128  _dim(mesh.mesh_dimension()),
129  _miniter(miniter),
130  _maxiter(maxiter),
131  _miniterBC(miniterBC),
132 
133  _metric(uniform),
135  _theta(theta),
136  _generate_data(false),
137 
138  _area_of_interest(area_of_interest)
139  {}
140 
142  {
146  };
147 
149  {
150  cell=-1,
151  none=0,
153  };
154 
159 
166  virtual void smooth() { _distance = this->smooth(1); }
167 
173  double smooth(unsigned int n_iterations);
174 
180  double distanceMoved() const {return _distance;}
181 
182 private:
183 
187  double _distance;
188 
192  const double _percent_to_move;
193 
197  double _dist_norm;
198 
202  std::map<dof_id_type, std::vector<dof_id_type> > _hanging_nodes;
203 
207  std::vector<float> * _adapt_data;
208 
215  const double _theta;
216  const bool _generate_data;
217 
222 
223  void adjust_adapt_data();
224  float adapt_minimum() const;
225 
230  /*-- allocate memory --*/
231  LPDOUBLE alloc_d_n1(int m1) { return((LPDOUBLE)malloc(m1*sizeof(double))); }
232  LPINT alloc_i_n1(int m1) { return((LPINT)malloc(m1*sizeof(int))); }
233  LPLPINT alloc_i_n1_n2(int m1, int) { return((LPLPINT)malloc(m1*sizeof(LPINT))); }
234  LPLPDOUBLE alloc_d_n1_n2(int m1, int) { return((LPLPDOUBLE)malloc(m1*sizeof(LPDOUBLE))); }
235  LPLPLPDOUBLE alloc_d_n1_n2_n3(int m1, int, int) { return((LPLPLPDOUBLE)malloc(m1*sizeof(LPLPDOUBLE))); }
236 
237  int writegr(int n, int N, LPLPDOUBLE R, LPINT mask, int ncells, LPLPINT cells,
238  LPINT mcells, int nedges, LPINT edges, LPINT hnodes, const char grid[],
239  int me, const char grid_old[], FILE *sout);
240 
241  int readgr(int n, int N, LPLPDOUBLE R, LPINT mask, int ncells,
242  LPLPINT cells, LPINT mcells, int nedges, LPINT edges, LPINT hnodes, FILE *sout);
243 
244  int readmetr(char *name, LPLPLPDOUBLE H, int ncells, int n, FILE *sout);
245 
246  int read_adp(LPDOUBLE afun, char *adap, FILE *sout);
247 
248  double jac3(double x1,double y1,double z1,double x2,double y2,
249  double z2,double x3,double y3,double z3);
250 
251  double jac2(double x1,double y1,double x2,double y2);
252 
253  int basisA(int n, LPLPDOUBLE Q, int nvert, LPDOUBLE K, LPLPDOUBLE H, int me);
254 
255  void adp_renew(int n, int N, LPLPDOUBLE R, int ncells, LPLPINT cells,
256  LPDOUBLE afun, int adp, FILE *sout);
257 
258  void full_smooth(int n, int N, LPLPDOUBLE R, LPINT mask, int ncells, LPLPINT cells, LPINT mcells,
259  int nedges, LPINT edges, LPINT hnodes, double w, LPINT iter, int me,
260  LPLPLPDOUBLE H, int adp, char *adap, int gr, FILE *sout);
261 
262  double maxE(int n, int N, LPLPDOUBLE R, int ncells, LPLPINT cells, LPINT mcells,
263  int me, LPLPLPDOUBLE H, double v, double epsilon, double w, LPDOUBLE Gamma,
264  double *qmin, FILE *sout);
265 
266  double minq(int n, int N, LPLPDOUBLE R, int ncells, LPLPINT cells, LPINT mcells,
267  int me, LPLPLPDOUBLE H, double *vol, double *Vmin, FILE *sout);
268 
269  double minJ(int n, int N, LPLPDOUBLE R, LPINT mask, int ncells, LPLPINT cells, LPINT mcells,
270  double epsilon, double w, int me, LPLPLPDOUBLE H, double vol, int nedges,
271  LPINT edges, LPINT hnodes, int msglev, double *Vmin, double *emax, double *qmin,
272  int adp, LPDOUBLE afun, FILE *sout);
273 
274  double minJ_BC(int N, LPLPDOUBLE R, LPINT mask, int ncells, LPLPINT cells, LPINT mcells,
275  double epsilon, double w, int me, LPLPLPDOUBLE H, double vol, int msglev,
276  double *Vmin, double *emax, double *qmin, int adp, LPDOUBLE afun, int NCN, FILE *sout);
277 
278  double localP(int n, LPLPLPDOUBLE W, LPLPDOUBLE F, LPLPDOUBLE R, LPINT cell, LPINT mask, double epsilon,
279  double w, int nvert, LPLPDOUBLE H, int me, double vol, int f, double *Vmin,
280  double *qmin, int adp, LPDOUBLE afun, LPDOUBLE Gloc, FILE *sout);
281 
282  double avertex(int n, LPDOUBLE afun, LPDOUBLE G, LPLPDOUBLE R, LPINT cell, int nvert, int adp, FILE *sout);
283 
284  double vertex(int n, LPLPLPDOUBLE W, LPLPDOUBLE F, LPLPDOUBLE R, LPINT cell,
285  double epsilon, double w, int nvert, LPDOUBLE K,
286  LPLPDOUBLE H, int me, double vol, int f, double *Vmin, int adp,
287  LPDOUBLE G, double sigma, FILE *sout);
288 
289  void metr_data_gen(char grid[], char metr[], int n, int me, FILE *sout);
290 
291  int solver(int n, LPINT ia, LPINT ja, LPDOUBLE a, LPDOUBLE x, LPDOUBLE b, double eps,
292  int maxite, int msglev, FILE *sout);
293 
294  int pcg_ic0(int n, LPINT ia, LPINT ja, LPDOUBLE a, LPDOUBLE u, LPDOUBLE x, LPDOUBLE b, LPDOUBLE r,
295  LPDOUBLE p, LPDOUBLE z, double eps, int maxite, int msglev, FILE *sout);
296 
297  int pcg_par_check(int n, LPINT ia, LPINT ja, LPDOUBLE a, double eps, int maxite, int msglev, FILE *sout);
298 
299  void gener(char grid[], int n, FILE *sout);
300 
301  void local_sweep(int n, int N, LPLPDOUBLE R, LPINT mask, int ncells, LPLPINT cells, LPINT mcells,
302  int nedges, LPINT edges, LPINT hnodes, double w, LPINT iter, int me,
303  LPLPLPDOUBLE H, int adp, int OPT, FILE *sout);
304 
305  double minJ_l(int n, int N, LPLPDOUBLE R, LPINT mask, int ncells, LPLPINT cells, LPINT mcells,
306  double epsilon, double w, int me, LPLPLPDOUBLE H, double vol, int nedges,
307  LPINT edges, LPINT hnodes, int msglev, double *Vmin, double *emax, double *qmin,
308  int adp, LPDOUBLE afun, FILE *sout);
309 };
310 
311 } // namespace libMesh
312 
313 #endif // LIBMESH_ENABLE_VSMOOTHER
314 
315 #endif // LIBMESH_MESH_SMOOTHER_VSMOOTHER_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:06 UTC

Hosted By:
SourceForge.net Logo