% File: ~/OOP/analysis/model/AnalysisModel.tex 
%What: "@(#) AnalysisModel.tex, revA"

MODIFY INTERFACE TO OFFER USER DEFINED STORAGE TYPE. \\

\noindent {\bf Files}   \\
\indent \#include $<$/analysis/model/AnalysisModel.h$>$  \\

\noindent {\bf Class Declaration}  \\
\indent class AnalysisModel : public MovableObject  \\

\noindent {\bf Class Hierarchy} \\
\indent MovableObject \\
\indent\indent {\bf SolutionAlgorithm} \\

\noindent {\bf Description}  \\
\indent AnalysisModel is a container class. This class is responsible
for holding and providing access to the FE\_Element and DOF\_Group
objects that the ConstraintHandler creates. It is also responsible
for updating the response quantities at the DOF\_Groups and for
triggering methods in the associated Domain. It provides operations
for the following: \begin{itemize} 
\item Population: methods so that the ConstraintHandler can add the
FE\_Element and DOF\_Group objects to the analysis model. 
\item Access: methods so that other classes in the analysis aggregation
can access the components of the AnalysisModel. 
\item Connectivity: methods such that the SysOfEqn can determine the
connectivity of the dof, which is needed for storage, sparsity, etc.
\item Update: methods for updating the individual DOFs with the
response quantities given by the AnalysisMethod.
\item Trigger: methods which trigger events in the domain.
\end{itemize} 
Each subclass of AnalysisModel must have its own subclasses
of FE\_ELEIter and DOF\_GrpIter. NOTE at the moment FE\_Element and
DOF\_Group objects are not TaggedObjects and for this reason
TaggedObjectStorage classes cannot be used for storage. This may
change to allow efficient storage classes to be used.\\

\noindent {\bf Class Interface}  \\
\indent // Constructors \\
\indent {\em AnalysisModel();}  \\
\indent {\em AnalysisModel(int classTag);}  \\ \\
\indent // Destructor  \\
\indent {\em virtual $\tilde{ }$AnalysisModel();}  \\\\
\indent // Public Methods - Population/Depopulation  \\
\indent {\em virtual bool addFE\_Element(FE\_Element *theElementPtr);}  \\
\indent {\em virtual bool addDOF\_Group(DOF\_Group *theDOFPtr);}  \\
\indent {\em virtual void clearAll(void);} \\ \\
\indent // Public Member Functions - Access  \\
\indent {\em virtual int getNumDOF\_Groups(void) const;}\\
\indent {\em virtual DOF\_Group *getDOF\_GroupPtr(int tag);}\\
\indent {\em virtual FE\_EleIter getFEs(void)=0;} \\
\indent {\em virtual DOF\_Group getDOFs(void)=0;} \\ \\
\indent // Public Member Functions - Connectivity  \\
\indent {\em virtual void setNumEqn(int numEqn);} \\
\indent {\em virtual int getNumEqn(void) const;} \\
\indent {\em virtual const Graph \&getDOFGraph(void);} \\
\indent {\em virtual const Graph \&getDOFGroupGraph(void);} \\ \\
\indent // Public Member Functions - Update  \\
\indent {\em virtual void setResponse(const const Vector \&disp, const
const Vector \&vel, const const Vector \&accel);}\\ 
\indent {\em virtual void setDisp(const const Vector \&disp);} \\
\indent {\em virtual void setVel(const const Vector \&vel);} \\
\indent {\em virtual void setAccel(const const Vector \&accel);} \\
\indent {\em virtual void incrDisp(const const Vector \&disp);} \\
\indent {\em virtual void incrVel(const const Vector \&vel);} \\
\indent {\em virtual void incrAccel(const const Vector \&accel);} \\\\
\indent // Public Member Functions - Trigger  \\
\indent {\em void setLinks(Domain \&theDomain)} \\
\indent {\em virtual void applyLoadDomain(double timeStep = 0.0,
double loadFactor = 1.0);}\\
\indent {\em virtual void commitDomain(void);} \\
\indent {\em virtual void updateDomain(void);}\\ \\
\indent {\em virtual void revertDomainToLastCommit(void);}\\ 
\indent {\em virtual double getCurrentDomainTime(void);} \\
\indent {\em virtual void   setCurrentDomainTime(double newTime);}\\
\indent {\em virtual double getCurrentDomainLoadFactor(void);}\\
\indent {\em virtual void   setCurrentDomainLoadFactor(double
newFactor);}\\ \\
\indent // Public Methods for Output\\
\indent {\em virtual int sendSelf(int commitTag, Channel \&theChannel);}\\ 
\indent {\em virtual int recvSelf(int commitTag, Channel \&theChannel,
FEM\_ObjectBroker \&theBroker);}\\  \\
\indent // Protected Member Functions  \\
\indent {\em Domain *getDomainPtr(void) const;} \\



\noindent {\bf Constructors}  \\
\indent {\em AnalysisModel();}  \\
Constructs an empty AnalysisModel. The constructor allocates
space for two arrays of 256 pointers to FE\_Elements and DOF\_Groups.
If not enough memory is available for these arrays, an error message
is printed and the program is terminated. Note these arrays grow
automatically if the problem needs it.\\

