Changeset 372 for trunk/src2


Ignore:
Timestamp:
Mar 23, 2006, 7:41:29 AM (19 years ago)
Author:
mmc
Message:

Added field scaling and made points outside of volume invisible.

Location:
trunk/src2/core
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src2/core/RpField1D.cc

    r370 r372  
    1616 */
    1717#include <assert.h>
     18#include <math.h>
    1819#include "RpField1D.h"
    1920
     
    2122
    2223Field1D::Field1D()
    23   : _meshPtr(NULL),
     24  : _vmin(NAN),
     25    _vmax(NAN),
     26    _meshPtr(NULL),
    2427    _counter(0)
    2528{
     
    2932Field1D::Field1D(const Ptr<Mesh1D>& meshPtr)
    3033  : _valuelist(),
     34    _vmin(NAN),
     35    _vmax(NAN),
    3136    _meshPtr(meshPtr),
    3237    _counter(0)
     
    3641Field1D::Field1D(const Field1D& field)
    3742  : _valuelist(field._valuelist),
     43    _vmin(field._vmin),
     44    _vmax(field._vmax),
    3845    _meshPtr(field._meshPtr),
    3946    _counter(0)
     
    4552{
    4653    _valuelist = field._valuelist;
     54    _vmin = field._vmin;
     55    _vmax = field._vmax;
    4756    _meshPtr = field._meshPtr;
    4857    _counter = field._counter;
     
    130139{
    131140    _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    }
    132148}
    133149
     
    166182    return 0.0;
    167183}
     184
     185double
     186Field1D::valueMin() const
     187{
     188    return _vmin;
     189}
     190
     191double
     192Field1D::valueMax() const
     193{
     194    return _vmax;
     195}
  • trunk/src2/core/RpField1D.h

    r370 r372  
    4343    virtual int define(int nodeId, double y);
    4444    virtual double value(double x) const;
     45    virtual double valueMin() const;
     46    virtual double valueMax() const;
    4547
    4648private:
    4749    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
    4852    Ptr<Mesh1D> _meshPtr;           // mesh for all x-points
    4953    int _counter;                   // counter for generating node IDs
  • trunk/src2/core/RpFieldPrism3D.cc

    r370 r372  
    7777{
    7878    _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    }
    7986    return *this;
    8087}
     
    125132    return outside;
    126133}
     134
     135double
     136FieldPrism3D::valueMin() const
     137{
     138    return _vmin;
     139}
     140
     141double
     142FieldPrism3D::valueMax() const
     143{
     144    return _vmax;
     145}
  • trunk/src2/core/RpFieldPrism3D.h

    r370 r372  
    3838    virtual double value(double x, double y, double z,
    3939        double outside=NAN) const;
     40    virtual double valueMin() const;
     41    virtual double valueMax() const;
    4042
    4143private:
    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
    4347    Ptr<MeshPrism3D> _meshPtr;       // mesh for all (x,y,z) points
    44     int _counter;                   // counter for generating node IDs
     48    int _counter;                    // counter for generating node IDs
    4549};
    4650
  • trunk/src2/core/RpFieldRect3D.cc

    r370 r372  
    9797{
    9898    _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    }
    99106    return *this;
    100107}
     
    147154
    148155double
     156FieldRect3D::valueMin() const
     157{
     158    return _vmin;
     159}
     160
     161double
     162FieldRect3D::valueMax() const
     163{
     164    return _vmax;
     165}
     166
     167double
    149168FieldRect3D::_interpolate(double x0, double y0, double x1, double y1,
    150169    double x) const
  • trunk/src2/core/RpFieldRect3D.h

    r370 r372  
    4040    virtual double value(double x, double y, double z,
    4141        double outside=NAN) const;
     42    virtual double valueMin() const;
     43    virtual double valueMax() const;
    4244
    4345protected:
     
    4749private:
    4850    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
    4953    Ptr<MeshRect3D> _meshPtr;       // mesh for all (x,y,z) points
    5054    int _counter;                   // counter for generating node IDs
  • trunk/src2/core/RpFieldTri2D.cc

    r370 r372  
    9393{
    9494    _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    }
    95102    return *this;
    96103}
     
    118125    return outside;
    119126}
     127
     128double
     129FieldTri2D::valueMin() const
     130{
     131    return _vmin;
     132}
     133
     134double
     135FieldTri2D::valueMax() const
     136{
     137    return _vmax;
     138}
  • trunk/src2/core/RpFieldTri2D.h

    r370 r372  
    3939    virtual FieldTri2D& define(int nodeId, double f);
    4040    virtual double value(double x, double y, double outside=NAN) const;
     41    virtual double valueMin() const;
     42    virtual double valueMax() const;
    4143
    4244private:
    4345    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
    4448    Ptr<MeshTri2D> _meshPtr;        // mesh for all (x,y) points
    4549    int _counter;                   // counter for generating node IDs
  • trunk/src2/core/RpMeshTri2D.cc

    r370 r372  
    1414 */
    1515#include <math.h>
     16#include <iostream>
    1617#include "RpMeshTri2D.h"
    1718
     
    111112    double det = x2*y3-x3*y2;
    112113
    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    }
    116123}
    117124
     
    340347    }
    341348
     349    int lastCellId = -1;
    342350    while (!cell.isNull()) {
    343351        double phi[3];
     
    346354        // if all are >= 0, then this tri contains node
    347355        cell.barycentrics(node, phi);
     356        if (isnan(phi[0])) {
     357            cell.clear();
     358            return cell;
     359        }
    348360        if (phi[0] >= 0.0 && phi[1] >= 0.0 && phi[2] >= 0.0) {
    349361            break;
     
    360372        Tri2D& tri = nonconst->_celllist[ cell.cellId() ];
    361373        int neighborId = tri.neighbors[dir];
    362         if (neighborId < 0) {
     374        if (neighborId < 0 || neighborId == lastCellId) {
     375if (neighborId == lastCellId) {
     376std::cout << "loop at " << lastCellId << "->" << neighborId << std::endl;
     377}
    363378            cell.clear();
    364379            return cell;
    365380        }
    366381
     382        lastCellId = cell.cellId();
    367383        Tri2D& tri2 = nonconst->_celllist[neighborId];
    368384        Node2D *n1Ptr = &nonconst->_nodelist[tri2.nodes[0]];
Note: See TracChangeset for help on using the changeset viewer.