Commit 689f5dd8 authored by Dave Moxey's avatar Dave Moxey

Merge branch 'fix/FC_ReadDat' into 'master'

Fix/fc read dat

Fixes related to isocontour: Corrected the tolerance and restructred logic to globalcondense in ProcessIsoContour, Updated the InputDat.cpp file to be case insensitive.

See merge request !719
parents eb439808 a76a0fb9
......@@ -55,6 +55,7 @@ v4.4.0
- Allow equi-spaced output for 1D and 2DH1D fields (!613)
- Update quality metric to include scaled Jacobian output (!695)
- Allow multiple XML files to be specified in InterpField module (!705)
- Fix issues with isocontour module (!719)
**NekMesh:**
- Modify curve module to allow for spline input (!628)
......
......@@ -107,8 +107,9 @@ void InputDat::Process(po::variables_map &vm)
while (!datFile.eof())
{
getline(datFile, line);
if (line.find("VARIABLES") != string::npos)
string linetest = line;
boost::to_upper(linetest);
if (linetest.find("VARIABLES") != string::npos)
{
std::size_t pos = line.find('=');
pos++;
......@@ -138,10 +139,9 @@ void InputDat::Process(po::variables_map &vm)
while (!datFile.eof())
{
getline(datFile, line);
if ((line.find("ZONE") != string::npos) ||
(line.find("Zone") != string::npos) ||
(line.find("zone") != string::npos))
string linetest = line;
boost::to_upper(linetest);
if ((linetest.find("ZONE") != string::npos))
{
ReadTecplotFEBlockZone(datFile, line, pts, ptsConn);
}
......
......@@ -795,16 +795,20 @@ void OutputTecplot::WriteTecplotConnectivity(std::ofstream &outfile)
}
else
{
int cnt = 1;
for (int i = 0; i < m_conn.size(); ++i)
{
const int nConn = m_conn[i].num_elements();
for (int j = 0; j < nConn; ++j)
for (int j = 0; j < nConn; ++j,++cnt)
{
outfile << m_conn[i][j] + 1 << " ";
if (!(cnt % 1000))
{
outfile << std::endl;
}
}
outfile << endl;
}
outfile << endl;
if (m_oneOutputFile && m_f->m_comm->GetRank() == 0)
{
......@@ -814,7 +818,6 @@ void OutputTecplot::WriteTecplotConnectivity(std::ofstream &outfile)
{
Array<OneD, int> conn(m_rankConnSizes[n]);
m_f->m_comm->Recv(n, conn);
for (int j = 0; j < conn.num_elements(); ++j)
{
outfile << conn[j] + offset + 1 << " ";
......
......@@ -131,6 +131,11 @@ void ProcessIsoContour::Process(po::variables_map &vm)
if(m_f->m_fieldPts.get()) // assume we have read .dat file to directly input dat file.
{
if(rank == 0)
{
cout << "Process read iso from Field Pts" << endl;
}
SetupIsoFromFieldPts(iso);
}
else // extract isocontour from field
......@@ -196,6 +201,10 @@ void ProcessIsoContour::Process(po::variables_map &vm)
bool globalcondense = m_config["globalcondense"].m_beenSet;
if(globalcondense)
{
if(rank == 0)
{
cout << "Process global condense ..." << endl;
}
int nfields = m_f->m_fieldPts->GetNFields() + m_f->m_fieldPts->GetDim();
IsoSharedPtr g_iso = MemoryManager<Iso>::AllocateSharedPtr(nfields-3);
......@@ -832,13 +841,21 @@ void Iso::GlobalCondense(vector<IsoSharedPtr> &iso, bool verbose)
{
for(id1 = 0; id1 < iso[i]->m_nvert; ++id1)
{
inPoints.push_back(PointPair(BPoint( iso[i]->m_x[id1], iso[i]->m_y[id1], iso[i]->m_z[id1]), id2));
inPoints.push_back(PointPair(BPoint( iso[i]->m_x[id1],
iso[i]->m_y[id1],
iso[i]->m_z[id1]), id2));
global_to_unique_map[id2]=id2;
global_to_iso_map[id2] = make_pair(i,id1);
id2++;
}
}
if(verbose)
{
cout << "Process building tree ..." << endl;
}
//Build tree
bgi::rtree<PointPair, bgi::rstar<16> > rtree;
rtree.insert(inPoints.begin(), inPoints.end());
......@@ -851,49 +868,58 @@ void Iso::GlobalCondense(vector<IsoSharedPtr> &iso, bool verbose)
{
if(verbose)
{
prog = LibUtilities::PrintProgressbar(i,m_nvert,"Nearest verts",prog);
prog = LibUtilities::PrintProgressbar(i,m_nvert,
"Nearest verts",prog);
}
BPoint queryPoint = inPoints[i].first;
// find points within the distance box
std::vector<PointPair> result;
rtree.query(bgi::nearest(queryPoint, 100), std::back_inserter(result));
WARNINGL1(result.size() < 100,"Failed to find less than 100 neighbouring points");
id1 = 0;
unique_index_found = false;
int nptsfound = 0;
WARNINGL1(result.size() > 0,"Failed to find any nearest point");
for(id1 = 0; id1 < result.size(); ++id1)
// check to see if point has been already reset to lower than
// unique value
if(global_to_unique_map[i] < unique_index) // do nothing
{
}
else
{
if(bg::distance(queryPoint, result[id1].first)<SQ_PNT_TOL)
// find nearest 10 points within the distance box
std::vector<PointPair> result;
rtree.query(bgi::nearest(queryPoint, 10), std::back_inserter(result));
//see if any values have unique value already
set<int> samept;
set<int>::iterator it;
int new_index = -1;
for(id1 = 0; id1 < result.size(); ++id1)
{
id2 = result[id1].second;
nptsfound ++;
if(global_to_unique_map[id2] <unique_index)
NekDouble dist = bg::distance(queryPoint, result[id1].first);
if(dist*dist<SQ_PNT_TOL) // same point
{
// point has already been defined
continue;
}
else
{
global_to_unique_map[id2] = unique_index;
unique_index_found = true;
id2 = result[id1].second;
samept.insert(id2);
if(global_to_unique_map[id2] <unique_index)
{
new_index = global_to_unique_map[id2];
}
}
}
}
WARNINGL1(nptsfound > 0,"Failed to find any nearest point");
if(new_index == -1)
{
new_index = unique_index;
unique_index++;
}
if(unique_index_found)
{
unique_index++;
// reset all same values to new_index
global_to_unique_map[i] = new_index;
for(it = samept.begin(); it != samept.end(); ++it)
{
global_to_unique_map[*it] = new_index;
}
}
}
if(verbose)
{
cout << endl;
......@@ -946,14 +972,14 @@ void Iso::GlobalCondense(vector<IsoSharedPtr> &iso, bool verbose)
}
// define == if point is within 1e-4
// define == if point is within 1e-8
bool operator == (const IsoVertex& x, const IsoVertex& y)
{
return ((x.m_x-y.m_x)*(x.m_x-y.m_x) + (x.m_y-y.m_y)*(x.m_y-y.m_y) +
(x.m_z-y.m_z)*(x.m_z-y.m_z) < SQ_PNT_TOL)? true:false;
}
// define != if point is outside 1e-4
// define != if point is outside 1e-8
bool operator != (const IsoVertex& x, const IsoVertex& y)
{
return ((x.m_x-y.m_x)*(x.m_x-y.m_x) + (x.m_y-y.m_y)*(x.m_y-y.m_y) +
......
......@@ -53,7 +53,7 @@ namespace Nektar
namespace FieldUtils
{
const NekDouble SQ_PNT_TOL=1e-6;
const NekDouble SQ_PNT_TOL=1e-16;
class Iso
{
......
......@@ -28,6 +28,7 @@ ADD_NEKTAR_TEST(outflow_pointdatatofld)
ADD_NEKTAR_TEST(chan3D_equispacedoutput)
ADD_NEKTAR_TEST(chan3D_isocontour)
ADD_NEKTAR_TEST(naca0012_bnd_equispacedoutput)
ADD_NEKTAR_TEST(smallmesh_isocontour)
IF (NEKTAR_USE_MPI)
ADD_NEKTAR_TEST(chan3D_tec_par)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<test>
<description> Extract an isocontour</description>
<executable>FieldConvert</executable>
<parameters>-e -n6 -m isocontour:fieldstr="p":fieldvalue=0.1:globalcondense:smooth smallmesh.xml smallmesh.fld iso.dat</parameters>
<files>
<file description="Session File">smallmesh.xml</file>
<file description="Session File">smallmesh.fld</file>
</files>
<metrics>
<metric type="L2" id="1">
<value variable="x" tolerance="1e-4">0.644241</value>
<value variable="y" tolerance="1e-4">0.450692</value>
<value variable="z" tolerance="1e-4">0.434032</value>
<value variable="u" tolerance="1e-4">0.901556</value>
<value variable="v" tolerance="1e-4">0.101557</value>
<value variable="w" tolerance="1e-4">0.0892263</value>
<value variable="p" tolerance="1e-4">0.1</value>
<value variable="isocon" tolerance="1e-4">0.1</value>
</metric>
</metrics>
</test>
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