Nektar++
Classes | Typedefs | Functions | Variables
Nektar::GlobalMapping Namespace Reference

Classes

class  Mapping
 Base class for mapping to be applied to the coordinate system. More...
 
class  MappingGeneral
 
class  MappingTranslation
 
class  MappingXofXZ
 
class  MappingXofZ
 
class  MappingXYofXY
 
class  MappingXYofZ
 

Typedefs

typedef LibUtilities::NekFactory< std::string, Mapping, const LibUtilities::SessionReaderSharedPtr &, const Array< OneD, MultiRegions::ExpListSharedPtr > &, const TiXmlElement * > MappingFactory
 Declaration of the mapping factory. More...
 

Functions

void UpdateGeometry (SpatialDomains::MeshGraphSharedPtr graph, Array< OneD, MultiRegions::ExpListSharedPtr > &fields, Array< OneD, Array< OneD, NekDouble > > &PhysVals, bool modal)
 Update geometry according to displacement that is in current fields. More...
 
MappingFactoryGetMappingFactory ()
 Declaration of the mapping factory singleton. More...
 

Variables

GLOBAL_MAPPING_EXPORT typedef std::shared_ptr< MappingMappingSharedPtr
 A shared pointer to a Mapping object. More...
 

Typedef Documentation

◆ MappingFactory

Declaration of the mapping factory.

Definition at line 57 of file Mapping.h.

Function Documentation

◆ GetMappingFactory()

GLOBAL_MAPPING_EXPORT MappingFactory & Nektar::GlobalMapping::GetMappingFactory ( )

Declaration of the mapping factory singleton.

Definition at line 49 of file Mapping.cpp.

50{
51 static MappingFactory instance;
52 return instance;
53}
Provides a generic Factory class.
Definition: NekFactory.hpp:104

Referenced by Nektar::GlobalMapping::Mapping::Load().

◆ UpdateGeometry()

GLOBAL_MAPPING_EXPORT void Nektar::GlobalMapping::UpdateGeometry ( SpatialDomains::MeshGraphSharedPtr  graph,
Array< OneD, MultiRegions::ExpListSharedPtr > &  fields,
Array< OneD, Array< OneD, NekDouble > > &  PhysVals,
bool  modal 
)

Update geometry according to displacement that is in current fields.

Adds a summary item to the summary info list.

Parameters
graphThe MeshGraph of the current geometry.
fieldsThe fields containing the displacement.

Definition at line 59 of file Deform.cpp.

