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

Function trackP1isoline

plugin/seq/plotPDF.cpp:1306–1358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1304
1305//---------------------------------------------------------------------------
1306// P1 Finite Element (also used in P1nc : Non-Conforming Finite Element)
1307//---------------------------------------------------------------------------
1308
1309void trackP1isoline( std::vector<double> &px, std::vector<double> &py,
1310 const double *const vx, const double *const vy,
1311 const double value, const double *const vf )
1312{
1313 const double TOLERANCE = 1e-12;
1314
1315 const int nVertices_in_each_Element = 3;
1316
1317 for(int i = 0; i < nVertices_in_each_Element; i++){
1318
1319 const double &x0 = vx[i];
1320 const double &y0 = vy[i];
1321 const double &f0 = vf[i];
1322
1323 const double &x1 = vx[(i+1)%3];
1324 const double &y1 = vy[(i+1)%3];
1325 const double &f1 = vf[(i+1)%3];
1326
1327 if( (value < f0) && (value < f1) ) // no cossing point
1328 continue;
1329
1330 if( (f0 < value) && (f1 < value) ) // no crossing point
1331 continue;
1332
1333 if( (fabs(f0-f1) < TOLERANCE) && (fabs(f0-value) < TOLERANCE) ){ // coinside: edge is isoline
1334 px.push_back( x0 );
1335 py.push_back( y0 );
1336 px.push_back( x1 );
1337 py.push_back( y1 );
1338 continue;
1339 }
1340
1341 const double t = (value-f0)/(f1-f0); // (1-t)*f0 + t*f1 = value
1342 const double x = (1-t)*x0 + t*x1;
1343 const double y = (1-t)*y0 + t*y1;
1344
1345 px.push_back( x );
1346 py.push_back( y );
1347 }
1348
1349 if( px.size() == 3 ){ // if f(x,y)==value on either vertex
1350
1351 if( (px[0] == px[1]) && (py[0] == py[1]) ){
1352 px[1] = px[2];
1353 py[1] = py[2];
1354 }
1355
1356 //if( (px[1] == px[2]) && (py[1] == py[2]) ) // node 0 is differ from node 1
1357 //if( (px[2] == px[0]) && (py[2] == py[0]) ) // node 0 is differ from node 1
1358 }
1359
1360 return;
1361}

Callers 2

plot_P1_isoline_bodyFunction · 0.85
plot_P2_isoline_bodyFunction · 0.85

Calls 3

fabsFunction · 0.50
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected