MCPcopy Create free account
hub / github.com/FreeFem/FreeFem-sources / hRefine2

Method hRefine2

plugin/seq/GeometryQA.cpp:166–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164 }
165
166 Edge *Edge::hRefine2(double h, Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator,
167 const Metric2 &metric, safe_vector< Edge * > *recursive, bool exaggerate) {
168 // in the case recursive=!NULL of a recursive split, the safe_vector recursive contains all
169 // newly created edges which are oriented like *this.
170 const R2 Vec = vec( );
171 sym2 m = metric(*u);
172
173 if (exaggerate) {
174 m = m.exaggerate( );
175 }
176
177 double minSize = 1 / m.norm(Vec);
178
179 if (metric.lip == 0) {
180 if (h * minSize < 1) {
181 Edge *const e = refine(EdgeAllocator, VertexAllocator, metric, selected_edge_first);
182 if (recursive) {
183 hRefine2(h, EdgeAllocator, VertexAllocator, metric, recursive, exaggerate);
184 e->hRefine2(h, EdgeAllocator, VertexAllocator, metric, recursive, exaggerate);
185 recursive->push_back(e);
186 }
187
188 return e;
189 }
190
191 return NULL;
192 }
193
194 // If the metric is not constant, it is sampled until resolution allows to make a sensible
195 // choice (based on lip constant). Smallest eigenvalue used only.
196 for (int pow = 1; h * (minSize - metric.lip / (2 * pow)) < 0.5;
197 pow *= 2) { // !!! condition should be checked
198 for (int i = 0; i <= pow; i++) {
199 if (i % 2 == 0) {
200 continue;
201 }
202
203 m = metric((*u * i + *v * (pow - i)) / pow);
204 if (exaggerate) {
205 m = m.exaggerate( );
206 }
207
208 minSize = min(minSize, 1 / m.norm(Vec));
209 if (h * minSize < 1) {
210 Edge *const e = refine(EdgeAllocator, VertexAllocator, metric, selected_edge_first);
211 if (recursive) {
212 hRefine2(h, EdgeAllocator, VertexAllocator, metric, recursive, exaggerate);
213 e->hRefine2(h, EdgeAllocator, VertexAllocator, metric, recursive, exaggerate);
214 recursive->push_back(e);
215 }
216
217 return e;
218 }
219 }
220 }
221
222 return NULL;
223 }

Callers 1

hRefineQAMethod · 0.80

Calls 4

exaggerateMethod · 0.80
minFunction · 0.70
normMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected