//! Get required faces of every element and store the unqiue ones static void apply( const MESH & mesh, const std::vector<Face> & faces, FaceMesh & faceMesh ) { // 1. Allocate space for nodes and face elements const std::size_t numNodes = std::distance( mesh.nodesBegin(), mesh.nodesEnd() ); const std::size_t numElements = faces.size(); faceMesh.allocate( numNodes, numElements ); // 2. Copy nodes (not just the pointers!!!) typename MESH::NodePtrConstIter sourceNode = mesh.nodesBegin(); typename MESH::NodePtrConstIter finalNode = mesh.nodesEnd(); typename FaceMesh::NodePtrIter copyNode = faceMesh.nodesBegin(); for ( ; sourceNode != finalNode; ++sourceNode, ++copyNode ) { // Copy the global ID (*copyNode) -> setID( (*sourceNode) -> getID() ); // Copy the coordinates std::vector<double> x( Node::dim ); (*sourceNode) -> getX( x.begin() ); (*copyNode) -> setX( x.begin() ); } // 3. Generate new elements from faces typename FaceMesh::ElementPtrIter elemIter = faceMesh.elementsBegin(); typename FaceMesh::ElementPtrIter elemEnd = faceMesh.elementsEnd(); typename std::vector<Face>::const_iterator faceIter = faces.begin(); for ( ; elemIter != elemEnd; ++elemIter, ++faceIter ) { // Extract face's node IDs Face nodeIDs; for ( unsigned v = 0; v < nodeIDs.size(); v ++ ) nodeIDs[v] = faceIter -> at( v ); // Set face element connectivity typename FaceMesh::Element::NodePtrIter node = (*elemIter) -> nodesBegin(); for ( unsigned v = 0; v < Face::size(); v++, ++node ) { (*node) = mesh.nodePtr( nodeIDs[v] ); } } return; }
double giveRadius( const MESH& mesh, const FIELD& field ) { typename MESH::NodePtrConstIter nIter = mesh.nodesBegin(); typename FIELD::DoFPtrConstIter dIter = field.doFsBegin(); return ((*nIter) -> getX())[0] + ((*dIter) -> getValue(0)); }