Bug Summary

File:snes/utils/dmadapt.c
Warning:line 650, column 7
Value stored to 'qc' is never read

Annotated Source Code

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