Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::Utilities::ProcessDisplacement Class Reference

#include <ProcessDisplacement.h>

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

Public Member Functions

 ProcessDisplacement (FieldSharedPtr f)
 
virtual ~ProcessDisplacement ()
 
virtual void Process (po::variables_map &vm)
 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)
 
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)
 
virtual void Process ()=0
 
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 (FieldSharedPtr f)
 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 ()
 
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

Definition at line 46 of file ProcessDisplacement.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessDisplacement::ProcessDisplacement ( FieldSharedPtr  f)

Definition at line 107 of file ProcessDisplacement.cpp.

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

107  :
108  ProcessModule(f)
109  {
110  m_config["to"] = ConfigOption(
111  false, "", "Name of file containing high order boundary");
112  m_config["id"] = ConfigOption(
113  false, "", "Boundary ID to calculate displacement for");
114  m_config["usevertexids"] = ConfigOption(
115  false, "0", "Use vertex IDs instead of face IDs for matching");
116  f->m_declareExpansionAsContField = true;
117  f->m_writeBndFld = true;
118  f->m_fldToBnd = false;
119  }
map< string, ConfigOption > m_config
List of configuration values.
Nektar::Utilities::ProcessDisplacement::~ProcessDisplacement ( )
virtual

Definition at line 121 of file ProcessDisplacement.cpp.

122  {
123  }

Member Function Documentation

static boost::shared_ptr<Module> Nektar::Utilities::ProcessDisplacement::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 50 of file ProcessDisplacement.h.

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

