mesh_smoother_vsmoother.h
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 00020 #ifndef LIBMESH_MESH_SMOOTHER_VSMOOTHER_H 00021 #define LIBMESH_MESH_SMOOTHER_VSMOOTHER_H 00022 00023 #include "libmesh/libmesh_config.h" 00024 #ifdef LIBMESH_ENABLE_VSMOOTHER 00025 00026 // Local Includes ----------------------------------- 00027 #include "libmesh/mesh_smoother.h" 00028 #include "libmesh/unstructured_mesh.h" 00029 00030 // C++ Includes ----------------------------------- 00031 #include <cstddef> 00032 #include <vector> 00033 #include <map> 00034 00035 namespace libMesh 00036 { 00037 00038 //jj 00039 typedef double * LPDOUBLE; 00040 typedef LPDOUBLE * LPLPDOUBLE; 00041 typedef LPLPDOUBLE * LPLPLPDOUBLE; 00042 typedef void * LPVOID; 00043 typedef LPVOID * LPLPVOID; 00044 typedef int * LPINT; 00045 typedef LPINT * LPLPINT; 00046 typedef unsigned int uint; 00047 00069 // ------------------------------------------------------------ 00070 // VariationalMeshSmoother class definition 00071 class VariationalMeshSmoother : public MeshSmoother 00072 { 00073 public: 00074 00078 VariationalMeshSmoother(UnstructuredMesh& mesh, const double theta=0.5, const uint miniter=2, 00079 const uint maxiter=5, const uint miniterBC=5) 00080 :MeshSmoother(mesh), 00081 _percent_to_move(1), 00082 _adapt_data(NULL), 00083 _dim(mesh.mesh_dimension()), 00084 _miniter(miniter), 00085 _maxiter(maxiter), 00086 _miniterBC(miniterBC), 00087 00088 _metric(uniform), 00089 _adaptive_func(none), 00090 _theta(theta), 00091 _generate_data(false), 00092 00093 _area_of_interest(NULL) 00094 {} 00095 00099 VariationalMeshSmoother(UnstructuredMesh& mesh, std::vector<float>* adapt_data, const double theta=0.5, 00100 const uint miniter=2, const uint maxiter=5, const uint miniterBC=5, 00101 const double percent_to_move=1) 00102 :MeshSmoother(mesh), 00103 _percent_to_move(percent_to_move), 00104 _adapt_data(adapt_data), 00105 _dim(mesh.mesh_dimension()), 00106 _miniter(miniter), 00107 _maxiter(maxiter), 00108 _miniterBC(miniterBC), 00109 00110 _metric(uniform), 00111 _adaptive_func(cell), 00112 _theta(theta), 00113 _generate_data(false), 00114 00115 _area_of_interest(NULL) 00116 {} 00117 00122 VariationalMeshSmoother(UnstructuredMesh& mesh, const UnstructuredMesh* area_of_interest, std::vector<float>* adapt_data, 00123 const double theta=0.5, const uint miniter=2, const uint maxiter=5, 00124 const uint miniterBC=5, const double percent_to_move=1) 00125 :MeshSmoother(mesh), 00126 _percent_to_move(percent_to_move), 00127 _adapt_data(adapt_data), 00128 _dim(mesh.mesh_dimension()), 00129 _miniter(miniter), 00130 _maxiter(maxiter), 00131 _miniterBC(miniterBC), 00132 00133 _metric(uniform), 00134 _adaptive_func(cell), 00135 _theta(theta), 00136 _generate_data(false), 00137 00138 _area_of_interest(area_of_interest) 00139 {} 00140 00141 enum metric_type 00142 { 00143 uniform=1, 00144 volumetric=2, 00145 directional=3 00146 }; 00147 00148 enum adapt_type 00149 { 00150 cell=-1, 00151 none=0, 00152 node=1 00153 }; 00154 00158 virtual ~VariationalMeshSmoother() {} 00159 00166 virtual void smooth() { _distance = this->smooth(1); } 00167 00173 double smooth(unsigned int n_iterations); 00174 00180 double distanceMoved() const {return _distance;} 00181 00182 private: 00183 00187 double _distance; 00188 00192 const double _percent_to_move; 00193 00197 double _dist_norm; 00198 00202 std::map<dof_id_type, std::vector<dof_id_type> > _hanging_nodes; 00203 00207 std::vector<float> * _adapt_data; 00208 00212 const uint _dim,_miniter,_maxiter,_miniterBC; 00213 const metric_type _metric; 00214 const adapt_type _adaptive_func; 00215 const double _theta; 00216 const bool _generate_data; 00217 00221 const UnstructuredMesh * _area_of_interest; 00222 00223 void adjust_adapt_data(); 00224 float adapt_minimum() const; 00225 00230 /*-- allocate memory --*/ 00231 LPDOUBLE alloc_d_n1(int m1) { return((LPDOUBLE)malloc(m1*sizeof(double))); } 00232 LPINT alloc_i_n1(int m1) { return((LPINT)malloc(m1*sizeof(int))); } 00233 LPLPINT alloc_i_n1_n2(int m1, int) { return((LPLPINT)malloc(m1*sizeof(LPINT))); } 00234 LPLPDOUBLE alloc_d_n1_n2(int m1, int) { return((LPLPDOUBLE)malloc(m1*sizeof(LPDOUBLE))); } 00235 LPLPLPDOUBLE alloc_d_n1_n2_n3(int m1, int, int) { return((LPLPLPDOUBLE)malloc(m1*sizeof(LPLPDOUBLE))); } 00236 00237 int writegr(int n, int N, LPLPDOUBLE R, LPINT mask, int ncells, LPLPINT cells, 00238 LPINT mcells, int nedges, LPINT edges, LPINT hnodes, const char grid[], 00239 int me, const char grid_old[], FILE *sout); 00240 00241 int readgr(int n, int N, LPLPDOUBLE R, LPINT mask, int ncells, 00242 LPLPINT cells, LPINT mcells, int nedges, LPINT edges, LPINT hnodes, FILE *sout); 00243 00244 int readmetr(char *name, LPLPLPDOUBLE H, int ncells, int n, FILE *sout); 00245 00246 int read_adp(LPDOUBLE afun, char *adap, FILE *sout); 00247 00248 double jac3(double x1,double y1,double z1,double x2,double y2, 00249 double z2,double x3,double y3,double z3); 00250 00251 double jac2(double x1,double y1,double x2,double y2); 00252 00253 int basisA(int n, LPLPDOUBLE Q, int nvert, LPDOUBLE K, LPLPDOUBLE H, int me); 00254 00255 void adp_renew(int n, int N, LPLPDOUBLE R, int ncells, LPLPINT cells, 00256 LPDOUBLE afun, int adp, FILE *sout); 00257 00258 void full_smooth(int n, int N, LPLPDOUBLE R, LPINT mask, int ncells, LPLPINT cells, LPINT mcells, 00259 int nedges, LPINT edges, LPINT hnodes, double w, LPINT iter, int me, 00260 LPLPLPDOUBLE H, int adp, char *adap, int gr, FILE *sout); 00261 00262 double maxE(int n, int N, LPLPDOUBLE R, int ncells, LPLPINT cells, LPINT mcells, 00263 int me, LPLPLPDOUBLE H, double v, double epsilon, double w, LPDOUBLE Gamma, 00264 double *qmin, FILE *sout); 00265 00266 double minq(int n, int N, LPLPDOUBLE R, int ncells, LPLPINT cells, LPINT mcells, 00267 int me, LPLPLPDOUBLE H, double *vol, double *Vmin, FILE *sout); 00268 00269 double minJ(int n, int N, LPLPDOUBLE R, LPINT mask, int ncells, LPLPINT cells, LPINT mcells, 00270 double epsilon, double w, int me, LPLPLPDOUBLE H, double vol, int nedges, 00271 LPINT edges, LPINT hnodes, int msglev, double *Vmin, double *emax, double *qmin, 00272 int adp, LPDOUBLE afun, FILE *sout); 00273 00274 double minJ_BC(int N, LPLPDOUBLE R, LPINT mask, int ncells, LPLPINT cells, LPINT mcells, 00275 double epsilon, double w, int me, LPLPLPDOUBLE H, double vol, int msglev, 00276 double *Vmin, double *emax, double *qmin, int adp, LPDOUBLE afun, int NCN, FILE *sout); 00277 00278 double localP(int n, LPLPLPDOUBLE W, LPLPDOUBLE F, LPLPDOUBLE R, LPINT cell, LPINT mask, double epsilon, 00279 double w, int nvert, LPLPDOUBLE H, int me, double vol, int f, double *Vmin, 00280 double *qmin, int adp, LPDOUBLE afun, LPDOUBLE Gloc, FILE *sout); 00281 00282 double avertex(int n, LPDOUBLE afun, LPDOUBLE G, LPLPDOUBLE R, LPINT cell, int nvert, int adp, FILE *sout); 00283 00284 double vertex(int n, LPLPLPDOUBLE W, LPLPDOUBLE F, LPLPDOUBLE R, LPINT cell, 00285 double epsilon, double w, int nvert, LPDOUBLE K, 00286 LPLPDOUBLE H, int me, double vol, int f, double *Vmin, int adp, 00287 LPDOUBLE G, double sigma, FILE *sout); 00288 00289 void metr_data_gen(char grid[], char metr[], int n, int me, FILE *sout); 00290 00291 int solver(int n, LPINT ia, LPINT ja, LPDOUBLE a, LPDOUBLE x, LPDOUBLE b, double eps, 00292 int maxite, int msglev, FILE *sout); 00293 00294 int pcg_ic0(int n, LPINT ia, LPINT ja, LPDOUBLE a, LPDOUBLE u, LPDOUBLE x, LPDOUBLE b, LPDOUBLE r, 00295 LPDOUBLE p, LPDOUBLE z, double eps, int maxite, int msglev, FILE *sout); 00296 00297 int pcg_par_check(int n, LPINT ia, LPINT ja, LPDOUBLE a, double eps, int maxite, int msglev, FILE *sout); 00298 00299 void gener(char grid[], int n, FILE *sout); 00300 00301 void local_sweep(int n, int N, LPLPDOUBLE R, LPINT mask, int ncells, LPLPINT cells, LPINT mcells, 00302 int nedges, LPINT edges, LPINT hnodes, double w, LPINT iter, int me, 00303 LPLPLPDOUBLE H, int adp, int OPT, FILE *sout); 00304 00305 double minJ_l(int n, int N, LPLPDOUBLE R, LPINT mask, int ncells, LPLPINT cells, LPINT mcells, 00306 double epsilon, double w, int me, LPLPLPDOUBLE H, double vol, int nedges, 00307 LPINT edges, LPINT hnodes, int msglev, double *Vmin, double *emax, double *qmin, 00308 int adp, LPDOUBLE afun, FILE *sout); 00309 }; 00310 00311 } // namespace libMesh 00312 00313 #endif // LIBMESH_ENABLE_VSMOOTHER 00314 00315 #endif // LIBMESH_MESH_SMOOTHER_VSMOOTHER_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:47 UTC
Hosted By: