NORMA (1158464), страница 4
Текст из файла (страница 4)
Newsquare: Square / AxiisK+RIGHT(3), L=50...80.
If the list of modifications has more than one element modifications declared in that list act on modificated domain in writing order (from the left to the right).
Besides rectangular domain declarations in NORMA there is a possibility of diagonal domain settings by the superposition of conditions on previously declared domain (rectangular or diagonal).
Diagonal domain is defined by conditions on indexes of some previously declared domain D. It consists of domain D points in which the conditions are true. E.g.
KL: ( (k=1..10) ; (l=1..10) ) . Diagonal: KL/ k=l.
set domain Diagonal consists of the points (k=1, l=1), (k=2, l=2), ...,(k=10, l=10).
Indexes on variables used in the notation of conditions on indexes can be either internal (from D domains set of indexes) or external (see 5.2.3.2).
The valid form of conditions on indexes defines statically the points of diagonal domain (it is also possible for rectangular domain). That’s rectangular and diagonal domain are static objects. They differ from conditional domain described below.
5.1.1.2. Declaration of conditional domain
declaration-of-conditional-domain :
name-conditional domain , name-conditional-domain : name-domain / condition-on-domain
Besides static domains in NORMA you can set conditional domain consists of the points from index space. Their number and coordinates can change depending on fulfilment or nonfulfilment of conditions on domain.
Here we describe how you can set conditional domain. Previously declared domain D is divided into two disjoint subdomains D1 and D2. The first subdomain consists of the points where the conditions on domain are true, the second one - where they are false. Besides D1 D2 = D, D1
D2 =
.
E.g. set domains:
Domain: ( ( i=2..n) ) ; ( j=1..m ) ) .
Domain1,Domain2: Domain / x+y[ i-1, j ] - z[ j+1 ] > 0 .
This declaration defines division of initial domain Domain into domains Domain1 and Domain2 and
Domain1 Domain2 = Domain, Domain1
Domain2 =
.
Domain1 consists of the points of Domain in which the condition x+y[i-1, j] - z[j +1] > 0 is true. Domain2 - where the condition is false.
Indexes of the variables used in the conditions notation can be either internal (from D domains set of indexes) or external (5.2.3.2).
Program fragment defining conditional domains Bf2PI and BfNot2PI, and their further division into smaller domains (first domain BfNot2PI is divided into two conditional domains Nodes and NotNodes, and then domain NotNodes is divided into two conditional domains DomainTrue, DomainFalse ) is given below :
DOMAIN PARAMETERS N=3, NV=3 .
Bnu : (Nu=0..2*N) . Bf : ( II=0..(2*N+1) * (2*NV+1 ) . BfNu : (Bf ; Nu) .
Bf2PI , BfNot2PI : BfNu / II=(2*N+1)*(2*NV+! ) AND NU=0 .
Nodes , NotNodes : BfNot2PI / ABS (BTNodes -BT ) < 0.0001 .
DomainTrue , DomainFalse : Nodes / ABS(BTNu - BTNodes ) < 0.0001 .
VARIABLE BT, BTNodes DEFINED ON Bf DOUBLE .
VARIABLE BTNu DEFINED ON Bnu DOUBLE .
5.1.2. Declaration of domains’ indexes
declaration-of-domain-indexes :
INDEX list-name-index
The order of the index space directions in domain’s declaration isn’t fixed (or fixed arbitrarily, that is the same for user ). If the order of index space directions is important (e.g. consistency of directions is needed for using the same variables on the same domains in the different parts) it may be set by declaration of domains’ indexes. The order of index space directions is the same as the order of index’s names enumeration in declaration INDEX ( from the left to the right ).
We consider call of part B from part A with variable X values communication from A to B. Variable X is defined on SquareInA domain:
PART A.
BEGIN
INDEX k,l .
SquareInA.: (AxisK: (k=1..5) ;AxisL: (l=1..10) ).
VARIABLE X DEFINED ON SquareInA.
COMPUTE B( X ON SquareInA).
END PART
PART B. X
BEGIN
INDEX i,j.
SquareInB : (AxisK: (i=1..5) ; AxisL: (j=1..10) ) .
VARIABLE X DEFINED ON SquareInB.
END PART
Declarations INDEX k,l and INDEX i,j make correspondence between indexes: i~k,j~l . In other words the values of X variable are considered in the one and the same way in both parts. If INDEX i,j declaration from part B is substituted to INDEX j,i the values on corresponding directions will be inconsistent: 5 10, 10
5.
5.1.3. Declaration of variables
declaration-of-scalar-variables :
VARIABLE list-name-scalar [ type ]
declaration-of-variables-on-domains :
VARIABLE list-name-variable-on-domain DEFINED ON name-unconditional-domain [ type ]
type :
{ REAL, INTEGER, DOUBLE }
Scalar variables and variables on domain are arithmetical variables. There is a unique name and the type of variable in the declaration corresponding to every arithmetical variable. The types of variables are REAL, INTEGER or DOUBLE (default REAL).
It is an example of scalar‘s declaration:
VARIABLE Alpha, X, H. VARIABLE IJK, Z INTEGER.
Every variable on domain is connected with the domain in the declaration. This domain defines index’s names, which can be used in index expressions in calls to this variable ( the order of index expressions isn’t important).There is no special declaration for indexes, they are introduced in domain’s declarations.
Square: (AxisK: (k=1..5) ; AxisL: (l=1..5) ).
VARIABLE First,Last DEFINED ON Square.
VARIABLE SingleK DEFINED ON AxisK DOUBLE.
VARIABLE SingleL DEFINED ON AxisL INTEGER.
Given declarations define variables First, Last on domain Square. It means that these variables can have corresponding indexes k and l in the index expressions. Variables SingleK and SingleL are defined on domains AxisK and AxisL. It means that they can have corresponding indexes k and l in the index expressions. In this call First[k-1,l+1] and First[l+1,k-1] are equivalent (5.1.2).
In call to variable on domain the rule of default indexes setting is performed: index expressions which coincide with index name may be omitted. E.g. notations First[k,l], First[k], First[l], First for variable First are equivalent.
If some index is set by constant (constant expression) you must declare which index direction this constant concerns to, e.g. First[k=5,l-1]. If you need to link two directions by some formula you must do it in explicit way, e.g. diagonal elements of the matrix First may be defined as First[k,l=k] or First[l=k] or First[k=l].
5.1.4. Declaration of domain parameters
declaration-of-domain-parameters :
DOMAIN PARAMETERS list-prescription
prescription :
name-domain-parameter = int-const
Range boundaries in domain’s declaration may be set by parameters of domain (in implicit way). The values of these parameters must be defined in the part, in the domain parameters declaration. E.g.
DOMAIN PARAMETERS M=3, J=90, DomainLeftBoundParameter=15.
Parameters of domain may be included into arithmetical expressions and constant expressions.
5.1.5. Declaration of input and output
declaration-of-input :
INPUT list-input-scalar
INPUT input-on-domain
input-scalar :
name-scalar [ attributes ]
input-on-domain :
list input-output-variable ON unconditional domain
input-output-variable :
name-variable-on-domain [ attributes ]
declaration-of-output :
OUTPUT list-output-scalar
OUTPUT output-on-domain
output-scalar :
name-scalar [ attributes ]
output-on-domain :
list- input-output-variable ON domain
attributes :
( list-attribute )
attribute :
STR( int-constant )
string
ORDER( list-name-index )
FILE = ' file-name '
ALL
format
format :
I int-constant
{ F,E,D } int-constant . int-constant
Declaration of input (output) variables means that all the variables mentioned in the list of input (output) are liable to input (output). E.g. declarations
B1 , B2 : B / Z<Eps.
INPUT Velocity ON A. OUTPUT Tau ON B1.
INPUT X, ALPHA.
are requests for input of scalar X, ALPHA values, value of Velocity in all the points of A domain and output Tau in all the points of B1 domain where condition Z<Eps is fulfilled.
The order of variables input (output) isn’t set, it is defined during the translation. Minimal piece of information which is input (output) as a whole is scalar or variable on domain. Attributes may control input (output) of these elements.
Attributes act on the variable declared before. E.g. declaration
INPUT R1,R2 (FILE ='myfile') ON Grid.
is a request for input of variables R2 values on Grid domain (in other words for all the index values of this domain) from file myfile.dat and R1 values from file norma.dat (default file name).
Attributes help to control the form of input and output data and bind data with input and output files:
STR(n) sets the skip of n-1 lines;
‘string’ set output of the textual constant string;
ORDER defines the order of index changing for input; the highest index is the first from the right, the lowest is the first from the left; for one value of every high index the low index has run over all their values ;
FILE sets the name of input or output files; the method of setting file name is defined during realization ( in general input file has a default name with .dat extension; when you set file name this extension may be omitted; if attribute FILE isn’t given input is carried out from file norma.dat and output to display screen );
ALL sets output variable’s name and its coordinates (index values) for every value of variable on domain.
format sets format for numerical values for input and output and corresponds to format specificators I, F, E, D in the FORTRAN language. There are default formats: E15.8 for variables of REAL type, D15.8 for variables of DOUBLE type and I5 for variables of INTEGER type.
For input variables only attributes of format and FILE type are allowed.
Here is an example of input variables declaration :