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

Last change on this file since 12450 was 12450, checked in by Mathieu Morlighem, 13 years ago

changing xmalloc to xNew and xfree to xDelete

File size: 1.3 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** pys, Vector* yg, Nodes* nodes,Parameters* parameters){
9
10 /*output: */
11 Vector* 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(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.