APBS  1.5
vhal.h
Go to the documentation of this file.
1 
55 #ifndef _VAPBSHAL_H_
56 #define _VAPBSHAL_H_
57 
58 #include "stdio.h"
59 
66 enum eVrc_Codes {
67 
68  VRC_WARNING=-1,
72 };
73 typedef enum eVrc_Codes Vrc_Codes;
74 
81 enum eVsol_Meth {
82 
83  VSOL_CGMG, /* 0: conjugate gradient multigrid */
84  VSOL_Newton, /* 1: newton */
85  VSOL_MG, /* 2: multigrid */
86  VSOL_CG, /* 3: conjugate gradient */
87  VSOL_SOR, /* 4: sucessive overrelaxation */
88  VSOL_RBGS, /* 5: red-black gauss-seidel */
89  VSOL_WJ, /* 6: weighted jacobi */
90  VSOL_Richardson,/* 7: richardson */
91  VSOL_CGMGAqua, /* 8: conjugate gradient multigrid aqua */
92  VSOL_NewtonAqua /* 9: newton aqua */
93 
94 };
95 typedef enum eVsol_Meth Vsol_Meth;
96 
127 };
128 
133 typedef enum eVsurf_Meth Vsurf_Meth;
134 
143  PBE_NRPBE,
145 };
146 
152 
158  IPKEY_SMPBE = -2,
161 };
162 
168 
174  NONLIN_LPBE = 0,
175  NONLIN_NPBE,
176  NONLIN_SMPBE,
177  NONLIN_LPBEAQUA,
178  NONLIN_NPBEAQUA
179 };
180 
186 
194 };
195 
201 
207 enum eVbcfl {
217 };
218 
223 typedef enum eVbcfl Vbcfl;
224 
238 };
239 
244 typedef enum eVchrg_Meth Vchrg_Meth;
245 
256 };
257 
262 typedef enum eVchrg_Src Vchrg_Src;
263 
296 };
297 
302 typedef enum eVdata_Type Vdata_Type;
303 
310  VDF_DX=0,
314  VDF_GZ=4,
317 };
318 
324 
329 #define APBS_TIMER_WALL_CLOCK 26
330 
335 #define APBS_TIMER_SETUP 27
336 
341 #define APBS_TIMER_SOLVER 28
342 
347 #define APBS_TIMER_ENERGY 29
348 
353 #define APBS_TIMER_FORCE 30
354 
359 #define APBS_TIMER_TEMP1 31
360 
365 #define APBS_TIMER_TEMP2 32
366 
371 #define MAXMOL 5
372 
377 #define MAXION 10
378 
382 #define MAXFOCUS 5
383 
387 #define VMGNLEV 4
388 
392 #define VREDFRAC 0.25
393 
397 #define VAPBS_NVS 4
398 
402 #define VAPBS_DIM 3
403 
408 #define VAPBS_RIGHT 0
409 
414 #define VAPBS_FRONT 1
415 
420 #define VAPBS_UP 2
421 
426 #define VAPBS_LEFT 3
427 
432 #define VAPBS_BACK 4
433 
438 #define VAPBS_DOWN 5
439 
444 #define VPMGSMALL 1e-12
445 
450 #define SINH_MIN -85.0
451 
456 #define SINH_MAX 85.0
457 
458 #define MAX_HASH_DIM 75
459 
460 #if defined(VDEBUG)
461 # if !defined(APBS_NOINLINE)
462 # define APBS_NOINLINE 1
463 # endif
464 #endif
465 
466 #if !defined(APBS_NOINLINE)
467 
471 # define VINLINE_VACC
472 
476 # define VINLINE_VATOM
477 
481 # define VINLINE_VCSM
482 
486 # define VINLINE_VPBE
487 
491 # define VINLINE_VPEE
492 
496 # define VINLINE_VGREEN
497 
501 # define VINLINE_VFETK
502 
506 # define VINLINE_VPMG
507 
512 #endif
513 
514 /* Fortran name mangling */
515 #if defined(VF77_UPPERCASE)
516 # if defined(VF77_NOUNDERSCORE)
517 # define VF77_MANGLE(name,NAME) NAME
518 # elif defined(VF77_ONEUNDERSCORE)
519 # define VF77_MANGLE(name,NAME) NAME ## _
520 # else
521 # define VF77_MANGLE(name,NAME) name
522 # endif
523 #else
524 # if defined(VF77_NOUNDERSCORE)
525 # define VF77_MANGLE(name,NAME) name
526 # elif defined(VF77_ONEUNDERSCORE)
527 # define VF77_MANGLE(name,NAME) name ## _
528 # else
529 
532 # define VF77_MANGLE(name,NAME) name
533 # endif
534 #endif
535 
536 /* Floating Point Error */
537 #if defined(FLOAT_EPSILON)
538 # define VFLOOR(value) \
539  ((floor(value) != floor(value + FLOAT_EPSILON)) ? \
540  floor(value + FLOAT_EPSILON) : floor(value))
541 #else
542 
547 # define VFLOOR(value) floor(value)
548 #endif
549 
550 /* String embedding for ident */
551 #if defined(HAVE_EMBED)
552 
556 # define VEMBED(rctag) \
557  VPRIVATE const char* rctag; \
558  static void* use_rcsid=(0 ? &use_rcsid : (void**)&rcsid);
559 #else
560 
564 # define VEMBED(rctag)
565 #endif /* if defined(HAVE_EMBED) */
566 
567 
568 
570 #if !defined(_WIN32) || defined(__MINGW32__)
571 #define PRINT_FUNC __PRETTY_FUNCTION__
572 #define OS_SEP_STR "/"
573 #define OS_SEP_CHAR '/'
574 #else
575 #define OS_SEP_STR "\\"
576 #define OS_SEP_CHAR '\\'
577 #define PRINT_FUNC __FUNCSIG__
578 #define snprintf sprintf_s
579 #endif
580 
581 #ifdef VERGBOSE_DEBUG
582 #define ANNOUNCE_FUNCTION \
583  do { \
584  Vnm_prrint(2, "%s() [%s:%d]\n", \
585  PRINT_FUNC, __FILE__, __LINE__ ); \
586  } while(0)
587 
588 #define WARN_UNTESTED \
589  do { \
590  Vnm_print(2, "%s() [%s:%d]: Untested Translation!\n", \
591  __FUNCTION__, __FILE__, __LINE__); \
592  } while(0)
593 
594 #define WARN_PARTTESTED \
595  do{ \
596  Vnm_print(2, "%s() [%s:%d]: Partially Tested Translation.\n", \
597  __FUNCTION__, __FILE__, __LINE__); \
598  } while(0)
599 #else
600 #define ANNOUNCE_FUNCTION
601 #define WARN_UNTESTED
602 #define WARN_PARTTESTED
603 #endif
604 
605 
606 
607 /* Utility messages. Print out messages with location information */
608 #ifdef DEBUG
609 #define VCHANNELEDMESSAGE0(channel, msg) \
610  do { \
611  Vnm_print(channel, "%s:%d [%s()]: MESSAGE:\n" \
612  " %s\n\n", \
613  __FILE__, __LINE__, __FUNCTION__, msg); \
614  } while(0)
615 
616 #define VCHANNELEDMESSAGE1(channel, msg, arg) \
617  do { \
618  char buff[1000]; \
619  snprintf( buff, 1000, msg, arg ); \
620  Vnm_print(channel, "%s:%d [%s()]: MESSAGE:\n" \
621  " %s\n\n", \
622  __FILE__, __LINE__, __FUNCTION__, buff); \
623  } while(0)
624 
625 #define VCHANNELEDMESSAGE2(channel, msg, arg0, arg1) \
626  do { \
627  char buff[1000]; \
628  snprintf( buff, 1000, msg, arg0, arg1 ); \
629  Vnm_print(channel, "%s:%d [%s()]: MESSAGE:\n" \
630  " %s\n\n", \
631  __FILE__, __LINE__, __FUNCTION__, buff); \
632  } while(0)
633 
634 #define VCHANNELEDMESSAGE3(channel, msg, arg0, arg1, arg2) \
635  do { \
636  char buff[1000]; \
637  snprintf(buff, 1000, msg, arg0, arg1, arg2); \
638  Vnm_print(channel, "%s:%d [%s()]: MESSAGE:\n" \
639  " %s\n\n", \
640  __FILE__, __LINE__, __FUNCTION__, buff); \
641  } while(0)
642 
643 #define VMESSAGE0(msg) VCHANNELEDMESSAGE0(2, msg)
644 #define VMESSAGE1(msg, arg0) VCHANNELEDMESSAGE1(2, msg, arg0)
645 #define VMESSAGE2(msg, arg0, arg1) VCHANNELEDMESSAGE2(2, msg, arg0, arg1)
646 #define VMESSAGE3(msg, arg0, arg1, arg2) VCHANNELEDMESSAGE3(2, msg, arg0, arg1, arg2)
647 
648 #define VERRMSG0(msg) VMESSAGE0(msg)
649 #define VERRMSG1(msg, arg0) VMESSAGE1(msg, arg0)
650 #define VERRMSG2(msg, arg0, arg1) VMESSAGE2(msg, arg0, arg1)
651 #define VERRMSG3(msg, arg0, arg1, arg2) VMESSAGE3(msg, arg0, arg1, arg2)
652 #else
653 #define VCHANNELEDMESSAGE0(channel, msg) \
654  do { \
655  Vnm_print(channel, "%s: %s\n", __FUNCTION__, msg); \
656  } while(0)
657 
658 #define VCHANNELEDMESSAGE1(channel, msg, arg0) \
659  do { \
660  char buff[1000]; \
661  snprintf( buff, 1000, msg, arg0 ); \
662  Vnm_print(channel, "%s: %s\n", __FUNCTION__, buff); \
663  } while(0)
664 
665 #define VCHANNELEDMESSAGE2(channel, msg, arg0, arg1) \
666  do { \
667  char buff[1000]; \
668  snprintf( buff, 1000, msg, arg0, arg1 ); \
669  Vnm_print(channel, "%s: %s\n", __FUNCTION__, buff); \
670  } while(0)
671 
672 #define VCHANNELEDMESSAGE3(channel, msg, arg0, arg1, arg2) \
673  do { \
674  char buff[1000]; \
675  snprintf(buff, 1000, msg, arg0, arg1, arg2); \
676  Vnm_print(channel, "%s: %s\n", __FUNCTION__, buff); \
677  } while(0)
678 
679 #define VMESSAGE0(msg) VCHANNELEDMESSAGE0(0, msg)
680 #define VMESSAGE1(msg, arg0) VCHANNELEDMESSAGE1(0, msg, arg0)
681 #define VMESSAGE2(msg, arg0, arg1) VCHANNELEDMESSAGE2(0, msg, arg0, arg1)
682 #define VMESSAGE3(msg, arg0, arg1, arg2) VCHANNELEDMESSAGE3(0, msg, arg0, arg1, arg2)
683 
684 #define VERRMSG0(msg) VCHANNELEDMESSAGE0(2, msg)
685 #define VERRMSG1(msg, arg0) VCHANNELEDMESSAGE1(2, msg, arg0)
686 #define VERRMSG2(msg, arg0, arg1) VCHANNELEDMESSAGE2(2, msg, arg0, arg1)
687 #define VERRMSG3(msg, arg0, arg1, arg2) VCHANNELEDMESSAGE3(2, msg, arg0, arg1, arg2)
688 #endif
689 
690 
691 
692 /* Utility assertions. If they fail, they print out messages with possible
693  * arguments and then abort
694  * The do{...} while(0) simply enforces that a semicolon appears at the end
695  */
696 #ifdef DEBUG
697 #define VASSERT_MSG0(cnd, msg) \
698  do { \
699  if( (cnd) == 0 ) { \
700  Vnm_print(2, "%s:%d [%s()]: ERROR:\n" \
701  " Assertion Failed (%s): %s\n\n", \
702  __FILE__, __LINE__, __FUNCTION__, #cnd, msg); \
703  abort(); \
704  } \
705  } while(0)
706 
707 #define VASSERT_MSG1(cnd, msg, arg) \
708  do { \
709  if( (cnd) == 0 ) { \
710  char buff[1000]; \
711  snprintf( buff, 1000, msg, arg ); \
712  Vnm_print(2, "%s:%d [%s()]: ERROR:\n" \
713  " Assertion Failed (%s): %s\n\n", \
714  __FILE__, __LINE__, __FUNCTION__, #cnd, buff); \
715  abort(); \
716  } \
717  } while(0)
718 
719 #define VASSERT_MSG2(cnd, msg, arg0, arg1) \
720  do { \
721  if( (cnd) == 0 ) { \
722  char buff[1000]; \
723  snprintf( buff, 1000, msg, arg0, arg1 ); \
724  Vnm_print(2, "%s:%d [%s()]: ERROR:\n" \
725  " Assertion Failed (%s): %s\n\n", \
726  __FILE__, __LINE__, __FUNCTION__, #cnd, buff); \
727  abort(); \
728  } \
729  } while(0)
730 #else
731 #define VASSERT_MSG0(cnd, msg) \
732  do { \
733  if( (cnd) == 0 ) { \
734  Vnm_print(2, "%[%s()]: ERROR:\n" \
735  " Assertion Failed (%s): %s\n\n", \
736  __FUNCTION__, #cnd, msg); \
737  abort(); \
738  } \
739  } while(0)
740 
741 #define VASSERT_MSG1(cnd, msg, arg) \
742  do { \
743  if( (cnd) == 0 ) { \
744  char buff[1000]; \
745  snprintf( buff, 1000, msg, arg ); \
746  Vnm_print(2, "[%s()]: ERROR:\n" \
747  " Assertion Failed (%s): %s\n\n", \
748  __FUNCTION__, #cnd, buff); \
749  abort(); \
750  } \
751  } while(0)
752 
753 #define VASSERT_MSG2(cnd, msg, arg0, arg1) \
754  do { \
755  if( (cnd) == 0 ) { \
756  char buff[1000]; \
757  snprintf( buff, 1000, msg, arg0, arg1 ); \
758  Vnm_print(2, "[%s()]: ERROR:\n" \
759  " Assertion Failed (%s): %s\n\n", \
760  __FUNCTION__, #cnd, buff); \
761  abort(); \
762  } \
763  } while(0)
764 #endif
765 
766 
767 
768 /* Utility warning. Tests a condition and if it fails prints out a message
769  * with optional arguments
770  * The do{...} while(0) simply enforces that a semicolon at the end
771  */
772 #ifdef DEBUG
773 #define VWARN_MSG0(cnd, msg) \
774  do { \
775  if( (cnd) == 0 ) { \
776  Vnm_print( \
777  2, \
778  "%s:%d [%s()]: WARNING:\n" \
779  " Condition Failed (%s):\n %s\n\n", \
780  __FILE__, \
781  __LINE__, \
782  __FUNCTION__, \
783  #cnd, \
784  msg \
785  ); \
786  } \
787  } while(0)
788 
789 #define VWARN_MSG1(cnd, msg, arg0) \
790  do { \
791  if( (cnd) == 0 ) { \
792  char buff[1000]; \
793  snprintf(buff, 1000, msg, arg0); \
794  Vnm_print( \
795  2, \
796  "%s:%d [%s()]: WARNING:\n" \
797  " Condition Failed (%s):\n %s\n\n", \
798  __FILE__, \
799  __LINE__, \
800  __FUNCTION__, \
801  #cnd, \
802  buff \
803  ); \
804  } \
805  } while(0)
806 
807 #define VWARN_MSG2(cnd, msg, arg0, arg1) \
808  do { \
809  if( (cnd) == 0 ) { \
810  char buff[1000]; \
811  snprintf(buff, 1000, msg, arg0, arg1); \
812  Vnm_print( \
813  2, \
814  "%s:%d [%s()]: WARNING:\n" \
815  " Condition Failed (%s):\n %s\n\n", \
816  __FILE__, \
817  __LINE__, \
818  __FUNCTION__, \
819  #cnd, \
820  buff \
821  ); \
822  } \
823  } while(0)
824 #else
825 #define VWARN_MSG0(cnd, msg) \
826  do { \
827  if( (cnd) == 0 ) { \
828  Vnm_print( \
829  2, \
830  "[%s()]: WARNING:\n" \
831  " %s\n\n", \
832  __FUNCTION__, \
833  msg \
834  ); \
835  } \
836  } while(0)
837 
838 #define VWARN_MSG1(cnd, msg, arg0) \
839  do { \
840  if( (cnd) == 0 ) { \
841  char buff[1000]; \
842  snprintf(buff, 1000, msg, arg0); \
843  Vnm_print( \
844  2, \
845  "[%s()]: WARNING:\n" \
846  " %s\n\n", \
847  __FUNCTION__, \
848  buff \
849  ); \
850  } \
851  } while(0)
852 
853 #define VWARN_MSG2(cnd, msg, arg0, arg1) \
854  do { \
855  if( (cnd) == 0 ) { \
856  char buff[1000]; \
857  snprintf(buff, 1000, msg, arg0, arg1); \
858  Vnm_print( \
859  2, \
860  "[%s()]: WARNING:\n" \
861  " %s\n\n", \
862  __FUNCTION__, \
863  buff \
864  ); \
865  } \
866  } while(0)
867 #endif
868 
869 /* Utility Abort. Prints a message with optional arugments and aborts */
870 #ifdef DEBUG
871 #define VABORT_MSG0(msg) \
872  do { \
873  Vnm_print(2, "%s:%d [%s()]: ABORTING:\n" \
874  " %s\n\n", \
875  __FILE__, __LINE__, __FUNCTION__, msg); \
876  abort(); \
877  } while(0)
878 
879 #define VABORT_MSG1(msg, arg) \
880  do { \
881  char buff[1000]; \
882  snprintf( buff, 1000, msg, arg ); \
883  Vnm_print(2, "%s:%d [%s()]: ABORTING:\n" \
884  " %s\n\n", \
885  __FILE__, __LINE__, __FUNCTION__, buff); \
886  abort(); \
887  } while(0)
888 
889 #define VABORT_MSG2(msg, arg0, arg1) \
890  do { \
891  char buff[1000]; \
892  snprintf( buff, 1000, msg, arg0, arg1); \
893  Vnm_print(2, "%s:%d [%s()]: ABORTING:\n" \
894  " %s\n\n", \
895  __FILE__, __LINE__, __FUNCTION__, buff); \
896  abort(); \
897  } while(0)
898 #else
899 #define VABORT_MSG0(msg) \
900  do { \
901  Vnm_print(2, "%[%s()]: ABORTING:\n" \
902  " %s\n\n", \
903  __FUNCTION__, msg); \
904  abort(); \
905  } while(0)
906 
907 #define VABORT_MSG1(msg, arg) \
908  do { \
909  char buff[1000]; \
910  snprintf( buff, 1000, msg, arg ); \
911  Vnm_print(2, "[%s()]: ABORTING:\n" \
912  " %s\n\n", \
913  __FUNCTION__, buff); \
914  abort(); \
915  } while(0)
916 
917 #define VABORT_MSG2(msg, arg0, arg1) \
918  do { \
919  char buff[1000]; \
920  snprintf( buff, 1000, msg, arg0, arg1); \
921  Vnm_print(2, "[%s()]: ABORTING:\n" \
922  " %s\n\n", \
923  __FUNCTION__, buff); \
924  abort(); \
925  } while(0)
926 #endif
927 
928 
929 
930 /* Utility expression printers. Print the expression and its value */
931 #ifdef DEBUG
932 #define PRINT_INT(expr) \
933  do { \
934  Vnm_print(2, "%s:%d [%s()]: %s == %d\n", \
935  __FILE__, __LINE__, __FUNCTION__, #expr, expr); \
936  } while(0)
937 
938 #define PRINT_DBL(expr) \
939  do { \
940  Vnm_print(2, "%s:%d [%s()]: %s == %f\n\n", \
941  __FILE__, __LINE__, __FUNCTION__, #expr, expr); \
942  } while(0)
943 #else
944 #define PRINT_INT(expr)
945 #define PRINT_DBL(expr)
946 #endif
947 
948 #define VMALLOC(vmem, n, type) ((type*)Vmem_malloc(vmem, n, sizeof(type)))
949 
950 #define VFREE(vmem, n, type, ptr) (Vmem_free(vmem, n, sizeof(type), (void **)&(ptr)))
951 
952 #define VFILL(vec, n, val) \
953  do { \
954  int fill_idx; \
955  for (fill_idx = 0; fill_idx < n; fill_idx++) \
956  vec[fill_idx] = val; \
957  } while(0)
958 
959 #define VCOPY(srcvec, dstvec, i, n) \
960  do { \
961  for (i = 0; i < n; i++) \
962  dstvec[i] = srcvec[i]; \
963  } while(0)
964 
965 
966 char* wrap_text( char* str, int right_margin, int left_padding );
967 
968 #define VAT(array, i) ((array)[(i) - 1])
969 #define RAT(array, i) ((array) + i - 1)
970 
971 #endif /* #ifndef _VAPBSHAL_H_ */
enum eVchrg_Src Vchrg_Src
Declaration of the Vchrg_Src type as the Vchrg_Meth enum.
Definition: vhal.h:262
Definition: vhal.h:271
Definition: vhal.h:231
Definition: vhal.h:314
Definition: vhal.h:215
eVhal_PBEType
Version of PBE to solve.
Definition: vhal.h:139
enum eVdata_Format Vdata_Format
Declaration of the Vdata_Format type as the Vdata_Format enum.
Definition: vhal.h:323
enum eVoutput_Format Voutput_Format
Declaration of the Voutput_Format type as the VOutput_Format enum.
Definition: vhal.h:200
enum eVsurf_Meth Vsurf_Meth
Declaration of the Vsurf_Meth type as the Vsurf_Meth enum.
Definition: vhal.h:133
enum eVhal_IPKEYType Vhal_IPKEYType
Declaration of the Vhal_IPKEYType type as the Vhal_IPKEYType enum.
Definition: vhal.h:167
eVsurf_Meth
Types of molecular surface definitions.
Definition: vhal.h:102
Definition: vhal.h:209
Definition: vhal.h:313
enum eVbcfl Vbcfl
Declare Vbcfl type.
Definition: vhal.h:223
Definition: vhal.h:315
eVchrg_Src
Charge source.
Definition: vhal.h:251
enum eVhal_PBEType Vhal_PBEType
Declaration of the Vhal_PBEType type as the Vhal_PBEType enum.
Definition: vhal.h:151
Definition: vhal.h:141
Definition: vhal.h:277
eVdata_Format
Format of data for APBS I/O.
Definition: vhal.h:309
Definition: vhal.h:279
Definition: vhal.h:312
Definition: vhal.h:310
Definition: vhal.h:103
eVbcfl
Types of boundary conditions.
Definition: vhal.h:207
eVrc_Codes
Return code enumerations.
Definition: vhal.h:66
Definition: vhal.h:275
Definition: vhal.h:216
Definition: vhal.h:273
Definition: vhal.h:311
Definition: vhal.h:211
Definition: vhal.h:140
eVsol_Meth
Solution Method enumerations.
Definition: vhal.h:81
Definition: vhal.h:281
eVoutput_Format
Output file format.
Definition: vhal.h:191
enum eVdata_Type Vdata_Type
Declaration of the Vdata_Type type as the Vdata_Type enum.
Definition: vhal.h:302
eVhal_NONLINType
Type of nonlinear to use for MG methods.
Definition: vhal.h:173
enum eVhal_NONLINType Vhal_NONLINType
Declaration of the Vhal_NONLINType type as the Vhal_NONLINType enum.
Definition: vhal.h:185
eVchrg_Meth
Types of charge discretization methods.
Definition: vhal.h:230
eVhal_IPKEYType
Type of ipkey to use for MG methods.
Definition: vhal.h:157
enum eVchrg_Meth Vchrg_Meth
Declaration of the Vchrg_Meth type as the Vchrg_Meth enum.
Definition: vhal.h:244
eVdata_Type
Types of (scalar) data that can be written out of APBS.
Definition: vhal.h:269