Nektar++
Loading...
Searching...
No Matches
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.
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module.
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set.
 
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.
 
- Static Public Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
static std::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class.
 

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.
 
std::string v_GetModuleName () override
 
std::string v_GetModuleDescription () override
 
- Protected Member Functions inherited from Nektar::FieldUtils::ProcessBoundaryExtract
ModulePriority v_GetModulePriority () override
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
virtual std::vector< ModuleKeyv_GetModulePrerequisites ()
 

Additional Inherited Members

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

Detailed Description

Definition at line 43 of file ProcessDisplacement.h.

Constructor & Destructor Documentation

◆ ProcessDisplacement()

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

Definition at line 101 of file ProcessDisplacement.cpp.

103{
104 m_config["to"] =
105 ConfigOption(false, "", "Name of file containing high order boundary");
106
107 m_config["usevertexids"] = ConfigOption(
108 true, "0", "Use vertex IDs instead of face IDs for matching");
109}
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 111 of file ProcessDisplacement.cpp.

112{
113}

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

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

Definition at line 51 of file ProcessDisplacement.h.