Nektar++
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:
[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 ()
 
virtual std::string GetModuleDescription ()
 
- Public Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
 ProcessBoundaryExtract (FieldSharedPtr f)
 
virtual ~ProcessBoundaryExtract ()
 
virtual ModulePriority GetModulePriority ()
 
- 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)
 
virtual ~Module ()=default
 
const ConfigOptionGetConfigOption (const std::string &key) const
 
FIELD_UTILS_EXPORT void RegisterConfig (std::string key, std::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 void AddFile (std::string fileType, std::string fileName)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

static std::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 
- Static Public Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
static std::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey className
 
- Static Public Attributes inherited from Nektar::FieldUtils::ProcessBoundaryExtract
static ModuleKey className
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 
std::set< std::string > m_allowedFiles
 List of allowed file formats. More...
 

Detailed Description

Definition at line 45 of file ProcessDisplacement.h.

Constructor & Destructor Documentation

◆ ProcessDisplacement()

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

Definition at line 103 of file ProcessDisplacement.cpp.

105 {
106  m_config["to"] =
107  ConfigOption(false, "", "Name of file containing high order boundary");
108 
109  m_config["usevertexids"] = ConfigOption(
110  true, "0", "Use vertex IDs instead of face IDs for matching");
111 }
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:233

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

◆ ~ProcessDisplacement()

Nektar::FieldUtils::ProcessDisplacement::~ProcessDisplacement ( )
virtual

Definition at line 113 of file ProcessDisplacement.cpp.

114 {
115 }

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 49 of file ProcessDisplacement.h.

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

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

◆ GetModuleDescription()

virtual std::string Nektar::FieldUtils::ProcessDisplacement::GetModuleDescription ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 66 of file ProcessDisplacement.h.

67  {
68  return "Calculating displacement";
69  }

◆ GetModuleName()

virtual std::string Nektar::FieldUtils::ProcessDisplacement::GetModuleName ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 61 of file ProcessDisplacement.h.

62  {
63  return "ProcessDisplacement";
64  }

◆ Process()

void Nektar::FieldUtils::ProcessDisplacement::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 117 of file ProcessDisplacement.cpp.

118 {
120  ASSERTL0( !boost::iequals(m_config["bnd"].as<string>(), "All"),
121  "ProcessDisplacement needs bnd parameter with a single id.");
122 
123  string toFile = m_config["to"].as<string>();
124 
125  if (toFile == "")
126  {
127  cout << "ProcessDisplacement: you must provide a file" << endl;
128  return;
129  }
130 
131  bool useVertexIds = m_config["usevertexids"].as<bool>();
132 
133  vector<string> files;
134  files.push_back(toFile);
139 
140  // Try to find boundary condition expansion.
141  int bndCondId = m_config["bnd"].as<int>();
142 
143  // FIXME: We should be storing boundary condition IDs
144  // somewhere...
145  if (bndGraph->GetMeshDimension() == 1)
146  {
147  m_f->m_exp.push_back(m_f->AppendExpList(0, "v"));
148  m_f->m_variables.push_back("v");
149 
150  MultiRegions::ExpListSharedPtr bndCondExpU =
151  m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
152  MultiRegions::ExpListSharedPtr bndCondExpV =
153  m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
154 
155  map<int, int> bndCondIds;
156  for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
157  {
158  bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()] = i;
159  }
160 
161  const SpatialDomains::SegGeomMap &tmp = bndGraph->GetAllSegGeoms();
162 
163  for (auto &sIt : tmp)
164  {
165  auto mIt = bndCondIds.find(sIt.first);
166 
167  if (mIt == bndCondIds.end())
168  {
169  cout << "Warning: couldn't find element " << sIt.first << endl;
170  continue;
171  }
172 
173  int e = mIt->second;
174 
176  std::dynamic_pointer_cast<SpatialDomains::SegGeom>(
177  bndCondExpU->GetExp(e)->GetGeom());
178 
179  SpatialDomains::SegGeomSharedPtr to = sIt.second;
180 
181  // Create temporary SegExp
184  bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(), to);
185 
186  const int offset = bndCondExpU->GetPhys_Offset(e);
187  const int nq = toSeg->GetTotPoints();
188 
189  Array<OneD, NekDouble> xL(nq), xC(nq), yL(nq), yC(nq), tmp;
190 
191  bndCondExpU->GetExp(e)->GetCoords(xC, yC);
192  toSeg->GetCoords(xL, yL);
193 
194  Vmath::Vsub(nq, xL, 1, xC, 1,
195  tmp = bndCondExpU->UpdatePhys() + offset, 1);
196  Vmath::Vsub(nq, yL, 1, yC, 1,
197  tmp = bndCondExpV->UpdatePhys() + offset, 1);
198  }
199 
200  // bndconstrained?
201  bndCondExpU->FwdTrans_BndConstrained(bndCondExpU->GetPhys(),
202  bndCondExpU->UpdateCoeffs());
203  bndCondExpV->FwdTrans_BndConstrained(bndCondExpV->GetPhys(),
204  bndCondExpV->UpdateCoeffs());
205  }
206  else if (bndGraph->GetMeshDimension() == 2)
207  {
208  m_f->m_exp.push_back(m_f->AppendExpList(0, "v"));
209  m_f->m_exp.push_back(m_f->AppendExpList(0, "w"));
210  m_f->m_variables.push_back("v");
211  m_f->m_variables.push_back("w");
212 
213  MultiRegions::ExpListSharedPtr bndCondExpU =
214  m_f->m_exp[0]->GetBndCondExpansions()[bndCondId];
215  MultiRegions::ExpListSharedPtr bndCondExpV =
216  m_f->m_exp[1]->GetBndCondExpansions()[bndCondId];
217  MultiRegions::ExpListSharedPtr bndCondExpW =
218  m_f->m_exp[2]->GetBndCondExpansions()[bndCondId];
219 
220  map<int, int> bndCondIds;
221  for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
222  {
223  bndCondIds[bndCondExpU->GetExp(i)->GetGeom()->GetGlobalID()] = i;
224  }
225 
226  TriFaceMap vertexFaceMap;
227 
228  if (useVertexIds)
229  {
230  for (int i = 0; i < bndCondExpU->GetExpSize(); ++i)
231  {
233  std::dynamic_pointer_cast<SpatialDomains::TriGeom>(
234  bndCondExpU->GetExp(i)->GetGeom());
235 
236  TriFaceIDs t(from->GetVid(0), from->GetVid(1), from->GetVid(2));
237  vertexFaceMap[t] = i;
238  }
239  }
240 
241  const SpatialDomains::TriGeomMap &tmp = bndGraph->GetAllTriGeoms();
242 
243  for (auto &sIt : tmp)
244  {
245  int e;
246 
247  if (useVertexIds)
248  {
249  TriFaceIDs t(sIt.second->GetVid(0), sIt.second->GetVid(1),
250  sIt.second->GetVid(2));
251 
252  auto tIt = vertexFaceMap.find(t);
253  e = tIt == vertexFaceMap.end() ? -1 : tIt->second;
254  }
255  else
256  {
257  auto mIt = bndCondIds.find(sIt.first);
258  e = mIt == bndCondIds.end() ? -1 : mIt->second;
259  }
260 
261  if (e == -1)
262  {
263  cout << "Warning: couldn't find element " << sIt.first << endl;
264  continue;
265  }
266 
268  std::dynamic_pointer_cast<SpatialDomains::TriGeom>(
269  bndCondExpU->GetExp(e)->GetGeom());
270 
271  SpatialDomains::TriGeomSharedPtr to = sIt.second;
272 
273  // Create temporary SegExp
276  bndCondExpU->GetExp(e)->GetBasis(0)->GetBasisKey(),
277  bndCondExpV->GetExp(e)->GetBasis(1)->GetBasisKey(), to);
278 
279  const int offset = bndCondExpU->GetPhys_Offset(e);
280  const int nq = toSeg->GetTotPoints();
281 
282  Array<OneD, NekDouble> xL(nq), xC(nq), yL(nq), yC(nq), tmp;
283  Array<OneD, NekDouble> zL(nq), zC(nq);
284 
285  bndCondExpU->GetExp(e)->GetCoords(xC, yC, zC);
286  toSeg->GetCoords(xL, yL, zL);
287 
288  Vmath::Vsub(nq, xL, 1, xC, 1,
289  tmp = bndCondExpU->UpdatePhys() + offset, 1);
290  Vmath::Vsub(nq, yL, 1, yC, 1,
291  tmp = bndCondExpV->UpdatePhys() + offset, 1);
292  Vmath::Vsub(nq, zL, 1, zC, 1,
293  tmp = bndCondExpW->UpdatePhys() + offset, 1);
294  }
295 
296  // bndconstrained?
297  bndCondExpU->FwdTrans_BndConstrained(bndCondExpU->GetPhys(),
298  bndCondExpU->UpdateCoeffs());
299  bndCondExpV->FwdTrans_BndConstrained(bndCondExpV->GetPhys(),
300  bndCondExpV->UpdateCoeffs());
301  bndCondExpW->FwdTrans_BndConstrained(bndCondExpW->GetPhys(),
302  bndCondExpW->UpdateCoeffs());
303  }
304 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
FieldSharedPtr m_f
Field object.
Definition: Module.h:230
virtual void Process(po::variables_map &vm)
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true)
Definition: MeshGraph.cpp:113
std::unordered_map< TriFaceIDs, int, TriFaceHash > TriFaceMap
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< SegExp > SegExpSharedPtr
Definition: SegExp.h:272
std::shared_ptr< TriExp > TriExpSharedPtr
Definition: TriExp.h:297
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::map< int, TriGeomSharedPtr > TriGeomMap
Definition: TriGeom.h:59
std::map< int, SegGeomSharedPtr > SegGeomMap
Definition: SegGeom.h:52
std::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:62
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
std::shared_ptr< TriGeom > TriGeomSharedPtr
Definition: TriGeom.h:58
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:372

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

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessDisplacement::className
static
Initial value:
=
ModuleKey(eProcessModule, "displacement"),
"Deform a mesh given an input field defining displacement")
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:200
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:290
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49

Definition at line 53 of file ProcessDisplacement.h.