35 #include <boost/core/ignore_unused.hpp>    70         "Optimise mesh locations.");
    76         ConfigOption(
true, 
"", 
"Optimise for linear elasticity");
    88         ConfigOption(
false, 
"500", 
"Maximum number of iterations");
    92         ConfigOption(
false, 
"0.0", 
"create regions based on target");
    94         ConfigOption(
false, 
"", 
"writes residual values to file");
   112         cout << 
"ProcessVarOpti: Optimising... " << endl;
   115     if (
m_config[
"linearelastic"].beenSet)
   119     else if (
m_config[
"winslow"].beenSet)
   127     else if (
m_config[
"hyperelastic"].beenSet)
   133         ASSERTL0(
false, 
"not opti type set");
   136     const int maxIter      = 
m_config[
"maxiter"].as<
int>();
   151         for (
auto &edge : 
m_mesh->m_edgeSet)
   153             if (edge->m_edgeNodes.size() > 0)
   155                 m_mesh->m_nummode = edge->m_edgeNodes.size() + 2;
   161     ASSERTL0(fd, 
"failed to find order of mesh");
   165     int intOrder = 
m_config[
"overint"].as<
int>();
   166     intOrder = 
m_mesh->m_nummode + intOrder <= 11 ?
   167         intOrder : 11 - 
m_mesh->m_nummode;
   171         cout << 
"Identified mesh order as: " << 
m_mesh->m_nummode - 1 << endl;
   176         ASSERTL0(
false, 
"cannot deal with manifolds");
   192     map<LibUtilities::ShapeType, DerivUtilSharedPtr> derivUtils =
   198     m_res->worstJac = numeric_limits<double>::max();
   199     for (
int i = 0; i < 
m_dataSet.size(); i++)
   205     vector<ElUtilSharedPtr> elLock;
   214     vector<vector<NodeOptiSharedPtr> > optiNodes;
   218     for (
int i = 0; i < freenodes.size(); i++)
   220         vector<NodeOptiSharedPtr> ns;
   221         for (
int j = 0; j < freenodes[i].size(); j++)
   226             int optiKind = 
m_mesh->m_spaceDim;
   228             if (freenodes[i][j]->GetNumCadCurve() == 1)
   232             else if (freenodes[i][j]->GetNumCADSurf() == 1)
   238                 optiKind += 10 * 
m_mesh->m_expDim;
   241             auto c = check.find(freenodes[i][j]->m_id);
   242             ASSERTL0(c == check.end(), 
"duplicate node");
   243             check.insert(freenodes[i][j]->m_id);
   246                 optiKind, freenodes[i][j], it->second, 
m_res, derivUtils,
   249         optiNodes.push_back(ns);
   252     int nset = optiNodes.size();
   254     int mn   = numeric_limits<int>::max();
   256     for (
int i = 0; i < nset; i++)
   258         p += optiNodes[i].size();
   259         mn = min(mn, 
int(optiNodes[i].size()));
   260         mx = max(mx, 
int(optiNodes[i].size()));
   266         string name = 
m_config[
"histfile"].as<
string>() + 
"_start.txt";
   267         histFile.open(name.c_str());
   269         for (
int i = 0; i < 
m_dataSet.size(); i++)
   271             histFile << 
m_dataSet[i]->GetScaledJac() << endl;
   278         cout << scientific << endl;
   279         cout << 
"N elements:\t\t" << 
m_mesh->m_element[
m_mesh->m_expDim].size() - elLock.size() << endl
   280              << 
"N elements invalid:\t" << 
m_res->startInv << endl
   281              << 
"Worst jacobian:\t\t" << 
m_res->worstJac << endl
   282              << 
"N free nodes:\t\t" << 
m_res->n << endl
   283              << 
"N Dof:\t\t\t" << 
m_res->nDoF << endl
   284              << 
"N color sets:\t\t" << nset << endl
   285              << 
"Avg set colors:\t\t" << p/nset << endl
   286              << 
"Min set:\t\t" << mn << endl
   287              << 
"Max set:\t\t" << mx << endl
   288              << 
"Residual tolerance:\t" << restol << endl;
   291     int nThreads = 
m_config[
"numthreads"].as<
int>();
   305         resFile.open(
m_config[
"resfile"].as<string>().c_str());
   308     for (
int i = 0; i < optiNodes.size(); i++)
   310         vector<Thread::ThreadJob *> jobs(optiNodes[i].size());
   311         for (
int j = 0; j < optiNodes[i].size(); j++)
   313             optiNodes[i][j]->CalcMinJac();
   317     while (
m_res->val > restol)
   322         m_res->nReset[0] = 0;
   323         m_res->nReset[1] = 0;
   324         m_res->nReset[2] = 0;
   326         for (
int i = 0; i < optiNodes.size(); i++)
   328             vector<Thread::ThreadJob *> jobs(optiNodes[i].size());
   329             for (
int j = 0; j < optiNodes[i].size(); j++)
   331                 jobs[j] = optiNodes[i][j]->GetJob();
   334             tm->SetNumWorkers(0);
   336             tm->SetNumWorkers(nThreads);
   341         m_res->worstJac = numeric_limits<double>::max();
   343         vector<Thread::ThreadJob *> elJobs(
m_dataSet.size());
   344         for (
int i = 0; i < 
m_dataSet.size(); i++)
   349         tm->SetNumWorkers(0);
   350         tm->QueueJobs(elJobs);
   351         tm->SetNumWorkers(nThreads);
   356             resFile << 
