Skip to content

Commit 3265663

Browse files
committed
Get error when try to create ics for pressure
1 parent 4ebe4aa commit 3265663

16 files changed

+153
-75
lines changed

examples/Hdiv-mixed/include/setup-libceed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Convert PETSc MemType to libCEED MemType
77
CeedMemType MemTypeP2C(PetscMemType mtype);
88
// Destroy libCEED objects
9-
PetscErrorCode CeedDataDestroy(CeedData ceed_data);
9+
PetscErrorCode CeedDataDestroy(CeedData ceed_data, ProblemData problem_data);
1010
// Utility function - essential BC dofs are encoded in closure indices as -(i+1)
1111
PetscInt Involute(PetscInt i);
1212
// Utility function to create local CEED restriction from DMPlex

examples/Hdiv-mixed/include/structs.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ struct OperatorApplyContext_ {
3838
// libCEED data struct
3939
typedef struct CeedData_ *CeedData;
4040
struct CeedData_ {
41-
CeedBasis basis_x, basis_u, basis_p, basis_u_face;
41+
CeedBasis basis_x, basis_u, basis_p, basis_u_face, basis_xc;
4242
CeedElemRestriction elem_restr_x, elem_restr_u, elem_restr_U_i,
4343
elem_restr_p, elem_restr_p_i;
44-
CeedQFunction qf_residual, qf_jacobian, qf_error, qf_ics, qf_true;
45-
CeedOperator op_residual, op_jacobian, op_error, op_ics, op_true;
46-
CeedVector x_ceed, y_ceed, x_coord, x0_ceed, x_t_ceed;
44+
CeedQFunction qf_residual, qf_jacobian, qf_error, qf_ics_u, qf_ics_p;
45+
CeedOperator op_residual, op_jacobian, op_error, op_ics_u, op_ics_p;
46+
CeedVector x_ceed, y_ceed, x_coord, u0_ceed, x_t_ceed;
4747
OperatorApplyContext ctx_residual, ctx_jacobian, ctx_error, ctx_residual_ut;
4848
CeedInt num_elem;
4949
};
5050

5151
// Problem specific data
5252
typedef struct ProblemData_ *ProblemData;
5353
struct ProblemData_ {
54-
CeedQFunctionUser true_solution, residual, jacobian, error, ics,
54+
CeedQFunctionUser true_solution, residual, jacobian, error, ics_u, ics_p,
5555
bc_pressure;
5656
const char *true_solution_loc, *residual_loc, *jacobian_loc,
57-
*error_loc, *bc_pressure_loc, *ics_loc;
57+
*error_loc, *bc_pressure_loc, *ics_u_loc, *ics_p_loc;
5858
CeedQuadMode quadrature_mode;
5959
CeedInt elem_node, dim, q_data_size_face;
6060
CeedQFunctionContext qfunction_context;

examples/Hdiv-mixed/main.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ int main(int argc, char **argv) {
143143
// ---------------------------------------------------------------------------
144144
// Create global initial conditions
145145
// ---------------------------------------------------------------------------
146-
CreateInitialConditions(dm, ceed_data, U_loc, U);
147-
VecView(U, PETSC_VIEWER_STDOUT_WORLD);
146+
//CreateInitialConditions(dm, ceed_data, U_loc, U);
147+
//VecView(U, PETSC_VIEWER_STDOUT_WORLD);
148148
}
149149

150150
if (!problem_data->has_ts) {
@@ -192,6 +192,7 @@ int main(int argc, char **argv) {
192192
PetscCall( DMDestroy(&dm) );
193193
PetscCall( VecDestroy(&U) );
194194
PetscCall( VecDestroy(&U_loc) );
195+
PetscCall( CeedDataDestroy(ceed_data, problem_data) );
195196

196197
// -- Function list
197198
PetscCall( PetscFunctionListDestroy(&app_ctx->problems) );
@@ -203,9 +204,6 @@ int main(int argc, char **argv) {
203204

204205
// Free libCEED objects
205206
//CeedVectorDestroy(&bc_pressure);
206-
//PetscCall( CeedDataDestroy(ceed_data) );
207-
CeedQFunctionDestroy(&ceed_data->qf_true);
208-
CeedOperatorDestroy(&ceed_data->op_true);
209207
CeedDestroy(&ceed);
210208

211209
return PetscFinalize();

examples/Hdiv-mixed/problems/richard2d.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ PetscErrorCode Hdiv_RICHARD2D(Ceed ceed, ProblemData problem_data, void *ctx) {
3939
problem_data->elem_node = 4;
4040
problem_data->q_data_size_face = 3;
4141
problem_data->quadrature_mode = CEED_GAUSS;
42-
problem_data->ics = RichardICs2D;
43-
problem_data->ics_loc = RichardICs2D_loc;
42+
problem_data->ics_u = RichardICsU2D;
43+
problem_data->ics_u_loc = RichardICsU2D_loc;
44+
problem_data->ics_p = RichardICsP2D;
45+
problem_data->ics_p_loc = RichardICsP2D_loc;
4446
problem_data->true_solution = RichardTrue2D;
4547
problem_data->true_solution_loc = RichardTrue2D_loc;
4648
//problem_data->residual = RichardSystem2D;
@@ -97,6 +99,7 @@ PetscErrorCode Hdiv_RICHARD2D(Ceed ceed, ProblemData problem_data, void *ctx) {
9799
CeedQFunctionContextRegisterDouble(richard_context, "final_time",
98100
offsetof(struct RICHARDContext_, t_final), 1, "final time");
99101
problem_data->qfunction_context = richard_context;
102+
PetscCall( PetscFree(richard_ctx) );
100103

101104
PetscFunctionReturn(0);
102105
}

examples/Hdiv-mixed/qfunctions/darcy-error2d.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define DARCY_ERROR2D_H
2222

2323
#include <math.h>
24+
#include <ceed.h>
2425
#include "utils.h"
2526

2627
// -----------------------------------------------------------------------------

examples/Hdiv-mixed/qfunctions/darcy-error3d.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define DARCY_ERROR3D_H
2222

2323
#include <math.h>
24+
#include <ceed.h>
2425
#include "utils.h"
2526

2627

examples/Hdiv-mixed/qfunctions/darcy-system2d.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define DARCY_SYSTEM2D_H
2222

2323
#include <math.h>
24-
#include "ceed/ceed-f64.h"
24+
#include <ceed.h>
2525
#include "utils.h"
2626

2727
// -----------------------------------------------------------------------------

examples/Hdiv-mixed/qfunctions/darcy-system3d.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define DARCY_SYSTEM3D_H
2222

2323
#include <math.h>
24+
#include <ceed.h>
2425
#include "utils.h"
2526

2627
// -----------------------------------------------------------------------------

examples/Hdiv-mixed/qfunctions/darcy-true2d.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define DARCY_TRUE2D_H
2222

2323
#include <math.h>
24+
#include <ceed.h>
2425
#include "utils.h"
2526

2627
// -----------------------------------------------------------------------------

examples/Hdiv-mixed/qfunctions/darcy-true3d.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define DARCY_TRUE3D_H
2222

2323
#include <math.h>
24+
#include <ceed.h>
2425
#include "utils.h"
2526

2627
// -----------------------------------------------------------------------------

examples/Hdiv-mixed/qfunctions/pressure-boundary2d.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#ifndef pressure_bc_2d_h
1212
#define pressure_bc_2d_h
1313

14+
#include <math.h>
15+
#include <ceed.h>
16+
#include "utils.h"
1417
// -----------------------------------------------------------------------------
1518
// Strong form:
1619
// u = -\grad(p) on \Omega

examples/Hdiv-mixed/qfunctions/pressure-boundary3d.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#ifndef pressure_bc_3d_h
1212
#define pressure_bc_3d_h
1313

14+
#include <math.h>
15+
#include <ceed.h>
16+
#include "utils.h"
1417
// -----------------------------------------------------------------------------
1518
// Strong form:
1619
// u = -\grad(p) on \Omega

examples/Hdiv-mixed/qfunctions/richard-system2d.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define RICHARD_SYSTEM2D_H
2222

2323
#include <math.h>
24+
#include <ceed.h>
2425
#include "utils.h"
2526

2627
// See Matthew Farthing, Christopher Kees, Cass Miller (2003)

examples/Hdiv-mixed/qfunctions/richard-true2d.h

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define RICHARD_TRUE2D_H
2222

2323
#include <math.h>
24+
#include <ceed.h>
2425
#include "utils.h"
2526

2627
// See Matthew Farthing, Christopher Kees, Cass Miller (2003)
@@ -80,15 +81,15 @@ struct RICHARDContext_ {
8081
// -----------------------------------------------------------------------------
8182
// Initial conditions for Richard problem
8283
// -----------------------------------------------------------------------------
83-
CEED_QFUNCTION(RichardICs2D)(void *ctx, const CeedInt Q,
84-
const CeedScalar *const *in,
85-
CeedScalar *const *out) {
84+
CEED_QFUNCTION(RichardICsU2D)(void *ctx, const CeedInt Q,
85+
const CeedScalar *const *in,
86+
CeedScalar *const *out) {
8687
// *INDENT-OFF*
8788
// Inputs
8889
const CeedScalar (*coords) = in[0],
8990
(*dxdX)[2][CEED_Q_VLA] = (const CeedScalar(*)[2][CEED_Q_VLA])in[1];
9091
// Outputs
91-
CeedScalar (*u_0) = out[0], (*psi_0) = out[1];
92+
CeedScalar (*u_0) = out[0];
9293
RICHARDContext context = (RICHARDContext)ctx;
9394
const CeedScalar kappa = context->kappa;
9495
const CeedScalar alpha_a = context->alpha_a;
@@ -108,9 +109,6 @@ CEED_QFUNCTION(RichardICs2D)(void *ctx, const CeedInt Q,
108109
CeedScalar x1 = coords[1+0*Q], y1 = coords[1+1*Q];
109110
CeedScalar x2 = coords[2+0*Q], y2 = coords[2+1*Q];
110111
CeedScalar x3 = coords[3+0*Q], y3 = coords[3+1*Q];
111-
CeedScalar xc = (x0+x1)/2., yc = (y0+y2)/2.;
112-
113-
CeedScalar psic = sin(PI_DOUBLE*xc)*sin(PI_DOUBLE*yc);
114112

115113
CeedScalar psi0_x = PI_DOUBLE*cos(PI_DOUBLE*x0)*sin(PI_DOUBLE*y0);
116114
CeedScalar psi0_y = PI_DOUBLE*sin(PI_DOUBLE*x0)*cos(PI_DOUBLE*y0);
@@ -149,6 +147,7 @@ CEED_QFUNCTION(RichardICs2D)(void *ctx, const CeedInt Q,
149147
d5 = ue3[0]*nt3[0]+ue3[1]*nt3[1];
150148
d6 = ue0[0]*nl0[0]+ue0[1]*nl0[1];
151149
d7 = ue2[0]*nl2[0]+ue2[1]*nl2[1];
150+
// 2nd output
152151
u_0[0] = d0;
153152
u_0[1] = d1;
154153
u_0[2] = d2;
@@ -157,11 +156,31 @@ CEED_QFUNCTION(RichardICs2D)(void *ctx, const CeedInt Q,
157156
u_0[5] = d5;
158157
u_0[6] = d6;
159158
u_0[7] = d7;
160-
// 2nd eq
161-
psi_0[0] = psic;
162-
psi_0[1] = psic;
163-
psi_0[2] = psic;
164-
psi_0[3] = psic;
159+
} // End of Quadrature Point Loop
160+
return 0;
161+
}
162+
163+
CEED_QFUNCTION(RichardICsP2D)(void *ctx, const CeedInt Q,
164+
const CeedScalar *const *in,
165+
CeedScalar *const *out) {
166+
// *INDENT-OFF*
167+
// Inputs
168+
const CeedScalar (*coords) = in[0];
169+
// Outputs
170+
CeedScalar (*psi_0) = out[0];
171+
// Quadrature Point Loop
172+
{
173+
CeedScalar x0 = coords[0+0*Q], y0 = coords[0+1*Q];
174+
CeedScalar x1 = coords[1+0*Q];
175+
CeedScalar y2 = coords[2+1*Q];
176+
CeedScalar xc = (x0+x1)/2., yc = (y0+y2)/2.;
177+
CeedScalar psi_c = sin(PI_DOUBLE*xc)*sin(PI_DOUBLE*yc);
178+
179+
// 1st output
180+
psi_0[0] = psi_c;
181+
//psi_0[1] = psi_c;
182+
//psi_0[2] = psi_c;
183+
//psi_0[3] = psi_c;
165184
} // End of Quadrature Point Loop
166185
return 0;
167186
}

0 commit comments

Comments
 (0)