/[ascend]/trunk/ascend4/solver/bndman.c
ViewVC logotype

Annotation of /trunk/ascend4/solver/bndman.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations) (download) (as text)
Fri Oct 29 20:54:12 2004 UTC (17 years, 8 months ago) by aw0a
File MIME type: text/x-csrc
File size: 3668 byte(s)
Setting up web subdirectory in repository
1 aw0a 1 /*
2     * Boundary Manipulator Module
3     * Created: 04/97
4     * Version: $Revision: 1.6 $
5     * Version control file: $RCSfile: bndman.c,v $
6     * Date last modified: $Date: 1997/07/18 12:13:57 $
7     * Last modified by: $Author: mthomas $
8     *
9     * This file is part of the SLV solver.
10     *
11     * The SLV solver is free software; you can redistribute
12     * it and/or modify it under the terms of the GNU General Public License as
13     * published by the Free Software Foundation; either version 2 of the
14     * License, or (at your option) any later version.
15     *
16     * The SLV solver is distributed in hope that it will be
17     * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
18     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19     * General Public License for more details.
20     *
21     * You should have received a copy of the GNU General Public License
22     * along with the program; if not, write to the Free Software Foundation,
23     * Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named
24     * COPYING. COPYING is found in ../compiler.
25     *
26     */
27    
28     #include <math.h>
29     #include "utilities/ascConfig.h"
30     #include "compiler/instance_enum.h"
31     #include "compiler/fractions.h"
32     #include "compiler/compiler.h"
33     #include "utilities/ascMalloc.h"
34     #include "compiler/functype.h"
35     #include "compiler/safe.h"
36     #include "compiler/extfunc.h"
37     #include "compiler/dimen.h"
38     #include "compiler/types.h"
39     #include "compiler/find.h"
40     #include "general/list.h"
41     #include "compiler/atomvalue.h"
42     #include "compiler/mathinst.h"
43     #include "compiler/relation_type.h"
44     #include "compiler/relation.h"
45     #include "compiler/relation_util.h"
46     #include "compiler/relation_io.h"
47     #define _SLV_SERVER_C_SEEN_
48     #include "solver/mtx.h"
49     #include "solver/slv_types.h"
50     #include "solver/var.h"
51     #include "solver/rel.h"
52     #include "solver/discrete.h"
53     #include "solver/conditional.h"
54     #include "solver/logrel.h"
55     #include "solver/bnd.h"
56     #include "solver/relman.h"
57     #include "solver/logrelman.h"
58     #include "solver/bndman.h"
59     #include "solver/slv_server.h"
60    
61    
62     real64 bndman_real_eval(struct bnd_boundary *bnd)
63     {
64     struct rel_relation *rel;
65     real64 res;
66     int32 status;
67    
68     if (bnd_kind(bnd)!=e_bnd_rel) {
69     FPRINTF(stderr,"Incorrect bnd passed to bnd_real_eval.\n");
70     return 0.0;
71     }
72     status = 0;
73     rel = bnd_rel(bnd_real_cond(bnd));
74     res = relman_eval(rel,&status,1);
75     return res;
76     }
77    
78    
79     int32 bndman_log_eval(struct bnd_boundary *bnd)
80     {
81     struct logrel_relation *lrel;
82     int32 status,res;
83    
84     if (bnd_kind(bnd)!=e_bnd_logrel) {
85     FPRINTF(stderr,"Incorrect bnd passed to bnd_log_eval.\n");
86     return 0;
87     }
88    
89     status = 0;
90     lrel = bnd_logrel(bnd_log_cond(bnd));
91     res = logrelman_eval(lrel,&status);
92     return res;
93     }
94    
95    
96     int32 bndman_calc_satisfied(struct bnd_boundary *bnd)
97     {
98     int32 logres;
99     struct rel_relation *rel;
100     real64 res,tol;
101     boolean rstat;
102    
103     switch(bnd_kind(bnd)) {
104     case e_bnd_rel:
105     rel = bnd_rel(bnd_real_cond(bnd));
106     res = bndman_real_eval(bnd); /* force to reset real residual */
107     tol = bnd_tolerance(bnd);
108     rstat = relman_calc_satisfied(rel,tol);
109     if (rstat) {
110     return 1;
111     } else {
112     return 0;
113     }
114     case e_bnd_logrel:
115     logres = bndman_log_eval(bnd); /* force to reset boolean residual */
116     return logres;
117     default:
118     FPRINTF(stderr,"Incorrect bnd passed to bnd_calc_satisfied.\n");
119     return 0;
120     }
121     }
122    
123    
124     int32 bndman_calc_at_zero(struct bnd_boundary *bnd)
125     {
126     real64 tol,res;
127    
128     if (bnd_kind(bnd)!=e_bnd_rel) {
129     FPRINTF(stderr,"Incorrect bnd passed to bnd_calc_at_zero.\n");
130     return 0;
131     }
132     tol = bnd_tolerance(bnd);
133     res = bndman_real_eval(bnd);
134    
135     if (fabs(tol) > fabs(res)) {
136     return 1;
137     } else {
138     return 0;
139     }
140     }
141    
142    
143    

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22