Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
 
virtual std::string GetModuleName ()=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 (std::string key, std::string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 
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...
 
virtual void ClearElementLinks ()
 

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, std::set< int > &doneIds, std::vector< ElementSharedPtr > &block)
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Utilities::Module
 Module ()
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::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...
 
std::map< std::string,
ConfigOption
m_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 52 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"] =
57  ConfigOption(false, "-1", "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 56 of file ProcessDetectSurf.h.

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

57  {
59  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::Utilities::ProcessDetectSurf::FindContiguousSurface ( ElementSharedPtr  start,
std::set< int > &  doneIds,
std::vector< ElementSharedPtr > &  block 
)
private

Definition at line 219 of file ProcessDetectSurf.cpp.

Referenced by Process().

222 {
223  block.push_back(start);
224  doneIds.erase(start->GetId());
225 
226  vector<EdgeSharedPtr> edges = start->GetEdgeList();
227 
228  for (int i = 0; i < edges.size(); ++i)
229  {
230  for (int j = 0; j < edges[i]->m_elLink.size(); ++j)
231  {
232  ElementSharedPtr elmt = edges[i]->m_elLink[j].first;
233  if (elmt == start)
234  {
235  continue;
236  }
237 
238  if (doneIds.count(elmt->GetId()) == 0)
239  {
240  continue;
241  }
242 
243  FindContiguousSurface(elmt, doneIds, block);
244  }
245  }
246 }
void FindContiguousSurface(ElementSharedPtr start, std::set< int > &doneIds, std::vector< ElementSharedPtr > &block)
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:52
void Nektar::Utilities::ProcessDetectSurf::Process ( )
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 74 of file ProcessDetectSurf.cpp.

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

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

Member Data Documentation

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

Definition at line 60 of file ProcessDetectSurf.h.