File: | snes/utils/dmadapt.c |
Warning: | line 656, column 7 Value stored to 'qc' is never read |
[?] Use j/k keys for keyboard navigation
1 | #include <petscdmadaptor.h> /*I "petscdmadaptor.h" I*/ |
2 | #include <petscdmplex.h> |
3 | #include <petscdmforest.h> |
4 | #include <petscds.h> |
5 | #include <petscblaslapack.h> |
6 | |
7 | #include <petsc/private/dmadaptorimpl.h> |
8 | #include <petsc/private/dmpleximpl.h> |
9 | #include <petsc/private/petscfeimpl.h> |
10 | |
11 | static PetscErrorCode DMAdaptorSimpleErrorIndicator_Private(DMAdaptor, PetscInt, PetscInt, const PetscScalar *, const PetscScalar *, const PetscFVCellGeom *, PetscReal *, void *); |
12 | |
13 | static PetscErrorCode DMAdaptorTransferSolution_Exact_Private(DMAdaptor adaptor, DM dm, Vec u, DM adm, Vec au, void *ctx) |
14 | { |
15 | PetscErrorCode ierr; |
16 | |
17 | PetscFunctionBeginUserdo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 17; petscstack->petscroutine [petscstack->currentsize] = PETSC_FALSE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
18 | ierr = DMProjectFunction(adm, 0.0, adaptor->exactSol, (void **) ctx, INSERT_ALL_VALUES, au);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),18,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
19 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
20 | } |
21 | |
22 | /*@ |
23 | DMAdaptorCreate - Create a DMAdaptor object. Its purpose is to construct a adaptation DMLabel or metric Vec that can be used to modify the DM. |
24 | |
25 | Collective on MPI_Comm |
26 | |
27 | Input Parameter: |
28 | . comm - The communicator for the DMAdaptor object |
29 | |
30 | Output Parameter: |
31 | . adaptor - The DMAdaptor object |
32 | |
33 | Level: beginner |
34 | |
35 | .keywords: DMAdaptor, convergence, create |
36 | .seealso: DMAdaptorDestroy(), DMAdaptorAdapt() |
37 | @*/ |
38 | PetscErrorCode DMAdaptorCreate(MPI_Comm comm, DMAdaptor *adaptor) |
39 | { |
40 | VecTaggerBox refineBox, coarsenBox; |
41 | PetscErrorCode ierr; |
42 | |
43 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 43; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
44 | PetscValidPointer(adaptor, 2)do { if (!adaptor) return PetscError(((MPI_Comm)0x44000001),44 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(adaptor,PETSC_CHAR)) return PetscError(( (MPI_Comm)0x44000001),44,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); |
45 | ierr = PetscSysInitializePackage();CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),45,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
46 | ierr = PetscHeaderCreate(*adaptor, DM_CLASSID, "DMAdaptor", "DM Adaptor", "SNES", comm, DMAdaptorDestroy, DMAdaptorView)(PetscMallocA(1,PETSC_TRUE,46,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,(size_t)(1)*sizeof(**((&(*adaptor)))),((&(*adaptor)) )) || PetscHeaderCreate_Private((PetscObject)*adaptor,DM_CLASSID ,"DMAdaptor","DM Adaptor","SNES",comm,(PetscObjectDestroyFunction )DMAdaptorDestroy,(PetscObjectViewFunction)DMAdaptorView) || ( (PetscLogPHC) ? (*PetscLogPHC)((PetscObject)(*adaptor)) : 0) || PetscLogObjectMemory((PetscObject)*adaptor,sizeof(*(*adaptor ))));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),46,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
47 | |
48 | (*adaptor)->monitor = PETSC_FALSE; |
49 | (*adaptor)->adaptCriterion = DM_ADAPTATION_NONE; |
50 | (*adaptor)->numSeq = 1; |
51 | (*adaptor)->Nadapt = -1; |
52 | (*adaptor)->refinementFactor = 2.0; |
53 | (*adaptor)->h_min = 1.; |
54 | (*adaptor)->h_max = 10000.; |
55 | (*adaptor)->ops->computeerrorindicator = DMAdaptorSimpleErrorIndicator_Private; |
56 | refineBox.min = refineBox.max = PETSC_MAX_REAL1.7976931348623157e+308; |
57 | ierr = VecTaggerCreate(PetscObjectComm((PetscObject) *adaptor), &(*adaptor)->refineTag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),57,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
58 | ierr = PetscObjectSetOptionsPrefix((PetscObject) (*adaptor)->refineTag, "refine_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),58,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
59 | ierr = VecTaggerSetType((*adaptor)->refineTag, VECTAGGERABSOLUTE"absolute");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),59,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
60 | ierr = VecTaggerAbsoluteSetBox((*adaptor)->refineTag, &refineBox);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),60,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
61 | coarsenBox.min = coarsenBox.max = PETSC_MAX_REAL1.7976931348623157e+308; |
62 | ierr = VecTaggerCreate(PetscObjectComm((PetscObject) *adaptor), &(*adaptor)->coarsenTag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),62,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
63 | ierr = PetscObjectSetOptionsPrefix((PetscObject) (*adaptor)->coarsenTag, "coarsen_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),63,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
64 | ierr = VecTaggerSetType((*adaptor)->coarsenTag, VECTAGGERABSOLUTE"absolute");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),64,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
65 | ierr = VecTaggerAbsoluteSetBox((*adaptor)->coarsenTag, &coarsenBox);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),65,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
66 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
67 | } |
68 | |
69 | /*@ |
70 | DMAdaptorDestroy - Destroys a DMAdaptor object |
71 | |
72 | Collective on DMAdaptor |
73 | |
74 | Input Parameter: |
75 | . adaptor - The DMAdaptor object |
76 | |
77 | Level: beginner |
78 | |
79 | .keywords: DMAdaptor, convergence, destroy |
80 | .seealso: DMAdaptorCreate(), DMAdaptorAdapt() |
81 | @*/ |
82 | PetscErrorCode DMAdaptorDestroy(DMAdaptor *adaptor) |
83 | { |
84 | PetscErrorCode ierr; |
85 | |
86 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 86; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
87 | if (!*adaptor) PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
88 | PetscValidHeaderSpecific((*adaptor), DM_CLASSID, 1)do { if (!(*adaptor)) return PetscError(((MPI_Comm)0x44000001 ),88,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer((*adaptor),PETSC_OBJECT)) return PetscError (((MPI_Comm)0x44000001),88,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)((*adaptor)))->classid != DM_CLASSID ) { if (((PetscObject)((*adaptor)))->classid == -1) return PetscError(((MPI_Comm)0x44000001),88,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),88,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c",62, PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1) ; } } while (0); |
89 | if (--((PetscObject)(*adaptor))->refct > 0) { |
90 | *adaptor = NULL((void*)0); |
91 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
92 | } |
93 | ierr = VecTaggerDestroy(&(*adaptor)->refineTag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),93,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
94 | ierr = VecTaggerDestroy(&(*adaptor)->coarsenTag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),94,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
95 | ierr = PetscFree((*adaptor)->exactSol)((*PetscTrFree)((void*)((*adaptor)->exactSol),95,__func__, "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c") || ( ((*adaptor)->exactSol) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),95,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
96 | ierr = PetscHeaderDestroy(adaptor)(PetscHeaderDestroy_Private((PetscObject)(*adaptor)) || ((*PetscTrFree )((void*)(*adaptor),96,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ) || ((*adaptor) = 0,0)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),96,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
97 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
98 | } |
99 | |
100 | /*@ |
101 | DMAdaptorSetFromOptions - Sets a DMAdaptor object from options |
102 | |
103 | Collective on DMAdaptor |
104 | |
105 | Input Parameters: |
106 | . adaptor - The DMAdaptor object |
107 | |
108 | Options Database Keys: |
109 | + -adaptor_monitor <bool> : Monitor the adaptation process |
110 | . -adaptor_sequence_num <num> : Number of adaptations to generate an optimal grid |
111 | . -adaptor_target_num <num> : Set the target number of vertices N_adapt, -1 for automatic determination |
112 | . -adaptor_refinement_factor <r> : Set r such that N_adapt = r^dim N_orig |
113 | . -adaptor_metric_h_min <min> : Set the minimum eigenvalue of Hessian (sqr max edge length) |
114 | - -adaptor_metric_h_max <max> : Set the maximum eigenvalue of Hessian (sqr min edge length) |
115 | |
116 | Level: beginner |
117 | |
118 | .keywords: DMAdaptor, convergence, options |
119 | .seealso: DMAdaptorCreate(), DMAdaptorAdapt() |
120 | @*/ |
121 | PetscErrorCode DMAdaptorSetFromOptions(DMAdaptor adaptor) |
122 | { |
123 | PetscErrorCode ierr; |
124 | |
125 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 125; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
126 | ierr = PetscOptionsBegin(PetscObjectComm((PetscObject) adaptor), "", "DM Adaptor Options", "DMAdaptor")0; do { PetscOptionItems PetscOptionsObjectBase; PetscOptionItems *PetscOptionsObject = &PetscOptionsObjectBase; PetscMemzero (PetscOptionsObject,sizeof(PetscOptionItems)); for (PetscOptionsObject ->count=(PetscOptionsPublish?-1:1); PetscOptionsObject-> count<2; PetscOptionsObject->count++) { PetscErrorCode _5_ierr = PetscOptionsBegin_Private(PetscOptionsObject,PetscObjectComm ((PetscObject) adaptor),"","DM Adaptor Options","DMAdaptor"); do {if (__builtin_expect(!!(_5_ierr),0)) return PetscError((( MPI_Comm)0x44000001),126,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0);;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),126,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
127 | ierr = PetscOptionsBool("-adaptor_monitor", "Monitor the adaptation process", "DMAdaptorMonitor", adaptor->monitor, &adaptor->monitor, NULL)PetscOptionsBool_Private(PetscOptionsObject,"-adaptor_monitor" ,"Monitor the adaptation process","DMAdaptorMonitor",adaptor-> monitor,&adaptor->monitor,((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),127,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
128 | ierr = PetscOptionsInt("-adaptor_sequence_num", "Number of adaptations to generate an optimal grid", "DMAdaptorSetSequenceLength", adaptor->numSeq, &adaptor->numSeq, NULL)PetscOptionsInt_Private(PetscOptionsObject,"-adaptor_sequence_num" ,"Number of adaptations to generate an optimal grid","DMAdaptorSetSequenceLength" ,adaptor->numSeq,&adaptor->numSeq,((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),128,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
129 | ierr = PetscOptionsInt("-adaptor_target_num", "Set the target number of vertices N_adapt, -1 for automatic determination", "DMAdaptor", adaptor->Nadapt, &adaptor->Nadapt, NULL)PetscOptionsInt_Private(PetscOptionsObject,"-adaptor_target_num" ,"Set the target number of vertices N_adapt, -1 for automatic determination" ,"DMAdaptor",adaptor->Nadapt,&adaptor->Nadapt,((void *)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),129,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
130 | ierr = PetscOptionsReal("-adaptor_refinement_factor", "Set r such that N_adapt = r^dim N_orig", "DMAdaptor", adaptor->refinementFactor, &adaptor->refinementFactor, NULL)PetscOptionsReal_Private(PetscOptionsObject,"-adaptor_refinement_factor" ,"Set r such that N_adapt = r^dim N_orig","DMAdaptor",adaptor ->refinementFactor,&adaptor->refinementFactor,((void *)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),130,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
131 | ierr = PetscOptionsReal("-adaptor_metric_h_min", "Set the minimum eigenvalue of Hessian (sqr max edge length)", "DMAdaptor", adaptor->h_min, &adaptor->h_min, NULL)PetscOptionsReal_Private(PetscOptionsObject,"-adaptor_metric_h_min" ,"Set the minimum eigenvalue of Hessian (sqr max edge length)" ,"DMAdaptor",adaptor->h_min,&adaptor->h_min,((void* )0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),131,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
132 | ierr = PetscOptionsReal("-adaptor_metric_h_max", "Set the maximum eigenvalue of Hessian (sqr min edge length)", "DMAdaptor", adaptor->h_max, &adaptor->h_max, NULL)PetscOptionsReal_Private(PetscOptionsObject,"-adaptor_metric_h_max" ,"Set the maximum eigenvalue of Hessian (sqr min edge length)" ,"DMAdaptor",adaptor->h_max,&adaptor->h_max,((void* )0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),132,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
133 | ierr = PetscOptionsEnd()_5_ierr = PetscOptionsEnd_Private(PetscOptionsObject);do {if ( __builtin_expect(!!(_5_ierr),0)) return PetscError(((MPI_Comm )0x44000001),133,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0);}} while (0); |
134 | ierr = VecTaggerSetFromOptions(adaptor->refineTag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),134,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
135 | ierr = VecTaggerSetFromOptions(adaptor->coarsenTag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),135,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
136 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
137 | } |
138 | |
139 | /*@ |
140 | DMAdaptorView - Views a DMAdaptor object |
141 | |
142 | Collective on DMAdaptor |
143 | |
144 | Input Parameters: |
145 | + adaptor - The DMAdaptor object |
146 | - viewer - The PetscViewer object |
147 | |
148 | Level: beginner |
149 | |
150 | .keywords: DMAdaptor, adaptivity, view |
151 | .seealso: DMAdaptorCreate(), DMAdaptorAdapt() |
152 | @*/ |
153 | PetscErrorCode DMAdaptorView(DMAdaptor adaptor, PetscViewer viewer) |
154 | { |
155 | PetscErrorCode ierr; |
156 | |
157 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 157; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
158 | ierr = PetscObjectPrintClassNamePrefixType((PetscObject) adaptor, viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),158,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
159 | ierr = PetscViewerASCIIPrintf(viewer, "DM Adaptor\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),159,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
160 | ierr = PetscViewerASCIIPrintf(viewer, " sequence length: %D\n", adaptor->numSeq);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),160,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
161 | ierr = VecTaggerView(adaptor->refineTag, viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),161,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
162 | ierr = VecTaggerView(adaptor->coarsenTag, viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),162,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
163 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
164 | } |
165 | |
166 | /*@ |
167 | DMAdaptorGetSolver - Gets the solver used to produce discrete solutions |
168 | |
169 | Not collective |
170 | |
171 | Input Parameter: |
172 | . adaptor - The DMAdaptor object |
173 | |
174 | Output Parameter: |
175 | . snes - The solver |
176 | |
177 | Level: intermediate |
178 | |
179 | .keywords: DMAdaptor, convergence |
180 | .seealso: DMAdaptorSetSolver(), DMAdaptorCreate(), DMAdaptorAdapt() |
181 | @*/ |
182 | PetscErrorCode DMAdaptorGetSolver(DMAdaptor adaptor, SNES *snes) |
183 | { |
184 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 184; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
185 | PetscValidHeaderSpecific(adaptor, DM_CLASSID, 1)do { if (!adaptor) return PetscError(((MPI_Comm)0x44000001),185 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(adaptor,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),185,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(adaptor))->classid != DM_CLASSID) { if (((PetscObject)(adaptor))->classid == -1) return PetscError (((MPI_Comm)0x44000001),185,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),185,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c",62, PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1) ; } } while (0); |
186 | PetscValidPointer(snes, 2)do { if (!snes) return PetscError(((MPI_Comm)0x44000001),186, __func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(snes,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),186,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); |
187 | *snes = adaptor->snes; |
188 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
189 | } |
190 | |
191 | /*@ |
192 | DMAdaptorSetSolver - Sets the solver used to produce discrete solutions |
193 | |
194 | Not collective |
195 | |
196 | Input Parameters: |
197 | + adaptor - The DMAdaptor object |
198 | - snes - The solver |
199 | |
200 | Level: intermediate |
201 | |
202 | Note: The solver MUST have an attached DM/DS, so that we know the exact solution |
203 | |
204 | .keywords: DMAdaptor, convergence |
205 | .seealso: DMAdaptorGetSolver(), DMAdaptorCreate(), DMAdaptorAdapt() |
206 | @*/ |
207 | PetscErrorCode DMAdaptorSetSolver(DMAdaptor adaptor, SNES snes) |
208 | { |
209 | PetscErrorCode ierr; |
210 | |
211 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 211; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
212 | PetscValidHeaderSpecific(adaptor, DM_CLASSID, 1)do { if (!adaptor) return PetscError(((MPI_Comm)0x44000001),212 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(adaptor,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),212,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(adaptor))->classid != DM_CLASSID) { if (((PetscObject)(adaptor))->classid == -1) return PetscError (((MPI_Comm)0x44000001),212,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),212,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c",62, PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1) ; } } while (0); |
213 | PetscValidHeaderSpecific(snes, SNES_CLASSID, 2)do { if (!snes) return PetscError(((MPI_Comm)0x44000001),213, __func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",2); if ( !PetscCheckPointer(snes,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),213,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,2); if (((PetscObject)(snes))->classid != SNES_CLASSID) { if (((PetscObject)(snes))->classid == -1) return PetscError (((MPI_Comm)0x44000001),213,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,2); else return PetscError(((MPI_Comm)0x44000001),213,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c",62, PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",2) ; } } while (0); |
214 | adaptor->snes = snes; |
215 | ierr = SNESGetDM(adaptor->snes, &adaptor->idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),215,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
216 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
217 | } |
218 | |
219 | /*@ |
220 | DMAdaptorGetSequenceLength - Gets the number of sequential adaptations |
221 | |
222 | Not collective |
223 | |
224 | Input Parameter: |
225 | . adaptor - The DMAdaptor object |
226 | |
227 | Output Parameter: |
228 | . num - The number of adaptations |
229 | |
230 | Level: intermediate |
231 | |
232 | .keywords: DMAdaptor, convergence |
233 | .seealso: DMAdaptorSetSequenceLength(), DMAdaptorCreate(), DMAdaptorAdapt() |
234 | @*/ |
235 | PetscErrorCode DMAdaptorGetSequenceLength(DMAdaptor adaptor, PetscInt *num) |
236 | { |
237 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 237; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
238 | PetscValidHeaderSpecific(adaptor, DM_CLASSID, 1)do { if (!adaptor) return PetscError(((MPI_Comm)0x44000001),238 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(adaptor,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),238,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(adaptor))->classid != DM_CLASSID) { if (((PetscObject)(adaptor))->classid == -1) return PetscError (((MPI_Comm)0x44000001),238,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),238,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c",62, PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1) ; } } while (0); |
239 | PetscValidPointer(num, 2)do { if (!num) return PetscError(((MPI_Comm)0x44000001),239,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c",85, PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer (num,PETSC_CHAR)) return PetscError(((MPI_Comm)0x44000001),239 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); |
240 | *num = adaptor->numSeq; |
241 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
242 | } |
243 | |
244 | /*@ |
245 | DMAdaptorSetSequenceLength - Sets the number of sequential adaptations |
246 | |
247 | Not collective |
248 | |
249 | Input Parameters: |
250 | + adaptor - The DMAdaptor object |
251 | - num - The number of adaptations |
252 | |
253 | Level: intermediate |
254 | |
255 | .keywords: DMAdaptor, convergence |
256 | .seealso: DMAdaptorGetSequenceLength(), DMAdaptorCreate(), DMAdaptorAdapt() |
257 | @*/ |
258 | PetscErrorCode DMAdaptorSetSequenceLength(DMAdaptor adaptor, PetscInt num) |
259 | { |
260 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 260; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
261 | PetscValidHeaderSpecific(adaptor, DM_CLASSID, 1)do { if (!adaptor) return PetscError(((MPI_Comm)0x44000001),261 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(adaptor,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),261,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(adaptor))->classid != DM_CLASSID) { if (((PetscObject)(adaptor))->classid == -1) return PetscError (((MPI_Comm)0x44000001),261,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),261,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c",62, PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1) ; } } while (0); |
262 | adaptor->numSeq = num; |
263 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
264 | } |
265 | |
266 | /*@ |
267 | DMAdaptorSetUp - After the solver is specified, we create structures for controlling adaptivity |
268 | |
269 | Collective on DMAdaptor |
270 | |
271 | Input Parameters: |
272 | . adaptor - The DMAdaptor object |
273 | |
274 | Level: beginner |
275 | |
276 | .keywords: DMAdaptor, convergence, setup |
277 | .seealso: DMAdaptorCreate(), DMAdaptorAdapt() |
278 | @*/ |
279 | PetscErrorCode DMAdaptorSetUp(DMAdaptor adaptor) |
280 | { |
281 | PetscDS prob; |
282 | PetscInt Nf, f; |
283 | PetscErrorCode ierr; |
284 | |
285 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 285; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
286 | ierr = DMGetDS(adaptor->idm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),286,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
287 | ierr = VecTaggerSetUp(adaptor->refineTag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),287,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
288 | ierr = VecTaggerSetUp(adaptor->coarsenTag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),288,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
289 | ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),289,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
290 | ierr = PetscMalloc1(Nf, &adaptor->exactSol)PetscMallocA(1,PETSC_FALSE,290,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,(size_t)(Nf)*sizeof(**(&adaptor->exactSol)),(&adaptor ->exactSol));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),290,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
291 | for (f = 0; f < Nf; ++f) { |
292 | ierr = PetscDSGetExactSolution(prob, f, &adaptor->exactSol[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),292,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
293 | /* TODO Have a flag that forces projection rather than using the exact solution */ |
294 | if (adaptor->exactSol[0]) {ierr = DMAdaptorSetTransferFunction(adaptor, DMAdaptorTransferSolution_Exact_Private);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),294,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
295 | } |
296 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
297 | } |
298 | |
299 | PetscErrorCode DMAdaptorGetTransferFunction(DMAdaptor adaptor, PetscErrorCode (**tfunc)(DMAdaptor, DM, Vec, DM, Vec, void *)) |
300 | { |
301 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 301; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
302 | *tfunc = adaptor->ops->transfersolution; |
303 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
304 | } |
305 | |
306 | PetscErrorCode DMAdaptorSetTransferFunction(DMAdaptor adaptor, PetscErrorCode (*tfunc)(DMAdaptor, DM, Vec, DM, Vec, void *)) |
307 | { |
308 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 308; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
309 | adaptor->ops->transfersolution = tfunc; |
310 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
311 | } |
312 | |
313 | PetscErrorCode DMAdaptorPreAdapt(DMAdaptor adaptor, Vec locX) |
314 | { |
315 | DM plex; |
316 | PetscDS prob; |
317 | PetscObject obj; |
318 | PetscClassId id; |
319 | PetscBool isForest; |
320 | PetscErrorCode ierr; |
321 | |
322 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 322; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
323 | ierr = DMConvert(adaptor->idm, DMPLEX"plex", &plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),323,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
324 | ierr = DMGetDS(adaptor->idm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),324,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
325 | ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),325,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
326 | ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),326,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
327 | ierr = DMIsForest(adaptor->idm, &isForest);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),327,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
328 | if (adaptor->adaptCriterion == DM_ADAPTATION_NONE) { |
329 | if (isForest) {adaptor->adaptCriterion = DM_ADAPTATION_LABEL;} |
330 | #if defined(PETSC_HAVE_PRAGMATIC) |
331 | else {adaptor->adaptCriterion = DM_ADAPTATION_METRIC;} |
332 | #else |
333 | else {adaptor->adaptCriterion = DM_ADAPTATION_REFINE;} |
334 | #endif |
335 | } |
336 | if (id == PETSCFV_CLASSID) {adaptor->femType = PETSC_FALSE;} |
337 | else {adaptor->femType = PETSC_TRUE;} |
338 | if (adaptor->femType) { |
339 | /* Compute local solution bc */ |
340 | ierr = DMPlexInsertBoundaryValues(plex, PETSC_TRUE, locX, 0.0, adaptor->faceGeom, adaptor->cellGeom, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),340,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
341 | } else { |
342 | PetscFV fvm = (PetscFV) obj; |
343 | PetscLimiter noneLimiter; |
344 | Vec grad; |
345 | |
346 | ierr = PetscFVGetComputeGradients(fvm, &adaptor->computeGradient);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),346,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
347 | ierr = PetscFVSetComputeGradients(fvm, PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),347,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
348 | /* Use no limiting when reconstructing gradients for adaptivity */ |
349 | ierr = PetscFVGetLimiter(fvm, &adaptor->limiter);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),349,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
350 | ierr = PetscObjectReference((PetscObject) adaptor->limiter);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),350,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
351 | ierr = PetscLimiterCreate(PetscObjectComm((PetscObject) fvm), &noneLimiter);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),351,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
352 | ierr = PetscLimiterSetType(noneLimiter, PETSCLIMITERNONE"none");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),352,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
353 | ierr = PetscFVSetLimiter(fvm, noneLimiter);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),353,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
354 | /* Get FVM data */ |
355 | ierr = DMPlexGetDataFVM(plex, fvm, &adaptor->cellGeom, &adaptor->faceGeom, &adaptor->gradDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),355,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
356 | ierr = VecGetDM(adaptor->cellGeom, &adaptor->cellDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),356,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
357 | ierr = VecGetArrayRead(adaptor->cellGeom, &adaptor->cellGeomArray);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),357,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
358 | /* Compute local solution bc */ |
359 | ierr = DMPlexInsertBoundaryValues(plex, PETSC_TRUE, locX, 0.0, adaptor->faceGeom, adaptor->cellGeom, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),359,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
360 | /* Compute gradients */ |
361 | ierr = DMCreateGlobalVector(adaptor->gradDM, &grad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),361,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
362 | ierr = DMPlexReconstructGradientsFVM(plex, locX, grad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),362,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
363 | ierr = DMGetLocalVector(adaptor->gradDM, &adaptor->cellGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),363,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
364 | ierr = DMGlobalToLocalBegin(adaptor->gradDM, grad, INSERT_VALUES, adaptor->cellGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),364,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
365 | ierr = DMGlobalToLocalEnd(adaptor->gradDM, grad, INSERT_VALUES, adaptor->cellGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),365,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
366 | ierr = VecDestroy(&grad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),366,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
367 | ierr = VecGetArrayRead(adaptor->cellGrad, &adaptor->cellGradArray);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),367,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
368 | } |
369 | ierr = DMDestroy(&plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),369,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
370 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
371 | } |
372 | |
373 | PetscErrorCode DMAdaptorTransferSolution(DMAdaptor adaptor, DM dm, Vec x, DM adm, Vec ax) |
374 | { |
375 | PetscReal time = 0.0; |
376 | Mat interp; |
377 | void *ctx; |
378 | PetscErrorCode ierr; |
379 | |
380 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 380; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
381 | ierr = DMGetApplicationContext(dm, &ctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),381,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
382 | if (adaptor->ops->transfersolution) { |
383 | ierr = (*adaptor->ops->transfersolution)(adaptor, dm, x, adm, ax, ctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),383,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
384 | } else { |
385 | switch (adaptor->adaptCriterion) { |
386 | case DM_ADAPTATION_LABEL: |
387 | ierr = DMForestTransferVec(dm, x, adm, ax, PETSC_TRUE, time);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),387,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
388 | break; |
389 | case DM_ADAPTATION_REFINE: |
390 | case DM_ADAPTATION_METRIC: |
391 | ierr = DMCreateInterpolation(dm, adm, &interp, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),391,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
392 | ierr = MatInterpolate(interp, x, ax);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),392,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
393 | ierr = DMInterpolate(dm, interp, adm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),393,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
394 | ierr = MatDestroy(&interp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),394,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
395 | break; |
396 | default: SETERRQ1(PetscObjectComm((PetscObject) adaptor), PETSC_ERR_SUP, "No built-in projection for this adaptation criterion: %D", adaptor->adaptCriterion)return PetscError(PetscObjectComm((PetscObject) adaptor),396, __func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,56,PETSC_ERROR_INITIAL,"No built-in projection for this adaptation criterion: %D" ,adaptor->adaptCriterion); |
397 | } |
398 | } |
399 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
400 | } |
401 | |
402 | PetscErrorCode DMAdaptorPostAdapt(DMAdaptor adaptor) |
403 | { |
404 | PetscDS prob; |
405 | PetscObject obj; |
406 | PetscClassId id; |
407 | PetscErrorCode ierr; |
408 | |
409 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 409; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
410 | ierr = DMGetDS(adaptor->idm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),410,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
411 | ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),411,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
412 | ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),412,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
413 | if (id == PETSCFV_CLASSID) { |
414 | PetscFV fvm = (PetscFV) obj; |
415 | |
416 | ierr = PetscFVSetComputeGradients(fvm, adaptor->computeGradient);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),416,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
417 | /* Restore original limiter */ |
418 | ierr = PetscFVSetLimiter(fvm, adaptor->limiter);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),418,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
419 | |
420 | ierr = VecRestoreArrayRead(adaptor->cellGeom, &adaptor->cellGeomArray);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),420,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
421 | ierr = VecRestoreArrayRead(adaptor->cellGrad, &adaptor->cellGradArray);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),421,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
422 | ierr = DMRestoreLocalVector(adaptor->gradDM, &adaptor->cellGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),422,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
423 | } |
424 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
425 | } |
426 | |
427 | static PetscErrorCode DMAdaptorModifyHessian_Private(PetscInt dim, PetscReal h_min, PetscReal h_max, PetscScalar Hp[]) |
428 | { |
429 | PetscScalar *Hpos; |
430 | PetscReal *eigs; |
431 | PetscInt i, j, k; |
432 | PetscErrorCode ierr; |
433 | |
434 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 434; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
435 | ierr = PetscMalloc2(dim*dim, &Hpos, dim, &eigs)PetscMallocA(2,PETSC_FALSE,435,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,(size_t)(dim*dim)*sizeof(**(&Hpos)),(&Hpos),(size_t) (dim)*sizeof(**(&eigs)),(&eigs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),435,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
436 | #if 0 |
437 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "H = [");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),437,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
438 | for (i = 0; i < dim; ++i) { |
439 | if (i > 0) {ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), " ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),439,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
440 | for (j = 0; j < dim; ++j) { |
441 | if (j > 0) {ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), ", ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),441,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
442 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "%g", Hp[i*dim+j]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),442,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
443 | } |
444 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),444,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
445 | } |
446 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "]\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),446,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
447 | #endif |
448 | /* Symmetrize */ |
449 | for (i = 0; i < dim; ++i) { |
450 | Hpos[i*dim+i] = Hp[i*dim+i]; |
451 | for (j = i+1; j < dim; ++j) { |
452 | Hpos[i*dim+j] = 0.5*(Hp[i*dim+j] + Hp[j*dim+i]); |
453 | Hpos[j*dim+i] = Hpos[i*dim+j]; |
454 | } |
455 | } |
456 | #if 0 |
457 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "Hs = [");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),457,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
458 | for (i = 0; i < dim; ++i) { |
459 | if (i > 0) {ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), " ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),459,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
460 | for (j = 0; j < dim; ++j) { |
461 | if (j > 0) {ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), ", ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),461,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
462 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "%g", Hpos[i*dim+j]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),462,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
463 | } |
464 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),464,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
465 | } |
466 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "]\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),466,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
467 | #endif |
468 | /* Compute eigendecomposition */ |
469 | { |
470 | PetscScalar *work; |
471 | PetscBLASInt lwork; |
472 | |
473 | lwork = 5*dim; |
474 | ierr = PetscMalloc1(5*dim, &work)PetscMallocA(1,PETSC_FALSE,474,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,(size_t)(5*dim)*sizeof(**(&work)),(&work));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),474,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
475 | #if defined(PETSC_MISSING_LAPACK_GEEV) |
476 | SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_SUP, "GEEV - Lapack routine is unavailable\nNot able to provide eigen values.")return PetscError(PetscObjectComm((PetscObject) dm),476,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c",56, PETSC_ERROR_INITIAL,"GEEV - Lapack routine is unavailable\nNot able to provide eigen values." ); |
477 | #else |
478 | { |
479 | PetscBLASInt lierr; |
480 | PetscBLASInt nb; |
481 | |
482 | ierr = PetscBLASIntCast(dim, &nb);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),482,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
483 | ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),483,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
484 | #if defined(PETSC_USE_COMPLEX) |
485 | { |
486 | PetscReal *rwork; |
487 | ierr = PetscMalloc1(3*dim, &rwork)PetscMallocA(1,PETSC_FALSE,487,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,(size_t)(3*dim)*sizeof(**(&rwork)),(&rwork));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),487,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
488 | PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V","U",&nb,Hpos,&nb,eigs,work,&lwork,rwork,&lierr))do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = "LAPACKsyev"; petscstack->file[petscstack->currentsize ] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack->line[petscstack->currentsize] = 488; petscstack ->petscroutine[petscstack->currentsize] = PETSC_FALSE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); dsyev_("V","U",&nb,Hpos,&nb,eigs,work,&lwork,rwork ,&lierr); do { do {PetscErrorCode _7_ierr = PetscMallocValidate (488,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" );do {if (__builtin_expect(!!(_7_ierr),0)) return PetscError( ((MPI_Comm)0x44000001),488,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0);} while(0); do { ; if (petscstack && petscstack->currentsize > 0 ) { petscstack->currentsize--; petscstack->function[petscstack ->currentsize] = 0; petscstack->file[petscstack->currentsize ] = 0; petscstack->line[petscstack->currentsize] = 0; petscstack ->petscroutine[petscstack->currentsize] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack-> hotdepth-1)<(0)) ? (0) : (petscstack->hotdepth-1)); } ; } while (0); } while (0); } while(0); |
489 | ierr = PetscFree(rwork)((*PetscTrFree)((void*)(rwork),489,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ) || ((rwork) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),489,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
490 | } |
491 | #else |
492 | PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V","U",&nb,Hpos,&nb,eigs,work,&lwork,&lierr))do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = "LAPACKsyev"; petscstack->file[petscstack->currentsize ] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack->line[petscstack->currentsize] = 492; petscstack ->petscroutine[petscstack->currentsize] = PETSC_FALSE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); dsyev_("V","U",&nb,Hpos,&nb,eigs,work,&lwork,& lierr); do { do {PetscErrorCode _7_ierr = PetscMallocValidate (492,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" );do {if (__builtin_expect(!!(_7_ierr),0)) return PetscError( ((MPI_Comm)0x44000001),492,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0);} while(0); do { ; if (petscstack && petscstack->currentsize > 0 ) { petscstack->currentsize--; petscstack->function[petscstack ->currentsize] = 0; petscstack->file[petscstack->currentsize ] = 0; petscstack->line[petscstack->currentsize] = 0; petscstack ->petscroutine[petscstack->currentsize] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack-> hotdepth-1)<(0)) ? (0) : (petscstack->hotdepth-1)); } ; } while (0); } while (0); } while(0); |
493 | #endif |
494 | if (lierr) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_LIB, "Error in LAPACK routine %d", (int) lierr)return PetscError(((MPI_Comm)0x44000001),494,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,76,PETSC_ERROR_INITIAL,"Error in LAPACK routine %d",(int) lierr ); |
495 | ierr = PetscFPTrapPop();CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),495,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
496 | } |
497 | #endif |
498 | ierr = PetscFree(work)((*PetscTrFree)((void*)(work),498,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ) || ((work) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),498,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
499 | } |
500 | #if 0 |
501 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "L = [");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),501,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
502 | for (i = 0; i < dim; ++i) { |
503 | if (i > 0) {ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), ", ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),503,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
504 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "%g", eigs[i]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),504,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
505 | } |
506 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "]\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),506,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
507 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "Q = [");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),507,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
508 | for (i = 0; i < dim; ++i) { |
509 | if (i > 0) {ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), " ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),509,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
510 | for (j = 0; j < dim; ++j) { |
511 | if (j > 0) {ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), ", ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),511,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
512 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "%g", Hpos[i*dim+j]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),512,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
513 | } |
514 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),514,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
515 | } |
516 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "]\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),516,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
517 | #endif |
518 | /* Reflect to positive orthant, enforce maximum and minimum size, \lambda \propto 1/h^2 |
519 | TODO get domain bounding box */ |
520 | for (i = 0; i < dim; ++i) eigs[i] = PetscMin(h_max, PetscMax(h_min, PetscAbsReal(eigs[i])))(((h_max)<((((h_min)<(fabs(eigs[i]))) ? (fabs(eigs[i])) : (h_min)))) ? (h_max) : ((((h_min)<(fabs(eigs[i]))) ? (fabs (eigs[i])) : (h_min)))); |
521 | /* Reconstruct Hessian */ |
522 | for (i = 0; i < dim; ++i) { |
523 | for (j = 0; j < dim; ++j) { |
524 | Hp[i*dim+j] = 0.0; |
525 | for (k = 0; k < dim; ++k) { |
526 | Hp[i*dim+j] += Hpos[k*dim+i] * eigs[k] * Hpos[k*dim+j]; |
527 | } |
528 | } |
529 | } |
530 | ierr = PetscFree2(Hpos, eigs)PetscFreeA(2,530,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,&(Hpos),&(eigs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),530,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
531 | #if 0 |
532 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "H+ = [");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),532,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
533 | for (i = 0; i < dim; ++i) { |
534 | if (i > 0) {ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), " ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),534,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
535 | for (j = 0; j < dim; ++j) { |
536 | if (j > 0) {ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), ", ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),536,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
537 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "%g", Hp[i*dim+j]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),537,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
538 | } |
539 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),539,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
540 | } |
541 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "]\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),541,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
542 | #endif |
543 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
544 | } |
545 | |
546 | static void detHFunc(PetscInt dim, PetscInt Nf, PetscInt NfAux, |
547 | const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], |
548 | const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], |
549 | PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) |
550 | { |
551 | const PetscInt p = 1; |
552 | PetscReal detH = 0.0; |
553 | |
554 | if (dim == 2) DMPlex_Det2D_Scalar_Internal(&detH, u); |
555 | else if (dim == 3) DMPlex_Det3D_Scalar_Internal(&detH, u); |
556 | f0[0] = PetscPowReal(detH, p/(2.*p + dim))pow(detH,p/(2.*p + dim)); |
557 | } |
558 | |
559 | /* |
560 | DMAdaptorSimpleErrorIndicator - Just use the integrated gradient as an error indicator |
561 | |
562 | Input Parameters: |
563 | + adaptor - The DMAdaptor object |
564 | . dim - The topological dimension |
565 | . cell - The cell |
566 | . field - The field integrated over the cell |
567 | . gradient - The gradient integrated over the cell |
568 | . cg - A PetscFVCellGeom struct |
569 | - ctx - A user context |
570 | |
571 | Output Parameter: |
572 | . errInd - The error indicator |
573 | |
574 | .seealso: DMAdaptorComputeErrorIndicator() |
575 | */ |
576 | static PetscErrorCode DMAdaptorSimpleErrorIndicator_Private(DMAdaptor adaptor, PetscInt dim, PetscInt Nc, const PetscScalar *field, const PetscScalar *gradient, const PetscFVCellGeom *cg, PetscReal *errInd, void *ctx) |
577 | { |
578 | PetscReal err = 0.; |
579 | PetscInt c, d; |
580 | |
581 | PetscFunctionBeginHotdo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 581; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
582 | for (c = 0; c < Nc; c++) { |
583 | for (d = 0; d < dim; ++d) { |
584 | err += PetscSqr(PetscRealPart(gradient[c*dim+d]))(((gradient[c*dim+d]))*((gradient[c*dim+d]))); |
585 | } |
586 | } |
587 | *errInd = cg->volume * err; |
588 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
589 | } |
590 | |
591 | static PetscErrorCode DMAdaptorComputeErrorIndicator_Private(DMAdaptor adaptor, DM plex, PetscInt cell, Vec locX, PetscReal *errInd) |
592 | { |
593 | PetscDS prob; |
594 | PetscObject obj; |
595 | PetscClassId id; |
596 | void *ctx; |
597 | PetscQuadrature quad; |
598 | PetscInt dim, d, cdim, Nc; |
599 | PetscErrorCode ierr; |
600 | |
601 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 601; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
602 | *errInd = 0.; |
603 | ierr = DMGetDimension(plex, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),603,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
604 | ierr = DMGetCoordinateDim(plex, &cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),604,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
605 | ierr = DMGetApplicationContext(plex, &ctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),605,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
606 | ierr = DMGetDS(plex, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),606,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
607 | ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),607,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
608 | ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),608,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
609 | if (id == PETSCFV_CLASSID) { |
610 | const PetscScalar *pointSols; |
611 | const PetscScalar *pointSol; |
612 | const PetscScalar *pointGrad; |
613 | PetscFVCellGeom *cg; |
614 | |
615 | ierr = PetscFVGetNumComponents((PetscFV) obj, &Nc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),615,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
616 | ierr = VecGetArrayRead(locX, &pointSols);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),616,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
617 | ierr = DMPlexPointLocalRead(plex, cell, pointSols, (void *) &pointSol);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),617,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
618 | ierr = DMPlexPointLocalRead(adaptor->gradDM, cell, adaptor->cellGradArray, (void *) &pointGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),618,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
619 | ierr = DMPlexPointLocalRead(adaptor->cellDM, cell, adaptor->cellGeomArray, &cg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),619,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
620 | ierr = (*adaptor->ops->computeerrorindicator)(adaptor, dim, Nc, pointSol, pointGrad, cg, errInd, ctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),620,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
621 | ierr = VecRestoreArrayRead(locX, &pointSols);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),621,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
622 | } else { |
623 | PetscScalar *x = NULL((void*)0), *field, *gradient, *interpolant, *interpolantGrad; |
624 | PetscFVCellGeom cg; |
625 | const PetscReal *quadWeights; |
626 | PetscReal *coords, *detJ, *J, *invJ; |
627 | PetscInt Nb, fc, Nq, qNc, Nf, f, fieldOffset; |
628 | |
629 | ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),629,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
630 | ierr = PetscFEGetQuadrature((PetscFE) obj, &quad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),630,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
631 | ierr = DMPlexVecGetClosure(plex, NULL((void*)0), locX, cell, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),631,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
632 | ierr = PetscFEGetDimension((PetscFE) obj, &Nb);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),632,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
633 | ierr = PetscFEGetNumComponents((PetscFE) obj, &Nc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),633,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
634 | ierr = PetscQuadratureGetData(quad, NULL((void*)0), &qNc, &Nq, NULL((void*)0), &quadWeights);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),634,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
635 | ierr = PetscMalloc6(Nc,&field,cdim*Nc,&gradient,cdim*Nq,&coords,Nq,&detJ,cdim*cdim*Nq,&J,cdim*cdim*Nq,&invJ)PetscMallocA(6,PETSC_FALSE,635,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,(size_t)(Nc)*sizeof(**(&field)),(&field),(size_t)(cdim *Nc)*sizeof(**(&gradient)),(&gradient),(size_t)(cdim* Nq)*sizeof(**(&coords)),(&coords),(size_t)(Nq)*sizeof (**(&detJ)),(&detJ),(size_t)(cdim*cdim*Nq)*sizeof(**( &J)),(&J),(size_t)(cdim*cdim*Nq)*sizeof(**(&invJ) ),(&invJ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),635,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
636 | ierr = PetscMalloc2(Nc, &interpolant, cdim*Nc, &interpolantGrad)PetscMallocA(2,PETSC_FALSE,636,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,(size_t)(Nc)*sizeof(**(&interpolant)),(&interpolant) ,(size_t)(cdim*Nc)*sizeof(**(&interpolantGrad)),(&interpolantGrad ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),636,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
637 | ierr = DMPlexComputeCellGeometryFEM(plex, cell, quad, coords, J, invJ, detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),637,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
638 | ierr = DMPlexComputeCellGeometryFVM(plex, cell, &cg.volume, NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),638,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
639 | ierr = PetscMemzero(gradient, cdim*Nc * sizeof(PetscScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),639,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
640 | for (f = 0, fieldOffset = 0; f < Nf; ++f) { |
641 | PetscInt qc = 0, q; |
642 | |
643 | ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),643,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
644 | ierr = PetscMemzero(interpolant, Nc * sizeof(PetscScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),644,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
645 | ierr = PetscMemzero(interpolantGrad, cdim*Nc * sizeof(PetscScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),645,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
646 | for (q = 0; q < Nq; ++q) { |
647 | ierr = PetscFEInterpolateFieldAndGradient_Static((PetscFE) obj, x, dim, invJ, q, interpolant, interpolantGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),647,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
648 | for (fc = 0; fc < Nc; ++fc) { |
649 | const PetscReal wt = quadWeights[q*qNc+qc+fc]; |
650 | |
651 | field[fc] += interpolant[fc]*wt*detJ[q]; |
652 | for (d = 0; d < cdim; ++d) gradient[fc*cdim+d] += interpolantGrad[fc*dim+d]*wt*detJ[q]; |
653 | } |
654 | } |
655 | fieldOffset += Nb; |
656 | qc += Nc; |
Value stored to 'qc' is never read | |
657 | } |
658 | ierr = PetscFree2(interpolant, interpolantGrad)PetscFreeA(2,658,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,&(interpolant),&(interpolantGrad));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),658,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
659 | ierr = DMPlexVecRestoreClosure(plex, NULL((void*)0), locX, cell, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),659,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
660 | for (fc = 0; fc < Nc; ++fc) { |
661 | field[fc] /= cg.volume; |
662 | for (d = 0; d < cdim; ++d) gradient[fc*cdim+d] /= cg.volume; |
663 | } |
664 | ierr = (*adaptor->ops->computeerrorindicator)(adaptor, dim, Nc, field, gradient, &cg, errInd, ctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),664,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
665 | ierr = PetscFree6(field,gradient,coords,detJ,J,invJ)PetscFreeA(6,665,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,&(field),&(gradient),&(coords),&(detJ),& (J),&(invJ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),665,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
666 | } |
667 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
668 | } |
669 | |
670 | static PetscErrorCode DMAdaptorAdapt_Sequence_Private(DMAdaptor adaptor, Vec inx, PetscBool doSolve, DM *adm, Vec *ax) |
671 | { |
672 | PetscDS prob; |
673 | void *ctx; |
674 | MPI_Comm comm; |
675 | PetscInt numAdapt = adaptor->numSeq, adaptIter; |
676 | PetscInt dim, coordDim, numFields, cStart, cEnd, cEndInterior, c; |
677 | PetscErrorCode ierr; |
678 | |
679 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 679; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
680 | ierr = DMViewFromOptions(adaptor->idm, NULL((void*)0), "-dm_adapt_pre_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),680,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
681 | ierr = VecViewFromOptions(inx, NULL((void*)0), "-sol_adapt_pre_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),681,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
682 | ierr = PetscObjectGetComm((PetscObject) adaptor, &comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),682,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
683 | ierr = DMGetDimension(adaptor->idm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),683,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
684 | ierr = DMGetCoordinateDim(adaptor->idm, &coordDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),684,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
685 | ierr = DMGetApplicationContext(adaptor->idm, &ctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),685,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
686 | ierr = DMGetDS(adaptor->idm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),686,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
687 | ierr = PetscDSGetNumFields(prob, &numFields);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),687,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
688 | |
689 | /* Adapt until nothing changes */ |
690 | /* Adapt for a specified number of iterates */ |
691 | for (adaptIter = 0; adaptIter < numAdapt-1; ++adaptIter) {ierr = PetscViewerASCIIPushTab(PETSC_VIEWER_STDOUT_(comm));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),691,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
692 | for (adaptIter = 0; adaptIter < numAdapt; ++adaptIter) { |
693 | PetscBool adapted = PETSC_FALSE; |
694 | DM dm = adaptIter ? *adm : adaptor->idm, odm; |
695 | Vec x = adaptIter ? *ax : inx, locX, ox; |
696 | |
697 | ierr = DMGetLocalVector(dm, &locX);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),697,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
698 | ierr = DMGlobalToLocalBegin(dm, adaptIter ? *ax : x, INSERT_VALUES, locX);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),698,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
699 | ierr = DMGlobalToLocalEnd(dm, adaptIter ? *ax : x, INSERT_VALUES, locX);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),699,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
700 | ierr = DMAdaptorPreAdapt(adaptor, locX);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),700,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
701 | if (doSolve) { |
702 | SNES snes; |
703 | |
704 | ierr = DMAdaptorGetSolver(adaptor, &snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),704,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
705 | ierr = SNESSolve(snes, NULL((void*)0), adaptIter ? *ax : x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),705,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
706 | } |
707 | /* ierr = DMAdaptorMonitor(adaptor);CHKERRQ(ierr); |
708 | Print iterate, memory used, DM, solution */ |
709 | switch (adaptor->adaptCriterion) { |
710 | case DM_ADAPTATION_REFINE: |
711 | ierr = DMRefine(dm, comm, &odm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),711,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
712 | if (!odm) SETERRQ(comm, PETSC_ERR_ARG_INCOMP, "DMRefine() did not perform any refinement, cannot continue grid sequencing")return PetscError(comm,712,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,75,PETSC_ERROR_INITIAL,"DMRefine() did not perform any refinement, cannot continue grid sequencing" ); |
713 | adapted = PETSC_TRUE; |
714 | break; |
715 | case DM_ADAPTATION_LABEL: |
716 | { |
717 | /* Adapt DM |
718 | Create local solution |
719 | Reconstruct gradients (FVM) or solve adjoint equation (FEM) |
720 | Produce cellwise error indicator */ |
721 | DM plex; |
722 | DMLabel adaptLabel; |
723 | IS refineIS, coarsenIS; |
724 | Vec errVec; |
725 | PetscScalar *errArray; |
726 | const PetscScalar *pointSols; |
727 | PetscReal minMaxInd[2] = {PETSC_MAX_REAL1.7976931348623157e+308, PETSC_MIN_REAL(-1.7976931348623157e+308)}, minMaxIndGlobal[2]; |
728 | PetscInt nRefine, nCoarsen; |
729 | |
730 | ierr = DMConvert(dm, DMPLEX"plex", &plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),730,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
731 | ierr = DMLabelCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), "adapt", &adaptLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),731,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
732 | ierr = DMPlexGetHeightStratum(plex, 0, &cStart, &cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),732,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
733 | ierr = DMPlexGetHybridBounds(plex, &cEndInterior, NULL((void*)0), NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),733,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
734 | cEnd = (cEndInterior < 0) ? cEnd : cEndInterior; |
735 | |
736 | ierr = VecCreateMPI(PetscObjectComm((PetscObject) adaptor), cEnd-cStart, PETSC_DETERMINE-1, &errVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),736,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
737 | ierr = VecSetUp(errVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),737,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
738 | ierr = VecGetArray(errVec, &errArray);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),738,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
739 | ierr = VecGetArrayRead(locX, &pointSols);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),739,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
740 | for (c = cStart; c < cEnd; ++c) { |
741 | PetscReal errInd; |
742 | |
743 | ierr = DMAdaptorComputeErrorIndicator_Private(adaptor, plex, c, locX, &errInd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),743,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
744 | errArray[c-cStart] = errInd; |
745 | minMaxInd[0] = PetscMin(minMaxInd[0], errInd)(((minMaxInd[0])<(errInd)) ? (minMaxInd[0]) : (errInd)); |
746 | minMaxInd[1] = PetscMax(minMaxInd[1], errInd)(((minMaxInd[1])<(errInd)) ? (errInd) : (minMaxInd[1])); |
747 | } |
748 | ierr = VecRestoreArrayRead(locX, &pointSols);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),748,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
749 | ierr = VecRestoreArray(errVec, &errArray);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),749,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
750 | ierr = PetscGlobalMinMaxReal(PetscObjectComm((PetscObject) adaptor), minMaxInd, minMaxIndGlobal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),750,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
751 | ierr = PetscInfo2(adaptor, "DMAdaptor: error indicator range (%E, %E)\n", minMaxIndGlobal[0], minMaxIndGlobal[1])PetscInfo_Private(__func__,adaptor,"DMAdaptor: error indicator range (%E, %E)\n" ,minMaxIndGlobal[0],minMaxIndGlobal[1]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),751,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
752 | /* Compute IS from VecTagger */ |
753 | ierr = VecTaggerComputeIS(adaptor->refineTag, errVec, &refineIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),753,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
754 | ierr = VecTaggerComputeIS(adaptor->coarsenTag, errVec, &coarsenIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),754,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
755 | ierr = ISGetSize(refineIS, &nRefine);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),755,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
756 | ierr = ISGetSize(coarsenIS, &nCoarsen);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),756,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
757 | ierr = PetscInfo2(adaptor, "DMAdaptor: numRefine %D, numCoarsen %D\n", nRefine, nCoarsen)PetscInfo_Private(__func__,adaptor,"DMAdaptor: numRefine %D, numCoarsen %D\n" ,nRefine,nCoarsen);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),757,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
758 | if (nRefine) {ierr = DMLabelSetStratumIS(adaptLabel, DM_ADAPT_REFINE, refineIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),758,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
759 | if (nCoarsen) {ierr = DMLabelSetStratumIS(adaptLabel, DM_ADAPT_COARSEN, coarsenIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),759,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
760 | ierr = ISDestroy(&coarsenIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),760,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
761 | ierr = ISDestroy(&refineIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),761,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
762 | ierr = VecDestroy(&errVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),762,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
763 | /* Adapt DM from label */ |
764 | if (nRefine || nCoarsen) { |
765 | ierr = DMAdaptLabel(dm, adaptLabel, &odm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),765,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
766 | adapted = PETSC_TRUE; |
767 | } |
768 | ierr = DMLabelDestroy(&adaptLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),768,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
769 | ierr = DMDestroy(&plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),769,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
770 | } |
771 | break; |
772 | case DM_ADAPTATION_METRIC: |
773 | { |
774 | DM dmGrad, dmHess, dmMetric; |
775 | PetscDS probGrad, probHess; |
776 | Vec xGrad, xHess, metric; |
777 | PetscSection sec, msec; |
778 | PetscScalar *H, *M, integral; |
779 | PetscReal N; |
780 | DMLabel bdLabel; |
781 | PetscInt Nd = coordDim*coordDim, f, vStart, vEnd, v; |
782 | |
783 | /* Compute vertexwise gradients from cellwise gradients */ |
784 | ierr = DMClone(dm, &dmGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),784,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
785 | ierr = DMClone(dm, &dmHess);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),785,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
786 | ierr = DMGetDS(dmGrad, &probGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),786,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
787 | ierr = DMGetDS(dmHess, &probHess);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),787,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
788 | for (f = 0; f < numFields; ++f) { |
789 | PetscFE fe, feGrad, feHess; |
790 | PetscDualSpace Q; |
791 | DM K; |
792 | PetscQuadrature q; |
793 | PetscInt Nc, qorder; |
794 | const char *prefix; |
795 | |
796 | ierr = PetscDSGetDiscretization(prob, f, (PetscObject *) &fe);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),796,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
797 | ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),797,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
798 | ierr = PetscFEGetDualSpace(fe, &Q);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),798,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
799 | ierr = PetscDualSpaceGetDM(Q, &K);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),799,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
800 | ierr = DMPlexGetDepthStratum(K, 0, &vStart, &vEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),800,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
801 | ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),801,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
802 | ierr = PetscQuadratureGetOrder(q, &qorder);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),802,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
803 | ierr = PetscObjectGetOptionsPrefix((PetscObject) fe, &prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),803,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
804 | ierr = PetscFECreateDefault(PetscObjectComm((PetscObject) dmGrad), dim, Nc*coordDim, (vEnd-vStart) == dim+1 ? PETSC_TRUE : PETSC_FALSE, prefix, qorder, &feGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),804,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
805 | ierr = PetscDSSetDiscretization(probGrad, f, (PetscObject) feGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),805,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
806 | ierr = PetscFECreateDefault(PetscObjectComm((PetscObject) dmHess), dim, Nc*Nd, (vEnd-vStart) == dim+1 ? PETSC_TRUE : PETSC_FALSE, prefix, qorder, &feHess);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),806,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
807 | ierr = PetscDSSetDiscretization(probHess, f, (PetscObject) feHess);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),807,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
808 | ierr = PetscFEDestroy(&feGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),808,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
809 | ierr = PetscFEDestroy(&feHess);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),809,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
810 | } |
811 | ierr = DMGetGlobalVector(dmGrad, &xGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),811,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
812 | ierr = VecViewFromOptions(x, NULL((void*)0), "-sol_adapt_loc_pre_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),812,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
813 | ierr = DMPlexComputeGradientClementInterpolant(dm, locX, xGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),813,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
814 | ierr = VecViewFromOptions(xGrad, NULL((void*)0), "-adapt_gradient_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),814,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
815 | /* Compute vertexwise Hessians from cellwise Hessians */ |
816 | ierr = DMGetGlobalVector(dmHess, &xHess);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),816,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
817 | ierr = DMPlexComputeGradientClementInterpolant(dmGrad, xGrad, xHess);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),817,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
818 | ierr = VecViewFromOptions(xHess, NULL((void*)0), "-adapt_hessian_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),818,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
819 | /* Compute metric */ |
820 | ierr = DMClone(dm, &dmMetric);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),820,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
821 | ierr = DMGetSection(dm, &sec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),821,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
822 | ierr = DMPlexGetDepthStratum(dm, 0, &vStart, &vEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),822,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
823 | ierr = PetscSectionCreate(PetscObjectComm((PetscObject) dm), &msec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),823,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
824 | ierr = PetscSectionSetNumFields(msec, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),824,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
825 | ierr = PetscSectionSetFieldComponents(msec, 0, Nd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),825,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
826 | ierr = PetscSectionSetChart(msec, vStart, vEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),826,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
827 | for (v = vStart; v < vEnd; ++v) { |
828 | ierr = PetscSectionSetDof(msec, v, Nd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),828,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
829 | ierr = PetscSectionSetFieldDof(msec, v, 0, Nd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),829,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
830 | } |
831 | ierr = PetscSectionSetUp(msec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),831,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
832 | ierr = DMSetSection(dmMetric, msec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),832,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
833 | ierr = PetscSectionDestroy(&msec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),833,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
834 | ierr = DMGetLocalVector(dmMetric, &metric);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),834,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
835 | /* N is the target size */ |
836 | N = adaptor->Nadapt >= 0 ? adaptor->Nadapt : PetscPowRealInt(adaptor->refinementFactor, dim)*((PetscReal) (vEnd - vStart)); |
837 | if (adaptor->monitor) {ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "N_orig: %D N_adapt: %g\n", vEnd - vStart, N);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),837,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
838 | /* |H| means take the absolute value of eigenvalues */ |
839 | ierr = VecGetArray(xHess, &H);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),839,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
840 | ierr = VecGetArray(metric, &M);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),840,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
841 | for (v = vStart; v < vEnd; ++v) { |
842 | PetscScalar *Hp; |
843 | |
844 | ierr = DMPlexPointLocalRef(dmHess, v, H, &Hp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),844,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
845 | ierr = DMAdaptorModifyHessian_Private(coordDim, adaptor->h_min, adaptor->h_max, Hp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),845,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
846 | } |
847 | /* Pointwise on vertices M(x) = N^{2/d} (\int_\Omega det(|H|)^{p/(2p+d)})^{-2/d} det(|H|)^{-1/(2p+d)} |H| for L_p */ |
848 | ierr = PetscDSSetObjective(probHess, 0, detHFunc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),848,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
849 | ierr = DMPlexComputeIntegralFEM(dmHess, xHess, &integral, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),849,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
850 | for (v = vStart; v < vEnd; ++v) { |
851 | const PetscInt p = 1; |
852 | const PetscScalar *Hp; |
853 | PetscScalar *Mp; |
854 | PetscReal detH, fact; |
855 | PetscInt i; |
856 | |
857 | ierr = DMPlexPointLocalRead(dmHess, v, H, (void *) &Hp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),857,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
858 | ierr = DMPlexPointLocalRef(dmMetric, v, M, &Mp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),858,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
859 | if (dim == 2) DMPlex_Det2D_Scalar_Internal(&detH, Hp); |
860 | else if (dim == 3) DMPlex_Det3D_Scalar_Internal(&detH, Hp); |
861 | else SETERRQ1(PetscObjectComm((PetscObject) adaptor), PETSC_ERR_SUP, "Dimension %d not supported", dim)return PetscError(PetscObjectComm((PetscObject) adaptor),861, __func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,56,PETSC_ERROR_INITIAL,"Dimension %d not supported",dim); |
862 | fact = PetscPowReal(N, 2.0/dim)pow(N,2.0/dim) * PetscPowReal(PetscRealPart(integral), -2.0/dim)pow((integral),-2.0/dim) * PetscPowReal(PetscAbsReal(detH), -1.0/(2*p+dim))pow(fabs(detH),-1.0/(2*p+dim)); |
863 | #if 0 |
864 | ierr = PetscPrintf(PETSC_COMM_SELF((MPI_Comm)0x44000001), "fact: %g integral: %g |detH|: %g termA: %g termB: %g\n", fact, integral, PetscAbsReal(detH)fabs(detH), PetscPowReal(integral, -2.0/dim)pow(integral,-2.0/dim), PetscPowReal(PetscAbsReal(detH), -1.0/(2*p+dim))pow(fabs(detH),-1.0/(2*p+dim)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),864,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
865 | ierr = DMPrintCellMatrix(v, "H", coordDim, coordDim, Hp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),865,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
866 | #endif |
867 | for (i = 0; i < Nd; ++i) { |
868 | Mp[i] = fact * Hp[i]; |
869 | } |
870 | } |
871 | ierr = VecRestoreArray(xHess, &H);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),871,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
872 | ierr = VecRestoreArray(metric, &M);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),872,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
873 | /* Adapt DM from metric */ |
874 | ierr = DMGetLabel(dm, "marker", &bdLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),874,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
875 | ierr = DMAdaptMetric(dm, metric, bdLabel, &odm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),875,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
876 | adapted = PETSC_TRUE; |
877 | /* Cleanup */ |
878 | ierr = DMRestoreLocalVector(dmMetric, &metric);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),878,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
879 | ierr = DMDestroy(&dmMetric);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),879,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
880 | ierr = DMRestoreGlobalVector(dmHess, &xHess);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),880,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
881 | ierr = DMRestoreGlobalVector(dmGrad, &xGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),881,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
882 | ierr = DMDestroy(&dmGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),882,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
883 | ierr = DMDestroy(&dmHess);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),883,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
884 | } |
885 | break; |
886 | default: SETERRQ1(comm, PETSC_ERR_ARG_WRONG, "Invalid adaptation type: %D", adaptor->adaptCriterion)return PetscError(comm,886,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,62,PETSC_ERROR_INITIAL,"Invalid adaptation type: %D",adaptor ->adaptCriterion); |
887 | } |
888 | ierr = DMAdaptorPostAdapt(adaptor);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),888,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
889 | ierr = DMRestoreLocalVector(dm, &locX);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),889,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
890 | /* If DM was adapted, replace objects and recreate solution */ |
891 | if (adapted) { |
892 | const char *name; |
893 | |
894 | ierr = PetscObjectGetName((PetscObject) dm, &name);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),894,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
895 | ierr = PetscObjectSetName((PetscObject) odm, name);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),895,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
896 | /* Reconfigure solver */ |
897 | ierr = SNESReset(adaptor->snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),897,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
898 | ierr = SNESSetDM(adaptor->snes, odm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),898,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
899 | ierr = DMAdaptorSetSolver(adaptor, adaptor->snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),899,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
900 | ierr = DMPlexSetSNESLocalFEM(odm, ctx, ctx, ctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),900,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
901 | ierr = SNESSetFromOptions(adaptor->snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),901,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
902 | /* Transfer system */ |
903 | ierr = DMCopyDisc(adaptor->idm, odm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),903,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
904 | /* Transfer solution */ |
905 | ierr = DMCreateGlobalVector(odm, &ox);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),905,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
906 | ierr = PetscObjectGetName((PetscObject) x, &name);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),906,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
907 | ierr = PetscObjectSetName((PetscObject) ox, name);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),907,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
908 | ierr = DMAdaptorTransferSolution(adaptor, dm, x, odm, ox);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),908,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
909 | /* Cleanup adaptivity info */ |
910 | if (adaptIter > 0) {ierr = PetscViewerASCIIPopTab(PETSC_VIEWER_STDOUT_(comm));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),910,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} |
911 | ierr = DMForestSetAdaptivityForest(dm, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),911,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* clear internal references to the previous dm */ |
912 | ierr = DMDestroy(&dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),912,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
913 | ierr = VecDestroy(&x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),913,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
914 | *adm = odm; |
915 | *ax = ox; |
916 | } else { |
917 | *adm = dm; |
918 | *ax = x; |
919 | adaptIter = numAdapt; |
920 | } |
921 | if (adaptIter < numAdapt-1) { |
922 | ierr = DMViewFromOptions(odm, NULL((void*)0), "-dm_adapt_iter_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),922,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
923 | ierr = VecViewFromOptions(ox, NULL((void*)0), "-sol_adapt_iter_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),923,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
924 | } |
925 | } |
926 | ierr = DMViewFromOptions(*adm, NULL((void*)0), "-dm_adapt_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),926,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
927 | ierr = VecViewFromOptions(*ax, NULL((void*)0), "-sol_adapt_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),927,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
928 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
929 | } |
930 | |
931 | /*@ |
932 | DMAdaptorAdapt - Creates a new DM that is adapted to the problem |
933 | |
934 | Not collective |
935 | |
936 | Input Parameter: |
937 | + adaptor - The DMAdaptor object |
938 | . x - The global approximate solution |
939 | - strategy - The adaptation strategy |
940 | |
941 | Output Parameters: |
942 | + adm - The adapted DM |
943 | - ax - The adapted solution |
944 | |
945 | Options database keys: |
946 | . -snes_adapt <strategy> : initial, sequential, multigrid |
947 | . -adapt_gradient_view : View the Clement interpolant of the solution gradient |
948 | . -adapt_hessian_view : View the Clement interpolant of the solution Hessian |
949 | . -adapt_metric_view : View the metric tensor for adaptive mesh refinement |
950 | |
951 | Note: The available adaptation strategies are: |
952 | $ 1) Adapt the intial mesh until a quality metric, e,g, a priori error bound, is satisfied |
953 | $ 2) Solve the problem on a series of adapted meshes until a quality metric, e.g. a posteriori error bound, is satisfied |
954 | $ 3) Solve the problem on a hierarchy of adapted meshes generated to satisfy a quality metric using multigrid |
955 | |
956 | Level: intermediate |
957 | |
958 | .keywords: DMAdaptor, convergence |
959 | .seealso: DMAdaptorSetSolver(), DMAdaptorCreate(), DMAdaptorAdapt() |
960 | @*/ |
961 | PetscErrorCode DMAdaptorAdapt(DMAdaptor adaptor, Vec x, DMAdaptationStrategy strategy, DM *adm, Vec *ax) |
962 | { |
963 | PetscErrorCode ierr; |
964 | |
965 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c"; petscstack ->line[petscstack->currentsize] = 965; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); |
966 | switch (strategy) |
967 | { |
968 | case DM_ADAPTATION_INITIAL: |
969 | ierr = DMAdaptorAdapt_Sequence_Private(adaptor, x, PETSC_FALSE, adm, ax);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),969,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
970 | break; |
971 | case DM_ADAPTATION_SEQUENTIAL: |
972 | ierr = DMAdaptorAdapt_Sequence_Private(adaptor, x, PETSC_TRUE, adm, ax);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),972,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); |
973 | break; |
974 | default: SETERRQ1(PetscObjectComm((PetscObject) adaptor), PETSC_ERR_ARG_WRONG, "Unrecognized adaptation strategy %d", strategy)return PetscError(PetscObjectComm((PetscObject) adaptor),974, __func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmadapt.c" ,62,PETSC_ERROR_INITIAL,"Unrecognized adaptation strategy %d" ,strategy); |
975 | } |
976 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); |
977 | } |