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

« back to all changes in this revision

Viewing changes to dune/grid/io/file/dgfparser/blocks/simplex.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
#include <config.h>
2
4
 
3
5
#include <dune/grid/io/file/dgfparser/blocks/simplex.hh>
13
15
 
14
16
    SimplexBlock :: SimplexBlock
15
17
      ( std :: istream &in, int pnofvtx, int pvtxoffset, int &pdimgrid )
16
 
    : BasicBlock( in, "Simplex" ),
17
 
      nofvtx( pnofvtx ),
18
 
      vtxoffset( pvtxoffset ),
19
 
      dimgrid( pdimgrid ),
20
 
      goodline( true ),
21
 
      nofparams( 0 )
 
18
      : BasicBlock( in, "Simplex" ),
 
19
        nofvtx( pnofvtx ),
 
20
        vtxoffset( pvtxoffset ),
 
21
        dimgrid( pdimgrid ),
 
22
        goodline( true ),
 
23
        nofparams( 0 )
22
24
    {
23
25
      if( !isactive() )
24
26
        return;
35
37
        {
36
38
          DUNE_THROW( DGFException,
37
39
                      "Error in " << *this << ": "
38
 
                      << "Key 'parameters' found with no or non-positive value." );
 
40
                                  << "Key 'parameters' found with no or non-positive value." );
39
41
        }
40
42
      }
41
43
 
62
64
 
63
65
 
64
66
    int SimplexBlock
65
 
      :: get ( std :: vector< std :: vector< unsigned int > > &simplices,
66
 
               std :: vector< std :: vector< double > > &params,
67
 
               int &nofp)
 
67
    :: get ( std :: vector< std :: vector< unsigned int > > &simplices,
 
68
             std :: vector< std :: vector< double > > &params,
 
69
             int &nofp)
68
70
    {
69
71
      nofp = nofparams;
70
72
      reset();
76
78
      {
77
79
        simplices.push_back( simplex );
78
80
        /*
79
 
        for( size_t j = 0; j < simplex.size(); ++j )
80
 
          simplices[ nofsimpl ][ j ] = simplex[ j ];
81
 
        */
 
81
           for( size_t j = 0; j < simplex.size(); ++j )
 
82
           simplices[ nofsimpl ][ j ] = simplex[ j ];
 
83
         */
82
84
        if( nofparams > 0 )
83
85
          params.push_back( param );
84
86
      }
101
103
          if( n > 0 )
102
104
          {
103
105
            DUNE_THROW ( DGFException, "Error in " << *this << ": "
104
 
                                       << "Wrong number of vertex indices "
105
 
                                       << "(got " << idx
106
 
                                       << ", expected " << simplex.size() << ")" );
 
106
                                                   << "Wrong number of vertex indices "
 
107
                                                   << "(got " << idx
 
108
                                                   << ", expected " << simplex.size() << ")" );
107
109
          }
108
110
          else
109
111
            return next( simplex, param );
112
114
        {
113
115
          DUNE_THROW( DGFException,
114
116
                      "Error in " << *this << ": "
115
 
                      << "Invalid vertex index "
116
 
                      << "(" << idx << " not in ["
117
 
                      << vtxoffset << ", " << (nofvtx + vtxoffset) << "[)" );
 
117
                                  << "Invalid vertex index "
 
118
                                  << "(" << idx << " not in ["
 
119
                                  << vtxoffset << ", " << (nofvtx + vtxoffset) << "[)" );
118
120
        }
119
121
        simplex[ n ] = idx - vtxoffset;
120
122
      }
130
132
      if( np != param.size() )
131
133
      {
132
134
        DUNE_THROW ( DGFException, "Error in " << *this << ": "
133
 
                                   << "Wrong number of simplex parameters "
134
 
                                   << "(got " << np
135
 
                                   << ", expected " << param.size() << ")" );
 
135
                                               << "Wrong number of simplex parameters "
 
136
                                               << "(got " << np
 
137
                                               << ", expected " << param.size() << ")" );
136
138
      }
137
139
      return (goodline = true);
138
140
    }
139
141
 
140
 
    
 
142
 
141
143
    int SimplexBlock
142
 
      :: cube2simplex ( std :: vector< std :: vector< double > > &vtx,
143
 
                        std :: vector< std :: vector< unsigned int > > &elements,
144
 
                        std :: vector< std :: vector< double > > &params )
 
144
    :: cube2simplex ( std :: vector< std :: vector< double > > &vtx,
 
145
                      std :: vector< std :: vector< unsigned int > > &elements,
 
146
                      std :: vector< std :: vector< double > > &params )
145
147
    {
146
148
      static int offset3[6][4][3] = {{{0,0,0},{1,1,1},{1,0,0},{1,1,0}},
147
149
                                     {{0,0,0},{1,1,1},{1,0,1},{1,0,0}},
157
159
      const int dimworld = vtx[ 0 ].size();
158
160
 
159
161
      int dimgrid = 0;
160
 
      for( size_t n = elements[ 0 ].size(); n > 1; ++dimgrid, n /= 2 );
 
162
      for( size_t n = elements[ 0 ].size(); n > 1; ++dimgrid, n /= 2 ) ;
161
163
      if( size_t( 1 << dimgrid ) != elements[ 0 ].size() )
162
164
        DUNE_THROW( DGFException, "cube2simplex: all elements must be cubes." );
163
 
      
 
165
 
164
166
      dverb << "generating simplices...";
165
167
      dverb.flush();
166
168