Changeset 372 for trunk/src2
- Timestamp:
- Mar 23, 2006, 7:41:29 AM (19 years ago)
- Location:
- trunk/src2/core
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src2/core/RpField1D.cc
r370 r372 16 16 */ 17 17 #include <assert.h> 18 #include <math.h> 18 19 #include "RpField1D.h" 19 20 … … 21 22 22 23 Field1D::Field1D() 23 : _meshPtr(NULL), 24 : _vmin(NAN), 25 _vmax(NAN), 26 _meshPtr(NULL), 24 27 _counter(0) 25 28 { … … 29 32 Field1D::Field1D(const Ptr<Mesh1D>& meshPtr) 30 33 : _valuelist(), 34 _vmin(NAN), 35 _vmax(NAN), 31 36 _meshPtr(meshPtr), 32 37 _counter(0) … … 36 41 Field1D::Field1D(const Field1D& field) 37 42 : _valuelist(field._valuelist), 43 _vmin(field._vmin), 44 _vmax(field._vmax), 38 45 _meshPtr(field._meshPtr), 39 46 _counter(0) … … 45 52 { 46 53 _valuelist = field._valuelist; 54 _vmin = field._vmin; 55 _vmax = field._vmax; 47 56 _meshPtr = field._meshPtr; 48 57 _counter = field._counter; … … 130 139 { 131 140 _valuelist[nodeId] = y; 141 142 if (_vmin == NAN || _vmax == NAN) { 143 _vmin = _vmax = y; 144 } else { 145 if (y < _vmin) { _vmin = y; } 146 if (y > _vmax) { _vmax = y; } 147 } 132 148 } 133 149 … … 166 182 return 0.0; 167 183 } 184 185 double 186 Field1D::valueMin() const 187 { 188 return _vmin; 189 } 190 191 double 192 Field1D::valueMax() const 193 { 194 return _vmax; 195 } -
trunk/src2/core/RpField1D.h
r370 r372 43 43 virtual int define(int nodeId, double y); 44 44 virtual double value(double x) const; 45 virtual double valueMin() const; 46 virtual double valueMax() const; 45 47 46 48 private: 47 49 std::deque<double> _valuelist; // list of all values, in nodeId order 50 double _vmin; // minimum value in _valuelist 51 double _vmax; // maximum value in _valuelist 48 52 Ptr<Mesh1D> _meshPtr; // mesh for all x-points 49 53 int _counter; // counter for generating node IDs -
trunk/src2/core/RpFieldPrism3D.cc
r370 r372 77 77 { 78 78 _valuelist[nodeId] = f; 79 80 if (_vmin == NAN || _vmax == NAN) { 81 _vmin = _vmax = f; 82 } else { 83 if (f < _vmin) { _vmin = f; } 84 if (f > _vmax) { _vmax = f; } 85 } 79 86 return *this; 80 87 } … … 125 132 return outside; 126 133 } 134 135 double 136 FieldPrism3D::valueMin() const 137 { 138 return _vmin; 139 } 140 141 double 142 FieldPrism3D::valueMax() const 143 { 144 return _vmax; 145 } -
trunk/src2/core/RpFieldPrism3D.h
r370 r372 38 38 virtual double value(double x, double y, double z, 39 39 double outside=NAN) const; 40 virtual double valueMin() const; 41 virtual double valueMax() const; 40 42 41 43 private: 42 std::vector<double> _valuelist; // list of all values, in nodeId order 44 std::vector<double> _valuelist; // list of all values, in nodeId order 45 double _vmin; // minimum value in _valuelist 46 double _vmax; // maximum value in _valuelist 43 47 Ptr<MeshPrism3D> _meshPtr; // mesh for all (x,y,z) points 44 int _counter; // counter for generating node IDs48 int _counter; // counter for generating node IDs 45 49 }; 46 50 -
trunk/src2/core/RpFieldRect3D.cc
r370 r372 97 97 { 98 98 _valuelist[nodeId] = f; 99 100 if (_vmin == NAN || _vmax == NAN) { 101 _vmin = _vmax = f; 102 } else { 103 if (f < _vmin) { _vmin = f; } 104 if (f > _vmax) { _vmax = f; } 105 } 99 106 return *this; 100 107 } … … 147 154 148 155 double 156 FieldRect3D::valueMin() const 157 { 158 return _vmin; 159 } 160 161 double 162 FieldRect3D::valueMax() const 163 { 164 return _vmax; 165 } 166 167 double 149 168 FieldRect3D::_interpolate(double x0, double y0, double x1, double y1, 150 169 double x) const -
trunk/src2/core/RpFieldRect3D.h
r370 r372 40 40 virtual double value(double x, double y, double z, 41 41 double outside=NAN) const; 42 virtual double valueMin() const; 43 virtual double valueMax() const; 42 44 43 45 protected: … … 47 49 private: 48 50 std::vector<double> _valuelist; // list of all values, in nodeId order 51 double _vmin; // minimum value in _valuelist 52 double _vmax; // maximum value in _valuelist 49 53 Ptr<MeshRect3D> _meshPtr; // mesh for all (x,y,z) points 50 54 int _counter; // counter for generating node IDs -
trunk/src2/core/RpFieldTri2D.cc
r370 r372 93 93 { 94 94 _valuelist[nodeId] = f; 95 96 if (_vmin == NAN || _vmax == NAN) { 97 _vmin = _vmax = f; 98 } else { 99 if (f < _vmin) { _vmin = f; } 100 if (f > _vmax) { _vmax = f; } 101 } 95 102 return *this; 96 103 } … … 118 125 return outside; 119 126 } 127 128 double 129 FieldTri2D::valueMin() const 130 { 131 return _vmin; 132 } 133 134 double 135 FieldTri2D::valueMax() const 136 { 137 return _vmax; 138 } -
trunk/src2/core/RpFieldTri2D.h
r370 r372 39 39 virtual FieldTri2D& define(int nodeId, double f); 40 40 virtual double value(double x, double y, double outside=NAN) const; 41 virtual double valueMin() const; 42 virtual double valueMax() const; 41 43 42 44 private: 43 45 std::vector<double> _valuelist; // list of all values, in nodeId order 46 double _vmin; // minimum value in _valuelist 47 double _vmax; // maximum value in _valuelist 44 48 Ptr<MeshTri2D> _meshPtr; // mesh for all (x,y) points 45 49 int _counter; // counter for generating node IDs -
trunk/src2/core/RpMeshTri2D.cc
r370 r372 14 14 */ 15 15 #include <math.h> 16 #include <iostream> 16 17 #include "RpMeshTri2D.h" 17 18 … … 111 112 double det = x2*y3-x3*y2; 112 113 113 phi[1] = (xr*y3 - x3*yr)/det; 114 phi[2] = (x2*yr - xr*y2)/det; 115 phi[0] = 1.0-phi[1]-phi[2]; 114 if (det != 0.0) { 115 phi[1] = (xr*y3 - x3*yr)/det; 116 phi[2] = (x2*yr - xr*y2)/det; 117 phi[0] = 1.0-phi[1]-phi[2]; 118 } else { 119 phi[1] = NAN; 120 phi[2] = NAN; 121 phi[0] = NAN; 122 } 116 123 } 117 124 … … 340 347 } 341 348 349 int lastCellId = -1; 342 350 while (!cell.isNull()) { 343 351 double phi[3]; … … 346 354 // if all are >= 0, then this tri contains node 347 355 cell.barycentrics(node, phi); 356 if (isnan(phi[0])) { 357 cell.clear(); 358 return cell; 359 } 348 360 if (phi[0] >= 0.0 && phi[1] >= 0.0 && phi[2] >= 0.0) { 349 361 break; … … 360 372 Tri2D& tri = nonconst->_celllist[ cell.cellId() ]; 361 373 int neighborId = tri.neighbors[dir]; 362 if (neighborId < 0) { 374 if (neighborId < 0 || neighborId == lastCellId) { 375 if (neighborId == lastCellId) { 376 std::cout << "loop at " << lastCellId << "->" << neighborId << std::endl; 377 } 363 378 cell.clear(); 364 379 return cell; 365 380 } 366 381 382 lastCellId = cell.cellId(); 367 383 Tri2D& tri2 = nonconst->_celllist[neighborId]; 368 384 Node2D *n1Ptr = &nonconst->_nodelist[tri2.nodes[0]];
Note: See TracChangeset
for help on using the changeset viewer.