Ice Sheet System Model  4.18
Code documentation
Functions
mumpsincludes.h File Reference
#include "../../shared/Numerics/types.h"

Go to the source code of this file.

Functions

void SeqDenseMumpsSolve (IssmDouble *uf, int uf_M, int uf_n, IssmDouble *Kff, int Kff_M, int Kff_N, int Kff_m, IssmDouble *pf, int pf_M, int pf_m, Parameters *parameters)
 

Function Documentation

◆ SeqDenseMumpsSolve()

void SeqDenseMumpsSolve ( IssmDouble uf,
int  uf_M,
int  uf_n,
IssmDouble Kff,
int  Kff_M,
int  Kff_N,
int  Kff_m,
IssmDouble pf,
int  pf_M,
int  pf_m,
Parameters parameters 
)

Definition at line 296 of file MumpsSolve.cpp.

296  {/*{{{*/
297 
298  /*Variables*/
299  int *irn_loc = NULL;
300  int *jcn_loc = NULL;
301  IssmDouble *a_loc = NULL;
302  IssmDouble *rhs = NULL;
303 
304  /*First, some checks*/
305  if (Kff_M!=Kff_N)_error_("stiffness matrix Kff should be square");
306  if (Kff_M!=Kff_m)_error_("stiffness matrix Kff is not serial");
307  if (uf_M!=Kff_M || uf_M!=pf_M)_error_("solution vector should be the same size as stiffness matrix Kff and load vector pf");
308  if (uf_m!=Kff_m || uf_m!=pf_m)_error_("solution vector should be locally the same size as stiffness matrix Kff and load vector pf");
309 
310  /*Initialize matrix */
311  /*figure out number of non-zero entries: */
312  int nnz = 0;
313  for(int i=0;i<Kff_M;i++){
314  for(int j=0;j<Kff_N;j++){
315  if(Kff[i*Kff_N+j]!=0)nnz++;
316  }
317  }
318 
319  /*Allocate: */
320  if(nnz){
321  irn_loc = xNew<int>(nnz);
322  jcn_loc = xNew<int>(nnz);
323  a_loc = xNew<IssmDouble>(nnz);
324  }
325 
326  /*Populate the triplets: */
327  int count=0;
328  for(int i=0;i<Kff_M;i++){
329  for(int j=0;j<Kff_N;j++){
330  if(Kff[i*Kff_N+j]!=0){
331  irn_loc[count] = i+1; //fortran indexing
332  jcn_loc[count] = j+1; //fortran indexing
333  a_loc[count] = Kff[i*Kff_N+j];
334  count++;
335  }
336  }
337  }
338 
339  /*Deal with right hand side. We need to ISSM_MPI_Gather it onto cpu 0: */
340 // AD performance is sensitive to calls to ensurecontiguous.
341 // Providing "t" will cause ensurecontiguous to be called.
342 #ifdef _HAVE_AD_
343  rhs=xNew<IssmDouble>(pf_M,"t");
344 #else
345  rhs=xNew<IssmDouble>(pf_M);
346 #endif
347  xMemCpy<IssmDouble>(rhs,pf,Kff_M);
348 
349  MumpsSolve(Kff_M,nnz,nnz,irn_loc,jcn_loc,a_loc,rhs,parameters);
350 
351  /*Now scatter from cpu 0 to all other cpus*/
352  xMemCpy<IssmDouble>(uf,rhs,Kff_M);
353 
354  /*Cleanup*/
355  xDelete<int>(irn_loc);
356  xDelete<int>(jcn_loc);
357  xDelete<IssmDouble>(a_loc);
358  xDelete<IssmDouble>(rhs);
359 }/*}}}*/
IssmDouble
double IssmDouble
Definition: types.h:37
MumpsSolve
void MumpsSolve(int n, int nnz, int local_nnz, int *irn_loc, int *jcn_loc, IssmPDouble *a_loc, IssmPDouble *rhs, Parameters *parameters=0)
Definition: MumpsSolve.cpp:82
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49