diff --git a/examples/contact.cpp b/examples/contact.cpp index ad2d1a5f20..eb82e1194c 100644 --- a/examples/contact.cpp +++ b/examples/contact.cpp @@ -7,34 +7,34 @@ #include "mfem.hpp" #include #include -#include "nodepair.hpp" +//#include "nodepair.hpp" using namespace std; using namespace mfem; Vector GetNormalVector(Mesh & mesh, const int elem, const double *ref) { - ElementTransformation *trans = mesh.GetElementTransformation(elem); - const int dim = mesh.Dimension(); - const int spaceDim = trans->GetSpaceDim(); + ElementTransformation *trans = mesh.GetElementTransformation(elem); + const int dim = mesh.Dimension(); + const int spaceDim = trans->GetSpaceDim(); - MFEM_VERIFY(spaceDim == 3, ""); + MFEM_VERIFY(spaceDim == 3, ""); - Vector n(spaceDim); + Vector n(spaceDim); - IntegrationPoint ip; - ip.Set(ref, dim); + IntegrationPoint ip; + ip.Set(ref, dim); - trans->SetIntPoint(&ip); - //CalcOrtho(trans->Jacobian(), n); // Works only for face transformations - const DenseMatrix jac = trans->Jacobian(); + trans->SetIntPoint(&ip); + //CalcOrtho(trans->Jacobian(), n); // Works only for face transformations + const DenseMatrix jac = trans->Jacobian(); - int dimNormal = -1; - int normalSide = -1; + int dimNormal = -1; + int normalSide = -1; - const double tol = 1.0e-8; - for (int i=0; i= 0 && normalSide >= 0, ""); - - MFEM_VERIFY(dim == 3, ""); - - std::vector tang(2); - - int tangDir[2] = {-1, -1}; - { - int t = 0; - for (int i=0; i= 0 && normalSide >= 0, ""); + + MFEM_VERIFY(dim == 3, ""); + + std::vector tang(2); + + int tangDir[2] = {-1, -1}; + { + int t = 0; + for (int i=0; i vert; - mesh.GetElementVertices(elems[i], vert); - for (auto v : vert) - cout << " " << v << endl; + cout << " element: " << elems[i] << endl; + cout << " element " << elems[i] << " vertices:" << endl; + Array vert; + mesh.GetElementVertices(elems[i], vert); + for (auto v : vert) + { + cout << " " << v << endl; + } - cout << " reference coordinates: ("; - for (int j=0; jGetSpaceDim()); + trans->Transform(ip, phys); + cout << " physical coordinates: "; + phys.Print(); + } } int main(int argc, char *argv[]) @@ -224,22 +247,26 @@ int main(int argc, char *argv[]) attr.Sort(); cout << "Boundary attributes for contact surface faces in mesh 2" << endl; for (auto a : attr) - cout << a << endl; + { + cout << a << endl; + } Array bdryFaces2; // TODO: remove this? std::set bdryVerts2; for (int b=0; b= 0) - { - bdryFaces2.Append(b); - Array vert; - mesh2.GetBdrElementVertices(b, vert); - for (auto v : vert) - bdryVerts2.insert(v); - } - } + { + if (attr.FindSorted(mesh2.GetBdrAttribute(b)) >= 0) + { + bdryFaces2.Append(b); + Array vert; + mesh2.GetBdrElementVertices(b, vert); + for (auto v : vert) + { + bdryVerts2.insert(v); + } + } + } int npoints = bdryVerts2.size(); Vector xyz(dim * npoints); @@ -249,33 +276,22 @@ int main(int argc, char *argv[]) int count = 0; for (auto v : bdryVerts2) - { - cout << v << ": " << mesh2.GetVertex(v)[0] << ", " - << mesh2.GetVertex(v)[1] << ", " - << mesh2.GetVertex(v)[2] << endl; + { + cout << v << ": " << mesh2.GetVertex(v)[0] << ", " + << mesh2.GetVertex(v)[1] << ", " + << mesh2.GetVertex(v)[2] << endl; - for (int i=0; iGetSpaceDim()); - trans->Transform(ip, phys); - cout << " physical coordinates: "; - phys.Print(); - cout << endl; return 0; }