Skip to content

Commit bc2a3bc

Browse files
committed
Simplify redundant assertions
1 parent 5b5b2e8 commit bc2a3bc

File tree

6 files changed

+17
-36
lines changed

6 files changed

+17
-36
lines changed

src/bamglib/MeshGeom.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -783,16 +783,12 @@ namespace bamg {
783783
GeometricalEdge &e2 = *e1.link;
784784
cerr << i << " " << e1[0].The( ) << " " << e2[0].The( ) << " " << e1[1].The( ) << " "
785785
<< e2[1].The( ) << endl;
786-
if (e1[0].The( ) == e2[0].The( ) && e1[1].The( ) == e2[1].The( )) {
787-
} else if (e1[0].The( ) == e2[1].The( ) && e1[1].The( ) == e2[0].The( )) {
788-
} else {
786+
if (!((e1[0].The( ) == e2[0].The( ) && e1[1].The( ) == e2[1].The( )) ||
787+
(e1[0].The( ) == e2[1].The( ) && e1[1].The( ) == e2[0].The( )))) {
789788
err++;
790789
cerr << " Cracked edges with no same vertex " << &e1 - edges << " " << &e2 - edges
791790
<< endl;
792791
}
793-
} else {
794-
// if (!edges[i][0].IsThe()) err++;
795-
// if (!edges[i][1].IsThe()) err++;
796792
}
797793
if (err) {
798794
cerr << " Some vertex was not distint and not on cracked edge " << err << endl;

src/femlib/Element_RT.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ class TypeOfFE_RT : public TypeOfFE { public:
122122
R2 A(K[0]), B(K[1]),C(K[2]);
123123
// R l0=1-P.x-P.y,l1=P.x,l2=P.y;
124124
// R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2));
125-
if (val.N() <3)
126-
throwassert(val.N() >=3);
125+
throwassert(val.N() >=3);
127126
throwassert(val.M()==2 );
128127
// throwassert(val.K()==3 );
129128
val=0;
@@ -227,8 +226,7 @@ class TypeOfFE_RTmodif : public TypeOfFE { public:
227226
R2 A(K[0]), B(K[1]),C(K[2]);
228227
R la=1-PHat.x-PHat.y,lb=PHat.x,lc=PHat.y;
229228
R2 Dla(K.H(0)), Dlb(K.H(1)), Dlc(K.H(2));
230-
if (val.N() <3)
231-
throwassert(val.N() >=3);
229+
throwassert(val.N() >=3);
232230
throwassert(val.M()==2 );
233231

234232
R2 AB(A,B),AC(A,C),BA(B,A),BC(B,C),CA(C,A),CB(C,B);
@@ -386,8 +384,7 @@ void TypeOfFE_ConsEdge::FB(const bool * whatd,const Mesh & ,const Triangle & K,c
386384
R2 A(K[0]), B(K[1]),C(K[2]);
387385
R l0=1-P.x-P.y,l1=P.x,l2=P.y;
388386

389-
if (val.N() <3)
390-
throwassert(val.N() >=3);
387+
throwassert(val.N() >=3);
391388
throwassert(val.M()==1 );
392389

393390
val=0;
@@ -465,8 +462,7 @@ void TypeOfFE_P1ncLagrange::FB(const bool * whatd,const Mesh & ,const Triangle &
465462
// l1( cshrink1*(cshrink*((1,0)-G)+G)-G)+G = 1
466463
R l0=1-P.x-P.y,l1=P.x,l2=P.y;
467464

468-
if (val.N() <3)
469-
throwassert(val.N() >=3);
465+
throwassert(val.N() >=3);
470466
throwassert(val.M()==1 );
471467
// throwassert(val.K()==3 );
472468

@@ -525,8 +521,7 @@ class TypeOfFE_RTortho : public TypeOfFE { public:
525521
R2 A(K[0]), B(K[1]),C(K[2]);
526522
//R l0=1-P.x-P.y,l1=P.x,l2=P.y;
527523
// R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2));
528-
if (val.N() <3)
529-
throwassert(val.N() >=3);
524+
throwassert(val.N() >=3);
530525
throwassert(val.M()==2 );
531526
// throwassert(val.K()==3 );
532527
val=0;
@@ -680,8 +675,7 @@ void TypeOfFE_P1ttdc::FB(const bool *whatd,const Mesh & ,const Triangle & K,cons
680675
R2 A(K[0]), B(K[1]),C(K[2]);
681676
R l0=1-P.x-P.y,l1=P.x,l2=P.y;
682677

683-
if (val.N() <3)
684-
throwassert(val.N() >=3);
678+
throwassert(val.N() >=3);
685679
throwassert(val.M()==1 );
686680
// throwassert(val.K()==3 );
687681

src/femlib/FESpace-v0.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,8 +1064,7 @@ void TypeOfFE_P1Lagrange::FB(const bool *whatd,const Mesh & ,const Triangle & K,
10641064
R2 A(K[0]), B(K[1]),C(K[2]);
10651065
R l0=1-P.x-P.y,l1=P.x,l2=P.y;
10661066

1067-
if (val.N() <3)
1068-
throwassert(val.N() >=3);
1067+
throwassert(val.N() >=3);
10691068
throwassert(val.M()==1 );
10701069
// throwassert(val.K()==3 );
10711070

@@ -1126,8 +1125,7 @@ void TypeOfFE_P1Bubble::FB(const bool *whatd,const Mesh & ,const Triangle & K,co
11261125
R2 A(K[0]), B(K[1]),C(K[2]);
11271126
R l0=1-P.x-P.y, l1=P.x, l2=P.y, lb=l0*l1*l2*9.;
11281127

1129-
if (val.N() <4)
1130-
throwassert(val.N() >=4);
1128+
throwassert(val.N() >=4);
11311129
throwassert(val.M()==1 );
11321130
// throwassert(val.K()==3 );
11331131

src/femlib/FESpace.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,7 @@ void TypeOfFE_P0VF::FB(const bool *whatd,const Mesh & ,const Triangle & K,const
489489
l2 = l2 * 3. < 1;
490490
l0 = 1 - l1 -l2;// FH & AS july 2020
491491

492-
if (val.N() <3)
493-
throwassert(val.N() >=3);
492+
throwassert(val.N() >=3);
494493
throwassert(val.M()==1 );
495494

496495
val=0;
@@ -1102,8 +1101,7 @@ void TypeOfFE_P1Lagrange::FB(const bool *whatd,const Mesh & ,const Triangle & K,
11021101
R2 A(K[0]), B(K[1]),C(K[2]);
11031102
R l0=1-PHat.x-PHat.y,l1=PHat.x,l2=PHat.y;
11041103

1105-
if (val.N() <3)
1106-
throwassert(val.N() >=3);
1104+
throwassert(val.N() >=3);
11071105
throwassert(val.M()==1 );
11081106

11091107
val=0;
@@ -1145,8 +1143,7 @@ void TypeOfFE_P1Bubble::FB(const bool *whatd,const Mesh & ,const Triangle & K,co
11451143
R2 A(K[0]), B(K[1]),C(K[2]);
11461144
R l0=1-PHat.x-PHat.y, l1=PHat.x, l2=PHat.y, lb=l0*l1*l2*9.;
11471145

1148-
if (val.N() <4)
1149-
throwassert(val.N() >=4);
1146+
throwassert(val.N() >=4);
11501147
throwassert(val.M()==1 );
11511148

11521149
val=0;

src/femlib/GenericMesh.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,7 @@ class GenericMesh : public RefCounter
654654
R lb[Rd::d+1];//{1.-PHat.sum(),PHat};
655655
R lbb[Rd::d+1];//{1.-PHat.sum(),PHat};
656656
PHat.toBary(lb); // R1 R2 R3
657-
if(Abs(lb[j])>1e-10)
658-
assert(Abs(lb[j])<1e-10);
657+
assert(Abs(lb[j])<1e-10);
659658
int sigma[T::nva];
660659
const void * nvkj[T::nva], *nvkkjj[T::nva];
661660
int jj=p%nea;

src/femlib/fem.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,8 @@ class SubMortar {
471471
{pV = &V;break;} // ok good
472472
}
473473
}
474-
if ( ! (p>=0 && pV))
475-
throwassert(p>=0 && pV); // PB reach the end without founding
476-
if ( ! ( Abs((AM.perp(),A-*pV)) < 1e-5) )
477-
throwassert( Abs((AM.perp(),A-*pV)) < 1e-5);
474+
throwassert(p>=0 && pV); // PB reach the end without founding
475+
throwassert( Abs((AM.perp(),A-*pV)) < 1e-5);
478476

479477
throwassert(sm != number(pV));
480478
int kkgd= 3*k + j;
@@ -489,8 +487,7 @@ class SubMortar {
489487

490488
throwassert( s == number(triangles[kkgd/3][VerticesOfTriangularEdge[kkgd%3][dg]]));
491489
sgd[gd]=s;// save the last
492-
if ( ! ( Abs((AM.perp(),A-vertices[s])) < 1e-5) )
493-
throwassert( Abs((AM.perp(),A-vertices[s])) < 1e-5);
490+
throwassert( Abs((AM.perp(),A-vertices[s])) < 1e-5);
494491
throwassert(kkgd>=0 && kkgd < 3*nt);
495492
if (datamortars)
496493
{

0 commit comments

Comments
 (0)