"vscode:/vscode.git/clone" did not exist on "86c0bbca2c18df12b684f7ca441c5255506a7268"
BrookCommon.cpp 18.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* -------------------------------------------------------------------------- *
 *                                   OpenMM                                   *
 * -------------------------------------------------------------------------- *
 * This is part of the OpenMM molecular simulation toolkit originating from   *
 * Simbios, the NIH National Center for Physics-Based Simulation of           *
 * Biological Structures at Stanford, funded under the NIH Roadmap for        *
 * Medical Research, grant U54 GM072970. See https://simtk.org.               *
 *                                                                            *
 * Portions copyright (c) 2008 Stanford University and the Authors.           *
 * Authors: Mark Friedrichs                                                   *
 * Contributors:                                                              *
 *                                                                            *
 * Permission is hereby granted, free of charge, to any person obtaining a    *
 * copy of this software and associated documentation files (the "Software"), *
 * to deal in the Software without restriction, including without limitation  *
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
 * and/or sell copies of the Software, and to permit persons to whom the      *
 * Software is furnished to do so, subject to the following conditions:       *
 *                                                                            *
 * The above copyright notice and this permission notice shall be included in *
 * all copies or substantial portions of the Software.                        *
 *                                                                            *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
 * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,    *
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR      *
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE  *
 * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
 * -------------------------------------------------------------------------- */

#include <math.h>
Mark Friedrichs's avatar
Mark Friedrichs committed
33
34
#include <stdlib.h>

35
#include <sstream>
Mark Friedrichs's avatar
Mark Friedrichs committed
36

37
38
39
40
41
42
43
44
#include "BrookCommon.h"
#include "BrookPlatform.h"
#include "BrookStreamFactory.h"
#include "OpenMMException.h"

using namespace OpenMM;
using namespace std;

Mark Friedrichs's avatar
Mark Friedrichs committed
45
46
// bonded streams
    
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
47
const std::string BrookCommon::BondedParticleIndicesStream                        = "BondedParticleIndicesStream";
Mark Friedrichs's avatar
Mark Friedrichs committed
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const std::string BrookCommon::BondedParametersStream                             = "BondedParametersStream";
const std::string BrookCommon::UnrolledForceStream                                = "UnrolledForceStream";
const std::string BrookCommon::BondedChargeStream                                 = "BondedChargeStream";
const std::string BrookCommon::BondedInverseMapStreams                            = "BondedInverseMapStreams";

// non-bonded streams

const std::string BrookCommon::NonBondedExclusionStream                           = "NonBondedExclusionStream";
const std::string BrookCommon::OuterVdwStream                                     = "OuterVdwStream";
const std::string BrookCommon::InnerSigmaStream                                   = "InnerSigmaStream";
const std::string BrookCommon::InnerEpsilonStream                                 = "InnerEpsilonStream";
const std::string BrookCommon::NonBondedChargeStream                              = "NonBondedChargeStream";
const std::string BrookCommon::PartialForceStream                                 = "PartialForceStream";

// OBC Gbsa streams

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
64
65
66
const std::string BrookCommon::ObcParticleRadiiStream                             = "ObcParticleRadiiStream";
const std::string BrookCommon::ObcScaledParticleRadiiStream                       = "ObcScaledParticleRadiiStream";
const std::string BrookCommon::ObcParticleRadiiWithDielectricOffsetStream         = "ObcParticleRadiiWithDielectricOffsetStream";
Mark Friedrichs's avatar
Mark Friedrichs committed
67
68
69
70
71
const std::string BrookCommon::ObcBornRadiiStream                                 = "ObcBornRadiiStream";
const std::string BrookCommon::ObcBornRadii2Stream                                = "ObcBornRadii2Stream";
const std::string BrookCommon::ObcIntermediateForceStream                         = "ObcIntermediateForceStream";
const std::string BrookCommon::ObcChainStream                                     = "ObcChainStream";

Mark Friedrichs's avatar
Mark Friedrichs committed
72
73
74
75
76
77
// StochasticDynamics streams

const std::string BrookCommon::SDPC1Stream                                        = "SDPC1Stream";
const std::string BrookCommon::SDPC2Stream                                        = "SDPC2Stream";
const std::string BrookCommon::SD2XStream                                         = "SD2XStream";
const std::string BrookCommon::SD1VStream                                         = "SD1VStream";
Mark Friedrichs's avatar
Mark Friedrichs committed
78
79
80
const std::string BrookCommon::VPrimeStream                                       = "VPrimeStream";
const std::string BrookCommon::XPrimeStream                                       = "XPrimeStream";
const std::string BrookCommon::InverseMassStream                                  = "InverseMassStream";
Mark Friedrichs's avatar
Mark Friedrichs committed
81

