@@ -172,11 +172,21 @@ inline void DP_DeepPotCompute_variant(DP_DeepPot* dp,
172
172
DP_REQUIRES_OK (dp, dp->dp .compute (e, f, v, ae, av, coord_, atype_, cell_,
173
173
fparam_, aparam_));
174
174
// copy from C++ vectors to C arrays, if not NULL pointer
175
- if (energy) std::copy (e.begin (), e.end (), energy);
176
- if (force) std::copy (f.begin (), f.end (), force);
177
- if (virial) std::copy (v.begin (), v.end (), virial);
178
- if (atomic_energy) std::copy (ae.begin (), ae.end (), atomic_energy);
179
- if (atomic_virial) std::copy (av.begin (), av.end (), atomic_virial);
175
+ if (energy) {
176
+ std::copy (e.begin (), e.end (), energy);
177
+ }
178
+ if (force) {
179
+ std::copy (f.begin (), f.end (), force);
180
+ }
181
+ if (virial) {
182
+ std::copy (v.begin (), v.end (), virial);
183
+ }
184
+ if (atomic_energy) {
185
+ std::copy (ae.begin (), ae.end (), atomic_energy);
186
+ }
187
+ if (atomic_virial) {
188
+ std::copy (av.begin (), av.end (), atomic_virial);
189
+ }
180
190
}
181
191
182
192
template void DP_DeepPotCompute_variant<double >(DP_DeepPot* dp,
@@ -246,11 +256,21 @@ inline void DP_DeepPotComputeNList_variant(DP_DeepPot* dp,
246
256
DP_REQUIRES_OK (dp, dp->dp .compute (e, f, v, ae, av, coord_, atype_, cell_,
247
257
nghost, nlist->nl , ago, fparam_, aparam_));
248
258
// copy from C++ vectors to C arrays, if not NULL pointer
249
- if (energy) std::copy (e.begin (), e.end (), energy);
250
- if (force) std::copy (f.begin (), f.end (), force);
251
- if (virial) std::copy (v.begin (), v.end (), virial);
252
- if (atomic_energy) std::copy (ae.begin (), ae.end (), atomic_energy);
253
- if (atomic_virial) std::copy (av.begin (), av.end (), atomic_virial);
259
+ if (energy) {
260
+ std::copy (e.begin (), e.end (), energy);
261
+ }
262
+ if (force) {
263
+ std::copy (f.begin (), f.end (), force);
264
+ }
265
+ if (virial) {
266
+ std::copy (v.begin (), v.end (), virial);
267
+ }
268
+ if (atomic_energy) {
269
+ std::copy (ae.begin (), ae.end (), atomic_energy);
270
+ }
271
+ if (atomic_virial) {
272
+ std::copy (av.begin (), av.end (), atomic_virial);
273
+ }
254
274
}
255
275
256
276
template void DP_DeepPotComputeNList_variant<double >(DP_DeepPot* dp,
@@ -324,11 +344,21 @@ inline void DP_DeepPotComputeMixedType_variant(DP_DeepPot* dp,
324
344
dp, dp->dp .compute_mixed_type (e, f, v, ae, av, nframes, coord_, atype_,
325
345
cell_, fparam_, aparam_));
326
346
// copy from C++ vectors to C arrays, if not NULL pointer
327
- if (energy) std::copy (e.begin (), e.end (), energy);
328
- if (force) std::copy (f.begin (), f.end (), force);
329
- if (virial) std::copy (v.begin (), v.end (), virial);
330
- if (atomic_energy) std::copy (ae.begin (), ae.end (), atomic_energy);
331
- if (atomic_virial) std::copy (av.begin (), av.end (), atomic_virial);
347
+ if (energy) {
348
+ std::copy (e.begin (), e.end (), energy);
349
+ }
350
+ if (force) {
351
+ std::copy (f.begin (), f.end (), force);
352
+ }
353
+ if (virial) {
354
+ std::copy (v.begin (), v.end (), virial);
355
+ }
356
+ if (atomic_energy) {
357
+ std::copy (ae.begin (), ae.end (), atomic_energy);
358
+ }
359
+ if (atomic_virial) {
360
+ std::copy (av.begin (), av.end (), atomic_virial);
361
+ }
332
362
}
333
363
334
364
template void DP_DeepPotComputeMixedType_variant<double >(DP_DeepPot* dp,
@@ -385,7 +415,9 @@ void DP_DeepPotModelDeviComputeNList_variant(DP_DeepPotModelDevi* dp,
385
415
VALUETYPE* virial,
386
416
VALUETYPE* atomic_energy,
387
417
VALUETYPE* atomic_virial) {
388
- if (nframes > 1 ) throw std::runtime_error (" nframes > 1 not supported yet" );
418
+ if (nframes > 1 ) {
419
+ throw std::runtime_error (" nframes > 1 not supported yet" );
420
+ }
389
421
// init C++ vectors from C arrays
390
422
std::vector<VALUETYPE> coord_ (coord, coord + natoms * 3 );
391
423
std::vector<int > atype_ (atype, atype + natoms);
@@ -585,16 +617,26 @@ inline void DP_DeepTensorCompute_variant(DP_DeepTensor* dt,
585
617
586
618
DP_REQUIRES_OK (dt, dt->dt .compute (t, f, v, at, av, coord_, atype_, cell_));
587
619
// copy from C++ vectors to C arrays, if not NULL pointer
588
- if (global_tensor) std::copy (t.begin (), t.end (), global_tensor);
589
- if (force) std::copy (f.begin (), f.end (), force);
590
- if (virial) std::copy (v.begin (), v.end (), virial);
591
- if (atomic_virial) std::copy (av.begin (), av.end (), atomic_virial);
620
+ if (global_tensor) {
621
+ std::copy (t.begin (), t.end (), global_tensor);
622
+ }
623
+ if (force) {
624
+ std::copy (f.begin (), f.end (), force);
625
+ }
626
+ if (virial) {
627
+ std::copy (v.begin (), v.end (), virial);
628
+ }
629
+ if (atomic_virial) {
630
+ std::copy (av.begin (), av.end (), atomic_virial);
631
+ }
592
632
// do not know the size of atomic tensor in advance...
593
633
if (atomic_tensor) {
594
634
*atomic_tensor = new VALUETYPE[at.size ()];
595
635
std::copy (at.begin (), at.end (), *atomic_tensor);
596
636
}
597
- if (size_at) *size_at = at.size ();
637
+ if (size_at) {
638
+ *size_at = at.size ();
639
+ }
598
640
}
599
641
600
642
template void DP_DeepTensorCompute_variant<double >(DP_DeepTensor* dt,
@@ -648,16 +690,26 @@ inline void DP_DeepTensorComputeNList_variant(DP_DeepTensor* dt,
648
690
DP_REQUIRES_OK (dt, dt->dt .compute (t, f, v, at, av, coord_, atype_, cell_,
649
691
nghost, nlist->nl ));
650
692
// copy from C++ vectors to C arrays, if not NULL pointer
651
- if (global_tensor) std::copy (t.begin (), t.end (), global_tensor);
652
- if (force) std::copy (f.begin (), f.end (), force);
653
- if (virial) std::copy (v.begin (), v.end (), virial);
654
- if (atomic_virial) std::copy (av.begin (), av.end (), atomic_virial);
693
+ if (global_tensor) {
694
+ std::copy (t.begin (), t.end (), global_tensor);
695
+ }
696
+ if (force) {
697
+ std::copy (f.begin (), f.end (), force);
698
+ }
699
+ if (virial) {
700
+ std::copy (v.begin (), v.end (), virial);
701
+ }
702
+ if (atomic_virial) {
703
+ std::copy (av.begin (), av.end (), atomic_virial);
704
+ }
655
705
// do not know the size of atomic tensor in advance...
656
706
if (atomic_tensor) {
657
707
*atomic_tensor = new VALUETYPE[at.size ()];
658
708
std::copy (at.begin (), at.end (), *atomic_tensor);
659
709
}
660
- if (size_at) *size_at = at.size ();
710
+ if (size_at) {
711
+ *size_at = at.size ();
712
+ }
661
713
}
662
714
663
715
template void DP_DeepTensorComputeNList_variant<double >(DP_DeepTensor* dt,
@@ -721,8 +773,12 @@ inline void DP_DipoleChargeModifierComputeNList_variant(
721
773
DP_REQUIRES_OK (dcm, dcm->dcm .compute (df, dv, coord_, atype_, cell_, pairs_,
722
774
delef_, nghost, nlist->nl ));
723
775
// copy from C++ vectors to C arrays, if not NULL pointer
724
- if (dfcorr_) std::copy (df.begin (), df.end (), dfcorr_);
725
- if (dvcorr_) std::copy (dv.begin (), dv.end (), dvcorr_);
776
+ if (dfcorr_) {
777
+ std::copy (df.begin (), df.end (), dfcorr_);
778
+ }
779
+ if (dvcorr_) {
780
+ std::copy (dv.begin (), dv.end (), dvcorr_);
781
+ }
726
782
}
727
783
728
784
template void DP_DipoleChargeModifierComputeNList_variant<double >(
@@ -1316,10 +1372,18 @@ void DP_SelectByType(const int natoms,
1316
1372
int nghost_real_;
1317
1373
deepmd::select_by_type (fwd_map_, bkw_map_, nghost_real_,
1318
1374
std::vector<double >(), atype_, nghost, sel_type_);
1319
- if (fwd_map) std::copy (fwd_map_.begin (), fwd_map_.end (), fwd_map);
1320
- if (bkw_map) std::copy (bkw_map_.begin (), bkw_map_.end (), bkw_map);
1321
- if (nreal) *nreal = bkw_map_.size ();
1322
- if (nghost_real) *nghost_real = nghost_real_;
1375
+ if (fwd_map) {
1376
+ std::copy (fwd_map_.begin (), fwd_map_.end (), fwd_map);
1377
+ }
1378
+ if (bkw_map) {
1379
+ std::copy (bkw_map_.begin (), bkw_map_.end (), bkw_map);
1380
+ }
1381
+ if (nreal) {
1382
+ *nreal = bkw_map_.size ();
1383
+ }
1384
+ if (nghost_real) {
1385
+ *nghost_real = nghost_real_;
1386
+ }
1323
1387
}
1324
1388
1325
1389
void DP_SelectMapInt (const int * in,
@@ -1332,7 +1396,9 @@ void DP_SelectMapInt(const int* in,
1332
1396
std::vector<int > fwd_map_ (fwd_map, fwd_map + nall1);
1333
1397
std::vector<int > out_ (stride * nall2);
1334
1398
deepmd::select_map (out_, in_, fwd_map_, stride);
1335
- if (out) std::copy (out_.begin (), out_.end (), out);
1399
+ if (out) {
1400
+ std::copy (out_.begin (), out_.end (), out);
1401
+ }
1336
1402
}
1337
1403
1338
1404
} // extern "C"
0 commit comments