62{
63 // Clear existing curvature.
64 SpatialDomains::CurveMap &curvedEdges = graph->GetCurvedEdges();
65 SpatialDomains::CurveMap &curvedFaces = graph->GetCurvedFaces();
66 curvedEdges.clear();
67 curvedFaces.clear();
68
69 int i, j, k, l, dim;
70
71 // Sets to hold IDs of updated vertices to avoid duplicating effort.
72 set<int> updatedVerts, updatedEdges, updatedFaces;
73
74 dim = graph->GetSpaceDimension();
77
78 for (i = 0; i < fields[0]->GetExpSize(); ++i)
79 {
80 LocalRegions::ExpansionSharedPtr exp = fields[0]->GetExp(i);
81 int offset = fields[0]->GetPhys_Offset(i);
82 int nquad = exp->GetTotPoints();
83
84 // Extract displacement for this element, allocate storage for
85 // elemental coordinates.
86 for (j = 0; j < dim; ++j)
87 {
88 phys[j] = Array<OneD, NekDouble>(nquad, PhysVals[j] + offset);
89 coord[j] = Array<OneD, NekDouble>(nquad);
90 }
91
92 // In 2D loop over edges.
93 if (dim == 2)
94 {
95 exp->GetCoords(coord[0], coord[1]);
96
98 std::dynamic_pointer_cast<SpatialDomains::Geometry2D>(
99 exp->GetGeom());
100
101 for (j = 0; j < exp->GetGeom()->GetNumEdges(); ++j)
102 {
103 SpatialDomains::Geometry1DSharedPtr edge = geom->GetEdge(j);
104
105 // This edge has already been processed.
106 if (updatedEdges.find(edge->GetGlobalID()) !=
107 updatedEdges.end())
108 {
109 continue;
110 }
111
112 // Extract edge displacement.
113 int nEdgePts = exp->GetTraceNumPoints(j);
114 Array<OneD, Array<OneD, NekDouble>> edgePhys(dim);
115 Array<OneD, Array<OneD, NekDouble>> edgeCoord(dim);
116
117 const LibUtilities::BasisKey B(
119 LibUtilities::PointsKey(
122 MemoryManager<StdRegions::StdSegExp>::AllocateSharedPtr(B);
123
124 for (k = 0; k < dim; ++k)
125 {
126 edgePhys[k] = Array<OneD, NekDouble>(nEdgePts);
127 edgeCoord[k] = Array<OneD, NekDouble>(nEdgePts);
128 exp->GetTracePhysVals(j, seg, phys[k], edgePhys[k]);
129 exp->GetTracePhysVals(j, seg, coord[k], edgeCoord[k]);
130 }
131
132 // Update verts
133 for (k = 0; k < 2; ++k)
134 {
135 int id = edge->GetVid(k);
136 if (updatedVerts.find(id) != updatedVerts.end())
137 {
138 continue;
139 }
140
141 SpatialDomains::PointGeomSharedPtr pt = edge->GetVertex(k);
142
143 pt->UpdatePosition(
144 (*pt)(0) + edgePhys[0][k * (nEdgePts - 1)],
145 (*pt)(1) + edgePhys[1][k * (nEdgePts - 1)], (*pt)(2));
146
147 updatedVerts.insert(id);
148 }
149
150 // Update curve
152 MemoryManager<SpatialDomains::Curve>::AllocateSharedPtr(
153 edge->GetGlobalID(),
155
156 for (k = 0; k < nEdgePts; ++k)
157 {
159 MemoryManager<SpatialDomains::PointGeom>::
160 AllocateSharedPtr(dim, edge->GetGlobalID(),
161 edgeCoord[0][k] + edgePhys[0][k],
162 edgeCoord[1][k] + edgePhys[1][k],
163 0.0);
164
165 curve->m_points.push_back(vert);
166 }
167
168 curvedEdges[edge->GetGlobalID()] = curve;
169 updatedEdges.insert(edge->GetGlobalID());
170 }
171 }
172 else if (dim == 3)
173 {
174 exp->GetCoords(coord[0], coord[1], coord[2]);
175
177 std::dynamic_pointer_cast<SpatialDomains::Geometry3D>(
178 exp->GetGeom());
179
180 for (j = 0; j < exp->GetNtraces(); ++j)
181 {
182 SpatialDomains::Geometry2DSharedPtr face = geom->GetFace(j);
183
185 exp->as<LocalRegions::Expansion3D>();
186
187 // This edge has already been processed.
188 if (updatedFaces.find(face->GetGlobalID()) !=
189 updatedFaces.end())
190 {
191 continue;
192 }
193
194 // Extract face displacement.
195 LibUtilities::BasisKey B0 = exp->GetTraceBasisKey(j, 0);
196 LibUtilities::BasisKey B1 = exp->GetTraceBasisKey(j, 1);
197 int nq0 = B0.GetNumPoints();
198 int nq1 = B1.GetNumPoints();
199
200 ASSERTL1(B0.GetPointsType() ==
202 B1.GetPointsType() ==
204 "Deformation requires GLL points in both "
205 "directions on a face.");
206
207 Array<OneD, Array<OneD, NekDouble>> newPos(dim);
208
210 StdRegions::Orientation orient = exp->GetTraceOrient(j);
211
212 if (face->GetShapeType() == LibUtilities::eTriangle)
213 {
214 faceexp =
215 MemoryManager<StdRegions::StdTriExp>::AllocateSharedPtr(
216 B0, B1);
217 }
218 else
219 {
220 faceexp = MemoryManager<
221 StdRegions::StdQuadExp>::AllocateSharedPtr(B0, B1);
222 }
223
224 for (k = 0; k < dim; ++k)
225 {
226 Array<OneD, NekDouble> tmp(nq0 * nq1);
227 newPos[k] = Array<OneD, NekDouble>(nq0 * nq1);
228 exp3d->GetTracePhysVals(j, faceexp, phys[k], tmp, orient);
229 exp3d->GetTracePhysVals(j, faceexp, coord[k], newPos[k],
230 orient);
231 Vmath::Vadd(nq0 * nq1, tmp, 1, newPos[k], 1, newPos[k], 1);
232 }
233
234 // Now interpolate face onto a more reasonable set of
235 // points.
236 int nq = max(nq0, nq1);
237 if (!modal)
238 {
239 nq--;
240 }
241
242 LibUtilities::PointsKey edgePts(
244 LibUtilities::PointsKey triPts(nq, LibUtilities::eNodalTriElec);
245
246 Array<OneD, Array<OneD, NekDouble>> intPos(dim);
247
248 for (k = 0; k < dim; ++k)
249 {
250 intPos[k] = Array<OneD, NekDouble>(nq * nq);
251 LibUtilities::Interp2D(faceexp->GetPointsKeys()[0],
252 faceexp->GetPointsKeys()[1],
253 newPos[k], edgePts, edgePts,
254 intPos[k]);
255 }
256
257 int edgeOff[2][4][2] = {
258 {{0, 1}, {nq - 1, nq}, {nq * (nq - 1), -nq}, {-1, -1}},
259 {{0, 1},
260 {nq - 1, nq},
261 {nq * nq - 1, -1},
262 {nq * (nq - 1), -nq}}};
263
264 for (k = 0; k < face->GetNumVerts(); ++k)
265 {
266 // Update verts
267 int id = face->GetVid(k);
268 const int o =
269 face->GetShapeType() - LibUtilities::eTriangle;
270
271 if (updatedVerts.find(id) == updatedVerts.end())
272 {
274 face->GetVertex(k);
275 pt->UpdatePosition(intPos[0][edgeOff[o][k][0]],
276 intPos[1][edgeOff[o][k][0]],
277 intPos[2][edgeOff[o][k][0]]);
278 updatedVerts.insert(id);
279 }
280
281 // Update edges
282 id = face->GetEid(k);
283 if (updatedEdges.find(id) == updatedEdges.end())
284 {
286 face->GetEdge(k);
288 MemoryManager<SpatialDomains::Curve>::
289 AllocateSharedPtr(
290 edge->GetGlobalID(),
292
293 const int offset = edgeOff[o][k][0];
294 const int pos = edgeOff[o][k][1];
295
296 if (face->GetEorient(k) == StdRegions::eBackwards)
297 {
298 for (l = nq - 1; l >= 0; --l)
299 {
300 int m = offset + pos * l;
302 MemoryManager<SpatialDomains::PointGeom>::
303 AllocateSharedPtr(
304 dim, edge->GetGlobalID(),
305 intPos[0][m], intPos[1][m],
306 intPos[2][m]);
307 curve->m_points.push_back(vert);
308 }
309 }
310 else
311 {
312 for (l = 0; l < nq; ++l)
313 {
314 int m = offset + pos * l;
316 MemoryManager<SpatialDomains::PointGeom>::
317 AllocateSharedPtr(
318 dim, edge->GetGlobalID(),
319 intPos[0][m], intPos[1][m],
320 intPos[2][m]);
321 curve->m_points.push_back(vert);
322 }
323 }
324
325 curvedEdges[edge->GetGlobalID()] = curve;
326 updatedEdges.insert(edge->GetGlobalID());
327 }
328 }
329
330 // Update face-interior curvature
332 face->GetShapeType() == LibUtilities::eTriangle
335
337 MemoryManager<SpatialDomains::Curve>::AllocateSharedPtr(
338 face->GetGlobalID(), pType);
339
340 if (face->GetShapeType() == LibUtilities::eTriangle)
341 {
342 // This code is probably pretty crappy. Have to go from
343 // GLL-GLL points -> GLL-Gauss-Radau -> nodal triangle
344 // points.
345 const LibUtilities::BasisKey B0(
347 LibUtilities::PointsKey(
349 const LibUtilities::BasisKey B1(
351 LibUtilities::PointsKey(
352 nq, LibUtilities::eGaussRadauMAlpha1Beta0));
353 StdRegions::StdNodalTriExp nodalTri(B0, B1, pType);
354 StdRegions::StdTriExp tri(B0, B1);
355
356 for (k = 0; k < dim; ++k)
357 {
358 Array<OneD, NekDouble> nodal(nq * nq);
359
361 faceexp->GetBasis(0)->GetBasisKey(),
362 faceexp->GetBasis(1)->GetBasisKey(), newPos[k], B0,
363 B1, nodal);
364
365 Array<OneD, NekDouble> tmp1(nq * (nq + 1) / 2);
366 Array<OneD, NekDouble> tmp2(nq * (nq + 1) / 2);
367
368 tri.FwdTrans(nodal, tmp1);
369 nodalTri.ModalToNodal(tmp1, tmp2);
370 newPos[k] = tmp2;
371 }
372
373 for (l = 0; l < nq * (nq + 1) / 2; ++l)
374 {
376 MemoryManager<SpatialDomains::PointGeom>::
377 AllocateSharedPtr(dim, face->GetGlobalID(),
378 newPos[0][l], newPos[1][l],
379 newPos[2][l]);
380 curve->m_points.push_back(vert);
381 }
382 }
383 else
384 {
385 for (l = 0; l < nq * nq; ++l)
386 {
388 MemoryManager<SpatialDomains::PointGeom>::
389 AllocateSharedPtr(dim, face->GetGlobalID(),
390 intPos[0][l], intPos[1][l],
391 intPos[2][l]);
392 curve->m_points.push_back(vert);
393 }
394 }
395
396 curvedFaces[face->GetGlobalID()] = curve;
397 updatedFaces.insert(face->GetGlobalID());
398 }
399 }
400 }
401
402 // Reset geometry information
403 for (i = 0; i < fields.size(); ++i)
404 {
405 fields[i]->Reset();
406 }
407}
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
void Interp2D(const BasisKey &fbasis0, const BasisKey &fbasis1, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, const BasisKey &tbasis1, Array< OneD, NekDouble > &to)
this function interpolates a 2D function evaluated at the quadrature points of the 2D basis,...
Definition: Interp.cpp:101
@ eNodalTriElec
2D Nodal Electrostatic Points on a Triangle
Definition: PointsType.h:81
@ eGaussLobattoLegendre
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:51
@ eOrtho_A
Principle Orthogonal Functions .
Definition: BasisType.h:42
@ eOrtho_B
Principle Orthogonal Functions .
Definition: BasisType.h:44
@ eModified_A
Principle Modified Functions .
Definition: BasisType.h:48
std::shared_ptr< Expansion > ExpansionSharedPtr
Definition: Expansion.h:66
std::shared_ptr< Expansion3D > Expansion3DSharedPtr
Definition: Expansion2D.h:47
std::shared_ptr< Curve > CurveSharedPtr
Definition: Curve.hpp:58
std::unordered_map< int, CurveSharedPtr > CurveMap
Definition: Curve.hpp:59
std::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:57
std::shared_ptr< Geometry2D > Geometry2DSharedPtr
Definition: Geometry.h:62
std::shared_ptr< Geometry1D > Geometry1DSharedPtr
Definition: Geometry.h:61
std::shared_ptr< Geometry3D > Geometry3DSharedPtr
Definition: Geometry3D.h:50
std::shared_ptr< StdExpansion2D > StdExpansion2DSharedPtr
std::shared_ptr< StdExpansion1D > StdExpansion1DSharedPtr
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.hpp:180

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL1, Nektar::StdRegions::eBackwards, Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eModified_A, Nektar::LibUtilities::eNodalTriElec, Nektar::LibUtilities::eOrtho_A, Nektar::LibUtilities::eOrtho_B, Nektar::LibUtilities::eTriangle, Nektar::StdRegions::StdExpansion::FwdTrans(), Nektar::LibUtilities::BasisKey::GetNumPoints(), Nektar::LibUtilities::BasisKey::GetPointsType(), Nektar::LibUtilities::Interp2D(), Nektar::StdRegions::StdNodalTriExp::ModalToNodal(), and Vmath::Vadd().

Referenced by Nektar::IterativeElasticSystem::v_DoSolve(), and Nektar::FieldUtils::ProcessDeform::v_Process().

Variable Documentation

◆ MappingSharedPtr

GLOBAL_MAPPING_EXPORT typedef std::shared_ptr<Mapping> Nektar::GlobalMapping::MappingSharedPtr