Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 7d728459 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

some changes for the adaptive triangulation

parent 6ac97cb1
......@@ -183,7 +183,7 @@ public class EikonalSolverFMMTriangulation<P extends PotentialPoint, V extends I
public double getValue(final double x, final double y) {
Optional<F> optFace = triangulation.locateFace(x, y);
double result = 0.0;
double result = -1.0;
if(!optFace.isPresent()) {
logger.warn("no face found for coordinates (" + x + "," + y + ")");
}
......
......@@ -323,7 +323,7 @@ public class PSMeshing {
public void retriangulate() {
//Set<MeshPoint> points = getMesh().getVertices().stream().map(vertex -> getMesh().getPoint(vertex)).collect(Collectors.toSet());
//removeLowQualityTriangles();
removeLowQualityTriangles();
triangulation = ITriangulation.createPTriangulation(IPointLocator.Type.DELAUNAY_HIERARCHY, getMesh().getPoints(), (x, y) -> new MeshPoint(x, y, false));
removeTrianglesInsideObstacles();
triangulation.finalize();
......
......@@ -11,7 +11,7 @@ public class Parameters {
public final static double h0 = 0.15;
public final static boolean uniform = false;
public final static String method = "Distmesh"; // "Distmesh" or "Density"
final static double qualityMeasurement = 0.949;
final static double qualityMeasurement = 0.928;
final static double MINIMUM = 0.25;
final static double DENSITYWEIGHT = 2;
final static int NPOINTS = 100000;
......
......@@ -19,21 +19,21 @@ public class TestEnhancedVersion3 extends JFrame {
private TestEnhancedVersion3() {
IDistanceFunction distanceFunc1 = p -> 2 - Math.sqrt((p.getX()-1) * (p.getX()-1) + p.getY() * p.getY());
IDistanceFunction distanceFunc3 = p -> 2 - Math.sqrt((p.getX()-5) * (p.getX()-5) + p.getY() * p.getY());
//IDistanceFunction distanceFunc = p -> -10+Math.Math.sqrt(p.getX() * p.getX() + p.getY() * p.getY());
IDistanceFunction distanceFunc2 = p -> 2 - Math.max(Math.abs(p.getX()-3), Math.abs(p.getY()));
//IDistanceFunction distanceFunc1 = p -> 2 - Math.sqrt((p.getX()-1) * (p.getX()-1) + p.getY() * p.getY());
//IDistanceFunction distanceFunc3 = p -> 2 - Math.sqrt((p.getX()-5) * (p.getX()-5) + p.getY() * p.getY());
//IDistanceFunction distanceFunc = p -> -10+Math.sqrt(p.getX() * p.getX() + p.getY() * p.getY());
//IDistanceFunction distanceFunc = p -> 2 - Math.max(Math.abs(p.getX()-3), Math.abs(p.getY()));
IDistanceFunction distanceFunc = p -> Math.abs(6 - Math.sqrt(p.getX() * p.getX() + p.getY() * p.getY())) - 4;
//IDistanceFunction distanceFunc4 = p -> Math.max(Math.abs(p.getY()) - 4, Math.abs(p.getX()) - 25);
IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + p.distanceToOrigin();
IDistanceFunction distanceFunc4 = p -> Math.max(Math.abs(p.getY()) - 4, Math.abs(p.getX()) - 25);
//IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + p.distanceToOrigin();
IDistanceFunction distanceFunc = p -> Math.max(Math.max(Math.max(distanceFunc1.apply(p), distanceFunc2.apply(p)), distanceFunc3.apply(p)), distanceFunc4.apply(p));
IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + Math.abs(distanceFunc.apply(p));
//IDistanceFunction distanceFunc = p -> Math.max(Math.max(Math.max(distanceFunc1.apply(p), distanceFunc2.apply(p)), distanceFunc3.apply(p)), distanceFunc4.apply(p));
//IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + Math.abs(distanceFunc.apply(p))/2;
//IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + p.distanceToOrigin();
//IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + Math.min(Math.abs(distanceFunc.apply(p) + 4), Math.abs(distanceFunc.apply(p)));
//IEdgeLengthFunction edgeLengthFunc = p -> 1.0;
VRectangle bbox = new VRectangle(-25, -15, 50, 30);
PSMeshing meshGenerator = new PSMeshing(distanceFunc, edgeLengthFunc, 0.3, bbox, new ArrayList<>());
PSMeshing meshGenerator = new PSMeshing(distanceFunc, edgeLengthFunc, 0.6, bbox, new ArrayList<>());
meshGenerator.initialize();
PSMeshingPanel distmeshPanel = new PSMeshingPanel(meshGenerator, 1000, 800);
......@@ -46,7 +46,7 @@ public class TestEnhancedVersion3 extends JFrame {
double avgQuality = 0.0;
long obscuteTriangles = -1;
int counter = 0;
while (avgQuality < 0.94) {
while (avgQuality <= 0.9318) {
obscuteTriangles = meshGenerator.getTriangles().stream().filter(tri -> tri.isNonAcute()).count();
PriorityQueue<PFace<MeshPoint>> priorityQueue = meshGenerator.getQuailties();
avgQuality = priorityQueue.stream().reduce(0.0, (aDouble, meshPointPFace) -> aDouble + meshGenerator.faceToQuality(meshPointPFace), (d1, d2) -> d1 + d2) / priorityQueue.size();
......@@ -60,8 +60,9 @@ public class TestEnhancedVersion3 extends JFrame {
counter++;
meshGenerator.step();
}
//System.out.print("finished:" + meshGenerator.getMesh().getVertices().stream().filter(v -> !meshGenerator.getMesh().isDestroyed(v)).count());
System.out.print("finished:" + avgQuality);
//System.out.print("finished:" + avgQuality);
System.out.print(TexGraphGenerator.meshToGraph(meshGenerator.getMesh()));
//if(counter == 1) {
//
......
......@@ -28,6 +28,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class TestFFMNonUniformTriangulation {
......@@ -44,7 +45,7 @@ public class TestFFMNonUniformTriangulation {
//IDistanceFunction distanceFunc = p -> Math.abs(7 - Math.sqrt(p.getX() * p.getX() + p.getY() * p.getY())) - 3;
distanceFunc = p -> Math.abs(6 - Math.sqrt(p.getX() * p.getX() + p.getY() * p.getY())) - 4;
//IDistanceFunction distanceFunc = p -> -10+Math.sqrt(p.getX() * p.getX() + p.getY() * p.getY());
//distanceFunc = p -> -10+Math.sqrt(p.getX() * p.getX() + p.getY() * p.getY());
//IDistanceFunction distanceFunc = p -> Math.abs(7 - Math.max(Math.abs(p.getX()), Math.abs(p.getY()))) - 3;
//IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + p.distanceToOrigin()*10;
//IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + Math.abs(distanceFunc.apply(p));
......@@ -60,9 +61,10 @@ public class TestFFMNonUniformTriangulation {
public void testTriangulationFMM() {
IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + Math.min(Math.abs(distanceFunc.apply(p) + 4), Math.abs(distanceFunc.apply(p)));
IEdgeLengthFunction unifromEdgeLengthFunc = p -> 1.0;
List<VRectangle> targetAreas = new ArrayList<>();
List<IPoint> targetPoints = new ArrayList<>();
PSMeshing meshGenerator = new PSMeshing(distanceFunc, edgeLengthFunc, 0.4, bbox, new ArrayList<>());
PSMeshing meshGenerator = new PSMeshing(distanceFunc, edgeLengthFunc, 0.6, bbox, new ArrayList<>());
meshGenerator.execute();
triangulation = meshGenerator.getTriangulation();
......@@ -72,16 +74,24 @@ public class TestFFMNonUniformTriangulation {
VRectangle rect = new VRectangle(width / 2, height / 2, 100, 100);
targetAreas.add(rect);
EikonalSolver solver = new EikonalSolverFMMTriangulation(new UnitTimeCostFunction(), triangulation, triangulation.getMesh().getBoundaryVertices());
EikonalSolver solver = new EikonalSolverFMMTriangulation(new UnitTimeCostFunction(), triangulation,
triangulation.getMesh().getBoundaryVertices().stream().collect(Collectors.toList()));
log.info("start FFM");
solver.initialize();
log.info("FFM finished");
double maxError = 0;
try {
//System.out.println(getClass().getClassLoader().getResource("./potentialField.csv").getFile());
FileWriter writer = new FileWriter("./potentialField.csv");
for(double y = bbox.getMinY()+2; y <= bbox.getMaxY()-2; y += 0.1) {
for(double x = bbox.getMinX()+2; x < bbox.getMaxX()-2; x += 0.1) {
double val = solver.getValue(x ,y);
if(val >= 0.0) {
double side = Math.min((new VPoint(x, y).distanceToOrigin()-2.0), (10 - new VPoint(x, y).distanceToOrigin()));
side = Math.max(side, 0.0);
maxError = Math.max(maxError, Math.abs(val - side));
}
writer.write(""+solver.getValue(x ,y) + " ");
}
writer.write("\n");
......@@ -95,7 +105,9 @@ public class TestFFMNonUniformTriangulation {
}
log.info(triangulation.getMesh().getVertices().size());
log.info(solver.getValue(2.1,2.1));
log.info("max edge length: " + triangulation.getMesh().streamEdges().map(e -> triangulation.getMesh().toLine(e).length()).max((d1, d2) -> Double.compare(d1, d2)));
log.info("min edge length: " +triangulation.getMesh().streamEdges().map(e -> triangulation.getMesh().toLine(e).length()).min((d1, d2) -> Double.compare(d1, d2)));
log.info("max error: " + maxError);
//assertTrue(0.0 == solver.getValue(5, 5));
//assertTrue(0.0 < solver.getValue(1, 7));
}
......@@ -103,9 +115,12 @@ public class TestFFMNonUniformTriangulation {
@Test
public void testRegularFMM() {
CellGrid cellGrid = new CellGrid(bbox.getWidth()-4, bbox.getHeight()-4,0.4, new CellState());
double resolution = 0.4;
double rad = 2.0;
CellGrid cellGrid = new CellGrid(bbox.getWidth()-4, bbox.getHeight()-4,resolution, new CellState());
cellGrid.pointStream()
.filter(p -> distanceFunc.apply(new VPoint(bbox.getMinX()+2+p.getX() * 0.4, bbox.getMinY()+2 + p.getY() * 0.4)) >= 0)
.filter(p -> new VPoint(p.getX() * resolution, p.getY() * resolution).distance(new VPoint(10, 10)) <= rad
|| new VPoint(p.getX() * resolution, p.getY() * resolution).distance(new VPoint(10, 10)) >= 10)
.forEach(p -> cellGrid.setValue(p, new CellState(0.0, PathFindingTag.Target)));
EikonalSolver solver = new EikonalSolverFMM(cellGrid, new ArrayList<>(), false, new UnitTimeCostFunction(), 0.1);
......@@ -114,11 +129,20 @@ public class TestFFMNonUniformTriangulation {
log.info("start FFM");
solver.initialize();
log.info("FFM finished");
double maxError = 0;
try {
//System.out.println(getClass().getClassLoader().getResource("./potentialField.csv").getFile());
FileWriter writer = new FileWriter("./potentialField_reg.csv");
for(double y = 0; y <= bbox.getHeight()-4; y += 0.1) {
for(double x = 0; x < bbox.getWidth()-4; x += 0.1) {
double val = solver.getValue(x ,y);
if(val >= 0.0) {
double side = Math.min(new VPoint(x, y).distance(new VPoint(10, 10))-2.0, 10 - new VPoint(x, y).distance(new VPoint(10, 10)));
side = Math.max(side, 0.0);
//double distance = (new VPoint(x, y).distance(new VPoint(10, 10)))-rad;
//maxError = Math.max(maxError, Math.abs((distance >= 0.0 ? val-distance : val)));
maxError = Math.max(maxError, Math.abs(val - side));
}
writer.write(""+solver.getValue(x,y) + " ");
}
writer.write("\n");
......@@ -130,6 +154,6 @@ public class TestFFMNonUniformTriangulation {
} catch (IOException e) {
e.printStackTrace();
}
log.info(solver.getValue(2,5));
log.info("max error: " + maxError);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment