117 |
An alternative approach to change the representation (=\FunctionSpace) is |
An alternative approach to change the representation (=\FunctionSpace) is |
118 |
projection\index{projection}, see \Sec{SEC Projection}. |
projection\index{projection}, see \Sec{SEC Projection}. |
119 |
|
|
120 |
\subsection{\Data objects} |
\subsection{\Data Objects} |
121 |
In \escript the class that stores these functions is called \Data. |
In \escript the class that stores these functions is called \Data. |
122 |
The function is represented through its values on \DataSamplePoints where |
The function is represented through its values on \DataSamplePoints where |
123 |
the \DataSamplePoints are chosen according to the function space of the |
the \DataSamplePoints are chosen according to the function space of the |
222 |
mu=Scalar(2., Function(mydomain)) |
mu=Scalar(2., Function(mydomain)) |
223 |
s=getStress(u, lam, mu) |
s=getStress(u, lam, mu) |
224 |
\end{python} |
\end{python} |
225 |
|
% |
226 |
The function \var{lam} belongs to the \ContinuousFunction but with \var{g} the |
The function \var{lam} belongs to the \ContinuousFunction but with \var{g} the |
227 |
function \var{trace(g)} is in the \Function. |
function \var{trace(g)} is in the \Function. |
228 |
In the evaluation of the product \var{lam*trace(g)} we have different function |
In the evaluation of the product \var{lam*trace(g)} we have different function |
274 |
|
|
275 |
This brings us to a very important point about \escript. |
This brings us to a very important point about \escript. |
276 |
You can develop a simulation with constant Lame coefficients, and then later |
You can develop a simulation with constant Lame coefficients, and then later |
277 |
switch to tagged Lame coefficients without otherwise changing your python script. |
switch to tagged Lame coefficients without otherwise changing your \PYTHON script. |
278 |
In short, you can use the same script for models with different domains and |
In short, you can use the same script for models with different domains and |
279 |
different types of input data. |
different types of input data. |
280 |
|
|
286 |
This is where your largest data sets will be created because the values are |
This is where your largest data sets will be created because the values are |
287 |
stored as a complete array. |
stored as a complete array. |
288 |
The tagged case has already been discussed above. |
The tagged case has already been discussed above. |
289 |
|
Expanded data is created when specifying \code{expanded=True} in the \Data |
290 |
Expanded data is created when you create a \Data object with \code{expanded=True}. |
object constructor, while tagged data requires calling the \member{insertTaggedValue} |
|
Tagged data sets are created when you use the \member{insertTaggedValue} |
|
291 |
method as shown above. |
method as shown above. |
292 |
|
|
293 |
Values are accessed through a sample reference number. |
Values are accessed through a sample reference number. |
304 |
\netCDF\cite{NETCDF} file format. |
\netCDF\cite{NETCDF} file format. |
305 |
Use these to save data for checkpoint/restart or simply to save and reuse data |
Use these to save data for checkpoint/restart or simply to save and reuse data |
306 |
that was expensive to compute. |
that was expensive to compute. |
|
|
|
307 |
For instance, to save the coordinates of the data points of a |
For instance, to save the coordinates of the data points of a |
308 |
\ContinuousFunction to the file \file{x.nc} use |
\ContinuousFunction to the file \file{x.nc} use |
309 |
\begin{python} |
\begin{python} |
311 |
x.dump("x.nc") |
x.dump("x.nc") |
312 |
mydomain.dump("dom.nc") |
mydomain.dump("dom.nc") |
313 |
\end{python} |
\end{python} |
314 |
To recover the object \var{x}, and \var{mydomain} was a \finley mesh use |
To recover the object \var{x}, and you know that \var{mydomain} was an \finley |
315 |
|
mesh, use |
316 |
\begin{python} |
\begin{python} |
317 |
from esys.finley import LoadMesh |
from esys.finley import LoadMesh |
318 |
mydomain=LoadMesh("dom.nc") |
mydomain=LoadMesh("dom.nc") |
327 |
In order to avoid conflicts the file names are extended by the \MPI processor |
In order to avoid conflicts the file names are extended by the \MPI processor |
328 |
rank, that is instead of one file \file{dom.nc} you would get |
rank, that is instead of one file \file{dom.nc} you would get |
329 |
\file{dom.nc.0000}, \file{dom.nc.0001}, etc. You still call |
\file{dom.nc.0000}, \file{dom.nc.0001}, etc. You still call |
330 |
\code{LoadMesh('dom.nc')} to load the domain but you have to make sure that |
\code{LoadMesh("dom.nc")} to load the domain but you have to make sure that |
331 |
the appropriate file is accessible from the corresponding rank, and loading |
the appropriate file is accessible from the corresponding rank, and loading |
332 |
will only succeed if you run with as many processes as were used when calling |
will only succeed if you run with as many processes as were used when calling |
333 |
\member{dump}. |
\member{dump}. |
346 |
\Data objects but also other values\footnote{The \PYTHON \emph{pickle} module |
\Data objects but also other values\footnote{The \PYTHON \emph{pickle} module |
347 |
is used for other types.} you compute in your simulation script. |
is used for other types.} you compute in your simulation script. |
348 |
Further, \class{DataManager} objects can simultaneously create files for |
Further, \class{DataManager} objects can simultaneously create files for |
349 |
visualization so no extra calls to, e.g. \code{saveVTK} are needed. |
visualization so no extra calls to \code{saveVTK} etc. are needed. |
350 |
|
|
351 |
The following example shows how the \class{DataManager} class can be used. |
The following example shows how the \class{DataManager} class can be used. |
352 |
For an explanation of all member functions and options see the relevant |
For an explanation of all member functions and options see the relevant |
382 |
variables. Otherwise the same variables are initialized with appropriate |
variables. Otherwise the same variables are initialized with appropriate |
383 |
values to start a new simulation. |
values to start a new simulation. |
384 |
Note, that \var{t} and \var{t_max} are regular floating point values and not |
Note, that \var{t} and \var{t_max} are regular floating point values and not |
385 |
\Data objects but are treated the same way by the \class{DataManager}. |
\Data objects. Yet they are treated the same way by the \class{DataManager}. |
386 |
|
|
387 |
After this initialization step the script enters the main simulation loop |
After this initialization step the script enters the main simulation loop |
388 |
where calculations are performed. |
where calculations are performed. |
389 |
When these are finalized for a time step we call the \member{addData} method |
When these are finalized for a time step we call the \member{addData} method |
390 |
to let the manager know which variables to store on disk. |
to let the manager know which variables to store on disk. |
391 |
Note, that this does not actually save the data yet and it is allowed to call |
This does not actually save the data yet and it is allowed to call |
392 |
\member{addData} more than once to add information incrementally, e.g. from |
\member{addData} more than once to add information incrementally, e.g. from |
393 |
separate functions that have access to the \class{DataManager} instance. |
separate functions that have access to the \class{DataManager} instance. |
394 |
Once all variables have been added the \member{export} method has to be called |
Once all variables have been added the \member{export} method has to be called |
396 |
In this example, this call dumps \var{mydomain} and \var{val} to files |
In this example, this call dumps \var{mydomain} and \var{val} to files |
397 |
in a restart directory and also stores \var{t} and \var{t_max} on disk. |
in a restart directory and also stores \var{t} and \var{t_max} on disk. |
398 |
Additionally, it generates a \VTK file for visualization of the data. |
Additionally, it generates a \VTK file for visualization of the data. |
399 |
|
If the script would stop running before its completion for some reason (e.g. |
400 |
|
because its runtime limit was exceeded in a multiuser environment), you could |
401 |
|
simply run it again and it would resume at the point it stopped before. |
402 |
|
|
403 |
\section{\escript Classes} |
\section{\escript Classes} |
404 |
|
|
409 |
The \Domain class provides an abstract interface to the domain of \FunctionSpace and \Data objects. |
The \Domain class provides an abstract interface to the domain of \FunctionSpace and \Data objects. |
410 |
\Domain needs to be subclassed in order to provide a complete implementation. |
\Domain needs to be subclassed in order to provide a complete implementation. |
411 |
\end{classdesc} |
\end{classdesc} |
412 |
|
% |
413 |
The following methods are available: |
The following methods are available: |
414 |
|
% |
415 |
\begin{methoddesc}[Domain]{getDim}{} |
\begin{methoddesc}[Domain]{getDim}{} |
416 |
returns the spatial dimension of the \Domain. |
returns the spatial dimension of the \Domain. |
417 |
\end{methoddesc} |
\end{methoddesc} |
418 |
|
% |
419 |
\begin{methoddesc}[Domain]{dump}{filename} |
\begin{methoddesc}[Domain]{dump}{filename} |
420 |
dumps the \Domain into the file \var{filename}. |
writes the \Domain to the file \var{filename} using the \netCDF file format. |
421 |
\end{methoddesc} |
\end{methoddesc} |
422 |
|
% |
423 |
\begin{methoddesc}[Domain]{getX}{} |
\begin{methoddesc}[Domain]{getX}{} |
424 |
returns the locations in the \Domain. The \FunctionSpace of the returned |
returns the locations in the \Domain. The \FunctionSpace of the returned |
425 |
\Data object is chosen by the \Domain implementation. Typically it will be |
\Data object is chosen by the \Domain implementation. Typically it will be |
426 |
in the \Function. |
in the \Function. |
427 |
\end{methoddesc} |
\end{methoddesc} |
428 |
|
% |
429 |
\begin{methoddesc}[Domain]{setX}{newX} |
\begin{methoddesc}[Domain]{setX}{newX} |
430 |
assigns a new location to the \Domain. \var{newX} has to have \Shape $(d,)$ |
assigns new locations to the \Domain. \var{newX} has to have \Shape $(d,)$ |
431 |
where $d$ is the spatial dimension of the domain. Typically \var{newX} must be |
where $d$ is the spatial dimension of the domain. Typically \var{newX} |
432 |
in the \ContinuousFunction but the space actually to be used depends on the \Domain implementation. |
must be in the \ContinuousFunction but the space actually to be used |
433 |
|
depends on the \Domain implementation. |
434 |
\end{methoddesc} |
\end{methoddesc} |
435 |
|
% |
436 |
\begin{methoddesc}[Domain]{getNormal}{} |
\begin{methoddesc}[Domain]{getNormal}{} |
437 |
returns the surface normals on the boundary of the \Domain as \Data object. |
returns the surface normals on the boundary of the \Domain as a \Data object. |
438 |
\end{methoddesc} |
\end{methoddesc} |
439 |
|
% |
440 |
\begin{methoddesc}[Domain]{getSize}{} |
\begin{methoddesc}[Domain]{getSize}{} |
441 |
returns the local sample size, e.g. the element diameter, as \Data object. |
returns the local sample size, i.e. the element diameter, as a \Data object. |
442 |
\end{methoddesc} |
\end{methoddesc} |
443 |
|
% |
444 |
\begin{methoddesc}[Domain]{setTagMap}{tag_name, tag} |
\begin{methoddesc}[Domain]{setTagMap}{tag_name, tag} |
445 |
defines a mapping of the tag name \var{tag_name} to the \var{tag}. |
defines a mapping of the tag name \var{tag_name} to the \var{tag}. |
446 |
\end{methoddesc} |
\end{methoddesc} |
447 |
|
% |
448 |
\begin{methoddesc}[Domain]{getTag}{tag_name} |
\begin{methoddesc}[Domain]{getTag}{tag_name} |
449 |
returns the tag associated with the tag name \var{tag_name}. |
returns the tag associated with the tag name \var{tag_name}. |
450 |
\end{methoddesc} |
\end{methoddesc} |
451 |
|
% |
452 |
\begin{methoddesc}[Domain]{isValidTagName}{tag_name} |
\begin{methoddesc}[Domain]{isValidTagName}{tag_name} |
453 |
return \True if \var{tag_name} is a valid tag name. |
returns \True if \var{tag_name} is a valid tag name. |
454 |
\end{methoddesc} |
\end{methoddesc} |
455 |
|
% |
456 |
\begin{methoddesc}[Domain]{__eq__}{arg} |
\begin{methoddesc}[Domain]{__eq__}{arg} |
457 |
(python == operator) returns \True if the \Domain \var{arg} describes the same domain. Otherwise |
(\PYTHON \var{==} operator) returns \True if the \Domain \var{arg} |
458 |
\False is returned. |
describes the same domain, \False otherwise. |
459 |
\end{methoddesc} |
\end{methoddesc} |
460 |
|
% |
461 |
\begin{methoddesc}[Domain]{__ne__}{arg} |
\begin{methoddesc}[Domain]{__ne__}{arg} |
462 |
(python != operator) returns \True if the \Domain \var{arg} does not describe the same domain. |
(\PYTHON \var{!=} operator) returns \True if the \Domain \var{arg} does |
463 |
Otherwise \False is returned. |
not describe the same domain, \False otherwise. |
464 |
\end{methoddesc} |
\end{methoddesc} |
465 |
|
% |
466 |
\begin{methoddesc}[Domain]{__str__}{arg} |
\begin{methoddesc}[Domain]{__str__}{} |
467 |
(python str() function) returns string representation of the \Domain. |
(\PYTHON \var{str()} function) returns a string representation of the |
468 |
|
\Domain. |
469 |
\end{methoddesc} |
\end{methoddesc} |
470 |
|
% |
471 |
\begin{methoddesc}[Domain]{onMasterProcessor)}{} |
\begin{methoddesc}[Domain]{onMasterProcessor)}{} |
472 |
returns \True if the processor is the master processor within |
returns \True if the processor is the master processor within the \MPI |
473 |
the \MPI processor group used by the \Domain. This is the processor with rank 0. |
processor group used by the \Domain. This is the processor with rank 0. |
474 |
If \MPI support is not enabled the return value is always \True. |
If \MPI support is not enabled the return value is always \True. |
475 |
\end{methoddesc} |
\end{methoddesc} |
476 |
|
% |
477 |
\begin{methoddesc}[Domain]{getMPISize}{} |
\begin{methoddesc}[Domain]{getMPISize}{} |
478 |
returns the number of \MPI processors used for this \Domain. If \MPI support is not enabled |
returns the number of \MPI processors used for this \Domain. If \MPI |
479 |
1 is returned. |
support is not enabled 1 is returned. |
480 |
\end{methoddesc} |
\end{methoddesc} |
481 |
|
% |
482 |
\begin{methoddesc}[Domain]{getMPIRank}{} |
\begin{methoddesc}[Domain]{getMPIRank}{} |
483 |
returns the rank of the processor executing the statement |
returns the rank of the processor executing the statement within the |
484 |
within the \MPI processor group used by the \Domain. |
\MPI processor group used by the \Domain. If \MPI support is not enabled |
485 |
If \MPI support is not enabled 0 is returned. |
0 is returned. |
486 |
\end{methoddesc} |
\end{methoddesc} |
487 |
|
% |
488 |
\begin{methoddesc}[Domain]{MPIBarrier}{} |
\begin{methoddesc}[Domain]{MPIBarrier}{} |
489 |
executes barrier synchronization within |
executes barrier synchronization within the \MPI processor group used by |
490 |
the \MPI processor group used by the \Domain. |
the \Domain. If \MPI support is not enabled, this command does nothing. |
|
If \MPI support is not enabled, this command does nothing. |
|
491 |
\end{methoddesc} |
\end{methoddesc} |
492 |
|
|
493 |
\subsection{The \FunctionSpace class} |
\subsection{The \FunctionSpace class} |
494 |
\begin{classdesc}{FunctionSpace}{} |
\begin{classdesc}{FunctionSpace}{} |
495 |
\FunctionSpace objects are used to define properties of \Data objects, such as continuity. \FunctionSpace objects |
\FunctionSpace objects are used to define properties of \Data objects such as continuity. |
496 |
are instantiated by generator functions. A \Data object in a particular \FunctionSpace is |
\FunctionSpace objects are instantiated by generator functions. |
497 |
represented by its values at \DataSamplePoints which are defined by the type and the \Domain of the |
A \Data object in a particular \FunctionSpace is represented by its values at |
498 |
\FunctionSpace. |
\DataSamplePoints which are defined by the type and the \Domain of the \FunctionSpace. |
499 |
\end{classdesc} |
\end{classdesc} |
500 |
|
% |
501 |
The following methods are available: |
The following methods are available: |
502 |
|
% |
503 |
\begin{methoddesc}[FunctionSpace]{getDim}{} |
\begin{methoddesc}[FunctionSpace]{getDim}{} |
504 |
returns the spatial dimension of the \Domain of the \FunctionSpace. |
returns the spatial dimension of the \Domain of the \FunctionSpace. |
505 |
\end{methoddesc} |
\end{methoddesc} |
506 |
|
% |
|
|
|
|
|
|
507 |
\begin{methoddesc}[FunctionSpace]{getX}{} |
\begin{methoddesc}[FunctionSpace]{getX}{} |
508 |
returns the location of the \DataSamplePoints. |
returns the location of the \DataSamplePoints. |
509 |
\end{methoddesc} |
\end{methoddesc} |
510 |
|
% |
511 |
\begin{methoddesc}[FunctionSpace]{getNormal}{} |
\begin{methoddesc}[FunctionSpace]{getNormal}{} |
512 |
If the domain of functions in the \FunctionSpace |
If the domain of functions in the \FunctionSpace is a hyper-manifold (e.g. |
513 |
is a hyper-manifold (e.g. the boundary of a domain) |
the boundary of a domain) the method returns the outer normal at each of |
514 |
the method returns the outer normal at each of the |
the \DataSamplePoints. Otherwise an exception is raised. |
|
\DataSamplePoints. Otherwise an exception is raised. |
|
515 |
\end{methoddesc} |
\end{methoddesc} |
516 |
|
% |
517 |
\begin{methoddesc}[FunctionSpace]{getSize}{} |
\begin{methoddesc}[FunctionSpace]{getSize}{} |
518 |
returns a \Data objects measuring the spacing of the \DataSamplePoints. |
returns a \Data object measuring the spacing of the \DataSamplePoints. |
519 |
The size may be zero. |
The size may be zero. |
520 |
\end{methoddesc} |
\end{methoddesc} |
521 |
|
% |
522 |
\begin{methoddesc}[FunctionSpace]{getDomain}{} |
\begin{methoddesc}[FunctionSpace]{getDomain}{} |
523 |
returns the \Domain of the \FunctionSpace. |
returns the \Domain of the \FunctionSpace. |
524 |
\end{methoddesc} |
\end{methoddesc} |
525 |
|
% |
526 |
\begin{methoddesc}[FunctionSpace]{setTags}{new_tag, mask} |
\begin{methoddesc}[FunctionSpace]{setTags}{new_tag, mask} |
527 |
assigns a new tag \var{new_tag} to all data sample |
assigns a new tag \var{new_tag} to all data samples where \var{mask} is |
528 |
where \var{mask} is positive for a least one data point. |
positive for a least one data point. |
529 |
\var{mask} must be defined on the this \FunctionSpace. |
\var{mask} must be defined on this \FunctionSpace. |
530 |
Use the \var{setTagMap} to assign a tag name to \var{new_tag}. |
Use the \var{setTagMap} to assign a tag name to \var{new_tag}. |
531 |
\end{methoddesc} |
\end{methoddesc} |
532 |
|
% |
533 |
\begin{methoddesc}[FunctionSpace]{__eq__}{arg} |
\begin{methoddesc}[FunctionSpace]{__eq__}{arg} |
534 |
(python == operator) returns \True if the \Domain \var{arg} describes the same domain. Otherwise |
(\PYTHON \var{==} operator) returns \True if the \FunctionSpace \var{arg} |
535 |
\False is returned. |
describes the same function space, \False otherwise. |
536 |
\end{methoddesc} |
\end{methoddesc} |
537 |
|
% |
538 |
\begin{methoddesc}[FunctionSpace]{__ne__}{arg} |
\begin{methoddesc}[FunctionSpace]{__ne__}{arg} |
539 |
(python != operator) returns \True if the \Domain \var{arg} do not describe the same domain. |
(\PYTHON \var{!=} operator) returns \True if the \FunctionSpace \var{arg} |
540 |
Otherwise \False is returned. |
does not describe the same function space, \False otherwise. |
541 |
\end{methoddesc} |
\end{methoddesc} |
542 |
|
|
543 |
\begin{methoddesc}[Domain]{__str__}{g} |
\begin{methoddesc}[Domain]{__str__}{} |
544 |
(python str() function) returns string representation of the \Domain. |
(\PYTHON \var{str()} function) returns a string representation of the |
545 |
|
\FunctionSpace. |
546 |
\end{methoddesc} |
\end{methoddesc} |
547 |
|
% |
548 |
The following function provide generators for \FunctionSpace objects: |
The following functions provide generators for \FunctionSpace objects: |
549 |
|
% |
550 |
\begin{funcdesc}{Function}{domain} |
\begin{funcdesc}{Function}{domain} |
551 |
returns the \Function on the \Domain \var{domain}. \Data objects in this type of \Function |
returns the \Function on the \Domain \var{domain}. \Data objects in this |
552 |
are defined over the whole geometric region defined by \var{domain}. |
type of \Function are defined over the whole geometric region defined by |
553 |
|
\var{domain}. |
554 |
\end{funcdesc} |
\end{funcdesc} |
555 |
|
% |
556 |
\begin{funcdesc}{ContinuousFunction}{domain} |
\begin{funcdesc}{ContinuousFunction}{domain} |
557 |
returns the \ContinuousFunction on the \Domain domain. \Data objects in this type of \Function |
returns the \ContinuousFunction on the \Domain domain. \Data objects in |
558 |
are defined over the whole geometric region defined by \var{domain} and assumed to represent |
this type of \Function are defined over the whole geometric region defined |
559 |
a continuous function. |
by \var{domain} and assumed to represent a continuous function. |
560 |
\end{funcdesc} |
\end{funcdesc} |
561 |
|
% |
562 |
\begin{funcdesc}{FunctionOnBoundary}{domain} |
\begin{funcdesc}{FunctionOnBoundary}{domain} |
563 |
returns the \ContinuousFunction on the \Domain domain. \Data objects in this type of \Function |
returns the \FunctionOnBoundary on the \Domain domain. \Data objects in |
564 |
are defined on the boundary of the geometric region defined by \var{domain}. |
this type of \Function are defined on the boundary of the geometric region |
565 |
|
defined by \var{domain}. |
566 |
\end{funcdesc} |
\end{funcdesc} |
567 |
|
% |
568 |
\begin{funcdesc}{FunctionOnContactZero}{domain} |
\begin{funcdesc}{FunctionOnContactZero}{domain} |
569 |
returns the \FunctionOnContactZero the \Domain domain. \Data objects in this type of \Function |
returns the \FunctionOnContactZero the \Domain domain. \Data objects in |
570 |
are defined on side 0 of a discontinuity within the geometric region defined by \var{domain}. |
this type of \Function are defined on side 0 of a discontinuity within |
571 |
The discontinuity is defined when \var{domain} is instantiated. |
the geometric region defined by \var{domain}. |
572 |
|
The discontinuity is defined when \var{domain} is instantiated. |
573 |
\end{funcdesc} |
\end{funcdesc} |
574 |
|
% |
575 |
\begin{funcdesc}{FunctionOnContactOne}{domain} |
\begin{funcdesc}{FunctionOnContactOne}{domain} |
576 |
returns the \FunctionOnContactOne on the \Domain domain. |
returns the \FunctionOnContactOne on the \Domain domain. \Data objects in |
577 |
\Data objects in this type of \Function |
this type of \Function are defined on side 1 of a discontinuity within |
578 |
are defined on side 1 of a discontinuity within the geometric region defined by \var{domain}. |
the geometric region defined by \var{domain}. |
579 |
The discontinuity is defined when \var{domain} is instantiated. |
The discontinuity is defined when \var{domain} is instantiated. |
580 |
\end{funcdesc} |
\end{funcdesc} |
581 |
|
% |
582 |
\begin{funcdesc}{Solution}{domain} |
\begin{funcdesc}{Solution}{domain} |
583 |
returns the \SolutionFS on the \Domain domain. \Data objects in this type of \Function |
returns the \SolutionFS on the \Domain domain. \Data objects in this type |
584 |
are defined on geometric region defined by \var{domain} and are solutions of |
of \Function are defined on the geometric region defined by \var{domain} |
585 |
partial differential equations \index{partial differential equation}. |
and are solutions of partial differential equations\index{partial differential equation}. |
586 |
\end{funcdesc} |
\end{funcdesc} |
587 |
|
% |
588 |
\begin{funcdesc}{ReducedSolution}{domain} |
\begin{funcdesc}{ReducedSolution}{domain} |
589 |
returns the \ReducedSolutionFS on the \Domain domain. \Data objects in this type of \Function |
returns the \ReducedSolutionFS on the \Domain domain. \Data objects in |
590 |
are defined on geometric region defined by \var{domain} and are solutions of |
this type of \Function are defined on the geometric region defined by |
591 |
partial differential equations \index{partial differential equation} with a reduced smoothness |
\var{domain} and are solutions of partial differential |
592 |
for the solution approximation. |
equations\index{partial differential equation} with a reduced smoothness |
593 |
|
for the solution approximation. |
594 |
\end{funcdesc} |
\end{funcdesc} |
595 |
|
|
596 |
\subsection{The \Data Class} |
\subsection{The \Data Class} |
597 |
\label{SEC ESCRIPT DATA} |
\label{SEC ESCRIPT DATA} |
598 |
|
|
599 |
The following table shows arithmetic operations that can be performed point-wise on |
The following table shows arithmetic operations that can be performed |
600 |
\Data objects. |
point-wise on \Data objects: |
601 |
\begin{table} |
\begin{center} |
|
\centering |
|
602 |
\begin{tabular}{l|l} |
\begin{tabular}{l|l} |
603 |
\bfseries expression & Description\\ |
\textbf{Expression} & \textbf{Description}\\ |
604 |
\hline |
\hline |
605 |
+\var{arg0} & identical to \var{arg} \index{+}\\ |
\code{+arg} & identical to \var{arg}\index{+}\\ |
606 |
-\var{arg0} & negation\index{-}\\ |
\code{-arg} & negation of \var{arg}\index{-}\\ |
607 |
\var{arg0}+\var{arg1} & adds \var{arg0} and \var{arg1} \index{+}\\ |
\code{arg0+arg1} & adds \var{arg0} and \var{arg1}\index{+}\\ |
608 |
\var{arg0}*\var{arg1} & multiplies \var{arg0} and \var{arg1} \index{*}\\ |
\code{arg0*arg1} & multiplies \var{arg0} and \var{arg1}\index{*}\\ |
609 |
\var{arg0}-\var{arg1} & difference \var{arg1} from\var{arg1} \index{-}\\ |
\code{arg0-arg1} & subtracts \var{arg1} from \var{arg0}\index{-}\\ |
610 |
\var{arg0}/\var{arg1} & divide \var{arg0} by \var{arg1} \index{/}\\ |
\code{arg0/arg1} & divides \var{arg0} by \var{arg1}\index{/}\\ |
611 |
\var{arg0}**\var{arg1} & raises \var{arg0} to the power of \var{arg1} \index{**}\\ |
\code{arg0**arg1} & raises \var{arg0} to the power of \var{arg1}\index{**}\\ |
612 |
\end{tabular} |
\end{tabular} |
613 |
\end{table} |
\end{center} |
614 |
At least one of the arguments \var{arg0} or \var{arg1} must be a |
At least one of the arguments \var{arg0} or \var{arg1} must be a \Data object. |
615 |
\Data object. |
Either of the arguments may be a \Data object, a \PYTHON number or a \numpy |
616 |
Either of the arguments may be a \Data object, a python number or a \numpy object. |
object. |
617 |
|
If \var{arg0} or \var{arg1} are not defined on the same \FunctionSpace, then |
618 |
If \var{arg0} or \var{arg1} are |
an attempt is made to convert \var{arg0} to the \FunctionSpace of \var{arg1} |
619 |
not defined on the same \FunctionSpace, then an attempt is made to convert \var{arg0} |
or to convert \var{arg1} to the \FunctionSpace of \var{arg0}. |
620 |
to the \FunctionSpace of \var{arg1} or to convert \var{arg1} to |
Both arguments must have the same \Shape or one of the arguments may be of |
621 |
the \FunctionSpace of \var{arg0}. Both arguments must have the same |
rank 0 (a constant). |
|
\Shape or one of the arguments may be of rank 0 (a constant). |
|
|
|
|
622 |
The returned \Data object has the same \Shape and is defined on |
The returned \Data object has the same \Shape and is defined on |
623 |
the \DataSamplePoints as \var{arg0} or \var{arg1}. |
the \DataSamplePoints as \var{arg0} or \var{arg1}. |
624 |
|
|
625 |
The following table shows the update operations that can be applied to |
The following table shows the update operations that can be applied to |
626 |
\Data objects: |
\Data objects: |
627 |
\begin{table} |
\begin{center} |
|
\centering |
|
628 |
\begin{tabular}{l|l} |
\begin{tabular}{l|l} |
629 |
\bfseries Expression & Description\\ |
\textbf{Expression} & \textbf{Description}\\ |
630 |
\hline |
\hline |
631 |
\var{arg0}+=\var{arg2} & adds \var{arg0} to \var{arg2}\index{+}\\ |
\code{arg0+=arg1} & adds \var{arg1} to \var{arg0}\index{+}\\ |
632 |
\var{arg0}*=\var{arg2} & multiplies \var{arg0} with \var{arg2}\index{*}\\ |
\code{arg0*=arg1} & multiplies \var{arg0} by \var{arg1}\index{*}\\ |
633 |
\var{arg0}-=\var{arg2} & subtracts \var{arg2} from\var{arg2}\index{-}\\ |
\code{arg0-=arg1} & subtracts \var{arg1} from\var{arg0}\index{-}\\ |
634 |
\var{arg0}/=\var{arg2} & divides \var{arg0} by \var{arg2}\index{/}\\ |
\code{arg0/=arg1} & divides \var{arg0} by \var{arg1}\index{/}\\ |
635 |
\var{arg0}**=\var{arg2} & raises \var{arg0} by \var{arg2}\index{**}\\ |
\code{arg0**=arg1} & raises \var{arg0} to the power of \var{arg1}\index{**}\\ |
636 |
\end{tabular} |
\end{tabular} |
637 |
\end{table} |
\end{center} |
638 |
\var{arg0} must be a \Data object. \var{arg1} must be a |
\var{arg0} must be a \Data object. \var{arg1} must be a \Data object or an |
639 |
\Data object or an object that can be converted into a |
object that can be converted into a \Data object. |
640 |
\Data object. \var{arg1} must have the same \Shape as |
\var{arg1} must have the same \Shape as \var{arg0} or have rank 0. |
641 |
\var{arg0} or have rank 0. In the latter case it is |
In the latter case it is assumed that the values of \var{arg1} are constant |
642 |
assumed that the values of \var{arg1} are constant for all |
for all components. \var{arg1} must be defined in the same \FunctionSpace as |
|
components. \var{arg1} must be defined in the same \FunctionSpace as |
|
643 |
\var{arg0} or it must be possible to interpolate \var{arg1} onto the |
\var{arg0} or it must be possible to interpolate \var{arg1} onto the |
644 |
\FunctionSpace of \var{arg0}. |
\FunctionSpace of \var{arg0}. |
645 |
|
|
646 |
The \Data class supports taking slices from a \Data object as well as assigning new values to a slice of an existing |
The \Data class supports taking slices as well as assigning new values to a |
647 |
\Data object. \index{slicing} |
slice of an existing \Data object\index{slicing}. |
648 |
The following expressions for taking and setting slices are valid: |
The following expressions for taking and setting slices are valid: |
649 |
\begin{table} |
\begin{center} |
|
\centering |
|
650 |
\begin{tabular}{l|ll} |
\begin{tabular}{l|ll} |
651 |
\bfseries rank of \var{arg} & slicing expression & \Shape of returned and assigned object\\ |
\textbf{Rank of \var{arg}} & \textbf{Slicing expression} & \textbf{\Shape of returned and assigned object}\\ |
652 |
\hline |
\hline |
653 |
0 & no slicing & -\\ |
0 & no slicing & N/A\\ |
654 |
1 & \var{arg[l0:u0]} & (\var{u0}-\var{l0},)\\ |
1 & \var{arg[l0:u0]} & (\var{u0}-\var{l0},)\\ |
655 |
2 & \var{arg[l0:u0,l1:u1]} & (\var{u0}-\var{l0},\var{u1}-\var{l1})\\ |
2 & \var{arg[l0:u0,l1:u1]} & (\var{u0}-\var{l0},\var{u1}-\var{l1})\\ |
656 |
3 & \var{arg[l0:u0,l1:u1,l2:u2]} & (\var{u0}-\var{l0},\var{u1}-\var{l1},\var{u2}-\var{l2})\\ |
3 & \var{arg[l0:u0,l1:u1,l2:u2]} & (\var{u0}-\var{l0},\var{u1}-\var{l1},\var{u2}-\var{l2})\\ |
657 |
4 & \var{arg[l0:u0,l1:u1,l2:u2,l3:u3]} & (\var{u0}-\var{l0},\var{u1}-\var{l1},\var{u2}-\var{l2},\var{u3}-\var{l3})\\ |
4 & \var{arg[l0:u0,l1:u1,l2:u2,l3:u3]} & (\var{u0}-\var{l0},\var{u1}-\var{l1},\var{u2}-\var{l2},\var{u3}-\var{l3})\\ |
658 |
\end{tabular} |
\end{tabular} |
659 |
\end{table} |
\end{center} |
660 |
where \var{s} is the \Shape of \var{arg} and |
where \var{s} is the \Shape of \var{arg} and |
661 |
\[0 \le \var{l0} \le \var{u0} \le \var{s[0]},\] |
\[0 \le \var{l0} \le \var{u0} \le \var{s[0]},\] |
662 |
\[0 \le \var{l1} \le \var{u1} \le \var{s[1]},\] |
\[0 \le \var{l1} \le \var{u1} \le \var{s[1]},\] |