50  {
52  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::Utilities::ProcessDisplacement::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 125 of file ProcessDisplacement.cpp.

References Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::StdRegions::StdExpansion::GetTotPoints(), Nektar::iterator, Nektar::Utilities::Module::m_config, Nektar::Utilities::Module::m_f, Nektar::SpatialDomains::MeshGraph::Read(), and Vmath::Vsub().

126  {
127  if (m_f->m_verbose)
128  {
129  cout << "ProcessDisplacement: Calculating displacement..."
130  << endl;
131  }
132 
133  string toFile = m_config["to"].as<string>();
134 
135  if (toFile == "")
136  {
137  cout << "ProcessDisplacement: you must provide a file" << endl;
138  return;
139  }
140 
141  bool useVertexIds = m_config["usevertexids"].m_beenSet;
142 
143  vector<string> files;
144  files.push_back(toFile);
149 
150  // Try to find boundary condition expansion.
151  int bndCondId = m_config["id"].as<int>();
152 
153  // FIXME: We should be storing boundary condition IDs
154  // somewhere...
155  m_f->m_bndRegionsToWrite.push_back(bndCondId);
156 
157  if (bndGraph->GetMeshDimension() == 1)
158  {
159  m_f->m_exp.push_back(m_f->AppendExpList(0, "v"));
160 
161  MultiRegions::ExpListSharedPtr bndCondExpU =
162  m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
163  MultiRegions::ExpListSharedPtr bndCondExpV =
164  m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
165 
166  map<int, int> bndCondIds;
167  for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
168  {
169  bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()]
170  = i;
171  }
172 
173  const SpatialDomains::SegGeomMap &tmp =
174  bndGraph->GetAllSegGeoms();
175  SpatialDomains::SegGeomMap::const_iterator sIt;
176 
177  for (sIt = tmp.begin(); sIt != tmp.end(); ++sIt)
178  {
179  map<int, int>::iterator mIt = bndCondIds.find(sIt->first);
180 
181  if (mIt == bndCondIds.end())
182  {
183  cout << "Warning: couldn't find element "
184  << sIt->first << endl;
185  continue;
186  }
187 
188  int e = mIt->second;
189 
191  boost::dynamic_pointer_cast<SpatialDomains::SegGeom>(
192  bndCondExpU->GetExp(e)->GetGeom());
193 
194  SpatialDomains::SegGeomSharedPtr to = sIt->second;
195 
196  // Create temporary SegExp
197  LocalRegions::SegExpSharedPtr toSeg = MemoryManager<
198  LocalRegions::SegExp>::AllocateSharedPtr(
199  bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
200  to);
201 
202  const int offset = bndCondExpU->GetPhys_Offset(e);
203  const int nq = toSeg->GetTotPoints();
204 
205  Array<OneD, NekDouble> xL(nq), xC(nq), yL(nq), yC(nq), tmp;
206 
207  bndCondExpU->GetExp(e)->GetCoords(xC, yC);
208  toSeg->GetCoords(xL, yL);
209 
210  Vmath::Vsub(nq, xL, 1, xC, 1,
211  tmp = bndCondExpU->UpdatePhys() + offset, 1);
212  Vmath::Vsub(nq, yL, 1, yC, 1,
213  tmp = bndCondExpV->UpdatePhys() + offset, 1);
214  }
215 
216  // bndconstrained?
217  bndCondExpU->FwdTrans_BndConstrained(
218  bndCondExpU->GetPhys(), bndCondExpU->UpdateCoeffs());
219  bndCondExpV->FwdTrans_BndConstrained(
220  bndCondExpV->GetPhys(), bndCondExpV->UpdateCoeffs());
221  }
222  else if (bndGraph->GetMeshDimension() == 2)
223  {
224  m_f->m_exp.push_back(m_f->AppendExpList(0, "v"));
225  m_f->m_exp.push_back(m_f->AppendExpList(0, "w"));
226 
227  MultiRegions::ExpListSharedPtr bndCondExpU =
228  m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
229  MultiRegions::ExpListSharedPtr bndCondExpV =
230  m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
231  MultiRegions::ExpListSharedPtr bndCondExpW =
232  m_f->m_exp[2]->GetBndCondExpansions()[bndCondId];
233 
234  map<int, int> bndCondIds;
235  for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
236  {
237  bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()]
238  = i;
239  }
240 
241  TriFaceMap vertexFaceMap;
242 
243  if (useVertexIds)
244  {
245  for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
246  {
248  boost::dynamic_pointer_cast<SpatialDomains::TriGeom>(
249  bndCondExpU->GetExp(i)->GetGeom());
250 
251  TriFaceIDs t(from->GetVid(0), from->GetVid(1),
252  from->GetVid(2));
253  vertexFaceMap[t] = i;
254  }
255  }
256 
257  const SpatialDomains::TriGeomMap &tmp =
258  bndGraph->GetAllTriGeoms();
259  SpatialDomains::TriGeomMap::const_iterator sIt;
260 
261  for (sIt = tmp.begin(); sIt != tmp.end(); ++sIt)
262  {
264  int e;
265 
266  if (useVertexIds)
267  {
268  TriFaceIDs t(sIt->second->GetVid(0),
269  sIt->second->GetVid(1),
270  sIt->second->GetVid(2));
271 
272  tIt = vertexFaceMap.find(t);
273  e = tIt == vertexFaceMap.end() ? -1 : tIt->second;
274  }
275  else
276  {
278  mIt = bndCondIds.find(sIt->first);
279  e = mIt == bndCondIds.end() ? -1 : mIt->second;
280  }
281 
282  if (e == -1)
283  {
284  cout << "Warning: couldn't find element "
285  << sIt->first << endl;
286  continue;
287  }
288 
290  boost::dynamic_pointer_cast<SpatialDomains::TriGeom>(
291  bndCondExpU->GetExp(e)->GetGeom());
292 
293  SpatialDomains::TriGeomSharedPtr to = sIt->second;
294 
295  // Create temporary SegExp
296  LocalRegions::TriExpSharedPtr toSeg = MemoryManager<
297  LocalRegions::TriExp>::AllocateSharedPtr(
298  bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
299  bndCondExpV->GetExp(e)->GetBasis(1)->GetBasisKey(),
300  to);
301 
302  const int offset = bndCondExpU->GetPhys_Offset(e);
303  const int nq = toSeg->GetTotPoints();
304 
305  Array<OneD, NekDouble> xL(nq), xC(nq), yL(nq), yC(nq), tmp;
306  Array<OneD, NekDouble> zL(nq), zC(nq);
307 
308  bndCondExpU->GetExp(e)->GetCoords(xC, yC, zC);
309  toSeg->GetCoords(xL, yL, zL);
310 
311  Vmath::Vsub(nq, xL, 1, xC, 1,
312  tmp = bndCondExpU->UpdatePhys() + offset, 1);
313  Vmath::Vsub(nq, yL, 1, yC, 1,
314  tmp = bndCondExpV->UpdatePhys() + offset, 1);
315  Vmath::Vsub(nq, zL, 1, zC, 1,
316  tmp = bndCondExpW->UpdatePhys() + offset, 1);
317  }
318 
319  // bndconstrained?
320  bndCondExpU->FwdTrans_BndConstrained(
321  bndCondExpU->GetPhys(), bndCondExpU->UpdateCoeffs());
322  bndCondExpV->FwdTrans_BndConstrained(
323  bndCondExpV->GetPhys(), bndCondExpV->UpdateCoeffs());
324  bndCondExpW->FwdTrans_BndConstrained(
325  bndCondExpW->GetPhys(), bndCondExpW->UpdateCoeffs());
326  }
327  }
static boost::shared_ptr< MeshGraph > Read(const LibUtilities::SessionReaderSharedPtr &pSession, DomainRangeShPtr &rng=NullDomainRangeShPtr)
Definition: MeshGraph.cpp:121
map< string, ConfigOption > m_config
List of configuration values.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
FieldSharedPtr m_f
Field object.
std::map< int, TriGeomSharedPtr > TriGeomMap
Definition: TriGeom.h:62
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
boost::shared_ptr< SegExp > SegExpSharedPtr
Definition: SegExp.h:266
boost::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:60
std::map< int, SegGeomSharedPtr > SegGeomMap
Definition: SegGeom.h:54
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
boost::unordered_map< TriFaceIDs, int, TriFaceHash > TriFaceMap
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.cpp:329
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
boost::shared_ptr< TriGeom > TriGeomSharedPtr
Definition: TriGeom.h:58
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442
boost::shared_ptr< TriExp > TriExpSharedPtr
Definition: TriExp.h:291

Member Data Documentation

ModuleKey Nektar::Utilities::ProcessDisplacement::className
static
Initial value:
=
"Deform a mesh given an input field defining displacement")

Definition at line 53 of file ProcessDisplacement.h.