Skip to content

Commit 7931e5b

Browse files
authored
Merge pull request #4027 from roystgnr/calculator_error
Calculator app improvements
2 parents 54ffeed + 130f9c2 commit 7931e5b

17 files changed

Lines changed: 606 additions & 101 deletions

File tree

examples/vector_fe/vector_fe_ex6/run.sh

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,65 +9,65 @@ example_name=vector_fe_ex6
99
### Neumann boundary conditions
1010

1111
options="dim=2 element_type=TRI6 boundary_condition=neumann"
12-
run_example_no_extra_options "$example_name" "$options"
12+
run_example "$example_name" "$options"
1313

1414
options="dim=2 element_type=TRI7 boundary_condition=neumann"
15-
run_example_no_extra_options "$example_name" "$options"
15+
run_example "$example_name" "$options"
1616

1717
options="dim=2 element_type=QUAD8 boundary_condition=neumann"
18-
run_example_no_extra_options "$example_name" "$options"
18+
run_example "$example_name" "$options"
1919

2020
options="dim=2 element_type=QUAD9 boundary_condition=neumann"
21-
run_example_no_extra_options "$example_name" "$options"
21+
run_example "$example_name" "$options"
2222

2323
options="dim=2 order=2 element_type=TRI6 boundary_condition=neumann"
24-
run_example_no_extra_options "$example_name" "$options"
24+
run_example "$example_name" "$options"
2525

2626
options="dim=2 order=2 element_type=TRI7 boundary_condition=neumann"
27-
run_example_no_extra_options "$example_name" "$options"
27+
run_example "$example_name" "$options"
2828

2929
options="dim=2 order=2 element_type=QUAD8 boundary_condition=neumann"
30-
run_example_no_extra_options "$example_name" "$options"
30+
run_example "$example_name" "$options"
3131

3232
options="dim=2 order=2 element_type=QUAD9 boundary_condition=neumann"
33-
run_example_no_extra_options "$example_name" "$options"
33+
run_example "$example_name" "$options"
3434

3535
# Subdividing each hex into 24 tets gets expensive in dbg...
3636
options="dim=3 element_type=TET14 boundary_condition=neumann grid_size=6"
37-
run_example_no_extra_options "$example_name" "$options"
37+
run_example "$example_name" "$options"
3838

3939
options="dim=3 element_type=HEX27 boundary_condition=neumann"
40-
run_example_no_extra_options "$example_name" "$options"
40+
run_example "$example_name" "$options"
4141

4242
### Dirichlet boundary conditions
4343

4444
options="dim=2 element_type=TRI6 boundary_condition=dirichlet"
45-
run_example_no_extra_options "$example_name" "$options"
45+
run_example "$example_name" "$options"
4646

4747
options="dim=2 element_type=TRI7 boundary_condition=dirichlet"
48-
run_example_no_extra_options "$example_name" "$options"
48+
run_example "$example_name" "$options"
4949

5050
options="dim=2 element_type=QUAD8 boundary_condition=dirichlet"
51-
run_example_no_extra_options "$example_name" "$options"
51+
run_example "$example_name" "$options"
5252

5353
options="dim=2 element_type=QUAD9 boundary_condition=dirichlet"
54-
run_example_no_extra_options "$example_name" "$options"
54+
run_example "$example_name" "$options"
5555

5656
options="dim=2 order=2 element_type=TRI6 boundary_condition=dirichlet"
57-
run_example_no_extra_options "$example_name" "$options"
57+
run_example "$example_name" "$options"
5858

5959
options="dim=2 order=2 element_type=TRI7 boundary_condition=dirichlet"
60-
run_example_no_extra_options "$example_name" "$options"
60+
run_example "$example_name" "$options"
6161

6262
options="dim=2 order=2 element_type=QUAD8 boundary_condition=dirichlet"
63-
run_example_no_extra_options "$example_name" "$options"
63+
run_example "$example_name" "$options"
6464

6565
options="dim=2 order=2 element_type=QUAD9 boundary_condition=dirichlet"
66-
run_example_no_extra_options "$example_name" "$options"
66+
run_example "$example_name" "$options"
6767

6868
# Subdividing each hex into 24 tets gets expensive in dbg...
6969
options="dim=3 element_type=TET14 boundary_condition=dirichlet grid_size=6"
70-
run_example_no_extra_options "$example_name" "$options"
70+
run_example "$example_name" "$options"
7171

