Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::Utilities::ProcessExtractSurf Class Reference

This processing module calculates the Jacobian of elements using SpatialDomains::GeomFactors and the Element::GetGeom method. For now it simply prints a list of elements which have negative Jacobian. More...

#include <ProcessExtractSurf.h>

Inheritance diagram for Nektar::Utilities::ProcessExtractSurf:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::ProcessExtractSurf:
Collaboration graph
[legend]

Public Member Functions

 ProcessExtractSurf (MeshSharedPtr m)
 
virtual ~ProcessExtractSurf ()
 
virtual void Process ()
 Write mesh to output file. More...
 
- Public Member Functions inherited from Nektar::Utilities::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
 ProcessModule (MeshSharedPtr p_m)
 
- Public Member Functions inherited from Nektar::Utilities::Module
 Module (FieldSharedPtr p_f)
 
virtual void Process (po::variables_map &vm)=0
 
void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
void PrintConfig ()
 Print out all configuration options for a module. More...
 
void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
bool GetRequireEquiSpaced (void)
 
void SetRequireEquiSpaced (bool pVal)
 
void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 
 Module (MeshSharedPtr p_m)
 
void RegisterConfig (string key, string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 

Static Public Member Functions

static boost::shared_ptr< Modulecreate (MeshSharedPtr m)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey className
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Utilities::Module
 Module ()
 
virtual void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual void ProcessElements ()
 Generate element IDs. More...
 
virtual void ProcessComposites ()
 Generate composites. More...
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, set< int > &prismsDone, vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::Utilities::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 
MeshSharedPtr m_mesh
 Mesh object. More...
 

Detailed Description

This processing module calculates the Jacobian of elements using SpatialDomains::GeomFactors and the Element::GetGeom method. For now it simply prints a list of elements which have negative Jacobian.

Definition at line 51 of file ProcessExtractSurf.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessExtractSurf::ProcessExtractSurf ( MeshSharedPtr  m)

Definition at line 54 of file ProcessExtractSurf.cpp.

References Nektar::Utilities::Module::m_config.

54  : ProcessModule(m)
55  {
56  m_config["surf"] = ConfigOption(false, "-1",
57  "Tag identifying surface/composite to process.");
58  }
map< string, ConfigOption > m_config
List of configuration values.
Nektar::Utilities::ProcessExtractSurf::~ProcessExtractSurf ( )
virtual

Definition at line 60 of file ProcessExtractSurf.cpp.

61  {
62  }

Member Function Documentation

static boost::shared_ptr<Module> Nektar::Utilities::ProcessExtractSurf::create ( MeshSharedPtr  m)
inlinestatic

Creates an instance of this class.

Definition at line 55 of file ProcessExtractSurf.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

55  {
57  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::Utilities::ProcessExtractSurf::Process ( )
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 64 of file ProcessExtractSurf.cpp.

References Nektar::ParseUtils::GenerateSeqVector(), Nektar::iterator, Nektar::Utilities::Module::m_config, and Nektar::Utilities::Module::m_mesh.

65  {
66  int i, j;
67  string surf = m_config["surf"].as<string>();
68 
69  // Obtain vector of surface IDs from string.
70  vector<unsigned int> surfs;
71  ParseUtils::GenerateSeqVector(surf.c_str(), surfs);
72  sort(surfs.begin(), surfs.end());
73 
74  // If we're running in verbose mode print out a list of surfaces.
75  if (m_mesh->m_verbose)
76  {
77  cout << "ProcessExtractSurf: extracting surface"
78  << (surfs.size() > 1 ? "s" : "") << " " << surf << endl;
79  }
80 
81  // Make a copy of all existing elements of one dimension lower.
82  vector<ElementSharedPtr> el = m_mesh->m_element[m_mesh->m_expDim-1];
83 
84  // Clear all elements.
85  m_mesh->m_element[m_mesh->m_expDim] .clear();
86  m_mesh->m_element[m_mesh->m_expDim-1].clear();
87 
88  // Clear existing vertices, edges and faces.
89  m_mesh->m_vertexSet.clear();
90  m_mesh->m_edgeSet.clear();
91  m_mesh->m_faceSet.clear();
92 
93  // Clear all edge -> element links.
94  for (i = 0; i < el.size(); ++i)
95  {
96  vector<EdgeSharedPtr> edges = el[i]->GetEdgeList();
97  for (j = 0; j < edges.size(); ++j)
98  {
99  edges[j]->m_elLink.clear();
100  }
101 
102  FaceSharedPtr f = el[i]->GetFaceLink();
103  if (f)
104  {
105  for (j = 0; j < f->m_edgeList.size(); ++j)
106  {
107  f->m_edgeList[j]->m_elLink.clear();
108  }
109  }
110  }
111 
112  // keptIds stores IDs of elements we processed earlier.
113  boost::unordered_set<int> keptIds;
114 
115  // Iterate over list of surface elements.
116  for (i = 0; i < el.size(); ++i)
117  {
118  // Work out whether this lies on our surface of interest.
119  vector<int> inter, tags = el[i]->GetTagList();
120 
121  sort(tags.begin(), tags.end());
122  set_intersection(surfs.begin(), surfs.end(),
123  tags .begin(), tags .end(),
124  back_inserter(inter));
125 
126  // It doesn't continue to next element.
127  if (inter.size() != 1)
128  {
129  continue;
130  }
131 
132  // Get list of element vertices and edges.
133  ElementSharedPtr elmt = el[i];
134  vector<NodeSharedPtr> verts = elmt->GetVertexList();
135  vector<EdgeSharedPtr> edges = elmt->GetEdgeList();
136 
137  // Insert surface vertices.
138  for (j = 0; j < verts.size(); ++j)
139  {
140  m_mesh->m_vertexSet.insert(verts[j]);
141  }
142 
143  // Problem: edges and element IDs aren't enumerated with
144  // geometry IDs by some input modules/the Module ProcessEdges
145  // function. Get around this by replacing everything in the
146  // edge/face with information from edge/face link.
147  EdgeSharedPtr e = elmt->GetEdgeLink();
148  FaceSharedPtr f = elmt->GetFaceLink();
149  if (e)
150  {
151  elmt->SetId(e->m_id);
152  }
153  else if (f)
154  {
155  for (j = 0; j < edges.size(); ++j)
156  {
157  m_mesh->m_edgeSet.insert(f->m_edgeList[j]);
158  elmt->SetEdge(j, f->m_edgeList[j]);
159  f->m_edgeList[j]->m_elLink.push_back(
160  std::make_pair(elmt, j));
161  }
162  elmt->SetId(f->m_id);
163  }
164  else
165  {
166  for (j = 0; j < edges.size(); ++j)
167  {
168  m_mesh->m_edgeSet.insert(edges[j]);
169  }
170  }
171 
172  // Nullify edge/face links to get correct tag
173  elmt->SetFaceLink(FaceSharedPtr());
174  elmt->SetEdgeLink(EdgeSharedPtr());
175  keptIds.insert(elmt->GetId());
176 
177  // Push element back into the list.
178  m_mesh->m_element[m_mesh->m_expDim-1].push_back(elmt);
179  }
180 
181  // Decrement the expansion dimension to get manifold embedding.
182  m_mesh->m_expDim--;
183 
184  // Now process composites. This is necessary because 2D surfaces may
185  // contain both quadrilaterals and triangles and so need to be split
186  // up.
187  CompositeMap tmp = m_mesh->m_composite;
189 
190  m_mesh->m_composite.clear();
191  int maxId = -1;
192 
193  // Loop over composites for first time to determine any composites
194  // which don't have elements of the correct dimension.
195  for (it = tmp.begin(); it != tmp.end(); ++it)
196  {
197  if (it->second->m_items[0]->GetDim() != m_mesh->m_expDim)
198  {
199  continue;
200  }
201 
202  vector<ElementSharedPtr> el = it->second->m_items;
203  it->second->m_items.clear();
204 
205  for (i = 0; i < el.size(); ++i)
206  {
207  if (keptIds.count(el[i]->GetId()) > 0)
208  {
209  it->second->m_items.push_back(el[i]);
210  }
211  }
212 
213  if (it->second->m_items.size() == 0)
214  {
215  continue;
216  }
217 
218  m_mesh->m_composite.insert(*it);
219 
220  // Figure out the maximum ID so if we need to create new
221  // composites we can give them a unique ID.
222  maxId = (std::max)(maxId, (int)it->second->m_id) + 1;
223  }
224 
225  tmp = m_mesh->m_composite;
226  m_mesh->m_composite.clear();
228 
229  // Now do another loop over the composites to remove composites
230  // which don't contain any elements in the new mesh.
231  for (it = tmp.begin(); it != tmp.end(); ++it)
232  {
233  CompositeSharedPtr c = it->second;
234  vector<ElementSharedPtr> el = c->m_items;
235 
236  // Remove all but the first element from this composite.
237  string initialTag = el[0]->GetTag();
238  c->m_items.resize(1);
239  c->m_tag = initialTag;
240 
241  // newComps stores the new composites. The key is the composite
242  // type (e.g. Q for quad) and value is the composite.
243  map<string, CompositeSharedPtr> newComps;
244  newComps[initialTag] = c;
245 
246  // Loop over remaining elements in composite and figure out
247  // whether it needs to be split up.
248  for (i = 1; i < el.size(); ++i)
249  {
250  // See if tag exists. If it does, we append this to the
251  // composite, otherwise we create a new composite and store
252  // it in newComps.
253  string tag = el[i]->GetTag();
254  it2 = newComps.find(tag);
255  if (it2 == newComps.end())
256  {
257  CompositeSharedPtr newComp(new Composite());
258  newComp->m_id = maxId++;
259  newComp->m_tag = tag;
260  newComp->m_items.push_back(el[i]);
261  newComps[tag] = newComp;
262  }
263  else
264  {
265  it2->second->m_items.push_back(el[i]);
266  }
267  }
268 
269  // Print out mapping information if we remapped composite IDs.
270  if (m_mesh->m_verbose && newComps.size() > 1)
271  {
272  cout << "- Mapping composite " << it->first << " ->";
273  }
274 
275  // Insert new composites.
276  for (i = 0, it2 = newComps.begin(); it2 != newComps.end();
277  ++it2, ++i)
278  {
279  if (m_mesh->m_verbose && newComps.size() > 1)
280  {
281  cout << (i > 0 ? ", " : " ") << it2->second->m_id << "("
282  << it2->second->m_tag << ")";
283  }
284  m_mesh->m_composite[it2->second->m_id] = it2->second;
285  }
286 
287  if (m_mesh->m_verbose && newComps.size() > 1)
288  {
289  cout << endl;
290  }
291  }
292  }
std::map< unsigned int, CompositeSharedPtr > CompositeMap
Container of composites; key is the composite id, value is the composite.
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: MeshElements.h:318
map< string, ConfigOption > m_config
List of configuration values.
MeshSharedPtr m_mesh
Mesh object.
boost::shared_ptr< Face > FaceSharedPtr
Shared pointer to a face.
Definition: MeshElements.h:550
static bool GenerateSeqVector(const char *const str, std::vector< unsigned int > &vec)
Definition: ParseUtils.hpp:78
boost::shared_ptr< Composite > CompositeSharedPtr
Shared pointer to a composite.
boost::shared_ptr< Element > ElementSharedPtr
Shared pointer to an element.
Definition: MeshElements.h:63
boost::shared_ptr< GeometryVector > Composite
Definition: MeshGraph.h:111
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator

Member Data Documentation

ModuleKey Nektar::Utilities::ProcessExtractSurf::className
static
Initial value:
=
"Process elements to extract a specified surface(s) or composites(s).")

Definition at line 58 of file ProcessExtractSurf.h.