File: LocalSizeField.h

package info (click to toggle)
madlib 1.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,196 kB
  • sloc: cpp: 39,851; sh: 10,041; makefile: 473
file content (125 lines) | stat: -rw-r--r-- 4,064 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// -*- C++ -*-
// -------------------------------------------------------------------
// MAdLib - Copyright (C) 2008-2009 Universite catholique de Louvain
//
// See the Copyright.txt and License.txt files for license information. 
// You should have received a copy of these files along with MAdLib. 
// If not, see <http://www.madlib.be/license/>
//
// Please report all bugs and problems to <contrib@madlib.be>
//
// Authors: Gaetan Compere, Jean-Francois Remacle
// -------------------------------------------------------------------

#ifndef _H_LOCALSIZEFIELD
#define _H_LOCALSIZEFIELD

#include "SizeFieldBase.h"
#include "DistanceFunction.h"

#include <set>
#include <utility>
#include <string>

// -------------------------------------------------------------------
/*
  This class stores a size field around an object. 
  * The object is defined by a set of geometrical entities.
  * The size field is defined by a radius and strings giving the 
    size in function of the distance to the object.
  * Returns:
    - If the distance is superior to the radius, the class 
      returns a huge size.
    - Otherwise, it can return one of these sizes:
      - an isotropic size (evaluated from 'sizeN')
      - an anisotropic size with a main axis in the normal 
        direction to the object and a corresponding value ('sizeN'), 
        and two axis in the tangent directions with another value 
        ('sizeT').
*/
// -------------------------------------------------------------------

namespace MAd {

  class MAdStringFieldEvaluator;

  // -------------------------------------------------------------------
  class LocalSizeField : public SizeFieldBase {

  public:

    LocalSizeField(pMesh m, std::string name="", bool _distToFaces=false);
    LocalSizeField(const LocalSizeField& _lsf);
    ~LocalSizeField();

    sFieldType getType() const { return LOCALSFIELD; }

    void scale(double);

    void addGeometricEntity(int type, int tag);
    void updateTree();

    void setIsoSize(double _radius, std::string _sizeN);
    void setAnisoSize(double _radius, std::string _sizeN, std::string _sizeT);
    void setCurvatureLimiter(double onTgSize, double _maxCurv=1.e12);

    // get the size at a location (allocate space!)
    pMSize getSize(const pVertex) const;
    pMSize getSizeOnEntity(const pEntity, const double[3]) const;

    // edge length (squared)
    double SF_VV_lengthSq(const pVertex, const pVertex) const;
    double SF_XYZ_lengthSq(const double[3], const double[3],
                           const pMSize, const pMSize=NULL) const;

    // face area (squared)
    double SF_F_areaSq(const pFace) const;
    double SF_XYZ_areaSq(const double[3][3], const pMSize,
                         const double[3]) const;

    // region volume
    double SF_R_volume(const pRegion) const;
    double SF_XYZ_volume(const double[4][3], const pMSize) const;

    // center and its associated size
    double SF_E_center(const pEdge, double[3], double * reducSq, pMSize *) const;
    double SF_VV_center(const pVertex, const pVertex,
                        double[3], double * reducSq, pMSize *) const;

    // returns the distance to the walls
    double getDistance(const pVertex pv) const;

    // divergence of the curvature
    bool getCurvature(const pVertex pv, double *c) const;
    
  private:

    void collectEntities(std::set<pVertex> * verts, 
                         std::set<pEntity> * ents) const;

  private:

    pMesh mesh;

    std::set<pGEntity> geomEntities;
    int geoDim;

    bool isotropic;
    double radius;
    std::string sizeN, sizeT;
    MAdStringFieldEvaluator * sEvalN, * sEvalT;

    bool distToFaces; // true:  distance computed to the faces of the wall (exact)
                      // false: distance computed to the vertices of the wall
    distanceFunction dFct; // tool to compute distance and its derivatives

    // limiters based on curvature
    bool limit;
    double tgSizeLimitCoef;
    double maxCurv;
  };

}

// -------------------------------------------------------------------
#endif