Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | 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)
 
 ~ProcessDisplacement () override
 
- Public Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
 ProcessBoundaryExtract (FieldSharedPtr f)
 
 ~ProcessBoundaryExtract () override
 
- 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
 
void Process (po::variables_map &vm)
 
std::string GetModuleName ()
 
std::string GetModuleDescription ()
 
const ConfigOptionGetConfigOption (const std::string &key) const
 
ModulePriority GetModulePriority ()
 
std::vector< ModuleKeyGetModulePrerequisites ()
 
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
 

Protected Member Functions

void v_Process (po::variables_map &vm) override
 Write mesh to output file. More...
 
std::string v_GetModuleName () override
 
std::string v_GetModuleDescription () override
 
- Protected Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
void v_Process (po::variables_map &vm) override
 
std::string v_GetModuleName () override
 
std::string v_GetModuleDescription () override
 
ModulePriority v_GetModulePriority () override
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
virtual void v_Process (po::variables_map &vm)
 
virtual std::string v_GetModuleName ()
 
virtual std::string v_GetModuleDescription ()
 
virtual ModulePriority v_GetModulePriority ()
 
virtual std::vector< ModuleKeyv_GetModulePrerequisites ()
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
- 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 43 of file ProcessDisplacement.h.

Constructor & Destructor Documentation

◆ ProcessDisplacement()

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

Definition at line 100 of file ProcessDisplacement.cpp.

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

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

◆ ~ProcessDisplacement()

Nektar::FieldUtils::ProcessDisplacement::~ProcessDisplacement ( )
override

Definition at line 110 of file ProcessDisplacement.cpp.

111{
112}

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 47 of file ProcessDisplacement.h.

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

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

◆ v_GetModuleDescription()

std::string Nektar::FieldUtils::ProcessDisplacement::v_GetModuleDescription ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 65 of file ProcessDisplacement.h.

66 {
67 return "Calculating displacement";
68 }

◆ v_GetModuleName()

std::string Nektar::FieldUtils::ProcessDisplacement::v_GetModuleName ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 60 of file ProcessDisplacement.h.

61 {
62 return "ProcessDisplacement";
63 }

◆ v_Process()

void Nektar::FieldUtils::ProcessDisplacement::v_Process ( po::variables_map &  vm)
overrideprotectedvirtual

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 114 of file ProcessDisplacement.cpp.

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

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

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessDisplacement::className
static
Initial value:
=
"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:197
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:180
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:47

Definition at line 51 of file ProcessDisplacement.h.