Commit 3132971b authored by Dave Moxey's avatar Dave Moxey

Add regression test, some verbose information and fix incorrect functionality...

Add regression test, some verbose information and fix incorrect functionality in the Tester regex module.
parent becc986d
......@@ -51,6 +51,9 @@ namespace Nektar
// We do not mind which order the converged eigenvalues are listed.
m_unordered = true;
// Ignore additional regex matches
m_ignoreExtra = true;
// Regex for FP numbers of forms: 120, -23, 4.345, 2.4563e-01, -nan
std::string fp = "-?\\d+\\.?\\d*(?:e[+-]\\d+)?|-?nan";
......
......@@ -51,6 +51,7 @@ namespace Nektar
// error.
m_regex = "^L 2 error\\s*(?:\\(variable "
"(\\w+)\\))?\\s*:\\s*([+-]?\\d.+\\d|-?\\d|[+-]?nan|[+-]?inf).*";
m_ignoreExtra = true;
// Find the L2 error to match against.
TiXmlElement *value = metric->FirstChildElement("value");
......
......@@ -51,7 +51,8 @@ namespace Nektar
// error.
m_regex = "^L inf\\w* error\\s*(?:\\(variable "
"(\\w+)\\))?\\s*:\\s*([+-]?\\d.+\\d|-?\\d|[+-]?nan|[+-]?inf).*";
m_ignoreExtra = true;
// Find the L2 error to match against.
TiXmlElement *value = metric->FirstChildElement("value");
ASSERTL0(value || m_generate, "Missing value tag for LInf metric!");
......
......@@ -51,8 +51,9 @@ namespace Nektar
Metric(metric, generate)
{
// Default behaviour is that the regexes listed in the input file must
// be matched in order.
// be matched in order and we match everything.
m_unordered = false;
m_ignoreExtra = false;
// If we are a derived class, do nothing
if (m_type != "REGEX")
......@@ -127,13 +128,33 @@ namespace Nektar
// Process output file line by line searching for regex matches
std::string line;
while (getline(pStdout, line) && m_matches.size() > 0)
int gotMatches = 0;
while (getline(pStdout, line))
{
matchedTol = true;
// Test to see if we have a match on this line.
if (boost::regex_match(line.c_str(), matches, m_regex))
{
++gotMatches;
// In this case we have found more matches than are specified in
// the match list. Either ignore this if m_ignoreExtra is set,
// or keep going.
if (m_matches.size() == 0)
{
if (m_ignoreExtra)
{
--gotMatches;
break;
}
else
{
continue;
}
}
// Error if no fields in regex then throw an error.
if (matches.size() == 1)
{
......@@ -251,10 +272,10 @@ namespace Nektar
}
}
if (m_matches.size() != 0)
if (gotMatches != nMatch)
{
cerr << "Expected " << nMatch << " matches but only found "
<< (nMatch - m_matches.size()) << "!" << endl;
cerr << "Expected " << nMatch << " matches but found "
<< gotMatches << "!" << endl;
success = false;
}
......
......@@ -78,6 +78,9 @@ namespace Nektar
std::vector<std::vector<MetricRegexFieldValue> > m_matches;
/// If true, regex matches may be in any order in output
bool m_unordered;
/// If true, ignore any extra matches (i.e. if the output produces more
/// matches than we expect, the additional ones are ignored.
bool m_ignoreExtra;
MetricRegex(TiXmlElement *metric, bool generate);
......
......@@ -98,6 +98,7 @@ ENDIF (NEKTAR_USE_VTK)
# Nektar++
ADD_NEKTAR_TEST (Nektar++/InvalidTetFace)
ADD_NEKTAR_TEST (Nektar++/InvalidQuads)
ADD_NEKTAR_TEST (Nektar++/Tube45Refinement)
ADD_NEKTAR_TEST (Nektar++/Tube45Refinement_extractsurf)
ADD_NEKTAR_TEST (Nektar++/CylQuadBl)
......
......@@ -69,7 +69,9 @@ void ProcessLinear::Process()
bool all = m_config["all"].as<bool>();
bool invalid = m_config["invalid"].as<bool>();
ASSERTL0(all || invalid, "must specify option all or invalid");
ASSERTL0(all || invalid,
"Must specify an option: all (to remove all curvature) or invalid "
"(to remove curvature that makes elements invalid)");
if (all)
{
......@@ -92,11 +94,14 @@ void ProcessLinear::Process()
vector<NodeSharedPtr> empty;
m_mesh->m_element[m_mesh->m_expDim][i]->SetVolumeNodes(empty);
}
if (m_mesh->m_verbose)
{
cerr << "Removed all element curvature" << endl;
}
}
else if (invalid)
{
vector<NodeSharedPtr> zeroNodes;
map<int,vector<FaceSharedPtr> > eidToFace;
map<int,vector<ElementSharedPtr> > eidToElm;
......@@ -126,6 +131,8 @@ void ProcessLinear::Process()
}
set<int> neigh;
vector<NodeSharedPtr> zeroNodes;
boost::unordered_set<int> clearedEdges, clearedFaces, clearedElmts;
// Iterate over list of elements of expansion dimension.
while(el.size() > 0)
......@@ -137,31 +144,41 @@ void ProcessLinear::Process()
el[i]->GetGeom(m_mesh->m_spaceDim);
// Generate geometric factors.
SpatialDomains::GeomFactorsSharedPtr gfac = geom->GetGeomFactors();
SpatialDomains::GeomFactorsSharedPtr gfac =
geom->GetGeomFactors();
if (!gfac->IsValid())
{
clearedElmts.insert(el[i]->GetId());;
el[i]->SetVolumeNodes(zeroNodes);
vector<FaceSharedPtr> f = el[i]->GetFaceList();
for (int j = 0; j < f.size(); j++)
{
f[j]->m_faceNodes = zeroNodes;
f[j]->m_faceNodes.clear();
clearedFaces.insert(f[j]->m_id);
}
vector<EdgeSharedPtr> e = el[i]->GetEdgeList();
for(int j = 0; j < e.size(); j++)
{
e[j]->m_edgeNodes = zeroNodes;
e[j]->m_edgeNodes.clear();
clearedEdges.insert(e[j]->m_id);
}
for(int j = 0; j < e.size(); j++)
if(m_mesh->m_expDim > 2)
{
map<int,vector<FaceSharedPtr> >::iterator it =
eidToFace.find(e[j]->m_id);
for(int k = 0; k < it->second.size(); k++)
for(int j = 0; j < e.size(); j++)
{
it->second[k]->m_faceNodes = zeroNodes;
map<int,vector<FaceSharedPtr> >::iterator it =
eidToFace.find(e[j]->m_id);
for(int k = 0; k < it->second.size(); k++)
{
clearedEdges.insert(it->second[k]->m_id);
it->second[k]->m_faceNodes.clear();
}
}
}
for(int j = 0; j < e.size(); j++)
{
map<int,vector<ElementSharedPtr> >::iterator it =
......@@ -187,6 +204,13 @@ void ProcessLinear::Process()
}
neigh.clear();
}
if (m_mesh->m_verbose)
{
cerr << "Removed curvature from " << clearedElmts.size()
<< " elements (" << clearedEdges.size() << " edges, "
<< clearedFaces.size() << " faces)" << endl;
}
}
}
}
......
<?xml version="1.0" encoding="utf-8" ?>
<test>
<description>Remove curvature from invalid quads</description>
<executable>NekMesh</executable>
<parameters>-m jac:list -m linearise:invalid -m jac:list InvalidQuads.xml InvalidQuadsOut.xml:xml:test</parameters>
<files>
<file description="Input File">InvalidQuads.xml</file>
</files>
<metrics>
<metric type="regex" id="1">
<regex>^Total negative Jacobians: (\d+)</regex>
<matches>
<match>
<field id="0">1</field>
</match>
<match>
<field id="0">0</field>
</match>
</matches>
</metric>
</metrics>
</test>
<?xml version="1.0" encoding="utf-8" ?>
<NEKTAR>
<GEOMETRY DIM="2" SPACE="2">
<VERTEX>
<V ID="0">-5.00000000e-01 -5.00000000e-01 0.00000000e+00</V>
<V ID="1">-1.66666667e-01 -5.00000000e-01 0.00000000e+00</V>
<V ID="2">-1.66666667e-01 -1.66666667e-01 0.00000000e+00</V>
<V ID="3">-5.00000000e-01 -1.66666667e-01 0.00000000e+00</V>
<V ID="4">-1.66666667e-01 1.66666667e-01 0.00000000e+00</V>
<V ID="5">-5.00000000e-01 1.66666667e-01 0.00000000e+00</V>
<V ID="6">-1.66666667e-01 5.00000000e-01 0.00000000e+00</V>
<V ID="7">-5.00000000e-01 5.00000000e-01 0.00000000e+00</V>
<V ID="8">1.66666667e-01 -5.00000000e-01 0.00000000e+00</V>
<V ID="9">1.66666667e-01 -1.66666667e-01 0.00000000e+00</V>
<V ID="10">1.66666667e-01 1.66666667e-01 0.00000000e+00</V>
<V ID="11">1.66666667e-01 5.00000000e-01 0.00000000e+00</V>
<V ID="12">5.00000000e-01 -5.00000000e-01 0.00000000e+00</V>
<V ID="13">5.00000000e-01 -1.66666667e-01 0.00000000e+00</V>
<V ID="14">5.00000000e-01 1.66666667e-01 0.00000000e+00</V>
<V ID="15">5.00000000e-01 5.00000000e-01 0.00000000e+00</V>
</VERTEX>
<EDGE>
<E ID="0"> 0 1 </E>
<E ID="1"> 1 2 </E>
<E ID="2"> 2 3 </E>
<E ID="3"> 3 0 </E>
<E ID="4"> 2 4 </E>
<E ID="5"> 4 5 </E>
<E ID="6"> 5 3 </E>
<E ID="7"> 4 6 </E>
<E ID="8"> 6 7 </E>
<E ID="9"> 7 5 </E>
<E ID="10"> 1 8 </E>
<E ID="11"> 8 9 </E>
<E ID="12"> 9 2 </E>
<E ID="13"> 9 10 </E>
<E ID="14"> 10 4 </E>
<E ID="15"> 10 11 </E>
<E ID="16"> 11 6 </E>
<E ID="17"> 8 12 </E>
<E ID="18"> 12 13 </E>
<E ID="19"> 13 9 </E>
<E ID="20"> 13 14 </E>
<E ID="21"> 14 10 </E>
<E ID="22"> 14 15 </E>
<E ID="23"> 15 11 </E>
</EDGE>
<ELEMENT>
<Q ID="0"> 0 1 2 3 </Q>
<Q ID="1"> 2 4 5 6 </Q>
<Q ID="2"> 5 7 8 9 </Q>
<Q ID="3"> 10 11 12 1 </Q>
<Q ID="4"> 12 13 14 4 </Q>
<Q ID="5"> 14 15 16 7 </Q>
<Q ID="6"> 17 18 19 11 </Q>
<Q ID="7"> 19 20 21 13 </Q>
<Q ID="8"> 21 22 23 15 </Q>
</ELEMENT>
<CURVED>
<E ID="0" EDGEID="22" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> 5.00000000e-01 1.66666667e-01 0.00000000e+00 5.00000000e-01 2.77777778e-01 0.00000000e+00 5.00000000e-01 3.88888889e-01 0.00000000e+00 5.00000000e-01 5.00000000e-01 0.00000000e+00 </E>
<E ID="1" EDGEID="20" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> 5.00000000e-01 -1.66666667e-01 0.00000000e+00 5.00000000e-01 -5.55555556e-02 0.00000000e+00 5.00000000e-01 5.55555556e-02 0.00000000e+00 5.00000000e-01 1.66666667e-01 0.00000000e+00 </E>
<E ID="2" EDGEID="19" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> 5.00000000e-01 -1.66666667e-01 0.00000000e+00 3.88888889e-01 -1.66666667e-01 0.00000000e+00 2.77777778e-01 -1.66666667e-01 0.00000000e+00 1.66666667e-01 -1.66666667e-01 0.00000000e+00 </E>
<E ID="3" EDGEID="18" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> 5.00000000e-01 -5.00000000e-01 0.00000000e+00 5.00000000e-01 -3.88888889e-01 0.00000000e+00 5.00000000e-01 -2.77777778e-01 0.00000000e+00 5.00000000e-01 -1.66666667e-01 0.00000000e+00 </E>
<E ID="4" EDGEID="17" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> 1.66666667e-01 -5.00000000e-01 0.00000000e+00 2.77777778e-01 -5.00000000e-01 0.00000000e+00 3.88888889e-01 -5.00000000e-01 0.00000000e+00 5.00000000e-01 -5.00000000e-01 0.00000000e+00 </E>
<E ID="5" EDGEID="16" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> 1.66666667e-01 5.00000000e-01 0.00000000e+00 5.55555556e-02 5.00000000e-01 0.00000000e+00 -5.55555556e-02 5.00000000e-01 0.00000000e+00 -1.66666667e-01 5.00000000e-01 0.00000000e+00 </E>
<E ID="6" EDGEID="13" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> 1.66666667e-01 -1.66666667e-01 0.00000000e+00 1.66666667e-01 -5.55555556e-02 0.00000000e+00 1.66666667e-01 5.55555556e-02 0.00000000e+00 1.66666667e-01 1.66666667e-01 0.00000000e+00 </E>
<E ID="7" EDGEID="12" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> 1.66666667e-01 -1.66666667e-01 0.00000000e+00 5.55555556e-02 -1.66666667e-01 0.00000000e+00 -5.55555556e-02 -1.66666667e-01 0.00000000e+00 -1.66666667e-01 -1.66666667e-01 0.00000000e+00 </E>
<E ID="8" EDGEID="11" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> 1.66666667e-01 -5.00000000e-01 0.00000000e+00 1.66666667e-01 -3.88888889e-01 0.00000000e+00 1.66666667e-01 -2.77777778e-01 0.00000000e+00 1.66666667e-01 -1.66666667e-01 0.00000000e+00 </E>
<E ID="9" EDGEID="23" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> 5.00000000e-01 5.00000000e-01 0.00000000e+00 3.88888889e-01 5.00000000e-01 0.00000000e+00 2.77777778e-01 5.00000000e-01 0.00000000e+00 1.66666667e-01 5.00000000e-01 0.00000000e+00 </E>
<E ID="10" EDGEID="10" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> -1.66666667e-01 -5.00000000e-01 0.00000000e+00 -5.55555556e-02 -5.00000000e-01 0.00000000e+00 5.55555556e-02 -5.00000000e-01 0.00000000e+00 1.66666667e-01 -5.00000000e-01 0.00000000e+00 </E>
<E ID="11" EDGEID="21" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> 5.00000000e-01 1.66666667e-01 0.00000000e+00 3.88888889e-01 1.66666667e-01 0.00000000e+00 2.77777778e-01 1.66666667e-01 0.00000000e+00 1.66666667e-01 1.66666667e-01 0.00000000e+00 </E>
<E ID="12" EDGEID="7" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> -1.66666667e-01 1.66666667e-01 0.00000000e+00 -1.66666667e-01 2.77777778e-01 0.00000000e+00 -1.66666667e-01 3.88888889e-01 0.00000000e+00 -1.66666667e-01 5.00000000e-01 0.00000000e+00 </E>
<E ID="13" EDGEID="8" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> -1.66666667e-01 5.00000000e-01 0.00000000e+00 -2.77777778e-01 5.00000000e-01 0.00000000e+00 -3.88888889e-01 5.00000000e-01 0.00000000e+00 -5.00000000e-01 5.00000000e-01 0.00000000e+00 </E>
<E ID="14" EDGEID="14" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> 1.66666667e-01 1.66666667e-01 0.00000000e+00 5.55555556e-02 1.66666667e-01 0.00000000e+00 -5.55555556e-02 1.66666667e-01 0.00000000e+00 -1.66666667e-01 1.66666667e-01 0.00000000e+00 </E>
<E ID="15" EDGEID="6" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> -5.00000000e-01 1.66666667e-01 0.00000000e+00 -5.00000000e-01 5.55555556e-02 0.00000000e+00 -5.00000000e-01 -5.55555556e-02 0.00000000e+00 -5.00000000e-01 -1.66666667e-01 0.00000000e+00 </E>
<E ID="16" EDGEID="5" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> -1.66666667e-01 1.66666667e-01 0.00000000e+00 -2.77777778e-01 1.66666667e-01 0.00000000e+00 -3.88888889e-01 1.66666667e-01 0.00000000e+00 -5.00000000e-01 1.66666667e-01 0.00000000e+00 </E>
<E ID="17" EDGEID="15" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> 1.66666667e-01 1.66666667e-01 0.00000000e+00 1.66666667e-01 2.77777778e-01 0.00000000e+00 9.66666667e-01 3.88888889e-01 0.00000000e+00 1.66666667e-01 5.00000000e-01 0.00000000e+00 </E>
<E ID="18" EDGEID="4" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> -1.66666667e-01 -1.66666667e-01 0.00000000e+00 -1.66666667e-01 -5.55555556e-02 0.00000000e+00 -1.66666667e-01 5.55555556e-02 0.00000000e+00 -1.66666667e-01 1.66666667e-01 0.00000000e+00 </E>
<E ID="19" EDGEID="9" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> -5.00000000e-01 5.00000000e-01 0.00000000e+00 -5.00000000e-01 3.88888889e-01 0.00000000e+00 -5.00000000e-01 2.77777778e-01 0.00000000e+00 -5.00000000e-01 1.66666667e-01 0.00000000e+00 </E>
<E ID="20" EDGEID="3" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> -5.00000000e-01 -1.66666667e-01 0.00000000e+00 -5.00000000e-01 -2.77777778e-01 0.00000000e+00 -5.00000000e-01 -3.88888889e-01 0.00000000e+00 -5.00000000e-01 -5.00000000e-01 0.00000000e+00 </E>
<E ID="21" EDGEID="2" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> -1.66666667e-01 -1.66666667e-01 0.00000000e+00 -2.77777778e-01 -1.66666667e-01 0.00000000e+00 -3.88888889e-01 -1.66666667e-01 0.00000000e+00 -5.00000000e-01 -1.66666667e-01 0.00000000e+00 </E>
<E ID="22" EDGEID="1" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> -1.66666667e-01 -5.00000000e-01 0.00000000e+00 -1.66666667e-01 -3.88888889e-01 0.00000000e+00 -1.66666667e-01 -2.77777778e-01 0.00000000e+00 -1.66666667e-01 -1.66666667e-01 0.00000000e+00 </E>
<E ID="23" EDGEID="0" NUMPOINTS="4" TYPE="PolyEvenlySpaced"> -5.00000000e-01 -5.00000000e-01 0.00000000e+00 -3.88888889e-01 -5.00000000e-01 0.00000000e+00 -2.77777778e-01 -5.00000000e-01 0.00000000e+00 -1.66666667e-01 -5.00000000e-01 0.00000000e+00 </E>
</CURVED>
<COMPOSITE>
<C ID="0"> Q[0-8] </C>
<C ID="1"> E[0,10,17] </C>
<C ID="2"> E[18,20,22] </C>
<C ID="3"> E[8,16,23] </C>
<C ID="4"> E[3,6,9] </C>
</COMPOSITE>
<DOMAIN> C[0] </DOMAIN>
</GEOMETRY>
<EXPANSIONS>
<E COMPOSITE="C[0]" NUMMODES="4" TYPE="MODIFIED" FIELDS="u" />
</EXPANSIONS>
<CONDITIONS />
</NEKTAR>
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