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...
 
virtual std::string GetModuleName ()
 
- 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.
virtual std::string Nektar::Utilities::ProcessDisplacement::GetModuleName ( )
inlinevirtual

Implements Nektar::Utilities::Module.

Definition at line 61 of file ProcessDisplacement.h.

62  {
63  return "ProcessDisplacement";
64  }
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  if(m_f->m_comm->GetRank() == 0)
130  {
131  cout << "ProcessDisplacement: Calculating displacement..."
132  << endl;
133  }
134  }
135 
136  string toFile = m_config["to"].as<string>();
137 
138  if (toFile == "")
139  {
140  cout << "ProcessDisplacement: you must provide a file" << endl;
141  return;
142  }
143 
144  bool useVertexIds = m_config["usevertexids"].m_beenSet;
145 
146  vector<string> files;
147  files.push_back(toFile);
152 
153  // Try to find boundary condition expansion.
154  int bndCondId = m_config["id"].as<int>();
155 
156  // FIXME: We should be storing boundary condition IDs
157  // somewhere...
158  m_f->m_bndRegionsToWrite.push_back(bndCondId);
159 
160  if (bndGraph->GetMeshDimension() == 1)
161  {
162  m_f->m_exp.push_back(m_f->AppendExpList(0, "v"));
163 
164  MultiRegions::ExpListSharedPtr bndCondExpU =
165  m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
166  MultiRegions::ExpListSharedPtr bndCondExpV =
167  m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
168 
169  map<int, int> bndCondIds;
170  for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
171  {
172  bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()]
173  = i;
174  }
175 
176  const SpatialDomains::SegGeomMap &tmp =
177  bndGraph->GetAllSegGeoms();
178  SpatialDomains::SegGeomMap::const_iterator sIt;
179 
180  for (sIt = tmp.begin(); sIt != tmp.end(); ++sIt)
181  {
182  map<int, int>::iterator mIt = bndCondIds.find(sIt->first);
183 
184  if (mIt == bndCondIds.end())
185  {
186  cout << "Warning: couldn't find element "
187  << sIt->first << endl;
188  continue;
189  }
190 
191  int e = mIt->second;
192 
194  boost::dynamic_pointer_cast<SpatialDomains::SegGeom>(
195  bndCondExpU->GetExp(e)->GetGeom());
196 
197  SpatialDomains::SegGeomSharedPtr to = sIt->second;
198 
199  // Create temporary SegExp
200  LocalRegions::SegExpSharedPtr toSeg = MemoryManager<
201  LocalRegions::SegExp>::AllocateSharedPtr(
202  bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
203  to);
204 
205  const int offset = bndCondExpU->GetPhys_Offset(e);
206  const int nq = toSeg->GetTotPoints();
207 
208  Array<OneD, NekDouble> xL(nq), xC(nq), yL(nq), yC(nq), tmp;
209 
210  bndCondExpU->GetExp(e)->GetCoords(xC, yC);
211  toSeg->GetCoords(xL, yL);
212 
213  Vmath::Vsub(nq, xL, 1, xC, 1,
214  tmp = bndCondExpU->UpdatePhys() + offset, 1);
215  Vmath::Vsub(nq, yL, 1, yC, 1,
216  tmp = bndCondExpV->UpdatePhys() + offset, 1);
217  }
218 
219  // bndconstrained?
220  bndCondExpU->FwdTrans_BndConstrained(
221  bndCondExpU->GetPhys(), bndCondExpU->UpdateCoeffs());
222  bndCondExpV->FwdTrans_BndConstrained(
223  bndCondExpV->GetPhys(), bndCondExpV->UpdateCoeffs());
224  }
225  else if (bndGraph->GetMeshDimension() == 2)
226  {
227  m_f->m_exp.push_back(m_f->AppendExpList(0, "v"));
228  m_f->m_exp.push_back(m_f->AppendExpList(0, "w"));
229 
230  MultiRegions::ExpListSharedPtr bndCondExpU =
231  m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
232  MultiRegions::ExpListSharedPtr bndCondExpV =
233  m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
234  MultiRegions::ExpListSharedPtr bndCondExpW =
235  m_f->m_exp[2]->GetBndCondExpansions()[bndCondId];
236 
237  map<int, int> bndCondIds;
238  for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
239  {
240  bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()]
241  = i;
242  }
243 
244  TriFaceMap vertexFaceMap;
245 
246  if (useVertexIds)
247  {
248  for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
249  {
251  boost::dynamic_pointer_cast<SpatialDomains::TriGeom>(
252  bndCondExpU->GetExp(i)->GetGeom());
253 
254  TriFaceIDs t(from->GetVid(0), from->GetVid(1),
255  from->GetVid(2));
256  vertexFaceMap[t] = i;
257  }
258  }
259 
260  const SpatialDomains::TriGeomMap &tmp =
261  bndGraph->GetAllTriGeoms();
262  SpatialDomains::TriGeomMap::const_iterator sIt;
263 
264  for (sIt = tmp.begin(); sIt != tmp.end(); ++sIt)
265  {
267  int e;
268 
269  if (useVertexIds)
270  {
271  TriFaceIDs t(sIt->second->GetVid(0),
272  sIt->second->GetVid(1),
273  sIt->second->GetVid(2));
274 
275  tIt = vertexFaceMap.find(t);
276  e = tIt == vertexFaceMap.end() ? -1 : tIt->second;
277  }
278  else
279  {
281  mIt = bndCondIds.find(sIt->first);
282  e = mIt == bndCondIds.end() ? -1 : mIt->second;
283  }
284 
285  if (e == -1)
286  {
287  cout << "Warning: couldn't find element "
288  << sIt->first << endl;
289  continue;
290  }
291 
293  boost::dynamic_pointer_cast<SpatialDomains::TriGeom>(
294  bndCondExpU->GetExp(e)->GetGeom());
295 
296  SpatialDomains::TriGeomSharedPtr to = sIt->second;
297 
298  // Create temporary SegExp
299  LocalRegions::TriExpSharedPtr toSeg = MemoryManager<
300  LocalRegions::TriExp>::AllocateSharedPtr(
301  bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
302  bndCondExpV->GetExp(e)->GetBasis(1)->GetBasisKey(),
303  to);
304 
305  const int offset = bndCondExpU->GetPhys_Offset(e);
306  const int nq = toSeg->GetTotPoints();
307 
308  Array<OneD, NekDouble> xL(nq), xC(nq), yL(nq), yC(nq), tmp;
309  Array<OneD, NekDouble> zL(nq), zC(nq);
310 
311  bndCondExpU->GetExp(e)->GetCoords(xC, yC, zC);
312  toSeg->GetCoords(xL, yL, zL);
313 
314  Vmath::Vsub(nq, xL, 1, xC, 1,
315  tmp = bndCondExpU->UpdatePhys() + offset, 1);
316  Vmath::Vsub(nq, yL, 1, yC, 1,
317  tmp = bndCondExpV->UpdatePhys() + offset, 1);
318  Vmath::Vsub(nq, zL, 1, zC, 1,
319  tmp = bndCondExpW->UpdatePhys() + offset, 1);
320  }
321 
322  // bndconstrained?
323  bndCondExpU->FwdTrans_BndConstrained(
324  bndCondExpU->GetPhys(), bndCondExpU->UpdateCoeffs());
325  bndCondExpV->FwdTrans_BndConstrained(
326  bndCondExpV->GetPhys(), bndCondExpV->UpdateCoeffs());
327  bndCondExpW->FwdTrans_BndConstrained(
328  bndCondExpW->GetPhys(), bndCondExpW->UpdateCoeffs());
329  }
330  }
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.