Skip to content

Commit 7f47f70

Browse files
committedNov 12, 2021
Started work on supporting higher order elements in multiblock mesher.
1 parent cd9d6c4 commit 7f47f70

File tree

4 files changed

+596
-518
lines changed

4 files changed

+596
-518
lines changed
 

‎MeshTools/FEBox.cpp

+70
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,74 @@ FEMesh* FEBox::CreateRegularTET4()
764764

765765
//-----------------------------------------------------------------------------
766766
// Create a regular mesh
767+
FEMesh* FEBox::CreateRegularHEX27()
768+
{
769+
// get object parameters
770+
ParamBlock& param = m_pobj->GetParamBlock();
771+
double w = 0.5*param[GBox::WIDTH ].GetFloatValue();
772+
double h = 0.5*param[GBox::HEIGHT].GetFloatValue();
773+
double d = param[GBox::DEPTH ].GetFloatValue();
774+
775+
// get mesh parameters
776+
m_nx = GetIntValue(NX);
777+
m_ny = GetIntValue(NY);
778+
m_nz = GetIntValue(NZ);
779+
780+
m_gx = GetFloatValue(GX);
781+
m_gy = GetFloatValue(GY);
782+
m_gz = GetFloatValue(GZ);
783+
784+
m_bx = GetBoolValue(GX2);
785+
m_by = GetBoolValue(GY2);
786+
m_bz = GetBoolValue(GZ2);
787+
788+
// create the MB nodes
789+
m_MBNode.resize(8);
790+
m_MBNode[0].m_r = vec3d(-w, -h, 0);
791+
m_MBNode[1].m_r = vec3d( w, -h, 0);
792+
m_MBNode[2].m_r = vec3d( w, h, 0);
793+
m_MBNode[3].m_r = vec3d(-w, h, 0);
794+
m_MBNode[4].m_r = vec3d(-w, -h, d);
795+
m_MBNode[5].m_r = vec3d( w, -h, d);
796+
m_MBNode[6].m_r = vec3d( w, h, d);
797+
m_MBNode[7].m_r = vec3d(-w, h, d);
798+
799+
// create the MB blocks
800+
m_MBlock.resize(1);
801+
MBBlock& b1 = m_MBlock[0];
802+
b1.SetID(0);
803+
b1.SetNodes(0, 1, 2, 3, 4, 5, 6, 7);
804+
b1.SetSizes(m_nx, m_ny, m_nz);
805+
b1.SetZoning(m_gx, m_gy, m_gz, m_bx, m_by, m_bz);
806+
807+
// update the MB data
808+
UpdateMB();
809+
810+
// assign face ID's
811+
SetBlockFaceID(b1, 0, 1, 2, 3, 4, 5);
812+
813+
MBFace& F1 = GetBlockFace(0, 0); SetFaceEdgeID(F1, 0, 9, 4, 8);
814+
MBFace& F2 = GetBlockFace(0, 1); SetFaceEdgeID(F2, 1, 10, 5, 9);
815+
MBFace& F3 = GetBlockFace(0, 2); SetFaceEdgeID(F3, 2, 11, 6, 10);
816+
MBFace& F4 = GetBlockFace(0, 3); SetFaceEdgeID(F4, 3, 8, 7, 11);
817+
MBFace& F5 = GetBlockFace(0, 4); SetFaceEdgeID(F5, 3, 2, 1, 0);
818+
MBFace& F6 = GetBlockFace(0, 5); SetFaceEdgeID(F6, 4, 5, 6, 7);
819+
820+
m_MBNode[0].SetID(0);
821+
m_MBNode[1].SetID(1);
822+
m_MBNode[2].SetID(2);
823+
m_MBNode[3].SetID(3);
824+
m_MBNode[4].SetID(4);
825+
m_MBNode[5].SetID(5);
826+
m_MBNode[6].SetID(6);
827+
m_MBNode[7].SetID(7);
828+
829+
// create the MB
830+
FEMesh* pm = FEMultiBlockMesh::BuildMesh();
831+
832+
return pm;
833+
}
834+
767835
FEMesh* FEBox::CreateRegularHEX20()
768836
{
769837
int i, j, k;
@@ -983,6 +1051,7 @@ FEMesh* FEBox::CreateRegularHEX20()
9831051

9841052
//-----------------------------------------------------------------------------
9851053
// Create a regular mesh
1054+
/*
9861055
FEMesh* FEBox::CreateRegularHEX27()
9871056
{
9881057
int i, j, k;
@@ -1179,6 +1248,7 @@ FEMesh* FEBox::CreateRegularHEX27()
11791248
11801249
return pm;
11811250
}
1251+
*/
11821252

11831253
//-----------------------------------------------------------------------------
11841254
// Build faces of a regular hex mesh

‎MeshTools/FEMultiBlockMesh.cpp

+432-454
Large diffs are not rendered by default.

‎MeshTools/FEMultiBlockMesh.h

+94-4
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ class FEMultiBlockMesh : public FEMesher
212212
// destructor
213213
~FEMultiBlockMesh();
214214

215+
void SetElementType(int elemType);
216+
215217
// build the mesh
216218
FEMesh* BuildMesh();
217219

@@ -242,10 +244,10 @@ class FEMultiBlockMesh : public FEMesher
242244
void BuildMBEdges();
243245

244246
// build the mesh items
245-
void BuildNodes (FEMesh* pm);
246-
void BuildElements(FEMesh* pm);
247-
void BuildFaces (FEMesh* pm);
248-
void BuildEdges (FEMesh* pm);
247+
void BuildFENodes (FEMesh* pm);
248+
void BuildFEElements(FEMesh* pm);
249+
void BuildFEFaces (FEMesh* pm);
250+
void BuildFEEdges (FEMesh* pm);
249251

250252
void BuildNodeBlockTable(vector< vector<int> >& NBT);
251253
void BuildNodeFaceTable(vector< vector<int> >& NFT);
@@ -261,15 +263,103 @@ class FEMultiBlockMesh : public FEMesher
261263
int GetBlockFaceNodeIndex(MBBlock& b, int nf, int i, int j);
262264
int GetFaceEdgeNodeIndex(MBFace& f, int ne, int i);
263265

266+
protected:
267+
class MQPoint
268+
{
269+
public:
270+
int m_i, m_j, m_k;
271+
double m_r, m_s, m_t;
272+
273+
MQPoint() { m_i = m_j = m_k = -1; m_r = m_s = m_t = 0.0; }
274+
MQPoint(int i, double r) { m_i = i; m_j = m_k = -1; m_r = r; m_s = m_t = 0.0; }
275+
MQPoint(int i, int j, double r, double s) { m_i = i; m_j = j; m_k = -1; m_r = r; m_s = s; m_t = 0.0; }
276+
MQPoint(int i, int j, int k, double r, double s, double t) { m_i = i; m_j = j; m_k = k; m_r = r; m_s = s; m_t = t; }
277+
};
278+
279+
vec3d EdgePosition (MBEdge& E, const MQPoint& q);
280+
vec3d FacePosition (MBFace& F, const MQPoint& q);
281+
vec3d BlockPosition(MBBlock& B, const MQPoint& q);
282+
264283
protected:
265284
int GetFENode(MBNode& node);
266285
vector<int> GetFENodeList(MBEdge& node);
267286
vector<int> GetFENodeList(MBFace& node);
268287
vector<int> GetFENodeList(MBBlock& node);
269288

289+
int AddFENode(const vec3d& r, int gid = -1);
290+
int AddFEEdgeNode(MBEdge& E, const MQPoint& q);
291+
int AddFEFaceNode(MBFace& F, const MQPoint& q);
292+
270293
protected:
271294
vector<MBBlock> m_MBlock;
272295
vector<MBFace> m_MBFace;
273296
vector<MBEdge> m_MBEdge;
274297
vector<MBNode> m_MBNode;
298+
299+
int m_elemType;
300+
bool m_quadMesh;
301+
302+
FEMesh* m_pm;
303+
FENode* m_currentNode;
304+
int m_nodes;
305+
};
306+
307+
class Sampler1D
308+
{
309+
public:
310+
Sampler1D(int n, double bias, bool symm) : m_steps(n), m_bias(bias), m_symm(symm)
311+
{
312+
m_fr = bias;
313+
m_gr = 1;
314+
if (symm)
315+
{
316+
m_gr = 2; if (n % 2) m_gr += bias;
317+
for (int j = 0; j < n / 2 - 1; ++j) m_gr = bias * m_gr + 2;
318+
m_gr = 1 / m_gr;
319+
}
320+
else
321+
{
322+
for (int j = 0; j < n - 1; ++j) m_gr = bias * m_gr + 1;
323+
m_gr = 1 / m_gr;
324+
}
325+
326+
m_n = 0;
327+
m_r = 0;
328+
m_dr = m_gr;
329+
}
330+
331+
double value() const { return m_r; }
332+
333+
double increment() const { return m_dr; }
334+
335+
void advance()
336+
{
337+
m_r += m_dr;
338+
m_dr *= m_fr;
339+
if (m_symm && (m_n == m_steps / 2 - 1))
340+
{
341+
if (m_steps % 2 == 0) m_dr /= m_fr;
342+
m_fr = 1.0 / m_fr;
343+
}
344+
m_n++;
345+
}
346+
347+
void reset()
348+
{
349+
m_n = 0;
350+
m_r = 0;
351+
m_dr = m_gr;
352+
m_fr = m_bias;
353+
}
354+
355+
private:
356+
int m_n;
357+
int m_steps;
358+
double m_bias;
359+
bool m_symm;
360+
361+
double m_r;
362+
double m_dr;
363+
double m_gr;
364+
double m_fr;
275365
};