Mark Friedrichs's avatar
Mark Friedrichs committed
82
83
// Shake streams

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
84
85
const std::string BrookCommon::ShakeParticleIndicesStream                         = "ShakeParticleIndicesStream";
const std::string BrookCommon::ShakeParticleParameterStream                       = "ShakeParticleParameterStream";
Mark Friedrichs's avatar
Mark Friedrichs committed
86
87
88
89
90
91
const std::string BrookCommon::ShakeXCons0Stream                                  = "ShakeXCons0Stream";
const std::string BrookCommon::ShakeXCons1Stream                                  = "ShakeXCons1Stream";
const std::string BrookCommon::ShakeXCons2Stream                                  = "ShakeXCons2Stream";
const std::string BrookCommon::ShakeXCons3Stream                                  = "ShakeXCons3Stream";
const std::string BrookCommon::ShakeInverseMapStream                              = "ShakeInverseMapStream";

Mark Friedrichs's avatar
Mark Friedrichs committed
92
93
94
// Random number streams

const std::string BrookCommon::ShuffleStream                                      = "ShuffleStream";
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
95
const std::string BrookCommon::RandomValuesStream                                 = "RandomValuesStream";
Mark Friedrichs's avatar
Mark Friedrichs committed
96

97
98
99
100
101
// Random number streams

const std::string BrookCommon::BrookVelocityCenterOfMassRemovalWorkStream         = "VelocityCenterOfMassRemovalWorkStream";
const std::string BrookCommon::BrookVelocityCenterOfMassRemovalMassStream         = "VelocityCenterOfMassRemovalMassStream";

102
103
104
105
106
/** 
 * Constructor
 * 
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
107
BrookCommon::BrookCommon( ){
108
109
110
111
112
113
114
115

// ---------------------------------------------------------------------------------------

   // static const std::string methodName      = "BrookCommon::BrookCommon";
   // static const int debug                   = 1;

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
116
117
   _numberOfParticles             = 0;
   _particleSizeModified          = 0;
118

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
119
120
121
   _particleStreamWidth           = -1;
   _particleStreamHeight          = -1; 
   _particleStreamSize            = -1;
122

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
123
   _log                           = NULL;
Mark Friedrichs's avatar
Mark Friedrichs committed
124
   _isActive                      = 0;
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

}   
 
/** 
 * Destructor
 * 
 */

BrookCommon::~BrookCommon( ){

// ---------------------------------------------------------------------------------------

   //static const std::string methodName      = "BrookCommon::~BrookCommon";
   //static const int debug                   = 1;

// ---------------------------------------------------------------------------------------

}

/** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
145
 * Get number of particles
146
 * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
147
 * @return  number of particles
148
149
150
 *
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
151
152
int BrookCommon::getNumberOfParticles( void ) const {
   return _numberOfParticles;
153
154
155
}

/** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
156
 * Get number of particles
157
 * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
158
159
 * @param  numberOfParticles number of particles
 * @return  number of particles
160
161
162
 *
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
163
164
165
int BrookCommon::setNumberOfParticles( int numberOfParticles ){
   if( numberOfParticles != _numberOfParticles ){
      _particleSizeModified = numberOfParticles;
166
   }
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
167
168
   _numberOfParticles = numberOfParticles;
   return _numberOfParticles;
169
170
171
}

/** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
172
 * Get particle stream width
173
174
175
 * 
 * @param platform  platform
 *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
176
 * @return  particle stream width
177
178
179
 *
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
180
int BrookCommon::getParticleStreamWidth( const Platform& platform ){
181
182
183

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
184
   // static const std::string methodName      = "BrookCommon::getParticleStreamWidth";
185
186
187
188
   // static const int debug                   = 1;

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
189
   // get particle stream width
190

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
191
192
   if( _particleStreamWidth < 0 ){
      _getParticleStreamDimensions( platform );
193
   }
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
194
   return _particleStreamWidth;
195
196
197
}

/** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
198
 * Get particle stream width
199
 * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
200
 * @return  particle stream width
201
202
203
 *
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
204
int BrookCommon::getParticleStreamWidth( void ) const {
205
206
207

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
208
   // static const std::string methodName      = "BrookCommon::getParticleStreamWidth";
209
210
211
212
   // static const int debug                   = 1;

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
213
   return _particleStreamWidth;
214
215
216
}

/** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
217
 * Get particle stream height
218
219
220
 * 
 * @param platform platform
 *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
221
 * @return  particle stream height 
222
223
224
 *
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
225
int BrookCommon::getParticleStreamHeight( const Platform& platform ){
226
227
228

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
229
   // static const std::string methodName      = "BrookCommon::getParticleStreamHeight";
230
231
232
233
   // static const int debug                   = 1;

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
234
   // get particle stream height
235

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
236
237
   if( _particleStreamHeight < 0 ){
      _getParticleStreamDimensions( platform );
238
   }
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
239
   return _particleStreamHeight;
240
241
242
}

/** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
243
 * Get particle stream height
244
 * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
245
 * @return  particle stream height 
246
247
248
 *
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
249
int BrookCommon::getParticleStreamHeight( void ) const {
250
251
252

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
253
   // static const std::string methodName      = "BrookCommon::getParticleStreamHeight";
254
255
256
257
   // static const int debug                   = 1;

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
258
   return _particleStreamHeight;
259
260
261
}

/** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
262
 * Get particle stream size
263
264
265
 * 
 * @param platform  platform
 *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
266
 * @return  particle stream size
267
268
269
 *
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
270
int BrookCommon::getParticleStreamSize( const Platform& platform ){
271
272
273

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
274
   // static const std::string methodName      = "BrookCommon::getParticleStreamSize";
275
276
277
278
   // static const int debug                   = 1;

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
279
   // get particle stream size
280

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
281
282
   if( _particleStreamSize < 0 ){
      _getParticleStreamDimensions( platform );
283
   }
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
284
   return _particleStreamSize;
285
286
287
}

/** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
288
 * Get particle stream size
289
 * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
290
 * @return  particle stream size
291
292
293
 *
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
294
295
int BrookCommon::getParticleStreamSize( void ) const {
   return _particleStreamSize;
296
297
298
}

/** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
299
 * Get particle stream dimensions
300
301
302
303
304
 * 
 * @param platform                  platform
 *
 */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