7272
options="dim=3 element_type=HEX27 boundary_condition=dirichlet"
73-
run_example_no_extra_options "$example_name" "$options"
73+
run_example "$example_name" "$options"

examples/vector_fe/vector_fe_ex9/hdg_problem.C

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,17 @@ HDGProblem::vector_volume_jacobian(DenseMatrix<Number> & Jqq, DenseMatrix<Number
175175
}
176176
}
177177

178-
RealVectorValue
178+
NumberVectorValue
179179
HDGProblem::vel_cross_vel_residual(const std::vector<Number> & u_sol_local,
180180
const std::vector<Number> & v_sol_local,
181181
const unsigned int qp,
182182
const unsigned int vel_component) const
183183
{
184-
const RealVectorValue U(u_sol_local[qp], v_sol_local[qp]);
184+
const NumberVectorValue U(u_sol_local[qp], v_sol_local[qp]);
185185
return U * U(vel_component);
186186
}
187187

188-
RealVectorValue
188+
NumberVectorValue
189189
HDGProblem::vel_cross_vel_jacobian(const std::vector<Number> & u_sol_local,
190190
const std::vector<Number> & v_sol_local,
191191
const unsigned int qp,
@@ -194,8 +194,8 @@ HDGProblem::vel_cross_vel_jacobian(const std::vector<Number> & u_sol_local,
194194
const std::vector<std::vector<Real>> & phi,
195195
const unsigned int j) const
196196
{
197-
const RealVectorValue U(u_sol_local[qp], v_sol_local[qp]);
198-
RealVectorValue vector_phi_local;
197+
const NumberVectorValue U(u_sol_local[qp], v_sol_local[qp]);
198+
NumberVectorValue vector_phi_local;
199199
vector_phi_local(vel_j_component) = phi[j][qp];
200200
auto ret = vector_phi_local * U(vel_component);
201201
if (vel_component == vel_j_component)
@@ -318,11 +318,11 @@ HDGProblem::pressure_volume_jacobian(DenseMatrix<Number> & Jpu,
318318
for (const auto j : make_range(scalar_n_dofs))
319319
{
320320
{
321-
const Gradient phi((*scalar_phi)[j][qp], 0);
321+
const Gradient phi((*scalar_phi)[j][qp], Number(0));
322322
Jpu(i, j) -= (*JxW)[qp] * ((*grad_scalar_phi)[i][qp] * phi);
323323
}
324324
{
325-
const Gradient phi(0, (*scalar_phi)[j][qp]);
325+
const Gradient phi(Number(0), (*scalar_phi)[j][qp]);
326326
Jpv(i, j) -= (*JxW)[qp] * ((*grad_scalar_phi)[i][qp] * phi);
327327
}
328328
}
@@ -359,11 +359,11 @@ HDGProblem::pressure_face_jacobian(DenseMatrix<Number> & Jplm_u, DenseMatrix<Num
359359
for (const auto j : make_range(lm_n_dofs))
360360
{
361361
{
362-
const Gradient phi((*lm_phi_face)[j][qp], 0);
362+
const Gradient phi((*lm_phi_face)[j][qp], Number(0));
363363
Jplm_u(i, j) += (*JxW_face)[qp] * phi * (*normals)[qp] * (*scalar_phi_face)[i][qp];
364364
}
365365
{
366-
const Gradient phi(0, (*lm_phi_face)[j][qp]);
366+
const Gradient phi(Number(0), (*lm_phi_face)[j][qp]);
367367
Jplm_v(i, j) += (*JxW_face)[qp] * phi * (*normals)[qp] * (*scalar_phi_face)[i][qp];
368368
}
369369
}

examples/vector_fe/vector_fe_ex9/hdg_problem.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,18 @@ class HDGProblem : public NonlinearImplicitSystem::ComputeResidual,
114114

115115
void vector_volume_jacobian(DenseMatrix<Number> & Jqq, DenseMatrix<Number> & Jqs);
116116

117-
RealVectorValue vel_cross_vel_residual(const std::vector<Number> & u_sol_local,
118-
const std::vector<Number> & v_sol_local,
119-
const unsigned int qp,
120-
const unsigned int vel_component) const;
121-
122-
RealVectorValue vel_cross_vel_jacobian(const std::vector<Number> & u_sol_local,
123-
const std::vector<Number> & v_sol_local,
124-
const unsigned int qp,
125-
const unsigned int vel_component,
126-
const unsigned int vel_j_component,
127-
const std::vector<std::vector<Real>> & phi,
128-
const unsigned int j) const;
117+
NumberVectorValue vel_cross_vel_residual(const std::vector<Number> & u_sol_local,
118+
const std::vector<Number> & v_sol_local,
119+
const unsigned int qp,
120+
const unsigned int vel_component) const;
121+
122+
NumberVectorValue vel_cross_vel_jacobian(const std::vector<Number> & u_sol_local,
123+
const std::vector<Number> & v_sol_local,
124+
const unsigned int qp,
125+
const unsigned int vel_component,
126+
const unsigned int vel_j_component,
127+
const std::vector<std::vector<Real>> & phi,
128+
const unsigned int j) const;
129129

130130
void scalar_volume_residual(const std::vector<Gradient> & vel_gradient,
131131
const unsigned int vel_component,

include/Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ include_HEADERS = \
858858
numerics/eigen_preconditioner.h \
859859
numerics/eigen_sparse_matrix.h \
860860
numerics/eigen_sparse_vector.h \
861+
numerics/fdm_gradient.h \
861862
numerics/fem_function_base.h \
862863
numerics/function_base.h \
863864
numerics/lumped_mass_matrix.h \

include/error_estimation/exact_solution.h

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class EquationSystems;
3838
class Parameters;
3939
class Mesh;
4040
template <typename Output> class FunctionBase;
41+
template <typename Output> class FEMFunctionBase;
4142
enum FEMNormType : int;
4243

4344
// Is there any way to simplify this?
@@ -112,13 +113,26 @@ class ExactSolution
112113
*/
113114
void attach_exact_values (const std::vector<FunctionBase<Number> *> & f);
114115

116+
/**
117+
* Clone and attach arbitrary functors which compute the exact
118+
* values of the EquationSystems' solutions at any point.
119+
*/
120+
void attach_exact_values (const std::vector<FEMFunctionBase<Number> *> & f);
121+
115122
/**
116123
* Clone and attach an arbitrary functor which computes the exact
117124
* value of the system \p sys_num solution at any point.
118125
*/
119126
void attach_exact_value (unsigned int sys_num,
120127
FunctionBase<Number> * f);
121128

129+
/**
130+
* Clone and attach an arbitrary functor which computes the exact
131+
* value of the system \p sys_num solution at any point.
132+
*/
133+
void attach_exact_value (unsigned int sys_num,
134+
FEMFunctionBase<Number> * f);
135+
122136
/**
123137
* Attach an arbitrary function which computes the exact value of
124138
* the solution at any point.
@@ -135,13 +149,26 @@ class ExactSolution
135149
*/
136150
void attach_exact_derivs (const std::vector<FunctionBase<Gradient> *> & g);
137151

152+
/**
153+
* Clone and attach arbitrary functors which compute the exact
154+
* gradients of the EquationSystems' solutions at any point.
155+
*/
156+
void attach_exact_derivs (const std::vector<FEMFunctionBase<Gradient> *> & g);
157+
138158
/**
139159
* Clone and attach an arbitrary functor which computes the exact
140160
* gradient of the system \p sys_num solution at any point.
141161
*/
142162
void attach_exact_deriv (unsigned int sys_num,
143163
FunctionBase<Gradient> * g);
144164

165+
/**
166+
* Clone and attach an arbitrary functor which computes the exact
167+
* gradient of the system \p sys_num solution at any point.
168+
*/
169+
void attach_exact_deriv (unsigned int sys_num,
170+
FEMFunctionBase<Gradient> * g);
171+
145172
/**
146173
* Attach an arbitrary function which computes the exact gradient of
147174
* the solution at any point.
@@ -157,6 +184,11 @@ class ExactSolution
157184
* second derivatives of the EquationSystems' solutions at any point.
158185
*/
159186
void attach_exact_hessians (std::vector<FunctionBase<Tensor> *> h);
187+
/**
188+
* Clone and attach arbitrary functors which compute the exact
189+
* second derivatives of the EquationSystems' solutions at any point.
190+
*/
191+
void attach_exact_hessians (std::vector<FEMFunctionBase<Tensor> *> h);
160192

161193
/**
162194
* Clone and attach an arbitrary functor which computes the exact
@@ -165,6 +197,13 @@ class ExactSolution
165197
void attach_exact_hessian (unsigned int sys_num,
166198
FunctionBase<Tensor> * h);
167199

200+
/**
201+
* Clone and attach an arbitrary functor which computes the exact
202+
* second derivatives of the system \p sys_num solution at any point.
203+
*/
204+
void attach_exact_hessian (unsigned int sys_num,
205+
FEMFunctionBase<Tensor> * h);
206+
168207
/**
169208
* Attach an arbitrary function which computes the exact second
170209
* derivatives of the solution at any point.
@@ -315,19 +354,19 @@ class ExactSolution
315354
* User-provided functors which compute the exact value of the
316355
* solution for each system.
317356
*/
318-
std::vector<std::unique_ptr<FunctionBase<Number>>> _exact_values;
357+
std::vector<std::unique_ptr<FEMFunctionBase<Number>>> _exact_values;
319358

320359
/**
321360
* User-provided functors which compute the exact derivative of the
322361
* solution for each system.
323362
*/
324-
std::vector<std::unique_ptr<FunctionBase<Gradient>>> _exact_derivs;
363+
std::vector<std::unique_ptr<FEMFunctionBase<Gradient>>> _exact_derivs;
325364

326365
/**
327366
* User-provided functors which compute the exact hessians of the
328367
* solution for each system.
329368
*/
330-
std::vector<std::unique_ptr<FunctionBase<Tensor>>> _exact_hessians;
369+
std::vector<std::unique_ptr<FEMFunctionBase<Tensor>>> _exact_hessians;
331370

332371
/**
333372
* Data structure which stores the errors:

include/include_HEADERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ include_HEADERS = \
257257
numerics/eigen_preconditioner.h \
258258
numerics/eigen_sparse_matrix.h \
259259
numerics/eigen_sparse_vector.h \
260+
numerics/fdm_gradient.h \
260261
numerics/fem_function_base.h \
261262
numerics/function_base.h \
262263
numerics/lumped_mass_matrix.h \

include/libmesh/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ BUILT_SOURCES = \
248248
eigen_preconditioner.h \
249249
eigen_sparse_matrix.h \
250250
eigen_sparse_vector.h \
251+
fdm_gradient.h \
251252
fem_function_base.h \
252253
function_base.h \
253254
laspack_matrix.h \
@@ -1333,6 +1334,9 @@ eigen_sparse_matrix.h: $(top_srcdir)/include/numerics/eigen_sparse_matrix.h
13331334
eigen_sparse_vector.h: $(top_srcdir)/include/numerics/eigen_sparse_vector.h
13341335
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
13351336

1337+
fdm_gradient.h: $(top_srcdir)/include/numerics/fdm_gradient.h
1338+
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
1339+
13361340
fem_function_base.h: $(top_srcdir)/include/numerics/fem_function_base.h
13371341
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
13381342

include/libmesh/Makefile.in

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,9 @@ BUILT_SOURCES = auto_ptr.h dirichlet_boundaries.h dof_map.h \
598598
dense_subvector.h dense_vector.h dense_vector_base.h \
599599
diagonal_matrix.h distributed_vector.h eigen_core_support.h \
600600
eigen_preconditioner.h eigen_sparse_matrix.h \
601-
eigen_sparse_vector.h fem_function_base.h function_base.h \
602-
laspack_matrix.h laspack_vector.h lumped_mass_matrix.h \
603-
numeric_vector.h parsed_fem_function.h \
601+
eigen_sparse_vector.h fdm_gradient.h fem_function_base.h \
602+
function_base.h laspack_matrix.h laspack_vector.h \
603+
lumped_mass_matrix.h numeric_vector.h parsed_fem_function.h \
604604
parsed_fem_function_parameter.h parsed_function.h \
605605
parsed_function_parameter.h petsc_macro.h petsc_matrix.h \
606606
petsc_matrix_base.h petsc_matrix_shell_matrix.h \
@@ -1667,6 +1667,9 @@ eigen_sparse_matrix.h: $(top_srcdir)/include/numerics/eigen_sparse_matrix.h
16671667
eigen_sparse_vector.h: $(top_srcdir)/include/numerics/eigen_sparse_vector.h
16681668
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
16691669

1670+
fdm_gradient.h: $(top_srcdir)/include/numerics/fdm_gradient.h
1671+
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
1672+
16701673
fem_function_base.h: $(top_srcdir)/include/numerics/fem_function_base.h
16711674
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
16721675

0 commit comments

Comments
 (0)