Skip to content

Commit 9c3069b

Browse files
committed
Quadratic simx meshes can be imported to Bezier
The inversion preserves the validity of the curved elements
1 parent e7b17b6 commit 9c3069b

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

crv/crvBezier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void getGregoryBlendedTransformationCoefficients(int blend, int type,
131131
apf::NewArray<double>& c);
132132

133133
/** \brief a per entity version of above */
134-
void snapToInterpolate(apf::Mesh2* m, apf::MeshEntity* e);
134+
void snapToInterpolate(apf::Mesh2* m, apf::MeshEntity* e, bool isNew = false);
135135

136136
/** \brief compute the matrix to transform between Bezier and Lagrange Points
137137
\details this is a support function, not actual ever needed.

crv/crvCurveMesh.cc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void convertInterpolationPoints(apf::Mesh2* m, apf::MeshEntity* e,
4444
apf::destroyElement(elem);
4545
}
4646

47-
void snapToInterpolate(apf::Mesh2* m, apf::MeshEntity* e)
47+
void snapToInterpolate(apf::Mesh2* m, apf::MeshEntity* e, bool isNew)
4848
{
4949
PCU_ALWAYS_ASSERT(m->canSnap());
5050
int type = m->getType(e);
@@ -56,9 +56,18 @@ void snapToInterpolate(apf::Mesh2* m, apf::MeshEntity* e)
5656
m->setPoint(e,0,pt);
5757
return;
5858
}
59+
// e is an edge or a face
60+
// either way, get a length-scale by computing
61+
// the distance b/w first two downward verts
62+
apf::MeshEntity* down[12];
63+
m->getDownward(e, 0, down);
64+
apf::Vector3 p0, p1;
65+
m->getPoint(down[0], 0, p0);
66+
m->getPoint(down[1], 0, p1);
67+
double lengthScale = (p1 - p0).getLength();
5968
apf::FieldShape * fs = m->getShape();
6069
int non = fs->countNodesOn(type);
61-
apf::Vector3 p, xi, pt(0,0,0);
70+
apf::Vector3 p, xi, pt0, pt(0,0,0);
6271
for(int i = 0; i < non; ++i){
6372
apf::ModelEntity* g = m->toModel(e);
6473
fs->getNodeXi(type,i,xi);
@@ -67,7 +76,13 @@ void snapToInterpolate(apf::Mesh2* m, apf::MeshEntity* e)
6776
else
6877
transferParametricOnTriSplit(m,e,xi,p);
6978
m->snapToModel(g,p,pt);
70-
m->setPoint(e,i,pt);
79+
if (isNew || !m->canGetClosestPoint()) {
80+
m->setPoint(e,i,pt);
81+
continue;
82+
}
83+
m->getPoint(e,i,pt0);
84+
if (!m->isOnModel(g, pt0, lengthScale))
85+
m->setPoint(e,i,pt);
7186
}
7287
}
7388

crv/crvShapeHandler.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class BezierTransfer : public ma::SolutionTransfer
149149
for (int i = 0; i < ne; ++i){
150150
if(shouldSnap && midEdgeVerts[i] &&
151151
isBoundaryEntity(mesh,midEdgeVerts[i])){
152-
snapToInterpolate(mesh,midEdgeVerts[i]);
152+
snapToInterpolate(mesh,midEdgeVerts[i],true);
153153
}
154154
}
155155
int np = mesh->getShape()->getEntityShape(parentType)->countNodes();
@@ -173,7 +173,7 @@ class BezierTransfer : public ma::SolutionTransfer
173173

174174
// do snapping here, inside refinement
175175
if (isBdryEnt && shouldSnap){
176-
snapToInterpolate(mesh,newEntities[i]);
176+
snapToInterpolate(mesh,newEntities[i],true);
177177
} else if (useLinear && !isBdryEnt) {
178178
// boundary entities that don't get snapped should interpolate
179179
if(childType == apf::Mesh::EDGE){
@@ -538,7 +538,7 @@ class BezierHandler : public ma::ShapeHandler
538538
if (newType != apf::Mesh::EDGE)
539539
{
540540
if (snap && P > 2){
541-
snapToInterpolate(mesh,newEntities[i]);
541+
snapToInterpolate(mesh,newEntities[i],true);
542542
convertInterpolationPoints(mesh,newEntities[i],n,ni,bt->coeffs[2]);
543543
} else {
544544
for (int j = 0; j < ni; ++j){
@@ -548,7 +548,7 @@ class BezierHandler : public ma::ShapeHandler
548548
}
549549
} else {
550550
if (snap){
551-
snapToInterpolate(mesh,newEntities[i]);
551+
snapToInterpolate(mesh,newEntities[i],true);
552552
convertInterpolationPoints(mesh,newEntities[i],n,ni,bt->coeffs[1]);
553553
} else {
554554
setLinearEdgePoints(mesh,newEntities[i]);

0 commit comments

Comments
 (0)