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 ...@@ -183,7 +183,7 @@ public class EikonalSolverFMMTriangulation<P extends PotentialPoint, V extends I
public double getValue(final double x, final double y) { public double getValue(final double x, final double y) {
Optional<F> optFace = triangulation.locateFace(x, y); Optional<F> optFace = triangulation.locateFace(x, y);
double result = 0.0; double result = -1.0;
if(!optFace.isPresent()) { if(!optFace.isPresent()) {
logger.warn("no face found for coordinates (" + x + "," + y + ")"); logger.warn("no face found for coordinates (" + x + "," + y + ")");
} }
......
...@@ -323,7 +323,7 @@ public class PSMeshing { ...@@ -323,7 +323,7 @@ public class PSMeshing {
public void retriangulate() { public void retriangulate() {
//Set<MeshPoint> points = getMesh().getVertices().stream().map(vertex -> getMesh().getPoint(vertex)).collect(Collectors.toSet()); //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)); triangulation = ITriangulation.createPTriangulation(IPointLocator.Type.DELAUNAY_HIERARCHY, getMesh().getPoints(), (x, y) -> new MeshPoint(x, y, false));
removeTrianglesInsideObstacles(); removeTrianglesInsideObstacles();
triangulation.finalize(); triangulation.finalize();
......
...@@ -11,7 +11,7 @@ public class Parameters { ...@@ -11,7 +11,7 @@ public class Parameters {
public final static double h0 = 0.15; public final static double h0 = 0.15;
public final static boolean uniform = false; public final static boolean uniform = false;
public final static String method = "Distmesh"; // "Distmesh" or "Density" 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 MINIMUM = 0.25;
final static double DENSITYWEIGHT = 2; final static double DENSITYWEIGHT = 2;
final static int NPOINTS = 100000; final static int NPOINTS = 100000;
......
...@@ -19,21 +19,21 @@ public class TestEnhancedVersion3 extends JFrame { ...@@ -19,21 +19,21 @@ public class TestEnhancedVersion3 extends JFrame {
private TestEnhancedVersion3() { private TestEnhancedVersion3() {
IDistanceFunction distanceFunc1 = p -> 2 - Math.sqrt((p.getX()-1) * (p.getX()-1) + p.getY() * 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 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 distanceFunc = p -> -10+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 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); //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 + p.distanceToOrigin(); //IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + Math.abs(distanceFunc.apply(p))/2;
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));
//IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + p.distanceToOrigin(); //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 + Math.min(Math.abs(distanceFunc.apply(p) + 4), Math.abs(distanceFunc.apply(p)));
//IEdgeLengthFunction edgeLengthFunc = p -> 1.0; //IEdgeLengthFunction edgeLengthFunc = p -> 1.0;
VRectangle bbox = new VRectangle(-25, -15, 50, 30); 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(); meshGenerator.initialize();
PSMeshingPanel distmeshPanel = new PSMeshingPanel(meshGenerator, 1000, 800); PSMeshingPanel distmeshPanel = new PSMeshingPanel(meshGenerator, 1000, 800);
...@@ -46,7 +46,7 @@ public class TestEnhancedVersion3 extends JFrame { ...@@ -46,7 +46,7 @@ public class TestEnhancedVersion3 extends JFrame {
double avgQuality = 0.0; double avgQuality = 0.0;
long obscuteTriangles = -1; long obscuteTriangles = -1;
int counter = 0; int counter = 0;
while (avgQuality < 0.94) { while (avgQuality <= 0.9318) {
obscuteTriangles = meshGenerator.getTriangles().stream().filter(tri -> tri.isNonAcute()).count(); obscuteTriangles = meshGenerator.getTriangles().stream().filter(tri -> tri.isNonAcute()).count();
PriorityQueue<PFace<MeshPoint>> priorityQueue = meshGenerator.getQuailties(); PriorityQueue<PFace<MeshPoint>> priorityQueue = meshGenerator.getQuailties();
avgQuality = priorityQueue.stream().reduce(0.0, (aDouble, meshPointPFace) -> aDouble + meshGenerator.faceToQuality(meshPointPFace), (d1, d2) -> d1 + d2) / priorityQueue.size(); 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 { ...@@ -60,8 +60,9 @@ public class TestEnhancedVersion3 extends JFrame {
counter++; counter++;
meshGenerator.step(); 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())); System.out.print(TexGraphGenerator.meshToGraph(meshGenerator.getMesh()));
//if(counter == 1) { //if(counter == 1) {
// //
......
...@@ -28,6 +28,7 @@ import java.io.FileWriter; ...@@ -28,6 +28,7 @@ import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
public class TestFFMNonUniformTriangulation { public class TestFFMNonUniformTriangulation {
...@@ -44,7 +45,7 @@ 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; //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; 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; //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 + p.distanceToOrigin()*10;
//IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + Math.abs(distanceFunc.apply(p)); //IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + Math.abs(distanceFunc.apply(p));
...@@ -60,9 +61,10 @@ public class TestFFMNonUniformTriangulation { ...@@ -60,9 +61,10 @@ public class TestFFMNonUniformTriangulation {
public void testTriangulationFMM() { public void testTriangulationFMM() {
IEdgeLengthFunction edgeLengthFunc = p -> 1.0 + Math.min(Math.abs(distanceFunc.apply(p) + 4), Math.abs(distanceFunc.apply(p))); 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<VRectangle> targetAreas = new ArrayList<>();
List<IPoint> targetPoints = 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(); meshGenerator.execute();
triangulation = meshGenerator.getTriangulation(); triangulation = meshGenerator.getTriangulation();
...@@ -72,16 +74,24 @@ public class TestFFMNonUniformTriangulation { ...@@ -72,16 +74,24 @@ public class TestFFMNonUniformTriangulation {
VRectangle rect = new VRectangle(width / 2, height / 2, 100, 100); VRectangle rect = new VRectangle(width / 2, height / 2, 100, 100);
targetAreas.add(rect); 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"); log.info("start FFM");
solver.initialize(); solver.initialize();
log.info("FFM finished"); log.info("FFM finished");
double maxError = 0;
try { try {
//System.out.println(getClass().getClassLoader().getResource("./potentialField.csv").getFile()); //System.out.println(getClass().getClassLoader().getResource("./potentialField.csv").getFile());
FileWriter writer = new FileWriter("./potentialField.csv"); FileWriter writer = new FileWriter("./potentialField.csv");
for(double y = bbox.getMinY()+2; y <= bbox.getMaxY()-2; y += 0.1) { 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) { 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(""+solver.getValue(x ,y) + " ");
} }
writer.write("\n"); writer.write("\n");
...@@ -95,7 +105,9 @@ public class TestFFMNonUniformTriangulation { ...@@ -95,7 +105,9 @@ public class TestFFMNonUniformTriangulation {
} }
log.info(triangulation.getMesh().getVertices().size()); 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(5, 5));
//assertTrue(0.0 < solver.getValue(1, 7)); //assertTrue(0.0 < solver.getValue(1, 7));
} }
...@@ -103,9 +115,12 @@ public class TestFFMNonUniformTriangulation { ...@@ -103,9 +115,12 @@ public class TestFFMNonUniformTriangulation {
@Test @Test
public void testRegularFMM() { 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() 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))); .forEach(p -> cellGrid.setValue(p, new CellState(0.0, PathFindingTag.Target)));
EikonalSolver solver = new EikonalSolverFMM(cellGrid, new ArrayList<>(), false, new UnitTimeCostFunction(), 0.1); EikonalSolver solver = new EikonalSolverFMM(cellGrid, new ArrayList<>(), false, new UnitTimeCostFunction(), 0.1);
...@@ -114,11 +129,20 @@ public class TestFFMNonUniformTriangulation { ...@@ -114,11 +129,20 @@ public class TestFFMNonUniformTriangulation {
log.info("start FFM"); log.info("start FFM");
solver.initialize(); solver.initialize();
log.info("FFM finished"); log.info("FFM finished");
double maxError = 0;
try { try {
//System.out.println(getClass().getClassLoader().getResource("./potentialField.csv").getFile()); //System.out.println(getClass().getClassLoader().getResource("./potentialField.csv").getFile());
FileWriter writer = new FileWriter("./potentialField_reg.csv"); FileWriter writer = new FileWriter("./potentialField_reg.csv");
for(double y = 0; y <= bbox.getHeight()-4; y += 0.1) { for(double y = 0; y <= bbox.getHeight()-4; y += 0.1) {
for(double x = 0; x < bbox.getWidth()-4; x += 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(""+solver.getValue(x,y) + " ");
} }
writer.write("\n"); writer.write("\n");
...@@ -130,6 +154,6 @@ public class TestFFMNonUniformTriangulation { ...@@ -130,6 +154,6 @@ public class TestFFMNonUniformTriangulation {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); 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