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:
[legend]

Public Member Functions

 ProcessDetectSurf (NekMeshUtils::MeshSharedPtr m)
 
virtual ~ProcessDetectSurf ()
 
virtual void Process ()
 Write mesh to output file. More...
 
- Public Member Functions inherited from Nektar::NekMeshUtils::ProcessModule
NEKMESHUTILS_EXPORT ProcessModule (MeshSharedPtr p_m)
 
- Public Member Functions inherited from Nektar::NekMeshUtils::Module
NEKMESHUTILS_EXPORT Module (MeshSharedPtr p_m)
 
NEKMESHUTILS_EXPORT void RegisterConfig (std::string key, std::string value=std::string())
 Register a configuration option with a module. More...
 
NEKMESHUTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
NEKMESHUTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
NEKMESHUTILS_EXPORT MeshSharedPtr GetMesh ()
 
virtual NEKMESHUTILS_EXPORT void ProcessVertices ()
 Extract element vertices. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessElements ()
 Generate element IDs. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessComposites ()
 Generate composites. More...
 
virtual NEKMESHUTILS_EXPORT void ClearElementLinks ()
 

Static Public Member Functions

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

Static Public Attributes

static NekMeshUtils::ModuleKey className
 

Private Member Functions

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

Additional Inherited Members

- Protected Member Functions inherited from Nektar::NekMeshUtils::Module
NEKMESHUTILS_EXPORT void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
NEKMESHUTILS_EXPORT void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::NekMeshUtils::Module
MeshSharedPtr m_mesh
 Mesh object. More...
 
std::map< std::string, ConfigOptionm_config
 List of configuration values. 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

◆ ProcessDetectSurf()

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

Definition at line 53 of file ProcessDetectSurf.cpp.

References Nektar::NekMeshUtils::Module::m_config.

53  : ProcessModule(m)
54 {
55  m_config["vol"] =
56  ConfigOption(false, "-1", "Tag identifying surface to process.");
57 }
Represents a command-line configuration option.
NEKMESHUTILS_EXPORT ProcessModule(MeshSharedPtr p_m)
std::map< std::string, ConfigOption > m_config
List of configuration values.

◆ ~ProcessDetectSurf()

Nektar::Utilities::ProcessDetectSurf::~ProcessDetectSurf ( )
virtual

Definition at line 59 of file ProcessDetectSurf.cpp.

60 {
61 }

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 55 of file ProcessDetectSurf.h.

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

56  {
58  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

◆ FindContiguousSurface()

void Nektar::Utilities::ProcessDetectSurf::FindContiguousSurface ( NekMeshUtils::ElementSharedPtr  start,
std::set< int > &  doneIds,
std::vector< NekMeshUtils::ElementSharedPtr > &  block 
)
private

Definition at line 214 of file ProcessDetectSurf.cpp.

Referenced by Process().

217 {
218  block.push_back(start);
219  doneIds.erase(start->GetId());
220 
221  vector<EdgeSharedPtr> edges = start->GetEdgeList();
222 
223  for (int i = 0; i < edges.size(); ++i)
224  {
225  for (int j = 0; j < edges[i]->m_elLink.size(); ++j)
226  {
227  ElementSharedPtr elmt = edges[i]->m_elLink[j].first;
228  if (elmt == start)
229  {
230  continue;
231  }
232 
233  if (doneIds.count(elmt->GetId()) == 0)
234  {
235  continue;
236  }
237 
238  FindContiguousSurface(elmt, doneIds, block);
239  }
240  }
241 }
void FindContiguousSurface(NekMeshUtils::ElementSharedPtr start, std::set< int > &doneIds, std::vector< NekMeshUtils::ElementSharedPtr > &block)
std::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:49

◆ Process()

void Nektar::Utilities::ProcessDetectSurf::Process ( )
virtual

Write mesh to output file.

Implements Nektar::NekMeshUtils::Module.

Definition at line 73 of file ProcessDetectSurf.cpp.

References ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::LibUtilities::eSegment, FindContiguousSurface(), Nektar::ParseUtils::GenerateSeqVector(), Nektar::NekMeshUtils::GetElementFactory(), Nektar::NekMeshUtils::Module::m_config, and Nektar::NekMeshUtils::Module::m_mesh.

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

Member Data Documentation

◆ className

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

Definition at line 59 of file ProcessDetectSurf.h.