305
void BrookCommon::_getParticleStreamDimensions( const Platform& platform ){
306
307
308

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
309
   // static const std::string methodName      = "BrookCommon::_getParticleStreamDimensions";
310
311
312
313
   // static const int debug                   = 1;

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
314
   // get particle stream size
315

316
   const BrookPlatform& brookPlatform           = dynamic_cast<const BrookPlatform&> (platform);
317
   const BrookStreamFactory& brookStreamFactory = dynamic_cast<const BrookStreamFactory&> (platform.getDefaultStreamFactory() );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
318
319
320
   _particleStreamWidth                         = brookStreamFactory.getDefaultParticleStreamWidth();
   _particleStreamSize                          = brookPlatform.getStreamSize( getNumberOfParticles(), _particleStreamWidth, NULL );
   _particleStreamHeight                        = (int) ( ((float) _particleStreamSize)/( (float) _particleStreamWidth) + 0.001);
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349

   return;
}

/** 
 * Get log file reference
 * 
 * @return  log file reference
 *
 */

FILE* BrookCommon::getLog( void ) const {
   return _log;
}

/** 
 * Set log file reference
 * 
 * @param  log file reference
 *
 * @return  DefaultReturnValue
 *
 */

int BrookCommon::setLog( FILE* log ){
   _log = log;
   return BrookCommon::DefaultReturnValue;
}

Mark Friedrichs's avatar
Mark Friedrichs committed
350
/** 
Mark Friedrichs's avatar
Mark Friedrichs committed
351
 * Get flag signalling whether active
Mark Friedrichs's avatar
Mark Friedrichs committed
352
 * 
Mark Friedrichs's avatar
Mark Friedrichs committed
353
 * @return  flag signalling whether active
Mark Friedrichs's avatar
Mark Friedrichs committed
354
355
356
 *
 */

Mark Friedrichs's avatar
Mark Friedrichs committed
357
358
int BrookCommon::isActive( void ) const {
   return _isActive;
Mark Friedrichs's avatar
Mark Friedrichs committed
359
360
361
}

/** 
Mark Friedrichs's avatar
Mark Friedrichs committed
362
 * Set flag signalling whether active
Mark Friedrichs's avatar
Mark Friedrichs committed
363
 * 
Mark Friedrichs's avatar
Mark Friedrichs committed
364
 * @param  flag signalling whether active
Mark Friedrichs's avatar
Mark Friedrichs committed
365
366
367
368
369
 *
 * @return  DefaultReturnValue
 *
 */

Mark Friedrichs's avatar
Mark Friedrichs committed
370
371
int BrookCommon::setIsActive( int isActive ){
   _isActive= isActive;
Mark Friedrichs's avatar
Mark Friedrichs committed
372
373
374
   return BrookCommon::DefaultReturnValue;
}

375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
/* 
 * Get contents of object
 *
 * @param tab         tab
 * @param description description
 * @param value       value
 *
 * @return string containing contents
 *
 * */

