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)
 
virtual ~ProcessDisplacement ()
 
- Public Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
 ProcessBoundaryExtract (FieldSharedPtr f)
 
virtual ~ProcessBoundaryExtract ()
 
- 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 ()
 
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

virtual void v_Process (po::variables_map &vm) override
 Write mesh to output file. More...
 
virtual std::string v_GetModuleName () override
 
virtual std::string v_GetModuleDescription () override
 
- Protected Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
virtual void v_Process (po::variables_map &vm) override
 
virtual std::string v_GetModuleName () override
 
virtual std::string v_GetModuleDescription () override
 
virtual 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 ()
 

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

Constructor & Destructor Documentation

◆ ProcessDisplacement()

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

Definition at line 102 of file ProcessDisplacement.cpp.

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

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

◆ ~ProcessDisplacement()

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

Definition at line 112 of file ProcessDisplacement.cpp.

113{
114}

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().

◆ v_GetModuleDescription()

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

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 67 of file ProcessDisplacement.h.

68 {
69 return "Calculating displacement";
70 }

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::ProcessBoundaryExtract.

Definition at line 62 of file ProcessDisplacement.h.

63 {
64 return "ProcessDisplacement";
65 }

◆ 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 116 of file ProcessDisplacement.cpp.

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

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:198
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:317
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49

Definition at line 53 of file ProcessDisplacement.h.