LCOV - code coverage report
Current view: top level - src/grid/common - grid_basis_set.c (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:47690d8) Lines: 37 37 100.0 %
Date: 2024-02-22 06:47:32 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*----------------------------------------------------------------------------*/
       2             : /*  CP2K: A general program to perform molecular dynamics simulations         */
       3             : /*  Copyright 2000-2024 CP2K developers group <https://cp2k.org>              */
       4             : /*                                                                            */
       5             : /*  SPDX-License-Identifier: BSD-3-Clause                                     */
       6             : /*----------------------------------------------------------------------------*/
       7             : 
       8             : #include <stdlib.h>
       9             : #include <string.h>
      10             : 
      11             : #include "grid_basis_set.h"
      12             : 
      13             : /*******************************************************************************
      14             :  * \brief Allocates a basis set which can be passed to grid_create_task_list.
      15             :  *        See grid_task_list.h for details.
      16             :  * \author Ole Schuett
      17             :  ******************************************************************************/
      18       14151 : void grid_create_basis_set(const int nset, const int nsgf, const int maxco,
      19             :                            const int maxpgf, const int lmin[nset],
      20             :                            const int lmax[nset], const int npgf[nset],
      21             :                            const int nsgf_set[nset], const int first_sgf[nset],
      22       14151 :                            const double sphi[nsgf][maxco],
      23       14151 :                            const double zet[nset][maxpgf],
      24             :                            grid_basis_set **basis_set_out) {
      25             : 
      26       14151 :   grid_basis_set *basis_set = malloc(sizeof(grid_basis_set));
      27             : 
      28       14151 :   basis_set->nset = nset;
      29       14151 :   basis_set->nsgf = nsgf;
      30       14151 :   basis_set->maxco = maxco;
      31       14151 :   basis_set->maxpgf = maxpgf;
      32             : 
      33       14151 :   size_t size = nset * sizeof(int);
      34       14151 :   basis_set->lmin = malloc(size);
      35       14151 :   memcpy(basis_set->lmin, lmin, size);
      36       14151 :   basis_set->lmax = malloc(size);
      37       14151 :   memcpy(basis_set->lmax, lmax, size);
      38       14151 :   basis_set->npgf = malloc(size);
      39       14151 :   memcpy(basis_set->npgf, npgf, size);
      40       14151 :   basis_set->nsgf_set = malloc(size);
      41       14151 :   memcpy(basis_set->nsgf_set, nsgf_set, size);
      42       14151 :   basis_set->first_sgf = malloc(size);
      43       14151 :   memcpy(basis_set->first_sgf, first_sgf, size);
      44       14151 :   size = nsgf * maxco * sizeof(double);
      45       14151 :   basis_set->sphi = malloc(size);
      46       14151 :   memcpy(basis_set->sphi, sphi, size);
      47       14151 :   size = nset * maxpgf * sizeof(double);
      48       14151 :   basis_set->zet = malloc(size);
      49       14151 :   memcpy(basis_set->zet, zet, size);
      50             : 
      51       14151 :   *basis_set_out = basis_set;
      52       14151 : }
      53             : 
      54             : /*******************************************************************************
      55             :  * \brief Deallocates given basis set.
      56             :  * \author Ole Schuett
      57             :  ******************************************************************************/
      58       14151 : void grid_free_basis_set(grid_basis_set *basis_set) {
      59       14151 :   free(basis_set->lmin);
      60       14151 :   free(basis_set->lmax);
      61       14151 :   free(basis_set->npgf);
      62       14151 :   free(basis_set->nsgf_set);
      63       14151 :   free(basis_set->first_sgf);
      64       14151 :   free(basis_set->sphi);
      65       14151 :   free(basis_set->zet);
      66       14151 :   free(basis_set);
      67       14151 : }
      68             : 
      69             : // EOF

Generated by: LCOV version 1.15