~ubuntu-branches/ubuntu/utopic/dune-grid/utopic-proposed

« back to all changes in this revision

Viewing changes to dune/grid/test/checktwists.cc

  • Committer: Package Import Robot
  • Author(s): Ansgar Burchardt
  • Date: 2014-02-14 10:49:16 UTC
  • mfrom: (1.3.1) (5.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20140214104916-2clchnny3eu7ks4w
Tags: 2.3.0-2
InstallĀ /usr/share/dune-grid.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 
2
// vi: set et ts=4 sw=2 sts=2:
1
3
int applyTwist ( const int twist, const int i, const int numCorners )
2
4
{
3
5
  return (twist < 0 ? (2*numCorners + 1 - i + twist) : i + twist) % numCorners;
31
33
 
32
34
  typedef typename Intersection::LocalGeometry LocalGeometry;
33
35
 
34
 
  typedef Dune::GenericReferenceElement< ctype, dimension > ReferenceElement;
35
 
  typedef Dune::GenericReferenceElements< ctype, dimension > ReferenceElements;
 
36
  typedef Dune::ReferenceElement< ctype, dimension > ReferenceElement;
 
37
  typedef Dune::ReferenceElements< ctype, dimension > ReferenceElements;
36
38
 
37
39
  typedef Dune::FieldVector< typename Geometry::ctype, Geometry::coorddimension >
38
 
    WorldVector;
 
40
  WorldVector;
39
41
  typedef Dune::FieldVector< typename LocalGeometry::ctype, LocalGeometry::coorddimension >
40
 
    LocalVector;
 
42
  LocalVector;
41
43
 
42
44
  if( !intersection.neighbor() || intersection.boundary() || !intersection.conforming() )
43
45
    return 0;
44
 
    
 
46
 
45
47
  int errors = 0;
46
48
 
47
49
  const int tIn = mapTwist( intersection.twistInInside() );
87
89
  for( int i = 0; i < numCorners; ++i )
88
90
  {
89
91
    const int gi = i;
90
 
    
 
92
 
91
93
    const int iIn = applyTwist( inverseTwist( tIn, numCorners ), i, numCorners );
92
94
    LocalVector xIn = refIn.position( refIn.subEntity( nIn, 1, iIn, dimension ), dimension );
93
95
    if( (xIn - lGeoIn.corner( gi )).two_norm() >= 1e-12 )
111
113
    }
112
114
  }
113
115
 
114
 
  // calculate inside twist 
 
116
  // calculate inside twist
115
117
  if( ! twistInside )
116
118
  {
117
 
    for( int nTwist = numCorners-1; nTwist>= -numCorners; --nTwist ) 
 
119
    for( int nTwist = numCorners-1; nTwist>= -numCorners; --nTwist )
118
120
    {
119
121
      twistInside = true ;
120
122
      for( int i = 0; i < numCorners; ++i )
128
130
        }
129
131
      }
130
132
 
131
 
      if( twistInside ) 
 
133
      if( twistInside )
132
134
      {
133
135
        std::cout << "\ninside " << nIn << "\n";
134
136
        std::cout << "twist " << tIn << " should be replaced by " << nTwist << "\n";
137
139
    }
138
140
  }
139
141
 
140
 
  // calculate outside twist 
 
142
  // calculate outside twist
141
143
  if( ! twistOutside )
142
144
  {
143
 
    for( int nTwist = numCorners-1; nTwist>=-numCorners; --nTwist ) 
 
145
    for( int nTwist = numCorners-1; nTwist>=-numCorners; --nTwist )
144
146
    {
145
147
      twistOutside = true ;
146
148
      for( int i = 0; i < numCorners; ++i )
154
156
        }
155
157
      }
156
158
 
157
 
      if( twistOutside ) 
 
159
      if( twistOutside )
158
160
      {
159
161
        std::cout << "\noutside " << nOut << " (inside = " << nIn << ")\n";
160
162
        std::cout << "twist " << tOut << " should be replaced by " << nTwist << "\n";
182
184
    for( IntersectionIterator iit = gridView.ibegin( *it ); iit != iend; ++iit )
183
185
      errors += checkTwistOnIntersection( gridView.grid().getRealIntersection( *iit ), mapTwist );
184
186
  }
185
 
  
 
187
 
186
188
  if( errors > 0 )
187
189
    std::cerr << "Error: Intersection twists contain errors." << std::endl;
188
190
}