Skip to content
Snippets Groups Projects
Commit f5d6bb75 authored by Tom Fischer's avatar Tom Fischer
Browse files

Merge branch 'gmldiff' into 'master'

gmldiff

Closes #3086

See merge request ogs/ogs!3377
parents 83d72692 252180ba
No related branches found
No related tags found
No related merge requests found
...@@ -10,19 +10,16 @@ AddTest( ...@@ -10,19 +10,16 @@ AddTest(
DIFF_DATA Ammer-Rivers-Mapped.gml DIFF_DATA Ammer-Rivers-Mapped.gml
) )
# Disable test on eve frontends AddTest(
if("${HOSTNAME}" MATCHES "envinf1") NAME MapGeometryToMeshSurface_Bode
AddTest( PATH MeshGeoToolsLib/Bode
NAME MapGeometryToMeshSurface_Bode WORKING_DIRECTORY ${Data_SOURCE_DIR}/MeshGeoToolsLib/Bode
PATH MeshGeoToolsLib/Bode EXECUTABLE MapGeometryToMeshSurface
WORKING_DIRECTORY ${Data_SOURCE_DIR}/MeshGeoToolsLib/Bode EXECUTABLE_ARGS -m BodeComplex.msh -i BodeEZG_Fliessgewaesser.gml -a -o ${Data_BINARY_DIR}/MeshGeoToolsLib/Bode/BodeEZG_Fliessgewaesser-Mapped.gml
EXECUTABLE MapGeometryToMeshSurface REQUIREMENTS NOT OGS_USE_MPI
EXECUTABLE_ARGS -m BodeComplex.msh -i BodeEZG_Fliessgewaesser.gml -a -o ${Data_BINARY_DIR}/MeshGeoToolsLib/Bode/BodeEZG_Fliessgewaesser-Mapped.gml TESTER gmldiff
REQUIREMENTS NOT OGS_USE_MPI DIFF_DATA BodeEZG_Fliessgewaesser-Mapped.gml 1e-10 1e-10
TESTER diff )
DIFF_DATA BodeEZG_Fliessgewaesser-Mapped.gml
)
endif()
AddTest( AddTest(
NAME MapGeometryToMeshSurface_Naegelstedt NAME MapGeometryToMeshSurface_Naegelstedt
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# EXECUTABLE_ARGS <arguments> # EXECUTABLE_ARGS <arguments>
# WRAPPER <time|memcheck|callgrind|mpirun> # optional # WRAPPER <time|memcheck|callgrind|mpirun> # optional
# WRAPPER_ARGS <arguments> # optional # WRAPPER_ARGS <arguments> # optional
# TESTER <diff|vtkdiff|memcheck> # optional # TESTER <diff|vtkdiff|gmldiff|memcheck> # optional
# REQUIREMENTS # optional simple boolean expression which has to be true to # REQUIREMENTS # optional simple boolean expression which has to be true to
# enable the test, e.g. # enable the test, e.g.
# OGS_USE_PETSC AND (OGS_USE_EIGEN OR OGS_USE_LIS) # OGS_USE_PETSC AND (OGS_USE_EIGEN OR OGS_USE_LIS)
...@@ -40,6 +40,12 @@ ...@@ -40,6 +40,12 @@
# Searches for all matching files in the working directory (PATH). # Searches for all matching files in the working directory (PATH).
# Matched files are then compared against files with the same name in # Matched files are then compared against files with the same name in
# the benchmark output directory. # the benchmark output directory.
#
# gmldiff-tester
# - DIFF_DATA
# <gml file> <absolute tolerance> <relative tolerance>
# Can be given multiple times; the point coordinates in the gml files are
# compared using the given absolute and relative tolerances.
function (AddTest) function (AddTest)
...@@ -142,6 +148,9 @@ function (AddTest) ...@@ -142,6 +148,9 @@ function (AddTest)
if(AddTest_TESTER STREQUAL "xdmfdiff" AND NOT TARGET xdmfdiff) if(AddTest_TESTER STREQUAL "xdmfdiff" AND NOT TARGET xdmfdiff)
return() return()
endif() endif()
if(AddTest_TESTER STREQUAL "gmldiff" AND NOT ${Python3_Interpreter_FOUND})
return()
endif()
if(AddTest_TESTER STREQUAL "memcheck" AND NOT GREP_TOOL_PATH) if(AddTest_TESTER STREQUAL "memcheck" AND NOT GREP_TOOL_PATH)
return() return()
endif() endif()
...@@ -236,7 +245,25 @@ Use six arguments version of AddTest with absolute and relative tolerances") ...@@ -236,7 +245,25 @@ Use six arguments version of AddTest with absolute and relative tolerances")
else () else ()
message(FATAL_ERROR "For vtkdiff tester the number of diff data arguments must be a multiple of six.") message(FATAL_ERROR "For vtkdiff tester the number of diff data arguments must be a multiple of six.")
endif() endif()
elseif(tester STREQUAL "memcheck") elseif(AddTest_TESTER STREQUAL "gmldiff")
list(LENGTH AddTest_DIFF_DATA DiffDataLength)
math(EXPR DiffDataLastIndex "${DiffDataLength}-1")
foreach(DiffDataIndex RANGE 0 ${DiffDataLastIndex} 3)
list(GET AddTest_DIFF_DATA "${DiffDataIndex}" GML_FILE)
math(EXPR DiffDataAuxIndex "${DiffDataIndex}+1")
list(GET AddTest_DIFF_DATA "${DiffDataAuxIndex}" ABS_TOL)
math(EXPR DiffDataAuxIndex "${DiffDataIndex}+2")
list(GET AddTest_DIFF_DATA "${DiffDataAuxIndex}" REL_TOL)
get_filename_component(FILE_EXPECTED ${GML_FILE} NAME)
list(APPEND TESTER_COMMAND
"${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/test/gmldiff.py \
--abs ${ABS_TOL} --rel ${REL_TOL} \
${TESTER_ARGS} \
${AddTest_SOURCE_PATH}/${FILE_EXPECTED} \
${AddTest_BINARY_PATH}/${GML_FILE}")
endforeach()
elseif(AddTest_TESTER STREQUAL "memcheck")
set(TESTER_COMMAND "! ${GREP_TOOL_PATH} definitely ${AddTest_SOURCE_PATH}/${AddTest_NAME}_memcheck.log") set(TESTER_COMMAND "! ${GREP_TOOL_PATH} definitely ${AddTest_SOURCE_PATH}/${AddTest_NAME}_memcheck.log")
endif() endif()
......
#!/usr/bin/env python3
# Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
# Distributed under a Modified BSD License.
# See accompanying file LICENSE.txt or
# http://www.opengeosys.org/project/license
from xml.dom import minidom
import argparse
import math
parser = argparse.ArgumentParser(description="Diff OpenGeoSys GML files.")
parser.add_argument(
"gmls", metavar="gml", type=str, nargs=2, help="Two gml files to compare"
)
parser.add_argument("--abs", type=float, default=1e-16)
parser.add_argument("--rel", type=float, default=1e-16)
args = parser.parse_args()
docA = minidom.parse(args.gmls[0])
docB = minidom.parse(args.gmls[1])
name = docA.getElementsByTagName("name")[0]
print(
f"Comparing gml with name '{name.firstChild.data}', abs={args.abs}, rel={args.rel}"
)
pointsA = docA.getElementsByTagName("point")
pointsB = docB.getElementsByTagName("point")
if len(pointsA) != len(pointsB):
print("Mismatch of number of points!")
exit(1)
for pointA, pointB in zip(pointsA, pointsB):
if int(pointA.getAttribute("id")) != int(pointB.getAttribute("id")):
print("Points do not have the same order!")
exit(1)
for dim in ["x", "y", "z"]:
a = float(pointA.getAttribute(dim))
b = float(pointB.getAttribute(dim))
if not math.isclose(
a,
b,
rel_tol=args.rel,
abs_tol=args.abs,
):
print(
f"Point with id={pointA.getAttribute('id')} differ: abs={abs(a - b)}, rel={abs(a - b) / b}"
)
exit(1)
polysA = docA.getElementsByTagName("polyline")
polysB = docB.getElementsByTagName("polyline")
if len(polysA) != len(polysB):
print("Mismatch of number of polylines!")
exit(1)
for polyA, polyB in zip(polysA, polysB):
if int(polyA.getAttribute("id")) != int(polyB.getAttribute("id")):
print("Polylines do not have the same order!")
exit(1)
pntsA = polyA.getElementsByTagName("pnt")
pntsB = polyA.getElementsByTagName("pnt")
for pntA, pntB in zip(pntsA, pntsB):
if int(pntA.childNodes[0].nodeValue) != int(pntB.childNodes[0].nodeValue):
print(f"Polyline with id={polyA.getAttribute('id')} differ!")
exit(1)
exit(0)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment