Actual source code: gridConst.c
1: #ifdef PETSC_RCS_HEADER
2: static char vcid[] = "$Id: gridConst.c,v 1.1 1999/10/17 19:47:46 knepley Exp $";
3: #endif
5: #include src/grid/gridimpl.h
7: /*--------------------------------------------- Constraint Functions ------------------------------------------------*/
8: #undef __FUNCT__
10: /*@C
11: GridIsConstrained - This function indicates whether or not constraints are active.
13: Not collective
15: Input Parameter:
16: . grid - The grid
18: Output Parameter:
19: . flag - The flag that indicates activate constraints
21: Level: intermediate
23: .keywords constraint
24: .seealso GridSetConstrained(), GridSetupConstraints()
25: @*/
26: int GridIsConstrained(Grid grid, PetscTruth *flag)
27: {
31: *flag = grid->isConstrained;
32: return(0);
33: }
35: #undef __FUNCT__
37: /*@C
38: GridSetConstrained - This function activates or deactivates constraints.
40: Collective on Grid
42: Input Parameters:
43: + grid - The grid
44: - flag - The activation flag
46: Level: intermediate
48: .keywords constraint
49: .seealso GridIsConstrained(), GridSetupConstraints()
50: @*/
51: int GridSetConstrained(Grid grid, PetscTruth flag)
52: {
55: grid->isConstrained = flag;
56: return(0);
57: }
59: #undef __FUNCT__
61: /*@C
62: GridGetNumNewFields - This function returns the number of fields introduced by constraints.
64: Not collective
66: Input Parameter:
67: . grid - The grid
69: Output Parameter:
70: . numNewFields - The number of fields introduced by constraints
72: Level: intermediate
74: .keywords constraint
75: .seealso GridSetNumNewFields(), GridSetupConstraints()
76: @*/
77: int GridGetNumNewFields(Grid grid, int *numNewFields)
78: {
82: *numNewFields = grid->numNewFields;
83: return(0);
84: }
86: #undef __FUNCT__
88: /*@C
89: GridSetNumNewFields - This function sets the number of fields introduced by constraints.
91: Collective on Grid
93: Input Parameters:
94: + grid - The grid
95: - numNewFields - The number of fields introduced by constraints
97: Level: intermediate
99: .keywords constraint
100: .seealso GridGetNumNewFields(), GridSetupConstraints()
101: @*/
102: int GridSetNumNewFields(Grid grid, int numNewFields)
103: {
106: grid->numNewFields = numNewFields;
107: return(0);
108: }
110: #undef __FUNCT__
112: /*@C
113: GridIsFieldConstrained - This function indicates whether or not a field is constrained.
115: Not collective
117: Input Parameters:
118: + grid - The grid
119: - field - The field
121: Output Parameter:
122: . isConstrained - The flag that indicates whether the field is constrained
124: Level: intermediate
126: .keywords constraint, field
127: .seealso GridIsConstrained(), GridSetupConstraints()
128: @*/
129: int GridIsFieldConstrained(Grid grid, int field, PetscTruth *isConstrained)
130: {
134: GridValidField(grid, field);
135: *isConstrained = grid->fields[field].isConstrained;
136: return(0);
137: }
139: #undef __FUNCT__
141: /*@C
142: GridSetFieldConstrained - This function determines whether or not a field is constrained.
144: Not collective
146: Input Parameters:
147: + grid - The grid
148: . field - The field
149: - isConstrained - The flag that determines whether the field is constrained
151: Level: intermediate
153: .keywords constraint, field
154: .seealso GridSetConstrained(), GridSetupConstraints()
155: @*/
156: int GridSetFieldConstrained(Grid grid, int field, PetscTruth isConstrained)
157: {
160: GridValidField(grid, field);
161: grid->fields[field].isConstrained = isConstrained;
162: return(0);
163: }
165: #undef __FUNCT__
167: /*@C
168: GridGetFieldConstraintCompDiff - This function returns the constraint component difference
170: Not collective
172: Input Parameter:
173: + grid - The grid
174: - field - The field
176: Output Parameter:
177: . constraintCompDiff - The difference between the number of components in the new and constrained field
179: Level: intermediate
181: .keywords constraint, field
182: .seealso GridIsConstrained(), GridSetupConstraints()
183: @*/
184: int GridGetFieldConstraintCompDiff(Grid grid, int field, int *constraintCompDiff)
185: {
189: GridValidField(grid, field);
190: *constraintCompDiff = grid->fields[field].constraintCompDiff;
191: return(0);
192: }
194: #undef __FUNCT__
196: /*@C
197: GridSetFieldConstraintCompDiff - This function sets the constraint component difference
199: Not collective
201: Input Parameters:
202: + grid - The grid
203: . field - The field
204: - constraintCompDiff - The difference between the number of components in the new and constrained field
206: Level: intermediate
208: .keywords constraint, field
209: .seealso GridSetConstrained(), GridSetupConstraints()
210: @*/
211: int GridSetFieldConstraintCompDiff(Grid grid, int field, int constraintCompDiff)
212: {
215: GridValidField(grid, field);
216: grid->fields[field].constraintCompDiff = constraintCompDiff;
217: return(0);
218: }
220: #undef __FUNCT__
222: /*@C
223: GridGetExplicitConstraints - This function indicates whether or not constrained
224: objects are formed explicitly or implicitly.
226: Not collective
228: Input Parameter:
229: . grid - The grid
231: Output Parameter:
232: . flag - The flag that indicates explicit constraints
234: Note:
235: Objects formed explicitly are actually vectors and matrices, whereas
236: constrained objects formed implicitly are products of projection
237: operators and normal objects.
239: Level: intermediate
241: .keywords constraint
242: .seealso GridSetExplicitConstraints(), GridSetupConstraints()
243: @*/
244: int GridGetExplicitConstraints(Grid grid, PetscTruth *flag)
245: {
249: *flag = grid->explicitConstraints;
250: return(0);
251: }
253: #undef __FUNCT__
255: /*@C
256: GridSetExplicitConstraints - This function determines how to form constrained objects.
258: Collective on Grid
260: Input Parameters:
261: + grid - The grid
262: - flag - The formation flag
264: Note:
265: Objects formed explicitly are actually vectors and matrices, whereas
266: constrained objects formed implicitly are products of projection
267: operators and normal objects.
269: Level: intermediate
271: .keywords constraint
272: .seealso GridGetExplicitConstraints(), GridSetupConstraints()
273: @*/
274: int GridSetExplicitConstraints(Grid grid, PetscTruth flag)
275: {
278: grid->explicitConstraints = flag;
279: return(0);
280: }
282: #undef __FUNCT__
284: /*@C
285: GridGetConstraints - This function return information about the constrained problem.
287: Not collective
289: Input Parameter:
290: . grid - The grid
292: Output Parameters:
293: + flag - The flag that activates constraints
294: . numInteriorVars - The number of constrained variables unaffected by constraints in this domain
295: . numLocVars - The number of constrained variables in this domain
296: - numVars - The global number of constrained variables
298: Level: advanced
300: .keywords constraint
301: .seealso GridSetBoundary
302: @*/
303: int GridGetConstraints(Grid grid, PetscTruth *flag, int *numInteriorVars, int *numLocVars, int *numVars)
304: {
307: if (flag != PETSC_NULL) {
309: *flag = grid->isConstrained;
310: }
311: if (numInteriorVars != PETSC_NULL) {
313: *numInteriorVars = grid->constraintOrder->numLocVars - grid->constraintOrder->numLocNewVars;
314: }
315: if (numLocVars != PETSC_NULL) {
317: *numLocVars = grid->constraintOrder->numLocVars;
318: }
319: if (numVars != PETSC_NULL) {
321: *numVars = grid->constraintOrder->numVars;
322: }
323: return(0);
324: }
326: #undef __FUNCT__
328: /*@C
329: GridGetConstraintContext - This function returns the constraint context or PETSC_NULL if no constraints exist.
331: Not collective
333: Input Parameter:
334: . grid - The grid
336: Output Parameter:
337: . ctx - The constraint context
339: Level: intermediate
341: .keywords constraint, context
342: .seealso GridSetConstraintContext(), GridSetConstraints()
343: @*/
344: int GridGetConstraintContext(Grid grid, PetscConstraintObject *ctx)
345: {
349: *ctx = grid->constraintCtx;
350: return(0);
351: }
353: #undef __FUNCT__
355: /*@C
356: GridSetConstraintContext - This function sets the context for the constrained problem.
358: Collective on Grid
360: Input Parameters:
361: + grid - The grid
362: - ctx - The constraint context
364: Level: intermediate
366: .keywords constraint, context
367: .seealso GridGetConstraintContext(), GridSetConstraints()
368: @*/
369: int GridSetConstraintContext(Grid grid, PetscConstraintObject ctx)
370: {
373: grid->constraintCtx = ctx;
374: return(0);
375: }
377: #undef __FUNCT__
379: /*@C
380: GridGetConstraintMatrix - This function returns the projector from the constrained to the unconstrained variables,
381: or PETSC_NULL if no projector exists.
383: Collective on Grid
385: Input Parameter:
386: . grid - The grid
388: Output Parameters:
389: . P - The projector from constrained to the unconstrained variables
391: Level: intermediate
393: .keywords constraint
394: .seealso GridSetupConstraints()
395: @*/
396: int GridGetConstraintMatrix(Grid grid, GMat *P)
397: {
401: *P = grid->constraintMatrix;
402: return(0);
403: }
405: #undef __FUNCT__
407: /*@C
408: GridGetConstraintInverse - This function returns the psuedo-inverse of the projector from the constrained
409: to the unconstrained variables, or PETSC_NULL if no inverse exists.
411: Collective on Grid
413: Input Parameter:
414: . grid - The grid
416: Output Parameter:
417: . invP - The pseudo-inverse of the projector from constrained to the unconstrained variables
419: Level: intermediate
421: .keywords constraint
422: .seealso GridSetupConstraints()
423: @*/
424: int GridGetConstraintInverse(Grid grid, GMat *invP)
425: {
429: *invP = grid->constraintInverse;
430: return(0);
431: }