General Commands > About General Commands > model.constr()

model.constr()
Creating and modifying constraints in a model.
Syntax
model.constr().create(<tag>,<shtags>);
model.constr().create(<tag>,<nglobal>);
model.constr(<tag>).shape(<shtags>);
model.constr(<tag>).shape(<pos>,<shtags>);
model.constr(<tag>).global(<nglobal>);
model.constr(<tag>).create(<ftag>);
model.constr(<tag>).feature(<ftag>).getAllowedPropertyValues(property);
model.constr(<tag>).feature(<ftag>).set(ctype,<value>);
 
model.constr(<tag>).shape();
model.constr(<tag>).global();
model.constr(<tag>).feature(<ftag>).getType(ctype);
 
model.constr(<tag>).hasProperty(String pname);
model.constr(<tag>).properties();
model.constr(<tag>).set(String pname, int value);
model.constr(<tag>).set(String pname, int pos, int value);
model.constr(<tag>).set(String pname, int pos, int[] value);
model.constr(<tag>).set(String pname, int pos1, int pos2, int value);
model.constr(<tag>).setIndex(String name, String value, int index);
model.constr(<tag>).setIndex(String name, String value, int firstIndex, int secondIndex);
model.constr(<tag>).setIndex(String name, String[] value, int index);
model.constr(<tag>).setIndex(String name, double value, int index);
model.constr(<tag>).setIndex(String name, double value, int firstIndex, int secondIndex);
model.constr(<tag>).setIndex(String name, double[] value, int index);
model.constr(<tag>).setIndex(String name, int value, int index);
model.constr(<tag>).setIndex(String name, String value, int index);
model.constr(<tag>).setIndex(String name, String value, int index);
model.constr(<tag>).setIndex(String name, int value, int firstIndex, int secondIndex);
model.constr(<tag>).setIndex(String name, int[] value, int index);
 
The set() methods index/position arguments are 1-based. The setIndex() methods index/position arguments are 0-based.
Description
model.constr(<tag>) returns the constraint with tag <tag>.
model.constr().create(<tag>,<shtags>) creates a constraint with tag <tag> using the shape functions <shtags>.
model.constr().create(<tag>,<nglobal>) creates a global constraint with tag <tag> expecting <nglobal> components.
model.constr(<tag>).shape(<shtags>) points to the shape functions associated with the constraint. Reassigning the shape functions can have the side effect of modifying the constraints since the number of constraints can change as the size of each constraint vector can change.
model.constr(<tag>).global(<nglobal>) specifies that the constraint is global and sets the expected number of components.
model.constr(<tag>).feature(<ftag>) is a feature in the constraint with tag <tag>.
model.constr(<tag>).create(<ftag>) creates a constraint feature.
model.constr(<tag>).feature(<ftag>).set(ctype,<value>) sets the parameter ctype to <value>, where ctype is either constr or constrf, and <value> is a single constraint expression or a list of constraint expressions. The number of elements in the constraint expression depends on the number of global constraint components or shape functions specified, and on the shape function type. A Lagrange shape function or global constraint component requires a single item, whereas a vector shape function requires one item for each space dimension. The supported set methods are the ones for double string arrays defined in Table 2-2.
model.constr(<tag>).feature(<ftag>).selection().named(<seltag>) assigns the constraint to the named selection <seltag>.
model.constr(<tag>).feature(<ftag>).selection().set(...) defines a local selection that assigns the constraint to geometric entities. For a complete list of methods available under selection(), see model.selection(). Only selections at a single geometry level is allowed in the selection.
model.constr(<tag>).shape() returns the shape function tags as a string array.
model.constr(<tag>).global() returns the number of components if the constraint is global, otherwise 1.
model.constr(<tag>).feature(<ftag>)).
getAllowedPropertyValues(property)
returns the set of allowed values for a property if the set is a finite set of strings; otherwise, it returns null.
model.constr(<tag>).feature(<ftag>).getType(ctype) returns the constraint or constraint force value. For available methods, see get* and Selection Access Methods.
model.constr(<tag>).feature(<ftag>).selection().named() returns the named selection tag, and model.constr(<tag>).feature(<ftag>).selection().getType() returns domain information. For available methods, see Selections.
model.constr(<tag>).feature(<ftag>).selection(<estype>).set(...) defines a subselection of a given lower-dimensional excluded selection type that should be excluded from the constraint selection. Excluded selection type can be exclude0 for points, exclude1 for edges, and exclude2 for excluded face subselections. The constraint is not enforced on the specified excluded subselections. Excluded subselections have to have lower dimension than the constraint selection. For a complete list of methods available under selection(<estype>), see model.selection().
Examples
Code for use with Java
Set several constraint by using multiple constraints:
model.constr().create("c1",new String[]{"shu","shv"});
ConstrFeature f = model.constr("c1").create("f1");
f.set("constr",new String[]{"u-1","v"});
f.selection().geom("geom1",1);
f.selection().all();
Vector elements need a set of constraints:
model.constr().create("c2",new String[]{"shE"});
ConstrFeature f = model.constr("c2").create("f1");
f.set("constr",new String[]{"Ex-1","Ey-0","Ez-0"});
f.selection().geom("geom1",1);
f.selection().all();
Code for use with MATLAB
model.constr.create('c1',{'shu','shv'});
f = model.constr('c1').create('f1');
f.set('constr',{'u-1','v'});
f.selection.geom('geom1',1);
f.selection.all;
Vector elements need a set of constraints:
model.constr.create('c2',{'shE'});
f = model.constr('c2').create('f1');
f.set('constr',{'Ex-1','Ey-0','Ez-0'});
f.selection.geom('geom1',1);
f.selection.all;
See Also
model.shape()