libsurf
Programmer's Documentation

fsimesh.h (r6227/r5385)
1 
2 /* Copyright (C) 2015 David Eller <david@larosterna.com>
3  *
4  * Commercial License Usage
5  * Licensees holding valid commercial licenses may use this file in accordance
6  * with the terms contained in their respective non-exclusive license agreement.
7  * For further information contact david@larosterna.com .
8  *
9  * GNU General Public License Usage
10  * Alternatively, this file may be used under the terms of the GNU General
11  * Public License version 3.0 as published by the Free Software Foundation and
12  * appearing in the file gpl.txt included in the packaging of this file.
13  */
14 
15 #ifndef SURF_FSIMESH_H
16 #define SURF_FSIMESH_H
17 
18 #include <genua/mxmesh.h>
19 #include <genua/boxsearchtree.h>
20 #include <genua/connectmap.h>
21 #include <genua/csrmatrix.h>
22 #include <genua/atomicop.h>
23 #include <boost/shared_ptr.hpp>
24 
25 class FsiElement;
26 
40 class FsiMesh
41 {
42 public:
43 
46 
48  FsiMesh() : searchRadius(0.0), minCosPhi(-1.0), maxCosPhi(1.0) {}
49 
51  virtual ~FsiMesh() {}
52 
54  Real catchRadius() const {return searchRadius;}
55 
57  void catchRadius(Real r) {searchRadius = r;}
58 
60  Real maxNormalAngle() const {return acos(minCosPhi);}
61 
63  void maxNormalAngle(Real phi) {minCosPhi = cos(phi);}
64 
66  Real minNormalAngle() const {return acos(maxCosPhi);}
67 
69  void minNormalAngle(Real phi) {maxCosPhi = cos(phi);}
70 
72  const MxMesh & fluidMesh() const {assert(fmx); return *fmx;}
73 
75  const MxMesh & structMesh() const {assert(smx); return *smx;}
76 
78  void mergeStruct(const MxMeshPtr & pmx,
79  const Indices & pidwet = Indices(),
80  const Indices & pidintern = Indices());
81 
83  void mergeBeams(const MxMeshPtr & pmx);
84 
86  void mergeFluid(const MxMeshPtr & pmx,
87  const Indices & ifboco = Indices());
88 
90  void buildInterpolator();
91 
93  const Indices & structuralElements() const {return sifElix;}
94 
96  const Indices & structuralNodes() const {return sifNode;}
97 
99  const Indices & fluidElements() const {return fifElix;}
100 
102  const Indices & fluidNodes() const {return fifNode;}
103 
105  bool extractPressure(Real qoo, uint ixf, Vector & pf) const;
106 
108  bool extractPressure(Real qoo, Vector & pf,
109  const std::string & fieldName = "CoefPressure") const;
110 
112  void assemblePressure(Real qoo, const Indices & ifield, const Vector & coef,
113  Vector & pf) const;
114 
116  void agglomerate(const Vector & pf, PointList<6> & fnodal) const;
117 
119  void agglomerate(const Matrix & mpf, PointGrid<6> & fnodal) const;
120 
122  void integrate(const Vector & pf, PointList<6> & fnodal) const;
123 
125  void integrate(const Matrix & pf, PointGrid<6> & fnodal) const;
126 
128  // void mapping(PFMap & map) const;
129 
131  uint exportForces(const PointList<3> & fnodal,
132  std::ostream &os, uint sid=1, Real ff=1.0) const;
133 
135  uint exportForces(const PointList<3> & fnodal,
136  const std::string & fname, uint sid=1, Real ff=1.0) const;
137 
139  uint exportForces(const PointList<6> & fnodal,
140  std::ostream & os,
141  uint sid=1, Real ff=1.0, Real lf=1.0) const;
142 
144  uint exportForces(const PointList<6> & fnodal,
145  const std::string & fname,
146  uint sid=1, Real ff=1.0, Real lf=1.0) const;
147 
149  uint exportForces(uint ifield, std::ostream & os,
150  uint sid=1, Real ff=1.0, Real lf=1.0) const;
151 
153  uint exportDarea(uint sid, const PointList<6> & fnodal,
154  std::ostream & os, Real ff=1.0, Real lf=1.0) const;
155 
157  Vct6 sum(const Vct3 & ptref, const PointList<6> & fm) const;
158 
160  uint appendSifField(const PointList<3> & fn,
161  const std::string & suffix = "");
162 
164  void appendSifField(const PointList<6> & fn,
165  const std::string & suffix = "");
166 
168  void residualizeLoads(const CsrMatrix<Real> & M);
169 
171  void augmentedStates(const CsrMatrix<Real> & M, const CsrMatrix<Real> & K);
172 
174  virtual void clear();
175 
177  void centerForces(const Vector & pf,
178  PointList<3> & ctr, PointList<3> & cf) const;
179 
181  void centerForces(const Matrix & pf,
182  PointList<3> & ctr, PointGrid<3> & cf) const;
183 
184 private:
185 
187  void collectNodes(const MxMesh & mx, const Indices & elix,
188  Indices & nds) const;
189 
191  void extractGids(const MxMesh & smx);
192 
194  void buildTree(const MxMesh & mx, const Indices & idx,
195  BSearchTree & tree) const;
196 
198  void buildMap(const MxMesh & mx, const Indices & nds, const Indices & elm,
199  ConnectMap & v2emap) const;
200 
202  void evalPressure(const Vector & pf, uint eix,
203  const Vct2 & uv, Vct3 & psn) const;
204 
206  void evalPressure(const Matrix & pf, uint eix,
207  const Vct2 & uv, PointList<3> & psn) const;
208 
210  uint nearestFluidElement(const Vct3 & pt, Vct2 & uv) const;
211 
213  uint nearestFluidElement(const Vct3 & pt, const Vct3 & nrm, Vct2 & uv) const;
214 
216  void nearbyFluidElements(const Vct3 & pt, const Vct3 & nrm, Indices & elm) const;
217 
219  Real project(const Vct3 & pt, uint eix, Vct2 & uv) const;
220 
222  Real projectTri3(const Vct3 & pt, const uint *vi, Vct2 & uv) const;
223 
225  template <int M>
226  void atomicUpdate(uint inode, const SVector<M> & fj, PointList<M> & nf) const {
227  uint jnode = sorted_index(sifNode, inode);
228  if (jnode == NotFound)
229  return;
230  for (int k=0; k<M; ++k)
231  atomic_add(nf[jnode][k], fj[k]);
232  }
233 
235  template <int M>
236  void atomicUpdate(uint inode, const SVector<M> & fj, uint jcol,
237  PointGrid<M> & nf) const {
238  uint jnode = sorted_index(sifNode, inode);
239  if (jnode == NotFound)
240  return;
241  for (int k=0; k<M; ++k)
242  atomic_add(nf(jnode,jcol)[k], fj[k]);
243  }
244 
246  Vct3 moment(const Vct3 & c,
247  const PointList<3> & ctr, const PointList<3> & cf) const;
248 
250  void mappingPattern(ConnectMap & spty) const;
251 
252 private:
253 
255  MxMeshPtr smx;
256 
258  MxMeshPtr fmx;
259 
261  Indices sifNode;
262 
264  Indices sifElix;
265 
267  Indices fifNode;
268 
270  Indices fifElix;
271 
273  Indices gids, allGids;
274 
277 
280 
283 
286 
288  Real minCosPhi, maxCosPhi;
289 
290  friend class FsiElement;
291  friend class FsiTri3;
292  friend class FsiQuad4;
293 };
294 
295 typedef boost::shared_ptr<FsiMesh> FsiMeshPtr;
296 
297 #endif // FSIMESH_H
Indices sifElix
indices of structural interface elements
Definition: fsimesh.h:264
const Indices & structuralElements() const
access array of structural interface elements
Definition: fsimesh.h:93
void integrate(const Vector &pf, PointList< 6 > &fnodal) const
integrate over structural elements
Definition: fsimesh.cpp:369
void minNormalAngle(Real phi)
minimum angle between normals of elements considered for projection
Definition: fsimesh.h:69
CsrMatrix< Real, 6 > PFMap
matrix mapping pressure values to nodal forces and moments
Definition: fsimesh.h:45
ConnectMap fn2e
connectivity from fluid nodes to elements
Definition: fsimesh.h:282
void buildTree(const MxMesh &mx, const Indices &idx, BSearchTree &tree) const
build search tree for node set
Definition: fsimesh.cpp:221
void mergeBeams(const MxMeshPtr &pmx)
Import sections of the structural mesh (Nastran).
Definition: fsimesh.cpp:96
Indices gids
nastran grid-point IDs for structIfNodes and all nodes
Definition: fsimesh.h:273
void atomicUpdate(uint inode, const SVector< M > &fj, PointList< M > &nf) const
update nodal force vector atomically
Definition: fsimesh.h:226
Vct6 sum(const Vct3 &ptref, const PointList< 6 > &fm) const
sum nodal forces and moments for a given reference point
Definition: fsimesh.cpp:618
Real searchRadius
algorithm parameter : radius to search for nearby element nodes
Definition: fsimesh.h:285
virtual void clear()
overload clear
Definition: fsimesh.cpp:263
Element wrapper for fluid-structure mapping.
Definition: fsielement.h:29
const MxMesh & fluidMesh() const
access attached aerodynamic mesh
Definition: fsimesh.h:72
void buildInterpolator()
call after all meshes have been merged
Definition: fsimesh.cpp:211
void nearbyFluidElements(const Vct3 &pt, const Vct3 &nrm, Indices &elm) const
collect fluid elements near an integration point
Definition: fsimesh.cpp:883
const MxMesh & structMesh() const
access attached structural mesh
Definition: fsimesh.h:75
uint appendSifField(const PointList< 3 > &fn, const std::string &suffix="")
append nodal structural nodal force vector as a vector field
Definition: fsimesh.cpp:722
void buildMap(const MxMesh &mx, const Indices &nds, const Indices &elm, ConnectMap &v2emap) const
build node-to-element mapping
Definition: fsimesh.cpp:231
MxMeshPtr fmx
pointer to aerdynamic mesh
Definition: fsimesh.h:258
const Indices & fluidElements() const
access array of structural interface elements
Definition: fsimesh.h:99
void centerForces(const Vector &pf, PointList< 3 > &ctr, PointList< 3 > &cf) const
compute element centers and center forces (for moments)
Definition: fsimesh.cpp:644
Real maxNormalAngle() const
maximum angle between normals of elements considered for projection
Definition: fsimesh.h:60
void evalPressure(const Vector &pf, uint eix, const Vct2 &uv, Vct3 &psn) const
compute -p*normal for fluid element eix
Definition: fsimesh.cpp:767
void mappingPattern(ConnectMap &spty) const
compute sparsity pattern for mapping matrix
Definition: fsimesh.cpp:1061
void collectNodes(const MxMesh &mx, const Indices &elix, Indices &nds) const
collect node indices
Definition: fsimesh.cpp:116
Wrapper for 3-node triangles in FSI problems.
Definition: fsielement.h:103
Wrapper for 4-node quadrilaterals in FSI problems.
Definition: fsielement.h:131
BSearchTree fnTree
search tree for fluid nodes
Definition: fsimesh.h:276
Real project(const Vct3 &pt, uint eix, Vct2 &uv) const
compute point-to-surface element distance and projection
Definition: fsimesh.cpp:957
BSearchTree snTree
search tree for structural nodes
Definition: fsimesh.h:279
Indices fifElix
indices of fluid interface elements
Definition: fsimesh.h:270
Vct3 moment(const Vct3 &c, const PointList< 3 > &ctr, const PointList< 3 > &cf) const
compute moments about c
Definition: fsimesh.cpp:712
uint exportDarea(uint sid, const PointList< 6 > &fnodal, std::ostream &os, Real ff=1.0, Real lf=1.0) const
export a nodal load vector as a DAREA set for direct transient analysis
Definition: fsimesh.cpp:587
Real catchRadius() const
radius to search for aerodynamic mesh elements to project on
Definition: fsimesh.h:54
MxMeshPtr smx
pointer to structural mesh
Definition: fsimesh.h:255
void mergeFluid(const MxMeshPtr &pmx, const Indices &ifboco=Indices())
Import aerodynamic mesh.
Definition: fsimesh.cpp:155
void atomicUpdate(uint inode, const SVector< M > &fj, uint jcol, PointGrid< M > &nf) const
update nodal force vector atomically
Definition: fsimesh.h:236
const Indices & structuralNodes() const
access array of structural interface nodes
Definition: fsimesh.h:96
Real projectTri3(const Vct3 &pt, const uint *vi, Vct2 &uv) const
element projection for linear triangles
Definition: fsimesh.cpp:976
void augmentedStates(const CsrMatrix< Real > &M, const CsrMatrix< Real > &K)
compute augmented states for MTA method
Definition: fsimesh.cpp:1185
void agglomerate(const Vector &pf, PointList< 6 > &fnodal) const
agglomerate aerodynamic element loads into nearest structural node
Definition: fsimesh.cpp:316
FsiMesh()
create empty mesh
Definition: fsimesh.h:48
Merged mesh for aeroelastic problems.
Definition: fsimesh.h:40
uint exportForces(const PointList< 3 > &fnodal, std::ostream &os, uint sid=1, Real ff=1.0) const
establish a mapping matrix - not implemented yet
Definition: fsimesh.cpp:477
void maxNormalAngle(Real phi)
maximum angle between normals of elements considered for projection
Definition: fsimesh.h:63
Indices sifNode
indices of structural interface nodes
Definition: fsimesh.h:261
Real minCosPhi
algorithm parameter : minimum and maximum cosine of angle between normals
Definition: fsimesh.h:288
virtual ~FsiMesh()
base class
Definition: fsimesh.h:51
void extractGids(const MxMesh &smx)
extract nastran GIDs
Definition: fsimesh.cpp:132
void catchRadius(Real r)
radius to search for aerodynamic mesh elements to project on
Definition: fsimesh.h:57
bool extractPressure(Real qoo, uint ixf, Vector &pf) const
access pressure field in fluid mesh
Definition: fsimesh.cpp:273
void residualizeLoads(const CsrMatrix< Real > &M)
residualize all stored load fields
Definition: fsimesh.cpp:1124
Indices fifNode
indices of fluid interface nodes
Definition: fsimesh.h:267
const Indices & fluidNodes() const
access array of structural interface nodes
Definition: fsimesh.h:102
uint nearestFluidElement(const Vct3 &pt, Vct2 &uv) const
determine nearest element and element coordinates
Definition: fsimesh.cpp:835
Real minNormalAngle() const
minimum angle between normals of elements considered for projection
Definition: fsimesh.h:66
void assemblePressure(Real qoo, const Indices &ifield, const Vector &coef, Vector &pf) const
assemble pressure field by linear combination
Definition: fsimesh.cpp:300
void mergeStruct(const MxMeshPtr &pmx, const Indices &pidwet=Indices(), const Indices &pidintern=Indices())
Import sections of the structural mesh (Nastran).
Definition: fsimesh.cpp:29
Generated on Mon Jan 24 2022 03:03:16 for libsurf by   doxygen 1.8.5