ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/sequentialProps/SequentialPropsCmd.cpp
(Generate patch)

Comparing trunk/src/applications/sequentialProps/SequentialPropsCmd.cpp (file contents):
Revision 2024 by gezelter, Thu Oct 16 19:13:51 2014 UTC vs.
Revision 2081 by gezelter, Tue Mar 17 18:22:18 2015 UTC

# Line 42 | Line 42 | const char *gengetopt_args_info_help[] = {
42    "  -o, --output=filename         output file name",
43    "      --sele1=selection script  select first stuntdouble set",
44    "      --sele2=selection script  select second stuntdouble set (if sele2 is not \n                                  set, use script from sele1)",
45 <  "  -n, --nbins=INT               Number of bins  (default=`100')",
45 >  "  -b, --nbins=INT               number of bins (general purpose)  \n                                  (default=`100')",
46 >  "      --nbins_z=INT             number of bins in z axis  (default=`100')",
47 >  "  -x, --centroidX=DOUBLE        Location of droplet centroid in x",
48 >  "  -y, --centroidY=DOUBLE        Location of droplet centroid in y",
49 >  "  -z, --referenceZ=DOUBLE       Reference z-height of solid surface",
50 >  "  -r, --dropletR=DOUBLE         Droplet radius in angstroms",
51 >  "      --threshDens=DOUBLE       Threshold Density in g/cm^3",
52 >  "      --bufferLength=DOUBLE     Buffer length in angstroms",
53    "\n Group: sequentialProps\n   an option of this group is required",
54 <  "  -d, --density                 selection correlation function",
54 >  "  -c, --com                     selection center of mass",
55 >  "      --ca1                     contact angle of selection (using center of \n                                  mass)",
56 >  "      --ca2                     contact angle of selection (using density \n                                  profile)",
57      0
58   };
59  
60   typedef enum {ARG_NO
61    , ARG_STRING
62    , ARG_INT
63 +  , ARG_DOUBLE
64   } cmdline_parser_arg_type;
65  
66   static
# Line 78 | Line 88 | void clear_given (struct gengetopt_args_info *args_inf
88    args_info->sele1_given = 0 ;
89    args_info->sele2_given = 0 ;
90    args_info->nbins_given = 0 ;
91 <  args_info->density_given = 0 ;
91 >  args_info->nbins_z_given = 0 ;
92 >  args_info->centroidX_given = 0 ;
93 >  args_info->centroidY_given = 0 ;
94 >  args_info->referenceZ_given = 0 ;
95 >  args_info->dropletR_given = 0 ;
96 >  args_info->threshDens_given = 0 ;
97 >  args_info->bufferLength_given = 0 ;
98 >  args_info->com_given = 0 ;
99 >  args_info->ca1_given = 0 ;
100 >  args_info->ca2_given = 0 ;
101    args_info->sequentialProps_group_counter = 0 ;
102   }
103  
# Line 96 | Line 115 | void clear_args (struct gengetopt_args_info *args_info
115    args_info->sele2_orig = NULL;
116    args_info->nbins_arg = 100;
117    args_info->nbins_orig = NULL;
118 +  args_info->nbins_z_arg = 100;
119 +  args_info->nbins_z_orig = NULL;
120 +  args_info->centroidX_orig = NULL;
121 +  args_info->centroidY_orig = NULL;
122 +  args_info->referenceZ_orig = NULL;
123 +  args_info->dropletR_orig = NULL;
124 +  args_info->threshDens_orig = NULL;
125 +  args_info->bufferLength_orig = NULL;
126    
127   }
128  
# Line 111 | Line 138 | void init_args_info(struct gengetopt_args_info *args_i
138    args_info->sele1_help = gengetopt_args_info_help[4] ;
139    args_info->sele2_help = gengetopt_args_info_help[5] ;
140    args_info->nbins_help = gengetopt_args_info_help[6] ;
141 <  args_info->density_help = gengetopt_args_info_help[8] ;
141 >  args_info->nbins_z_help = gengetopt_args_info_help[7] ;
142 >  args_info->centroidX_help = gengetopt_args_info_help[8] ;
143 >  args_info->centroidY_help = gengetopt_args_info_help[9] ;
144 >  args_info->referenceZ_help = gengetopt_args_info_help[10] ;
145 >  args_info->dropletR_help = gengetopt_args_info_help[11] ;
146 >  args_info->threshDens_help = gengetopt_args_info_help[12] ;
147 >  args_info->bufferLength_help = gengetopt_args_info_help[13] ;
148 >  args_info->com_help = gengetopt_args_info_help[15] ;
149 >  args_info->ca1_help = gengetopt_args_info_help[16] ;
150 >  args_info->ca2_help = gengetopt_args_info_help[17] ;
151    
152   }
153  
# Line 204 | Line 240 | cmdline_parser_release (struct gengetopt_args_info *ar
240    free_string_field (&(args_info->sele2_arg));
241    free_string_field (&(args_info->sele2_orig));
242    free_string_field (&(args_info->nbins_orig));
243 +  free_string_field (&(args_info->nbins_z_orig));
244 +  free_string_field (&(args_info->centroidX_orig));
245 +  free_string_field (&(args_info->centroidY_orig));
246 +  free_string_field (&(args_info->referenceZ_orig));
247 +  free_string_field (&(args_info->dropletR_orig));
248 +  free_string_field (&(args_info->threshDens_orig));
249 +  free_string_field (&(args_info->bufferLength_orig));
250    
251    
252    for (i = 0; i < args_info->inputs_num; ++i)
# Line 253 | Line 296 | cmdline_parser_dump(FILE *outfile, struct gengetopt_ar
296      write_into_file(outfile, "sele2", args_info->sele2_orig, 0);
297    if (args_info->nbins_given)
298      write_into_file(outfile, "nbins", args_info->nbins_orig, 0);
299 <  if (args_info->density_given)
300 <    write_into_file(outfile, "density", 0, 0 );
299 >  if (args_info->nbins_z_given)
300 >    write_into_file(outfile, "nbins_z", args_info->nbins_z_orig, 0);
301 >  if (args_info->centroidX_given)
302 >    write_into_file(outfile, "centroidX", args_info->centroidX_orig, 0);
303 >  if (args_info->centroidY_given)
304 >    write_into_file(outfile, "centroidY", args_info->centroidY_orig, 0);
305 >  if (args_info->referenceZ_given)
306 >    write_into_file(outfile, "referenceZ", args_info->referenceZ_orig, 0);
307 >  if (args_info->dropletR_given)
308 >    write_into_file(outfile, "dropletR", args_info->dropletR_orig, 0);
309 >  if (args_info->threshDens_given)
310 >    write_into_file(outfile, "threshDens", args_info->threshDens_orig, 0);
311 >  if (args_info->bufferLength_given)
312 >    write_into_file(outfile, "bufferLength", args_info->bufferLength_orig, 0);
313 >  if (args_info->com_given)
314 >    write_into_file(outfile, "com", 0, 0 );
315 >  if (args_info->ca1_given)
316 >    write_into_file(outfile, "ca1", 0, 0 );
317 >  if (args_info->ca2_given)
318 >    write_into_file(outfile, "ca2", 0, 0 );
319    
320  
321    i = EXIT_SUCCESS;
# Line 308 | Line 369 | reset_group_sequentialProps(struct gengetopt_args_info
369    if (! args_info->sequentialProps_group_counter)
370      return;
371    
372 <  args_info->density_given = 0 ;
372 >  args_info->com_given = 0 ;
373 >  args_info->ca1_given = 0 ;
374 >  args_info->ca2_given = 0 ;
375  
376    args_info->sequentialProps_group_counter = 0;
377   }
# Line 469 | Line 532 | int update_arg(void *field, char **orig_field,
532    case ARG_INT:
533      if (val) *((int *)field) = strtol (val, &stop_char, 0);
534      break;
535 +  case ARG_DOUBLE:
536 +    if (val) *((double *)field) = strtod (val, &stop_char);
537 +    break;
538    case ARG_STRING:
539      if (val) {
540        string_field = (char **)field;
# Line 484 | Line 550 | int update_arg(void *field, char **orig_field,
550    /* check numeric conversion */
551    switch(arg_type) {
552    case ARG_INT:
553 +  case ARG_DOUBLE:
554      if (val && !(stop_char && *stop_char == '\0')) {
555        fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
556        return 1; /* failure */
# Line 556 | Line 623 | cmdline_parser_internal (
623          { "output",     1, NULL, 'o' },
624          { "sele1",      1, NULL, 0 },
625          { "sele2",      1, NULL, 0 },
626 <        { "nbins",      1, NULL, 'n' },
627 <        { "density",    0, NULL, 'd' },
626 >        { "nbins",      1, NULL, 'b' },
627 >        { "nbins_z",    1, NULL, 0 },
628 >        { "centroidX",  1, NULL, 'x' },
629 >        { "centroidY",  1, NULL, 'y' },
630 >        { "referenceZ", 1, NULL, 'z' },
631 >        { "dropletR",   1, NULL, 'r' },
632 >        { "threshDens", 1, NULL, 0 },
633 >        { "bufferLength",       1, NULL, 0 },
634 >        { "com",        0, NULL, 'c' },
635 >        { "ca1",        0, NULL, 0 },
636 >        { "ca2",        0, NULL, 0 },
637          { 0,  0, 0, 0 }
638        };
639  
640 <      c = getopt_long (argc, argv, "hVi:o:n:d", long_options, &option_index);
640 >      c = getopt_long (argc, argv, "hVi:o:b:x:y:z:r:c", long_options, &option_index);
641  
642        if (c == -1) break;       /* Exit from `while (1)' loop.  */
643  
# Line 601 | Line 677 | cmdline_parser_internal (
677              goto failure;
678          
679            break;
680 <        case 'n':       /* Number of bins.  */
680 >        case 'b':       /* number of bins (general purpose).  */
681          
682          
683            if (update_arg( (void *)&(args_info->nbins_arg),
684                 &(args_info->nbins_orig), &(args_info->nbins_given),
685                &(local_args_info.nbins_given), optarg, 0, "100", ARG_INT,
686                check_ambiguity, override, 0, 0,
687 <              "nbins", 'n',
687 >              "nbins", 'b',
688                additional_error))
689              goto failure;
690          
691            break;
692 <        case 'd':       /* selection correlation function.  */
692 >        case 'x':       /* Location of droplet centroid in x.  */
693 >        
694 >        
695 >          if (update_arg( (void *)&(args_info->centroidX_arg),
696 >               &(args_info->centroidX_orig), &(args_info->centroidX_given),
697 >              &(local_args_info.centroidX_given), optarg, 0, 0, ARG_DOUBLE,
698 >              check_ambiguity, override, 0, 0,
699 >              "centroidX", 'x',
700 >              additional_error))
701 >            goto failure;
702 >        
703 >          break;
704 >        case 'y':       /* Location of droplet centroid in y.  */
705 >        
706 >        
707 >          if (update_arg( (void *)&(args_info->centroidY_arg),
708 >               &(args_info->centroidY_orig), &(args_info->centroidY_given),
709 >              &(local_args_info.centroidY_given), optarg, 0, 0, ARG_DOUBLE,
710 >              check_ambiguity, override, 0, 0,
711 >              "centroidY", 'y',
712 >              additional_error))
713 >            goto failure;
714          
715 +          break;
716 +        case 'z':       /* Reference z-height of solid surface.  */
717 +        
718 +        
719 +          if (update_arg( (void *)&(args_info->referenceZ_arg),
720 +               &(args_info->referenceZ_orig), &(args_info->referenceZ_given),
721 +              &(local_args_info.referenceZ_given), optarg, 0, 0, ARG_DOUBLE,
722 +              check_ambiguity, override, 0, 0,
723 +              "referenceZ", 'z',
724 +              additional_error))
725 +            goto failure;
726 +        
727 +          break;
728 +        case 'r':       /* Droplet radius in angstroms.  */
729 +        
730 +        
731 +          if (update_arg( (void *)&(args_info->dropletR_arg),
732 +               &(args_info->dropletR_orig), &(args_info->dropletR_given),
733 +              &(local_args_info.dropletR_given), optarg, 0, 0, ARG_DOUBLE,
734 +              check_ambiguity, override, 0, 0,
735 +              "dropletR", 'r',
736 +              additional_error))
737 +            goto failure;
738 +        
739 +          break;
740 +        case 'c':       /* selection center of mass.  */
741 +        
742            if (args_info->sequentialProps_group_counter && override)
743              reset_group_sequentialProps (args_info);
744            args_info->sequentialProps_group_counter += 1;
745          
746            if (update_arg( 0 ,
747 <               0 , &(args_info->density_given),
748 <              &(local_args_info.density_given), optarg, 0, 0, ARG_NO,
747 >               0 , &(args_info->com_given),
748 >              &(local_args_info.com_given), optarg, 0, 0, ARG_NO,
749                check_ambiguity, override, 0, 0,
750 <              "density", 'd',
750 >              "com", 'c',
751                additional_error))
752              goto failure;
753          
# Line 658 | Line 782 | cmdline_parser_internal (
782                goto failure;
783            
784            }
785 +          /* number of bins in z axis.  */
786 +          else if (strcmp (long_options[option_index].name, "nbins_z") == 0)
787 +          {
788            
789 +          
790 +            if (update_arg( (void *)&(args_info->nbins_z_arg),
791 +                 &(args_info->nbins_z_orig), &(args_info->nbins_z_given),
792 +                &(local_args_info.nbins_z_given), optarg, 0, "100", ARG_INT,
793 +                check_ambiguity, override, 0, 0,
794 +                "nbins_z", '-',
795 +                additional_error))
796 +              goto failure;
797 +          
798 +          }
799 +          /* Threshold Density in g/cm^3.  */
800 +          else if (strcmp (long_options[option_index].name, "threshDens") == 0)
801 +          {
802 +          
803 +          
804 +            if (update_arg( (void *)&(args_info->threshDens_arg),
805 +                 &(args_info->threshDens_orig), &(args_info->threshDens_given),
806 +                &(local_args_info.threshDens_given), optarg, 0, 0, ARG_DOUBLE,
807 +                check_ambiguity, override, 0, 0,
808 +                "threshDens", '-',
809 +                additional_error))
810 +              goto failure;
811 +          
812 +          }
813 +          /* Buffer length in angstroms.  */
814 +          else if (strcmp (long_options[option_index].name, "bufferLength") == 0)
815 +          {
816 +          
817 +          
818 +            if (update_arg( (void *)&(args_info->bufferLength_arg),
819 +                 &(args_info->bufferLength_orig), &(args_info->bufferLength_given),
820 +                &(local_args_info.bufferLength_given), optarg, 0, 0, ARG_DOUBLE,
821 +                check_ambiguity, override, 0, 0,
822 +                "bufferLength", '-',
823 +                additional_error))
824 +              goto failure;
825 +          
826 +          }
827 +          /* contact angle of selection (using center of mass).  */
828 +          else if (strcmp (long_options[option_index].name, "ca1") == 0)
829 +          {
830 +          
831 +            if (args_info->sequentialProps_group_counter && override)
832 +              reset_group_sequentialProps (args_info);
833 +            args_info->sequentialProps_group_counter += 1;
834 +          
835 +            if (update_arg( 0 ,
836 +                 0 , &(args_info->ca1_given),
837 +                &(local_args_info.ca1_given), optarg, 0, 0, ARG_NO,
838 +                check_ambiguity, override, 0, 0,
839 +                "ca1", '-',
840 +                additional_error))
841 +              goto failure;
842 +          
843 +          }
844 +          /* contact angle of selection (using density profile).  */
845 +          else if (strcmp (long_options[option_index].name, "ca2") == 0)
846 +          {
847 +          
848 +            if (args_info->sequentialProps_group_counter && override)
849 +              reset_group_sequentialProps (args_info);
850 +            args_info->sequentialProps_group_counter += 1;
851 +          
852 +            if (update_arg( 0 ,
853 +                 0 , &(args_info->ca2_given),
854 +                &(local_args_info.ca2_given), optarg, 0, 0, ARG_NO,
855 +                check_ambiguity, override, 0, 0,
856 +                "ca2", '-',
857 +                additional_error))
858 +              goto failure;
859 +          
860 +          }
861 +          
862            break;
863          case '?':       /* Invalid option.  */
864            /* `getopt_long' already printed an error message.  */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines