1 #include "hxt_linear_system.h"
2 #include "hxt_tools.h"
3 #include "hxt_class_macro.h"
4
5 #define HXTLinearSystem_MEMBERS(operation, opdata) \
6 operation(opdata,AddToMatrix,int,int,const double*,);\
7 operation(opdata,AddMatrixEntry,int,int,int,int, double,);\
8 operation(opdata,AddToRhs,double*,int,const double*,);\
9 operation(opdata,ZeroMatrix,);\
10 operation(opdata,Size,int*,);\
11 operation(opdata,Solve,double*,double*,);\
12 operation(opdata,SetMatrixRowIdentity,int,int,);\
13 operation(opdata,SetMatrixRowFieldCombinaison,int,int,double*,);\
14 operation(opdata,SetRhsEntry,double*,int,int,double,);\
15 operation(opdata,AddRhsEntry,double*,int,int,double,);\
16 operation(opdata,HasConverged,int*,);\
17 operation(opdata,GetRhsNorm,double*,double*,);
18
19 HXT_DECLARE_INTERFACE(LinearSystem)
20
21 #include "hxt_linear_system_lu.h"
HXT_DECLARE_DERIVED_CLASS(LinearSystem,LinearSystemLU)22 HXT_DECLARE_DERIVED_CLASS(LinearSystem, LinearSystemLU)
23
24 #ifdef HXT_HAVE_PETSC
25 #include "hxt_linear_system_petsc.h"
26 HXT_DECLARE_DERIVED_CLASS(LinearSystem, LinearSystemPETSc)
27 #endif
28
29 HXTStatus hxtInitializeLinearSystems(int *argc, char ***argv) {
30 #ifndef HXT_HAVE_PETSC
31 HXT_UNUSED(argc);
32 HXT_UNUSED(argv);
33 #endif
34
35 HXT_CHECK(hxtLinearSystemLURegister());
36 #ifdef HXT_HAVE_PETSC
37 HXT_CHECK(hxtInitializePETSc(argc, argv));
38 HXT_CHECK(hxtLinearSystemPETScRegister());
39 #endif
40 return HXT_STATUS_OK;
41 }
42
hxtLinearSystemCreateLU(HXTLinearSystem ** sys,int nElement,int nNodesByElement,int nFields,uint32_t * elements)43 HXTStatus hxtLinearSystemCreateLU(HXTLinearSystem **sys, int nElement, int nNodesByElement, int nFields, uint32_t *elements) {
44 if(hxtLinearSystemLUClass==NULL)
45 HXT_ERROR_MSG(HXT_STATUS_FAILED,"linear system lu class not registred");
46 HXTLinearSystemLU *syslu;
47 HXT_CHECK(hxtLinearSystemLUCreate(&syslu, nElement, nNodesByElement, nFields, elements));
48 HXT_CHECK(hxtLinearSystemCreate(sys, hxtLinearSystemLUClass, syslu));
49 return HXT_STATUS_OK;
50 };
51
52 #ifdef HXT_HAVE_PETSC
hxtLinearSystemCreatePETSc(HXTLinearSystem ** sys,int nElement,int nNodesByElement,int nFields,uint32_t * elements,const char * petscOptions)53 HXTStatus hxtLinearSystemCreatePETSc(HXTLinearSystem **sys, int nElement, int nNodesByElement, int nFields, uint32_t *elements, const char *petscOptions) {
54 if(hxtLinearSystemPETScClass==NULL)
55 HXT_ERROR_MSG(HXT_STATUS_FAILED,"linear system petsc class not registred");
56 HXTLinearSystemPETSc *syspetsc;
57 HXT_CHECK(hxtLinearSystemPETScCreate(&syspetsc, nElement, nNodesByElement, nFields, elements, petscOptions));
58 HXT_CHECK(hxtLinearSystemCreate(sys, hxtLinearSystemPETScClass, syspetsc));
59 return HXT_STATUS_OK;
60 };
61
62 #endif
63
64
65