"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Kernel/Operation_PostOperation.cpp" between
getdp-3.4.0-source.tgz and getdp-3.5.0-source.tgz

About: GetDP is a general finite element solver using mixed elements to discretize de Rham-type complexes in one, two and three dimensions.

Operation_PostOperation.cpp  (getdp-3.4.0-source.tgz):Operation_PostOperation.cpp  (getdp-3.5.0-source.tgz)
// GetDP - Copyright (C) 1997-2021 P. Dular and C. Geuzaine, University of Liege // GetDP - Copyright (C) 1997-2022 P. Dular and C. Geuzaine, University of Liege
// //
// See the LICENSE.txt file for license information. Please report all // See the LICENSE.txt file for license information. Please report all
// issues on https://gitlab.onelab.info/getdp/getdp/issues. // issues on https://gitlab.onelab.info/getdp/getdp/issues.
// //
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include "GetDPConfig.h" #include "GetDPConfig.h"
skipping to change at line 27 skipping to change at line 27
#include "Message.h" #include "Message.h"
#include "MallocUtils.h" #include "MallocUtils.h"
extern struct CurrentData Current; extern struct CurrentData Current;
extern struct Problem Problem_S; extern struct Problem Problem_S;
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* O p e r a t i o n _ P o s t O p e r a t i o n */ /* O p e r a t i o n _ P o s t O p e r a t i o n */
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
void Operation_PostOperation(Resolution *Resolution_P, void Operation_PostOperation(Resolution *Resolution_P, DofData *DofData_P0,
DofData *DofData_P0, GeoData *GeoData_P0, List_T *PostOperationNames)
GeoData *GeoData_P0,
List_T *PostOperationNames)
{ {
double Save_Time, Save_TimeImag, Save_TimeStep; double Save_Time, Save_TimeImag, Save_TimeStep;
char *str; char *str;
int i, j, k; int i, j, k;
Element *Save_Element; Element *Save_Element;
PostOperation *PostOperation_P; PostOperation *PostOperation_P;
PostProcessing *PostProcessing_P ; PostProcessing *PostProcessing_P;
Save_Time = Current.Time ; Save_Time = Current.Time;
Save_TimeImag = Current.TimeImag ; Save_TimeImag = Current.TimeImag;
Save_TimeStep = Current.TimeStep ; Save_TimeStep = Current.TimeStep;
Save_Element = Current.Element; Save_Element = Current.Element;
for(int i=0 ; i<List_Nbr(PostOperationNames); i++){ for(int i = 0; i < List_Nbr(PostOperationNames); i++) {
str = *(char**)List_Pointer(PostOperationNames, i); str = *(char **)List_Pointer(PostOperationNames, i);
if((j = List_ISearchSeq(Problem_S.PostOperation, str, fcmp_PostOperation_Nam if((j = List_ISearchSeq(Problem_S.PostOperation, str,
e)) < 0){ fcmp_PostOperation_Name)) < 0) {
Message::Warning("Unknown PostOperation '%s'", str) ; Message::Warning("Unknown PostOperation '%s'", str);
} }
else{ else {
PostOperation_P = (struct PostOperation*) PostOperation_P =
List_Pointer(Problem_S.PostOperation, j) ; (struct PostOperation *)List_Pointer(Problem_S.PostOperation, j);
PostProcessing_P = (struct PostProcessing *) PostProcessing_P = (struct PostProcessing *)List_Pointer(
List_Pointer(Problem_S.PostProcessing, PostOperation_P->PostProcessingIn Problem_S.PostProcessing, PostOperation_P->PostProcessingIndex);
dex) ;
Current.PostOpDataIndex = i; Current.PostOpDataIndex = i;
Treatment_PostOperation(Resolution_P, DofData_P0, Treatment_PostOperation(
(struct DefineSystem *)List_Pointer(Resolution_P->DefineSystem, 0), Resolution_P, DofData_P0,
GeoData_P0, PostProcessing_P, PostOperation_P) ; (struct DefineSystem *)List_Pointer(Resolution_P->DefineSystem, 0),
GeoData_P0, PostProcessing_P, PostOperation_P);
} }
} }
/* the post-processing can (and usually will) change the current /* the post-processing can (and usually will) change the current
timestep, current time and current solution pointers: we need timestep, current time and current solution pointers: we need
to reset them */ to reset them */
Current.Time = Save_Time ; Current.Time = Save_Time;
Current.TimeImag = Save_TimeImag ; Current.TimeImag = Save_TimeImag;
Current.TimeStep = Save_TimeStep ; Current.TimeStep = Save_TimeStep;
for (k = 0 ; k < Current.NbrSystem ; k++){ for(k = 0; k < Current.NbrSystem; k++) {
i = List_Nbr((Current.DofData_P0+k)->Solutions) - 1; i = List_Nbr((Current.DofData_P0 + k)->Solutions) - 1;
if(i >= 0) if(i >= 0)
(Current.DofData_P0+k)->CurrentSolution = (struct Solution*) (Current.DofData_P0 + k)->CurrentSolution =
List_Pointer((Current.DofData_P0+k)->Solutions, i); (struct Solution *)List_Pointer((Current.DofData_P0 + k)->Solutions, i);
} }
Current.Element = Save_Element; Current.Element = Save_Element;
Current.PostOpDataIndex = -1; Current.PostOpDataIndex = -1;
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* I n i t L E P o s t O p e r a t i o n */ /* I n i t L E P o s t O p e r a t i o n */
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
void InitLEPostOperation(Resolution *Resolution_P, void InitLEPostOperation(Resolution *Resolution_P, DofData *DofData_P0,
DofData *DofData_P0, GeoData *GeoData_P0, List_T *LEPostOp_L,
GeoData *GeoData_P0, List_T *LEPostOpNames_L, List_T *PostOpSolution_L)
List_T *LEPostOp_L,
List_T *LEPostOpNames_L,
List_T *PostOpSolution_L)
{ {
int NbrPostOps, Index, NbrPostSubOperation, PostOpSolLength int NbrPostOps, Index, NbrPostSubOperation, PostOpSolLength;
; int *Save_Format_P, *Save_LastTimeStepOnly_P;
int *Save_Format_P, *Save_LastTimeStepOnly_P; char **Save_FileOut_P;
char **Save_FileOut_P; PostOpSolutions *PostOpSolutions_P, PostOpSolutions_S;
PostOpSolutions *PostOpSolutions_P, PostOpSolutions_S;
LoopErrorPostOperation *LEPostOp_P; LoopErrorPostOperation *LEPostOp_P;
PostSubOperation *PostSubOperation_P; PostSubOperation *PostSubOperation_P;
List_T *PostSubOperation_L; List_T *PostSubOperation_L;
gVector PostOpSolution_S; gVector PostOpSolution_S;
Current.PostOpData_L = NULL; Current.PostOpData_L = NULL;
NbrPostOps = List_Nbr(LEPostOp_L); NbrPostOps = List_Nbr(LEPostOp_L);
if (NbrPostOps) { if(NbrPostOps) {
Current.PostOpData_L = List_Create(NbrPostOps,1,sizeof(PostOpSolutions)); Current.PostOpData_L = List_Create(NbrPostOps, 1, sizeof(PostOpSolutions));
for (int i=0; i < NbrPostOps; i++) { for(int i = 0; i < NbrPostOps; i++) {
LEPostOp_P = (struct LoopErrorPostOperation*)List_Pointer(LEPostOp_L, i); LEPostOp_P = (struct LoopErrorPostOperation *)List_Pointer(LEPostOp_L, i);
Index = List_ISearchSeq(Problem_S.PostOperation, LEPostOp_P->PostOperation Index =
Name, List_ISearchSeq(Problem_S.PostOperation, LEPostOp_P->PostOperationName,
fcmp_PostOperation_Name); fcmp_PostOperation_Name);
LEPostOp_P->PostOperationIndex = Index; LEPostOp_P->PostOperationIndex = Index;
if(Index < 0) if(Index < 0)
Message::Error("Unknown PostOperation %s in TimeLoopAdaptive", Message::Error("Unknown PostOperation %s in TimeLoopAdaptive",
LEPostOp_P->PostOperationName); LEPostOp_P->PostOperationName);
PostOpSolutions_S.PostOperation_P = (struct PostOperation*) PostOpSolutions_S.PostOperation_P =
List_Pointer(Problem_S.PostOperation, Index) ; (struct PostOperation *)List_Pointer(Problem_S.PostOperation, Index);
PostSubOperation_L = PostOpSolutions_S.PostOperation_P->PostSubOperation; PostSubOperation_L = PostOpSolutions_S.PostOperation_P->PostSubOperation;
NbrPostSubOperation = List_Nbr(PostSubOperation_L); NbrPostSubOperation = List_Nbr(PostSubOperation_L);
if (NbrPostSubOperation) { if(NbrPostSubOperation) {
LEPostOp_P->Save_Format_L = List_Create(NbrPostSubOperation,2, LEPostOp_P->Save_Format_L =
sizeof(int)); List_Create(NbrPostSubOperation, 2, sizeof(int));
LEPostOp_P->Save_LastTimeStepOnly_L = List_Create(NbrPostSubOperation, LEPostOp_P->Save_LastTimeStepOnly_L =
2,sizeof(int)); List_Create(NbrPostSubOperation, 2, sizeof(int));
LEPostOp_P->Save_FileOut_L = List_Create(NbrPostSubOperation, LEPostOp_P->Save_FileOut_L =
2,sizeof(char *)); List_Create(NbrPostSubOperation, 2, sizeof(char *));
} }
for (int j=0; j<NbrPostSubOperation; j++) { for(int j = 0; j < NbrPostSubOperation; j++) {
PostSubOperation_P = (struct PostSubOperation*) PostSubOperation_P =
List_Pointer(PostSubOperation_L, j); (struct PostSubOperation *)List_Pointer(PostSubOperation_L, j);
Save_Format_P = &PostSubOperation_P->Format; Save_Format_P = &PostSubOperation_P->Format;
Save_LastTimeStepOnly_P = &PostSubOperation_P->LastTimeStepOnly; Save_LastTimeStepOnly_P = &PostSubOperation_P->LastTimeStepOnly;
Save_FileOut_P = &PostSubOperation_P->FileOut; Save_FileOut_P = &PostSubOperation_P->FileOut;
List_Add(LEPostOp_P->Save_Format_L, Save_Format_P); List_Add(LEPostOp_P->Save_Format_L, Save_Format_P);
List_Add(LEPostOp_P->Save_LastTimeStepOnly_L, Save_LastTimeStepOnly_P); List_Add(LEPostOp_P->Save_LastTimeStepOnly_L, Save_LastTimeStepOnly_P);
List_Add(LEPostOp_P->Save_FileOut_L, Save_FileOut_P); List_Add(LEPostOp_P->Save_FileOut_L, Save_FileOut_P);
*Save_Format_P = FORMAT_LOOP_ERROR; *Save_Format_P = FORMAT_LOOP_ERROR;
*Save_LastTimeStepOnly_P = 1; *Save_LastTimeStepOnly_P = 1;
*Save_FileOut_P = NULL; *Save_FileOut_P = NULL;
} }
PostOpSolutions_S.Solutions_L = List_Create(2,2,sizeof(Solution)); PostOpSolutions_S.Solutions_L = List_Create(2, 2, sizeof(Solution));
List_Add(Current.PostOpData_L, &PostOpSolutions_S); List_Add(Current.PostOpData_L, &PostOpSolutions_S);
List_Add(LEPostOpNames_L, &LEPostOp_P->PostOperationName); List_Add(LEPostOpNames_L, &LEPostOp_P->PostOperationName);
} }
// Execute the PostOperations // Execute the PostOperations
Operation_PostOperation(Resolution_P, DofData_P0, GeoData_P0, LEPostOpNames_ Operation_PostOperation(Resolution_P, DofData_P0, GeoData_P0,
L); LEPostOpNames_L);
// Creating vectors for the PostOperation-solution // Creating vectors for the PostOperation-solution
for (int i=0; i < NbrPostOps; i++) { for(int i = 0; i < NbrPostOps; i++) {
PostOpSolutions_P = (struct PostOpSolutions*) PostOpSolutions_P =
List_Pointer(Current.PostOpData_L, i); (struct PostOpSolutions *)List_Pointer(Current.PostOpData_L, i);
LinAlg_GetVectorSize LinAlg_GetVectorSize(
(&((struct Solution*)List_Pointer(PostOpSolutions_P->Solutions_L, 0))->x &((struct Solution *)List_Pointer(PostOpSolutions_P->Solutions_L, 0))
, ->x,
&PostOpSolLength); &PostOpSolLength);
LinAlg_CreateVector(&PostOpSolution_S, &DofData_P0->Solver, PostOpSolLengt LinAlg_CreateVector(&PostOpSolution_S, &DofData_P0->Solver,
h); PostOpSolLength);
List_Add(PostOpSolution_L, &PostOpSolution_S); List_Add(PostOpSolution_L, &PostOpSolution_S);
} }
} }
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* F r e e _ U n u s e d P o s t O p e r a t i o n R e s u l t s */ /* F r e e _ U n u s e d P o s t O p e r a t i o n R e s u l t s */
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
void Free_UnusedPOresults() void Free_UnusedPOresults()
{ {
struct Solution *Solution_P; struct Solution *Solution_P;
int index = -1; int index = -1;
PostOpSolutions *PostOpSolutions_P; PostOpSolutions *PostOpSolutions_P;
for(int i = 0; i < List_Nbr(Current.PostOpData_L); i++) { for(int i = 0; i < List_Nbr(Current.PostOpData_L); i++) {
PostOpSolutions_P = (struct PostOpSolutions*) PostOpSolutions_P =
List_Pointer(Current.PostOpData_L, i); (struct PostOpSolutions *)List_Pointer(Current.PostOpData_L, i);
// We store 1 solution too much (to allow for an imbricated iterative loop) // We store 1 solution too much (to allow for an imbricated iterative loop)
switch (Current.TypeTime) { switch(Current.TypeTime) {
case TIME_THETA : case TIME_THETA:
index = List_Nbr(PostOpSolutions_P->Solutions_L)-4 ; index = List_Nbr(PostOpSolutions_P->Solutions_L) - 4;
// Fore TimeLoopAdaptive (Trapezoidal) we need 3 past solutions for the pr // Fore TimeLoopAdaptive (Trapezoidal) we need 3 past solutions for the
edictor // predictor
index = Message::GetOperatingInTimeLoopAdaptive() ? index - 1 : index; index = Message::GetOperatingInTimeLoopAdaptive() ? index - 1 : index;
break; break;
case TIME_GEAR : case TIME_GEAR:
// With -9 we store 7 past solutions (for Gear_6) // With -9 we store 7 past solutions (for Gear_6)
index = List_Nbr(PostOpSolutions_P->Solutions_L)-9 ; index = List_Nbr(PostOpSolutions_P->Solutions_L) - 9;
break; break;
case TIME_NEWMARK : case TIME_NEWMARK:
index = List_Nbr(PostOpSolutions_P->Solutions_L)-4 ; index = List_Nbr(PostOpSolutions_P->Solutions_L) - 4;
break; break;
} }
if(index >= 0){ if(index >= 0) {
Solution_P = (struct Solution*) Solution_P =
List_Pointer(PostOpSolutions_P->Solutions_L, index); (struct Solution *)List_Pointer(PostOpSolutions_P->Solutions_L, index);
if(Solution_P->SolutionExist){ if(Solution_P->SolutionExist) {
Message::Info("Freeing PostOperationResult %d", index); Message::Info("Freeing PostOperationResult %d", index);
LinAlg_DestroyVector(&Solution_P->x); LinAlg_DestroyVector(&Solution_P->x);
if (Solution_P->TimeFunctionValues) if(Solution_P->TimeFunctionValues) Free(Solution_P->TimeFunctionValues);
Free(Solution_P->TimeFunctionValues); Solution_P->SolutionExist = 0;
Solution_P->SolutionExist = 0 ;
} }
} }
} }
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* F r e e _ A l l P o s t O p e r a t i o n R e s u l t s */ /* F r e e _ A l l P o s t O p e r a t i o n R e s u l t s */
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
void Free_AllPOresults() void Free_AllPOresults()
{ {
PostOpSolutions *PostOpSolutions_P; PostOpSolutions *PostOpSolutions_P;
Solution *Solution_P; Solution *Solution_P;
for (int i=0; i < List_Nbr(Current.PostOpData_L); i++) { for(int i = 0; i < List_Nbr(Current.PostOpData_L); i++) {
PostOpSolutions_P = (struct PostOpSolutions*)List_Pointer(Current.PostOpData PostOpSolutions_P =
_L, i); (struct PostOpSolutions *)List_Pointer(Current.PostOpData_L, i);
for (int j=0; j < List_Nbr(PostOpSolutions_P->Solutions_L); j++) { for(int j = 0; j < List_Nbr(PostOpSolutions_P->Solutions_L); j++) {
Solution_P = (struct Solution*)List_Pointer(PostOpSolutions_P->Solutions_L Solution_P =
, j); (struct Solution *)List_Pointer(PostOpSolutions_P->Solutions_L, j);
if (Solution_P->SolutionExist) if(Solution_P->SolutionExist) LinAlg_DestroyVector(&Solution_P->x);
LinAlg_DestroyVector(&Solution_P->x); if(Solution_P->TimeFunctionValues) Free(Solution_P->TimeFunctionValues);
if (Solution_P->TimeFunctionValues)
Free(Solution_P->TimeFunctionValues);
} }
List_Delete(PostOpSolutions_P->Solutions_L); List_Delete(PostOpSolutions_P->Solutions_L);
} }
List_Delete(Current.PostOpData_L); List_Delete(Current.PostOpData_L);
Current.PostOpData_L = NULL; Current.PostOpData_L = NULL;
Current.PostOpDataIndex = -1; Current.PostOpDataIndex = -1;
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* C l e a r L E P o s t O p e r a t i o n */ /* C l e a r L E P o s t O p e r a t i o n */
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
void ClearLEPostOperation(Resolution *Resolution_P, void ClearLEPostOperation(Resolution *Resolution_P, DofData *DofData_P0,
DofData *DofData_P0, GeoData *GeoData_P0, List_T *LEPostOp_L,
GeoData *GeoData_P0, List_T *LEPostOpNames_L, List_T *PostOpSolution_L,
List_T *LEPostOp_L, bool Delete_LEPostOp_L)
List_T *LEPostOpNames_L,
List_T *PostOpSolution_L,
bool Delete_LEPostOp_L)
{ {
int Index, NbrPostSubOperation; int Index, NbrPostSubOperation;
int *Format_P, *LastTimeStepOnly_P; int *Format_P, *LastTimeStepOnly_P;
char **FileOut_P; char **FileOut_P;
LoopErrorPostOperation *LEPostOp_P; LoopErrorPostOperation *LEPostOp_P;
PostSubOperation *PostSubOperation_P; PostSubOperation *PostSubOperation_P;
List_T *PostSubOperation_L; List_T *PostSubOperation_L;
for(int i = 0; i < List_Nbr(LEPostOp_L); i++) { for(int i = 0; i < List_Nbr(LEPostOp_L); i++) {
LEPostOp_P = (struct LoopErrorPostOperation*)List_Pointer(LEPostOp_L, i); LEPostOp_P = (struct LoopErrorPostOperation *)List_Pointer(LEPostOp_L, i);
NbrPostSubOperation = List_Nbr(LEPostOp_P->Save_Format_L); NbrPostSubOperation = List_Nbr(LEPostOp_P->Save_Format_L);
Index = LEPostOp_P->PostOperationIndex; Index = LEPostOp_P->PostOperationIndex;
PostSubOperation_L = ((struct PostOperation*) PostSubOperation_L =
List_Pointer(Problem_S.PostOperation, Index)) ((struct PostOperation *)List_Pointer(Problem_S.PostOperation, Index))
->PostSubOperation; ->PostSubOperation;
// Restore variables Format, LastTimeStepOnly and FileOut of all used PostOp // Restore variables Format, LastTimeStepOnly and FileOut of all used
erations // PostOperations
for (int j=0; j<NbrPostSubOperation; j++) { for(int j = 0; j < NbrPostSubOperation; j++) {
PostSubOperation_P = (struct PostSubOperation*)List_Pointer(PostSubOperati PostSubOperation_P =
on_L, j); (struct PostSubOperation *)List_Pointer(PostSubOperation_L, j);
Format_P = &PostSubOperation_P->Format; Format_P = &PostSubOperation_P->Format;
LastTimeStepOnly_P = &PostSubOperation_P->LastTimeStepOnly; LastTimeStepOnly_P = &PostSubOperation_P->LastTimeStepOnly;
FileOut_P = &PostSubOperation_P->FileOut; FileOut_P = &PostSubOperation_P->FileOut;
List_Read(LEPostOp_P->Save_Format_L, j, Format_P); List_Read(LEPostOp_P->Save_Format_L, j, Format_P);
List_Read(LEPostOp_P->Save_LastTimeStepOnly_L, j, LastTimeStepOnly_P); List_Read(LEPostOp_P->Save_LastTimeStepOnly_L, j, LastTimeStepOnly_P);
List_Read(LEPostOp_P->Save_FileOut_L, j, FileOut_P); List_Read(LEPostOp_P->Save_FileOut_L, j, FileOut_P);
} }
if (Delete_LEPostOp_L) if(Delete_LEPostOp_L) free(LEPostOp_P->PostOperationName);
free(LEPostOp_P->PostOperationName); LinAlg_DestroyVector((gVector *)List_Pointer(PostOpSolution_L, i));
LinAlg_DestroyVector((gVector*)List_Pointer(PostOpSolution_L, i));
} }
if (Delete_LEPostOp_L) if(Delete_LEPostOp_L) List_Delete(LEPostOp_L);
List_Delete(LEPostOp_L);
List_Delete(PostOpSolution_L); List_Delete(PostOpSolution_L);
Free_AllPOresults(); Free_AllPOresults();
List_Delete(LEPostOpNames_L); List_Delete(LEPostOpNames_L);
} }
 End of changes. 38 change blocks. 
137 lines changed or deleted 123 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)