source: issm/trunk-jpl/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp@ 13216

Last change on this file since 13216 was 13216, checked in by Eric.Larour, 13 years ago

NEW: large change to the code, to adapt to ADOLC requirements.

This change relates to the introduction of template classes and functions for the
Option.h abstract class. This is needed, because we want to make the Matlab
API independent from the libCore objects, which are dependent on the IssmDouble*
ADOLC type (adouble), when the Matlab API is dependent on the IssmPDouble* type (double).

To make them independent, we need to be able to specify at run time Options, Matrix and
Vector objects that hold either IssmDouble or IssmPDouble objects. The only way to do
that is through the use of templated classes for Option.h, Matrix and Vector.

The change gets rid of a lot of useless code (especially in the classes/objects/Options
directory), by introducing template versions of the same code.

The bulk of the changes to src/modules and src/mex modules is to adapt to this
new runtime declaration of templated Matrix, Vector and Option objects.

File size: 1.4 KB
Line 
1/*!\file Reducevectorgtosx
2 * \brief reduce petsc vector from g set to s set (single point constraints), using the nodeset partitioning
3 * vectors.
4 */
5
6#include "./Reducevectorgtosx.h"
7
8void Reducevectorgtosx(Vector<IssmDouble>** pys, Vector<IssmDouble>* yg, Nodes* nodes,Parameters* parameters){
9
10 /*output: */
11 Vector<IssmDouble>* ys=NULL;
12
13 /*variables: */
14 int i;
15 int configuration_type;
16 int ssize;
17 double* yg_serial=NULL;
18
19 /*first figure out ssize: */
20 parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
21 ssize=nodes->NumberOfDofs(configuration_type,SsetEnum);
22
23 if(ssize==0){
24 ys=NULL;
25 }
26 else{
27 /*allocate: */
28 ys=new Vector<IssmDouble>(ssize);
29
30 if(nodes->NumberOfNodes(configuration_type)){
31
32 /*serialize yg, so nodes can index into it: */
33 yg_serial=yg->ToMPISerial();
34
35 /*Go throygh all nodes, and ask them to retrieve values from yg, and plyg them into ys: */
36 for(i=0;i<nodes->Size();i++){
37
38 Node* node=(Node*)nodes->GetObjectByOffset(i);
39
40 /*Check that this node corresponds to our analysis currently being carried out: */
41 if (node->InAnalysis(configuration_type)){
42
43 /*For this object, reduce values for enum set Fset: */
44 node->VecReduce(ys,yg_serial,SsetEnum);
45 }
46 }
47 }
48 /*Assemble vector: */
49 ys->Assemble();
50 }
51
52 /*Free ressources:*/
53 xDelete<double>(yg_serial);
54
55 /*Assign output pointers:*/
56 *pys=ys;
57}
Note: See TracBrowser for help on using the repository browser.