| 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 |
|
|---|
| 8 | void 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 | IssmDouble* 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<IssmDouble>(yg_serial);
|
|---|
| 54 |
|
|---|
| 55 | /*Assign output pointers:*/
|
|---|
| 56 | *pys=ys;
|
|---|
| 57 | }
|
|---|