m_res->val << 
" " << 
m_res->worstJac << 
" "   357                     << 
m_res->func << endl;
   363                  << 
"\tResidual: " << 
m_res->val
   364                  << 
"\tMin Jac: " << 
m_res->worstJac
   365                  << 
"\tInvalid: " << 
m_res->startInv
   366                  << 
"\tReset nodes: " << 
m_res->nReset[0] << 
"/" << 
m_res->nReset[1]
   367                  << 
"/" << 
m_res->nReset[2] << 
"\tFunctional: " << 
m_res->func
   380         string name = 
m_config[
"histfile"].as<
string>() + 
"_end.txt";
   381         histFile.open(name.c_str());
   383         for (
int i = 0; i < 
m_dataSet.size(); i++)
   385             histFile << 
m_dataSet[i]->GetScaledJac() << endl;
   400         cout << 
"Time to compute: " << t.
TimePerTest(1) << endl;
   401         cout << 
"Invalid at end: " << 
m_res->startInv << endl;
   402         cout << 
"Worst at end: " << 
m_res->worstJac << endl;
   423         std::pair<int, int> 
modes = m_ordering[mode];
   426         for (
int i = 0; i < m_numPoints; ++i)
   429                 pow(m_xi[0][i], modes.first) * pow(m_xi[1][i], modes.second);
   438         boost::ignore_unused(dir, mode);
   447             m_degree, xi[0], xi[1]);
   457     vector<NodeSharedPtr> nodes;
   458     elmt->GetCurvedNodes(nodes);
   464     const int nPoints       = 200;
   465     const int overInt       = 40;
   469     const NekDouble dx      = length / (nPoints - 1);
   471     cout << 
"# overint = " << overInt << endl;
   472     cout << 
"# Columns: x, y, over-integration orders (0 -> " << overInt - 1
   474          << 
" min(scaledJac)" << endl;
   477     for (
int k = 0; k < nPoints; ++k)
   479         node->m_y = originY + k * dx;
   480         for (
int j = 0; j < nPoints; ++j)
   482             node->m_x = originX + j * dx;
   483             cout << node->m_x << 
" " << node->m_y << 
" ";
   487             for (
int i = 0; i < overInt; ++i)
   494                 map<LibUtilities::ShapeType, DerivUtilSharedPtr> derivUtils =
   500                 for (
int j = 0; j < 
m_dataSet.size(); j++)
   509                         m_mesh->m_spaceDim * 11, node,
   516                 nodeOpti->CalcMinJac();
   517                 cout << nodeOpti->GetFunctional<2>(minJacNew) << 
" ";
   524             cout << minJacNew << endl;
 virtual std::shared_ptr< NodalUtil > v_CreateUtil(Array< OneD, Array< OneD, NekDouble > > &xi)
Construct a NodalUtil object of the appropriate element type for a given set of points. 
 
#define ASSERTL0(condition, msg)
 
virtual ~NodalUtilTriMonomial()
 
NodeOptiFactory & GetNodeOptiFactory()
 
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
 
std::shared_ptr< ThreadManager > ThreadManagerSharedPtr
 
Specialisation of the NodalUtil class to support nodal triangular elements. 
 
NekDouble TimePerTest(unsigned int n)
Returns amount of seconds per iteration in a test with n iterations. 
 
virtual NekVector< NekDouble > v_OrthoBasis(const int mode)
Return the value of the modal functions for the triangular element at the nodal points m_xi for a giv...
 
std::vector< ElUtilSharedPtr > GetLockedElements(NekDouble thres)
 
void GetElementMap(int o, std::map< LibUtilities::ShapeType, DerivUtilSharedPtr > derMap)
 
std::map< LibUtilities::ShapeType, DerivUtilSharedPtr > BuildDerivUtil(int o)
 
std::vector< ElUtilSharedPtr > m_dataSet
 
MeshSharedPtr m_mesh
Mesh object. 
 
std::shared_ptr< NodeOpti > NodeOptiSharedPtr
 
std::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh. 
 
std::shared_ptr< Node > NodeSharedPtr
 
std::vector< std::vector< NodeSharedPtr > > GetColouredNodes(std::vector< ElUtilSharedPtr > elLock)
 
NodalUtilTriMonomial(int degree, Array< OneD, NekDouble > r, Array< OneD, NekDouble > s)
 
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey. 
 
std::pair< ModuleType, std::string > ModuleKey
 
std::shared_ptr< Element > ElementSharedPtr
 
Represents a command-line configuration option. 
 
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool. 
 
std::map< std::string, ConfigOption > m_config
List of configuration values. 
 
ThreadManagerSharedPtr CreateInstance(const ThreadManagerName t, unsigned int nThr)
Creates an instance of a ThreadManager (which one is determined by a previous call to SetThreadingTyp...
 
Abstract base class for processing modules. 
 
virtual NekVector< NekDouble > v_OrthoBasisDeriv(const int dir, const int mode)
Return the value of the derivative of the modal functions for the triangular element at the nodal poi...
 
void SetThreadingType(const std::string &p_type)
Sets what ThreadManagers will be created in CreateInstance. 
 
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory. 
 
std::pair< ModuleType, std::string > ModuleKey
 
virtual ~ProcessVarOpti()
 
1D Gauss-Lobatto-Legendre quadrature points 
 
ModuleFactory & GetModuleFactory()