\indent {\em AnalysisModel(int classTag);}  \\
Provided for subclasses to be used. The storage of the FE\_Elements
and DOF\_Groups and iters to access them must be provided by the
subclass. \\

\noindent {\bf Destructor}  \\
\indent {\em virtual~ $\tilde{}$AnalysisModel();}  \\
Is responsible for returning to memory the arrays used for storing
pointers to the FE\_Element and DOF\_Groups which have been added to
the AnalysisModel. It is not responsible for deleting the individual
DOF\_Group and FE\_Element objects, that is the responsibility of the
ConstraintHandler. If the Graphs have been requested their destructor
is invoked.\\ 

\noindent {\bf Public Member Functions - Population/Depopulation}  \\
\indent {\em virtual bool addFE\_Element(FE\_Element *theElement);}  \\
Adds the FE\_Element pointed to by {\em theElement} to the domain and
invokes {\em setAnalysisModel(*this)} on the FE\_Element. If the
array for the FE\_Elements is large enough, it adds this pointer to
the array and increments the number of FE\_Elements in the array. If
the array is not large enough, a new one double in size is
constructed, all the old pointers are copied to this new array and the
new pointer is then added. If not enough room is available for this
array, an error message is printed and the program is
terminated. Returns {\em true}, otherwise {\em false} if {\em
theElement} is $0$ or derived class used which does not implement the
method. \\ 

{\em virtual bool addDOF\_Group(DOF\_Group *theGroup);}  \\
Adds the DOF\_Group pointed to by {\em theGroup} to the domain. If the
array for the DOF\_Groups is large enough, it adds this pointer to
the array and increments the number of DOF\_Groups in the array. If
the array is not large enough, a new one double in size is
constructed, all the old pointers are copied to this new array and the
new pointer is then added. If not enough room is available for this
array, an error message is printed and the program is
terminated. Returns {\em true}, otherwise {\em false} if {\em
theGroup} is $0$ or derived class used which does not implement the
method. \\ 



{\em virtual void clearAll(void);} \\
Clears from the model all FE\_Element and DOF\_Group objects that have
been added to the analysis model using the above two methods. It does
this by setting the components in the two arrays of pointers equal to
$0$ and setting the number of components to $0$. If the Graphs have
been created their destructor is invoked. Also sets {\em numEqn} to $0$. \\

\noindent {\bf Public Member Functions - Access}  \\
\indent {\em virtual int getNumDOF\_Groups(void) const;}\\
Returns the number of DOF\_Group objects that have been added to the
model.\\

\indent {\em virtual DOF\_Group *getDOF\_GroupPtr(int tag);}\\
Returns a pointer to the DOF\_Group object whose tag is given by {\em
tag}.  It first checks to see if the DOF\_Group object is at the
location in the array given by {\em tag}; if not it searches through
the array to find the DOF\_Group object. Returns a pointer to the
object if found, otherwise $0$ is returned.\\

\indent {\em virtual FE\_EleIter getFEs(void)=0;} \\
Returns an {\em FE\_EleIter} for the FE\_Elements of the model. \\

{\em virtual DOF\_Group getDOFs(void)=0;} \\
Returns a {\em DOF\_GrpIter} for the DOF\_Groups of the model. \\

\noindent {\bf Public Member Functions - Connectivity}  \\
\indent {\em virtual void setNumEqn(int numEqn);} \\
Sets the value of the number of equations in the model. Invoked by the
DOF\_Numberer when it is numbering the dofs. \\

\indent {\em virtual int getNumEqn(void) const;} \\
Returns the number of DOFs in the model which have been assigned
an equation number. Returns the value passed in {\em setNumEqn()},
if {\em setNumEqn()} was not invoked $0$ is returned.\\

{\em virtual const Graph \&getDOFGraph(void);} \\
Returns the DOF connectivity graph for the individual dofs in the
model. This graph is used by the system of equation object to
determine its size. If no graph has yet been constructed it creates
a new DOF\_Graph object using itself as the argument, otherwise it
returns a pointer to this graph. THIS WILL CHANGE WHEN I REMOVE
DOF\_Graph CLASS - will go through and construct the Graph.\\

{\em virtual const Graph \&getDOFGroupGraph(void);} \\
Returns the connectivity of the DOF\_Group objects in the model. 
This graph is used by the DOF\_Numberer to assign equation numbers to
the dofs. If no graph has yet been constructed it creates
a new DOF\_GroupGraph object using itself as the argument, otherwise it
returns a pointer to this graph. AGAIN WILL CHANGE.\\

\noindent {\bf Public Member Functions - Update}  \\
\indent {\em virtual void setResponse(const const Vector \&disp, const
const Vector \&vel, const const Vector \&accel);}\\ 
The model is responsible for invoking {\em setDisp(disp)}, {\em
setVel(vel)} and {\em setAccel(accel)} on each DOF\_Group in the
model. It does this by iterating over the DOF\_Group objects using the
iter. \\

