Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | List of all members
Nektar::Utilities::ProcessDetectSurf 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 <ProcessDetectSurf.h>

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

Public Member Functions

 ProcessDetectSurf (MeshSharedPtr m)
 
virtual ~ProcessDetectSurf ()
 
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
 

Private Member Functions

void FindContiguousSurface (ElementSharedPtr start, set< int > &doneIds, vector< ElementSharedPtr > &block)
 

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 ProcessDetectSurf.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessDetectSurf::ProcessDetectSurf ( MeshSharedPtr  m)

Definition at line 54 of file ProcessDetectSurf.cpp.

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

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

Definition at line 60 of file ProcessDetectSurf.cpp.

61  {
62  }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 55 of file ProcessDetectSurf.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::ProcessDetectSurf::FindContiguousSurface ( ElementSharedPtr  start,
set< int > &  doneIds,
vector< ElementSharedPtr > &  block 
)
private

Definition at line 212 of file ProcessDetectSurf.cpp.

Referenced by Process().

216  {
217  block.push_back(start);
218  doneIds.erase(start->GetId());
219 
220  vector<EdgeSharedPtr> edges = start->GetEdgeList();
221 
222  for (int i = 0; i < edges.size(); ++i)
223  {
224  for (int j = 0; j < edges[i]->m_elLink.size(); ++j)
225  {
226  ElementSharedPtr elmt = edges[i]->m_elLink[j].first;
227  if (elmt == start)
228  {
229  continue;
230  }
231 
232  if (doneIds.count(elmt->GetId()) == 0)
233  {
234  continue;
235  }
236 
237  FindContiguousSurface(elmt, doneIds, block);
238  }
239  }
240  }
boost::shared_ptr< Element > ElementSharedPtr
Shared pointer to an element.
Definition: MeshElements.h:63
void FindContiguousSurface(ElementSharedPtr start, set< int > &doneIds, vector< ElementSharedPtr > &block)
void Nektar::Utilities::ProcessDetectSurf::Process ( )
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 71 of file ProcessDetectSurf.cpp.

References ASSERTL0, Nektar::LibUtilities::eSegment, FindContiguousSurface(), Nektar::ParseUtils::GenerateSeqVector(), Nektar::Utilities::GetElementFactory(), Nektar::iterator, Nektar::Utilities::Module::m_config, and Nektar::Utilities::Module::m_mesh.

72  {
73  if (m_mesh->m_expDim > 2)
74  {
75  cerr << "Surface detection only implemented for 2D meshes" << endl;
76  return;
77  }
78 
79  int i, j;
80  string surf = m_config["vol"].as<string>();
81 
82  // Obtain vector of surface IDs from string.
83  vector<unsigned int> surfs;
84  if (surf != "-1")
85  {
86  ParseUtils::GenerateSeqVector(surf.c_str(), surfs);
87  sort(surfs.begin(), surfs.end());
88  }
89 
90  // If we're running in verbose mode print out a list of surfaces.
91  if (m_mesh->m_verbose)
92  {
93  cout << "ProcessDetectSurf: detecting surfaces";
94  if (surfs.size() > 0)
95  {
96  cout << " for surface" << (surfs.size() == 1 ? "" : "s")
97  << " " << surf << endl;
98  }
99  }
100 
101  vector<ElementSharedPtr> &el = m_mesh->m_element[m_mesh->m_expDim];
102  map<int, EdgeInfo> edgeCount;
103  set<int> doneIds;
104  map<int, int> idMap;
105 
106  // Iterate over list of surface elements.
107  for (i = 0; i < el.size(); ++i)
108  {
109  // Work out whether this lies on our surface of interest.
110  if (surfs.size() > 0)
111  {
112  vector<int> inter, tags = el[i]->GetTagList();
113 
114  sort(tags.begin(), tags.end());
115  set_intersection(surfs.begin(), surfs.end(),
116  tags .begin(), tags .end(),
117  back_inserter(inter));
118 
119  // It doesn't continue to next element.
120  if (inter.size() != 1)
121  {
122  continue;
123  }
124  }
125 
126  // List all edges.
127  ElementSharedPtr elmt = el[i];
128  for (j = 0; j < elmt->GetEdgeCount(); ++j)
129  {
130  EdgeSharedPtr e = elmt->GetEdge(j);
131  int eId = e->m_id;
132  edgeCount[eId].count++;
133  edgeCount[eId].edge = e;
134  }
135 
136  doneIds.insert(elmt->GetId());
137  ASSERTL0(idMap.count(elmt->GetId()) == 0, "Shouldn't happen");
138  idMap[elmt->GetId()] = i;
139  }
140 
142  unsigned int maxId = 0;
143 
144  for (cIt = m_mesh->m_composite.begin(); cIt != m_mesh->m_composite.end(); ++cIt)
145  {
146  maxId = (std::max)(cIt->first, maxId);
147  }
148 
149  ++maxId;
150 
152 
153  while (doneIds.size() > 0)
154  {
155  ElementSharedPtr start
156  = m_mesh->m_element[m_mesh->m_expDim][idMap[*(doneIds.begin())]];
157 
158  vector<ElementSharedPtr> block;
159  FindContiguousSurface(start, doneIds, block);
160  ASSERTL0(block.size() > 0, "Contiguous block not found");
161 
162  // Loop over all edges in block.
163  for (i = 0; i < block.size(); ++i)
164  {
165  // Find edge info.
166  ElementSharedPtr elmt = block[i];
167 
168  for (j = 0; j < elmt->GetEdgeCount(); ++j)
169  {
170  eIt = edgeCount.find(elmt->GetEdge(j)->m_id);
171  ASSERTL0(eIt != edgeCount.end(), "Couldn't find edge");
172  eIt->second.group = maxId;
173  }
174  }
175 
176  ++maxId;
177  }
178 
179  for (eIt = edgeCount.begin(); eIt != edgeCount.end(); ++eIt)
180  {
181  if (eIt->second.count > 1)
182  {
183  continue;
184  }
185 
186  unsigned int compId = eIt->second.group;
187  CompositeMap::iterator cIt = m_mesh->m_composite.find(compId);
188 
189  if (cIt == m_mesh->m_composite.end())
190  {
191  CompositeSharedPtr comp(new Composite());
192  comp->m_id = compId;
193  comp->m_tag = "E";
194  cIt = m_mesh->m_composite.insert(std::make_pair(compId, comp)).first;
195  }
196 
197  vector<int> tags(1);
198  tags[0] = compId;
199  vector<NodeSharedPtr> nodeList(2);
200  nodeList[0] = eIt->second.edge->m_n1;
201  nodeList[1] = eIt->second.edge->m_n2;
202 
203  ElmtConfig conf(LibUtilities::eSegment, 1, false, false);
205  CreateInstance(LibUtilities::eSegment,conf,nodeList,tags);
206  elmt->SetEdgeLink(eIt->second.edge);
207 
208  cIt->second->m_items.push_back(elmt);
209  }
210  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
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.
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
ElementFactory & GetElementFactory()
void FindContiguousSurface(ElementSharedPtr start, set< int > &doneIds, vector< ElementSharedPtr > &block)

Member Data Documentation

ModuleKey Nektar::Utilities::ProcessDetectSurf::className
static
Initial value:
=
"Process elements to detect a surface.")

Definition at line 58 of file ProcessDetectSurf.h.