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

#include <ProcessDisplacement.h>

Inheritance diagram for Nektar::FieldUtils::ProcessDisplacement:
Inheritance graph
[legend]
Collaboration diagram for Nektar::FieldUtils::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::FieldUtils::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
- Public Member Functions inherited from Nektar::FieldUtils::Module
FIELD_UTILS_EXPORT Module (FieldSharedPtr p_f)
 
FIELD_UTILS_EXPORT void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
FIELD_UTILS_EXPORT bool GetRequireEquiSpaced (void)
 
FIELD_UTILS_EXPORT void SetRequireEquiSpaced (bool pVal)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

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::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 

Detailed Description

Definition at line 46 of file ProcessDisplacement.h.

Constructor & Destructor Documentation

Nektar::FieldUtils::ProcessDisplacement::ProcessDisplacement ( FieldSharedPtr  f)

Definition at line 108 of file ProcessDisplacement.cpp.

References Nektar::FieldUtils::Module::m_config.

108  : ProcessModule(f)
109 {
110  m_config["to"] =
111  ConfigOption(false, "", "Name of file containing high order boundary");
112  m_config["id"] =
113  ConfigOption(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::FieldUtils::ProcessDisplacement::~ProcessDisplacement ( )
virtual

Definition at line 121 of file ProcessDisplacement.cpp.

122 {
123 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 50 of file ProcessDisplacement.h.

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

51  {
53  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual std::string Nektar::FieldUtils::ProcessDisplacement::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 62 of file ProcessDisplacement.h.

63  {
64  return "ProcessDisplacement";
65  }
void Nektar::FieldUtils::ProcessDisplacement::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::FieldUtils::Module.

Definition at line 125 of file ProcessDisplacement.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::iterator, Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, Nektar::SpatialDomains::MeshGraph::Read(), and Vmath::Vsub().

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

Member Data Documentation

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

Definition at line 54 of file ProcessDisplacement.h.