std::string BrookCommon::_getLine( const std::string& tab, const std::string& description, const std::string& value ) const {

// ---------------------------------------------------------------------------------------

   static const std::string methodName      = "BrookCommon::_getLine";

   static const unsigned int MAX_LINE_CHARS = 256;
   char line[MAX_LINE_CHARS];

// ---------------------------------------------------------------------------------------

   std::stringstream message;
   memset( line, ' ', MAX_LINE_CHARS ); 
#ifdef WIN32
   (void) sprintf_s( line, MAX_LINE_CHARS, "%s %-40s %s", tab.c_str(), description.c_str(), value.c_str() );
#else
   (void) sprintf( line, "%s %-40s %s", tab.c_str(), description.c_str(), value.c_str() );
#endif
   message << std::string( line ) << std::endl;

   return message.str();

}
Mark Friedrichs's avatar
Mark Friedrichs committed
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494

/* 
 * Given number of stream elements and width, returns the appropriate
 * height of the stream
 *
 * @param streamSize   stream size 
 * @param width        stream width
 *
 * @return stream height
 *
 */

int BrookCommon::getStreamHeight( int streamSize, int streamWidth ){

// ---------------------------------------------------------------------------------------

   //static const std::string methodName      = "BrookCommon::getStreamHeight";

// ---------------------------------------------------------------------------------------

	int streamHeight = streamSize/streamWidth;

	if( streamSize % streamWidth ){
      streamHeight++;
   }

	return streamHeight;
}

/* 
 * Given number of stream elements, get stream width & height
 *
 * @param streamSize    stream size 
 * @param streamWidth   output stream width
 * @param streamHeight  output stream height
 *
 * @return stream height
 *
 */

void BrookCommon::getStreamDimensions( int streamSize, int *streamWidth, int *streamHeight ){

// ---------------------------------------------------------------------------------------

   //static const std::string methodName      = "BrookCommon::getStreamDimensions";

// ---------------------------------------------------------------------------------------

	// There are two conditions - stream should be as square 
	// as possible, but should also be multiple of 16 along
	// one dimension
	
	float s = sqrtf( (float) streamSize );

	// find nearest multiple of 16 to the perfect square size

	int low  = ( (int) floor( s/16.0f ) ) * 16;

	if ( !low ) {
		*streamWidth  = 16;
		*streamHeight = getStreamHeight( streamSize, *streamWidth );
	} else { 

	   int high = low + 1;

		// I'm not sure 48 is such a good stream width. Things seem
		// to be faster with 32 or 64. Can make this a special
		// case later.
		
		// Choose low or high depending on which one is 
		// more square

		int htlow  = getStreamHeight( streamSize, low );
		int hthigh = getStreamHeight( streamSize, high );
		
		if ( abs( htlow - low ) < abs( hthigh - high ) ) {
			*streamWidth   = low;
			*streamHeight  = htlow;
		} else {
			*streamWidth   = high;
			*streamHeight  = hthigh;
		}
	}
	return;
}

495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
/* 
 * Allocate array
 *
 * @param length        length of array
 * @param width         width  of array
 *
 * @return ptr to array
 *
 */

RealOpenMM** BrookCommon::allocateRealArray( int length, int width ) const {

// ---------------------------------------------------------------------------------------

   //static const std::string methodName      = "BrookCommon::allocateRealArray";

// ---------------------------------------------------------------------------------------

   RealOpenMM** array  = new RealOpenMM*[length];
   RealOpenMM*  buffer = new RealOpenMM[length*width];
   for( int ii = 0; ii < length; ii++ ){
      array[ii] = buffer;
      buffer   += width;
   }
   return array;
}

/* 
 * Free array
 *
 * @param array         array to be freed (assumed allocated using BrookCommon::allocateRealArray
 *
 * @return DefaultReturnValue
 *
 */

int BrookCommon::disposeRealArray( RealOpenMM** array ) const {

// ---------------------------------------------------------------------------------------

   //static const std::string methodName      = "BrookCommon::disposeRealArray";

// ---------------------------------------------------------------------------------------

   delete[] array[0];
   delete[] array;

   return DefaultReturnValue;
}

/* 
 * Copy 1D BrookOpenMMFloat* array to 2D array of RealOpenMM
 *
 * @param length        length of array
 * @param width         width  of array
 * @param array1D       array to copy
 *
 * @return ptr to array
 *
 */

RealOpenMM** BrookCommon::copy1DArrayTo2DArray( int length, int width, BrookOpenMMFloat* array1D ) const {

// ---------------------------------------------------------------------------------------

   //static const std::string methodName      = "BrookCommon::copy1DArrayTo2DArray";

// ---------------------------------------------------------------------------------------

   RealOpenMM** array  = allocateRealArray( length, width );
   int index           = 0;
   for( int ii = 0; ii < length; ii++ ){
     for( int jj = 0; jj < width; jj++ ){
        array[ii][jj] = static_cast<RealOpenMM> (array1D[index++]);
     }
   }

   return array;
}
Mark Friedrichs's avatar
Mark Friedrichs committed
574