{\em virtual void setDisp(const const Vector \&disp);} \\
The model is responsible for invoking {\em setDisp(disp)} on each
DOF\_Group in the model. It does this by getting an iter to the
DOF\_Group objects and iterating through them invoking {\em
setNodeDisp(disp)} on each DOF\_Group. \\

{\em virtual void setVel(const const Vector \&vel);} \\
The model is responsible for invoking {\em setVel(vel)} on each
DOF\_Group in the model. It does this by getting an iter to the
DOF\_Group objects and iterating through them invoking {\em
setNodeVel(vel)} on each DOF\_Group. \\


{\em virtual void setAccel(const const Vector \&accel);} \\
The model is responsible for invoking {\em setAccel(accel)} on each
DOF\_Group in the model. It does this by getting an iter to the
DOF\_Group objects and iterating through them invoking {\em
setNodeAccel(accel)} on each DOF\_Group. \\

{\em virtual void incrDisp(const const Vector \&disp);} \\
The model is responsible for invoking {\em incrNodeDisp(disp)} on each
DOF\_Group in the model. It does this by getting an iter to the
DOF\_Group objects and iterating through them invoking {\em
incrNodeDisp(disp)} on each DOF\_Group. \\


{\em virtual void incrVel(const const Vector \&vel);} \\
The model is responsible for invoking {\em incrNodeVel(vel)} on each
DOF\_Group in the model. It does this by getting an iter to the
DOF\_Group objects and iterating through them invoking {\em
incrNodeVel(vel)} on each DOF\_Group. \\


{\em virtual void incrAccel(const const Vector \&accel);} \\
The model is responsible for invoking {\em incrNodeAccel(accel)} on each
DOF\_Group in the model. It does this by getting an iter to the
DOF\_Group objects and iterating through them invoking {\em
incrNodeAccel(accel)} on each DOF\_Group. \\



\noindent {\bf Public Member Functions - Trigger}  \\
\indent {\em void setLinks(Domain \&theDomain)} \\
Method to set the link to the associated Domain. Invoked by
during the construction of the {\em Analysis} object.\\

{\em virtual void applyLoadDomain(double timeStep = 0.0, double
loadFactor = 1.0);}\\
Method which invokes {\em applyLoad(timeStep, loadFactor)} on the
domain. This method causes the domain ask the loads in the currently
set to apply themselves. If no Domain has been set nothing is done and an error
message is printed. \\ 


{\em virtual int commitDomain(void);} \\
Method which invokes {\em commit()} on the domain: this is an
operation which causes all nodes in the domain to take the current
values of response quantities and copy them into the accepted values. 
Returns $0$ if successful , a negative number if not: $-1$ if no
Domain has been set and $-2$ if {\em commit()} fails on the Domain.\\

{\em virtual int revertDomainToLastCommit(void);} \\
Method which invokes {\em revertToLastCommit()} on the domain: this is an
operation which causes all nodes in the domain to set the trial
response quantities equal to the last committed response quantities.
Returns $0$ if successful , a negative number if not: $-1$ if no
Domain has been set and $-2$ if {\em revertToLastCommit}() fails on
the Domain.\\ 

{\em virtual void updateDomain(void);}\\
Method which invokes {\em update()} on the domain. If no Domain has
been set nothing is done and an error message is printed. \\ 

\indent {\em virtual double getCurrentDomainTime(void);} \\
To get the current time in the Domain. If no Domain has been set a
warning message is printed and $0.0$ is returned, otherwise the result
of invoking {\em getCurrentTime()} on the Domain is returned. \\

\indent {\em virtual void   setCurrentDomainTime(double newTime);}\\
To set the current time in the Domain to be {\em newTime}. If no
Domain has been set a warning message is printed, otherwise 
{\em setCurrentTime(newTime)} is invoked on the Domain. \\

\indent {\em virtual double getCurrentDomainLoadFactor(void);}\\
To get the current load factor in the Domain. If no Domain has been set a
warning message is printed and $0.0$ is returned, otherwise the result
of invoking {\em getCurrentLoadFactor()} on the Domain is returned. \\

\indent {\em virtual void setCurrentDomainLoadFactor(double newFactor)};\\
To set the current load factor in the Domain to be {\em newFactor}. If no
Domain has been set a warning message is printed, otherwise 
{\em setCurrentLoadFactor(newFactor)} is invoked on the Domain. \\

\indent {\em virtual int sendSelf(int commitTag, Channel
\&theChannel);}\\ 
Returns $0$. Note the FE\_Elements and DOF\_Group objects are not sent
as they are not MovableObjects. AnalysisModel objects are only sent
when setting up a DomainDecompAnalysis on a remote process; only type
info and whatever subclasses might need need to be sent.\\

\indent\indent {\em virtual int recvSelf(int commitTag, Channel \&theChannel,
FEM\_ObjectBroker \&theBroker)};\\
Returns $0$.  \\

\noindent {\bf Protected Member Functions}  \\
\indent {\em Domain *getDomainPtr(void) const;} \\
Returns a pointer to the associated Domain, that is the Domain
set when {\em setLinks()} was last invoked. 


