File: MeshParametersManager.cc

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 (161 lines) | stat: -rw-r--r-- 5,559 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// -------------------------------------------------------------------
// 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
// -------------------------------------------------------------------

#include "MeshParametersManager.h"
#include "MAdMessage.h"

// standart C/C++
#include <iostream>
using std::cout;
using std::cerr;
using std::endl;

namespace MAd {

  // -------------------------------------------------------------------
  MeshParametersManager::MeshParametersManager():
    lowerLengthSqBound(-1.), upperLengthSqBound(-1.), 
    sliverTetQualityBound(-1.), sliverTriQualityBound(-1.), 
    sliverPermInESplit(false), sliverPermInECollapse(false),
    sliverLowerLengthSqBound(-1.),sliverUpperLengthSqBound(-1.),
    noSwapQuality(-1.),swapMinImproveRatio(-1.), bigLength(1.e14)
  {}

  // -------------------------------------------------------------------
  void MeshParametersManager::initialize()
  {
  }

  // -------------------------------------------------------------------
  void MeshParametersManager::finalize()
  {
  }

  // -------------------------------------------------------------------
  // -------------------------------------------------------------------

  void MeshParametersManager::setLowerLengthSqBound(double lSq)
  {
    lowerLengthSqBound = lSq;
  }

  // -------------------------------------------------------------------

  void MeshParametersManager::setUpperLengthSqBound(double lSq)
  {
    upperLengthSqBound = lSq;
  }

  // -------------------------------------------------------------------
  double MeshParametersManager::getSliverBound(int dim) const
  {
    if (dim==3) return getSliverTetBound();
    return getSliverTriBound();
  }

  // -------------------------------------------------------------------
  double MeshParametersManager::getSliverBound(const pMesh mesh) const
  {
    return getSliverBound(M_dim(mesh));
  }

  // -------------------------------------------------------------------

  void MeshParametersManager::setSliverTriBound(double bound)
  {
    sliverTriQualityBound = bound;
  }

  // -------------------------------------------------------------------

  void MeshParametersManager::setSliverTetBound(double bound)
  {
    sliverTetQualityBound = bound;
  }

  // -------------------------------------------------------------------
  // -------------------------------------------------------------------

  void MeshParametersManager::setSliverPermissionInESplit(bool perm, 
                                                          double bound)
  {
    sliverPermInESplit = perm;
    sliverUpperLengthSqBound = bound;
    if ( sliverUpperLengthSqBound > 0. && 
         sliverUpperLengthSqBound < upperLengthSqBound ) {
      MAdMsgSgl::instance().warning(__LINE__,__FILE__,
                                    "Incoherent parameters: upper length square bound for edge splits creating slivers (%f) is lower than the global upper legnth square bound (%f)",
                                    sliverUpperLengthSqBound,upperLengthSqBound);
    }
  }

  // -------------------------------------------------------------------

  void MeshParametersManager::setSliverPermissionInECollapse(bool perm, 
                                                             double bound)
  {
    sliverPermInECollapse = perm;
    sliverLowerLengthSqBound = bound;
    if ( sliverLowerLengthSqBound > 0. && 
         sliverLowerLengthSqBound > lowerLengthSqBound ) {
      MAdMsgSgl::instance().warning(__LINE__,__FILE__,
                                    "Incoherent parameters: lower length square bound for edge collapses creating slivers (%f) is bigger than the global lower legnth square bound (%f)",
                                    sliverLowerLengthSqBound,lowerLengthSqBound);
    }
  }

  // -------------------------------------------------------------------
  // -------------------------------------------------------------------

  void MeshParametersManager::diagnostics() const
  {
    cout << "   *** Parameters for the mesh adaptation ***   \n";

    cout << "\n";

    cout << "- Bounds of the edge length squared: \n";
    cout << "\t Lower: " << lowerLengthSqBound << "\n";
    cout << "\t Upper: " << upperLengthSqBound << "\n";

    cout << "\n";

    cout << "- Quality bound for the sliver triangles: " 
         << sliverTriQualityBound << "\n";

    cout << "- Quality bound for the sliver tetrahedra: " 
         << sliverTetQualityBound << "\n";

    cout << "\n";

    cout << "Edge splits can create slivers: ";
    if (sliverPermInESplit) {
      cout << "yes: ";
      if ( sliverUpperLengthSqBound < 0) cout << "for any edge.";
      else cout << "if the edge is longer than "<< sliverUpperLengthSqBound<<" (square of adimensional length)";
    }
    else cout << "no";
    cout << "\n";
    cout << "Edge collapses can create slivers: ";
    if (sliverPermInECollapse) {
      cout << "yes: ";
      if ( sliverLowerLengthSqBound < 0) cout << "for any edge.";
      else cout << "the edge is shorter than "<< sliverLowerLengthSqBound<<" (square of adimensional length)";
    }
    else cout << "no";
    cout << "\n";

    cout << "\n";
  }

  // -------------------------------------------------------------------

}