Commit cd528440 authored by Michael Turner's avatar Michael Turner

make varopti run automatically and sort out verbosity

parent 59c2db4b
......@@ -67,7 +67,7 @@ bool CADSystemOCE::LoadCAD()
}
else
{
cout << m_name << " is not a step file, assuming it is a 4 digit naca code" << endl;
//cout << m_name << " is not a step file, assuming it is a 4 digit naca code" << endl;
shape = BuildNACA(m_name);
/*STEPControl_Writer writer;
......
......@@ -35,6 +35,8 @@
#include <LibUtilities/BasicUtils/SessionReader.h>
#include <boost/thread.hpp>
#include <tinyxml.h>
#include "InputCAD.h"
......@@ -190,6 +192,8 @@ void InputCAD::ParseFile(string nm)
m_surfopti = sit != boolparameters.end();
sit = boolparameters.find("WriteOctree");
m_woct = sit != boolparameters.end();
sit = boolparameters.find("VarOpti");
m_varopti = sit != boolparameters.end();
m_refine = refinement.size() > 0;
if(m_refine)
......@@ -278,6 +282,24 @@ void InputCAD::Process()
mods.back()->RegisterConfig("opti", "");
}
////*** VARIATIONAL OPTIMISATION ****////
if(m_varopti)
{
unsigned int np = boost::thread::physical_concurrency();
if(m_mesh->m_verbose)
{
cout << "Detecting 4 cores, will attempt to run in parrallel" << endl;
}
mods.push_back(GetModuleFactory().CreateInstance(
ModuleKey(eProcessModule, "varopti"), m_mesh));
mods.back()->RegisterConfig("nq",boost::lexical_cast<string>(m_mesh->m_nummode));
mods.back()->RegisterConfig("hyperelastic","");
mods.back()->RegisterConfig("maxiter","10");
mods.back()->RegisterConfig("restol","1e-6");
mods.back()->RegisterConfig("overint","6");
mods.back()->RegisterConfig("numthreads",boost::lexical_cast<string>(np));
}
////**** SPLIT BL ****////
if(m_splitBL)
{
......
......@@ -63,7 +63,7 @@ public:
private:
std::string m_minDelta, m_maxDelta, m_eps, m_cadfile, m_order,
m_blsurfs, m_blthick, m_blprog, m_bllayers, m_refinement;
bool m_makeBL, m_surfopti, m_refine, m_woct, m_2D, m_splitBL;
bool m_makeBL, m_surfopti, m_varopti, m_refine, m_woct, m_2D, m_splitBL;
};
}
......
......@@ -176,30 +176,31 @@ vector<vector<NodeSharedPtr> > ProcessVarOpti::GetColouredNodes(vector<ElUtilSha
//this figures out the dirclet nodes and colors the others into paralell sets
NodeSet boundaryNodes;
if(!m_mesh->m_cad)
switch (m_mesh->m_spaceDim)
{
switch (m_mesh->m_spaceDim)
case 2:
{
case 2:
EdgeSet::iterator it;
for(it = m_mesh->m_edgeSet.begin(); it != m_mesh->m_edgeSet.end(); it++)
{
EdgeSet::iterator it;
for(it = m_mesh->m_edgeSet.begin(); it != m_mesh->m_edgeSet.end(); it++)
if((*it)->m_elLink.size() == 2)
{
if((*it)->m_elLink.size() == 2)
{
continue;
}
continue;
}
boundaryNodes.insert((*it)->m_n1);
boundaryNodes.insert((*it)->m_n2);
for(int i = 0; i < (*it)->m_edgeNodes.size(); i++)
{
boundaryNodes.insert((*it)->m_edgeNodes[i]);
}
boundaryNodes.insert((*it)->m_n1);
boundaryNodes.insert((*it)->m_n2);
for(int i = 0; i < (*it)->m_edgeNodes.size(); i++)
{
boundaryNodes.insert((*it)->m_edgeNodes[i]);
}
break;
}
case 3:
break;
}
case 3:
{
if(!m_mesh->m_cad)
{
FaceSet::iterator it;
for(it = m_mesh->m_faceSet.begin(); it != m_mesh->m_faceSet.end(); it++)
......@@ -229,23 +230,23 @@ vector<vector<NodeSharedPtr> > ProcessVarOpti::GetColouredNodes(vector<ElUtilSha
boundaryNodes.insert((*it)->m_faceNodes[i]);
}
}
break;
}
default:
ASSERTL0(false,"space dim issue");
}
}
else
{
//if we have CAD we are 3D and therefore the only fixed nodes exist on vertices only
NodeSet::iterator nit;
for (nit = m_mesh->m_vertexSet.begin(); nit != m_mesh->m_vertexSet.end(); ++nit)
{
if((*nit)->GetNumCadCurve() > 1)
else
{
boundaryNodes.insert((*nit));
//if we have CAD therefore the only fixed nodes exist on vertices only
NodeSet::iterator nit;
for (nit = m_mesh->m_vertexSet.begin(); nit != m_mesh->m_vertexSet.end(); ++nit)
{
if((*nit)->GetNumCadCurve() > 1)
{
boundaryNodes.insert((*nit));
}
}
}
break;
}
default:
ASSERTL0(false,"space dim issue");
}
vector<NodeSharedPtr> remain;
......@@ -388,9 +389,17 @@ vector<vector<NodeSharedPtr> > ProcessVarOpti::GetColouredNodes(vector<ElUtilSha
}
ret.push_back(layer);
LibUtilities::PrintProgressbar(m_res->n - remain.size(), m_res->n, "Node Coloring");
if(m_mesh->m_verbose)
{
LibUtilities::PrintProgressbar(m_res->n - remain.size(), m_res->n, "Node Coloring");
}
}
cout << endl;
if(m_mesh->m_verbose)
{
cout << endl;
}
return ret;
}
......
......@@ -259,17 +259,20 @@ void ProcessVarOpti::Process()
histFile.close();
}
cout << scientific << endl;
cout << "N elements:\t\t" << m_mesh->m_element[m_mesh->m_expDim].size() - elLock.size() << endl
<< "N elements invalid:\t" << m_res->startInv << endl
<< "Worst jacobian:\t\t" << m_res->worstJac << endl
<< "N free nodes:\t\t" << m_res->n << endl
<< "N Dof:\t\t\t" << m_res->nDoF << endl
<< "N color sets:\t\t" << nset << endl
<< "Avg set colors:\t\t" << p/nset << endl
<< "Min set:\t\t" << mn << endl
<< "Max set:\t\t" << mx << endl
<< "Residual tolerance:\t" << restol << endl;
if(m_mesh->m_verbose)
{
cout << scientific << endl;
cout << "N elements:\t\t" << m_mesh->m_element[m_mesh->m_expDim].size() - elLock.size() << endl
<< "N elements invalid:\t" << m_res->startInv << endl
<< "Worst jacobian:\t\t" << m_res->worstJac << endl
<< "N free nodes:\t\t" << m_res->n << endl
<< "N Dof:\t\t\t" << m_res->nDoF << endl
<< "N color sets:\t\t" << nset << endl
<< "Avg set colors:\t\t" << p/nset << endl
<< "Min set:\t\t" << mn << endl
<< "Max set:\t\t" << mx << endl
<< "Residual tolerance:\t" << restol << endl;
}
int nThreads = m_config["numthreads"].as<int>();
......@@ -343,13 +346,17 @@ void ProcessVarOpti::Process()
resFile << m_res->val << " " << m_res->worstJac << " " << m_res->func << endl;
}
cout << ctr << "\tResidual: " << m_res->val
<< "\tMin Jac: " << m_res->worstJac
<< "\tInvalid: " << m_res->startInv
<< "\tReset nodes: " << m_res->nReset[0] << "/" << m_res->nReset[1] << "/" << m_res->nReset[2]
<< "\tFunctional: " << m_res->func
//<< "\tAlphaNotOne: " << m_res->alphaI
<< endl;
if(m_mesh->m_verbose)
{
cout << ctr << "\tResidual: " << m_res->val
<< "\tMin Jac: " << m_res->worstJac
<< "\tInvalid: " << m_res->startInv
<< "\tReset nodes: " << m_res->nReset[0] << "/" << m_res->nReset[1] << "/" << m_res->nReset[2]
<< "\tFunctional: " << m_res->func
//<< "\tAlphaNotOne: " << m_res->alphaI
<< endl;
}
if(ctr >= maxIter)
break;
}
......@@ -372,10 +379,13 @@ void ProcessVarOpti::Process()
}
t.Stop();
cout << "Time to compute: " << t.TimePerTest(1) << endl;
cout << "Invalid at end: " << m_res->startInv << endl;
cout << "Worst at end: " << m_res->worstJac << endl;
if(m_mesh->m_verbose)
{
cout << "Time to compute: " << t.TimePerTest(1) << endl;
cout << "Invalid at end: " << m_res->startInv << endl;
cout << "Worst at end: " << m_res->worstJac << endl;
}
}
class NodalUtilTriMonomial : public LibUtilities::NodalUtilTriangle
......
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