‎MeshTools/FEMultiQuadMesh.cpp

-60
Original file line numberDiff line numberDiff line change
@@ -248,66 +248,6 @@ vec3d FEMultiQuadMesh::FacePosition(MBFace& f, const FEMultiQuadMesh::MQPoint& q
248248
return p;
249249
}
250250

251-
class Sampler1D
252-
{
253-
public:
254-
Sampler1D(int n, double bias, bool symm) : m_steps(n), m_bias(bias), m_symm(symm)
255-
{
256-
m_fr = bias;
257-
m_gr = 1;
258-
if (symm)
259-
{
260-
m_gr = 2; if (n % 2) m_gr += bias;
261-
for (int j = 0; j < n / 2 - 1; ++j) m_gr = bias * m_gr + 2;
262-
m_gr = 1 / m_gr;
263-
}
264-
else
265-
{
266-
for (int j = 0; j < n - 1; ++j) m_gr = bias * m_gr + 1;
267-
m_gr = 1 / m_gr;
268-
}
269-
270-
m_n = 0;
271-
m_r = 0;
272-
m_dr = m_gr;
273-
}
274-
275-
double value() const { return m_r; }
276-
277-
double increment() const { return m_dr; }
278-
279-
void advance()
280-
{
281-
m_r += m_dr;
282-
m_dr *= m_fr;
283-
if (m_symm && (m_n == m_steps / 2 - 1))
284-
{
285-
if (m_steps % 2 == 0) m_dr /= m_fr;
286-
m_fr = 1.0 / m_fr;
287-
}
288-
m_n++;
289-
}
290-
291-
void reset()
292-
{
293-
m_n = 0;
294-
m_r = 0;
295-
m_dr = m_gr;
296-
m_fr = m_bias;
297-
}
298-
299-
private:
300-
int m_n;
301-
int m_steps;
302-
double m_bias;
303-
bool m_symm;
304-
305-
double m_r;
306-
double m_dr;
307-
double m_gr;
308-
double m_fr;
309-
};
310-
311251
//-----------------------------------------------------------------------------
312252
// build the FE nodes
313253
//

0 commit comments

Comments
 (0)
Please sign in to comment.