69         ConfigOption(
false, 
"-1", 
"Tag identifying first surface.");
 
   71         ConfigOption(
false, 
"-1", 
"Tag identifying first surface.");
 
   73         false, 
"", 
"Direction in which to align (either x, y, or z)");
 
   75         ConfigOption(
true, 
"0", 
"Attempt to reorient tets and prisms");
 
   87     int surf1   = 
m_config[
"surf1"].as<
int>();
 
   88     int surf2   = 
m_config[
"surf2"].as<
int>();
 
   89     string dir  = 
m_config[
"dir"].as<
string>();
 
   90     bool orient = 
m_config[
"orient"].as<
bool>();
 
   94         cerr << 
"WARNING: surf1 must be set to a positive integer. " 
   95              << 
"Skipping periodic alignment." << endl;
 
  101         cerr << 
"WARNING: surf2 must be set to a positive integer. " 
  102              << 
"Skipping periodic alignment." << endl;
 
  106     if (dir != 
"x" && dir != 
"y" && dir != 
"z")
 
  108         cerr << 
"WARNING: dir must be set to either x, y or z. " 
  109              << 
"Skipping periodic alignment." << endl;
 
  114     vec[0] = dir == 
"x" ? 1.0 : 0.0;
 
  115     vec[1] = dir == 
"y" ? 1.0 : 0.0;
 
  116     vec[2] = dir == 
"z" ? 1.0 : 0.0;
 
  121     if (it1 == 
m_mesh->m_composite.end())
 
  123         cerr << 
"WARNING: Couldn't find surface " << surf1
 
  124              << 
". Skipping periodic alignment." << endl;
 
  128     if (it2 == 
m_mesh->m_composite.end())
 
  130         cerr << 
"WARNING: Couldn't find surface " << surf2 << 
", " 
  131              << 
"skipping periodic alignment." << endl;
 
  138     if (c1->m_items.size() != c2->m_items.size())
 
  140         cerr << 
"WARNING: Surfaces " << surf1 << 
" and " << surf2
 
  141              << 
" have different numbers of elements. Skipping periodic" 
  142              << 
" alignment." << endl;
 
  146     c1->m_reorder = 
false;
 
  147     c2->m_reorder = 
false;
 
  149     map<int, pair<FaceSharedPtr, vector<int> > > perFaces;
 
  152     map<int, Node> centroidMap;
 
  154     for (
int i = 0; i < c2->m_items.size(); ++i)
 
  157         for (
int j = 0; j < c2->m_items[i]->GetVertexCount(); ++j)
 
  159             centroid += *(c2->m_items[i]->GetVertex(j));
 
  161         centroid /= (
NekDouble)c2->m_items[i]->GetVertexCount();
 
  162         centroidMap[i] = centroid;
 
  165     boost::unordered_set<int> elmtDone;
 
  166     map<int, int> elmtPairs;
 
  167     map<int, int> vertCheck;
 
  169     for (
int i = 0; i < c1->m_items.size(); ++i)
 
  172         for (
int j = 0; j < c1->m_items[i]->GetVertexCount(); ++j)
 
  174             centroid += *(c1->m_items[i]->GetVertex(j));
 
  176         centroid /= (
NekDouble)c1->m_items[i]->GetVertexCount();
 
  178         for (it = centroidMap.begin(); it != centroidMap.end(); ++it)
 
  180             if (elmtDone.count(it->first) > 0)
 
  185             Node dx = it->second - centroid;
 
  186             if (fabs(fabs(dx.
m_x * vec[0] + dx.
m_y * vec[1] + dx.
m_z * vec[2]) /
 
  195                     id1 = c1->m_items[i]->GetEdgeLink()->
m_id;
 
  196                     id2 = c2->m_items[it->first]->GetEdgeLink()->m_id;
 
  200                     id1 = c1->m_items[i]->GetFaceLink()->m_id;
 
  201                     id2 = c2->m_items[it->first]->GetFaceLink()->m_id;
 
  204                 elmtDone.insert(it->first);
 
  205                 elmtPairs[i] = it->first;
 
  208                 int nVerts = c1->m_items[i]->GetVertexCount();
 
  209                 vector<int> perVerts(nVerts, 0), perVertsInv(nVerts, 0);
 
  213                     for (
int k = 0; k < nVerts; ++k)
 
  216                             c1->m_items[i]->GetFaceLink()->m_vertexList[k];
 
  219                         for (l = 0; l < nVerts; ++l)
 
  226                             if (fabs(fabs(dn.
m_x * vec[0] + dn.
m_y * vec[1] +
 
  236                                 if (vertCheck.count(id1) == 0)
 
  238                                     vertCheck[id1] = id2;
 
  243                                              "Periodic vertex already " 
  250                                  "Could not identify periodic vertices.");
 
  253                     int tot1 = 0, tot2 = 0;
 
  254                     for (
int k = 0; k < nVerts; ++k)
 
  257                         tot2 += perVertsInv[k];
 
  259                     ASSERTL0(tot1 == nVerts * (nVerts - 1) / 2 &&
 
  260                                  tot2 == nVerts * (nVerts - 1) / 2,
 
  261                              "Error identifying periodic vertices");
 
  266                     perFaces[id1] = make_pair(
 
  267                         c2->m_items[it->first]->GetFaceLink(), perVerts);
 
  269                         make_pair(c1->m_items[i]->GetFaceLink(), perVertsInv);
 
  275         if (it == centroidMap.end())
 
  277             cerr << 
"WARNING: Could not find matching edge for surface " 
  278                  << 
"element " << c1->m_items[i]->GetId() << 
". " 
  279                  << 
"Skipping periodic alignment." << endl;
 
  285     vector<ElementSharedPtr> tmp = c2->m_items;
 
  289     for (
int i = 0; i < tmp.size(); ++i)
 
  291         c2->m_items[i] = tmp[elmtPairs[i]];
 
#define ASSERTL0(condition, msg)
 
pair< ModuleType, string > ModuleKey
 
map< string, ConfigOption > m_config
List of configuration values. 
 
MeshSharedPtr m_mesh
Mesh object. 
 
NekDouble m_y
Y-coordinate. 
 
Represents a point in the domain. 
 
NEKMESHUTILS_EXPORT NekDouble abs2() const 
 
boost::shared_ptr< Composite > CompositeSharedPtr
Shared pointer to a composite. 
 
boost::shared_ptr< Node > NodeSharedPtr
 
Represents a command-line configuration option. 
 
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
 
NekDouble m_x
X-coordinate. 
 
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh. 
 
virtual void Process()
Write mesh to output file. 
 
virtual ~ProcessPerAlign()
Destructor. 
 
void ReorderPrisms(PerMap &perFaces)
Reorder node IDs so that prisms and tetrahedra are aligned correctly. 
 
NekDouble m_z
Z-coordinate. 
 
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
 
ModuleFactory & GetModuleFactory()
 
Abstract base class for processing modules. 
 
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.