Skip to content

Commit

Permalink
do_not_solve for fee2ccx
Browse files Browse the repository at this point in the history
  • Loading branch information
gtheler committed Mar 7, 2025
1 parent 5b3bf50 commit f679d70
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 18 deletions.
2 changes: 1 addition & 1 deletion doc/CODE_OF_CONDUCT.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ chaptersDepth: 1
codeBlockCaptions: false
cref: false
crossrefYaml: pandoc-crossref.yaml
date: 2025-02-27
date: 2025-03-06
eqLabels: arabic
eqnBlockInlineMath: false
eqnBlockTemplate: |
Expand Down
2 changes: 1 addition & 1 deletion doc/FAQ.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ chaptersDepth: 1
codeBlockCaptions: false
cref: false
crossrefYaml: pandoc-crossref.yaml
date: 2025-02-27
date: 2025-03-06
eqLabels: arabic
eqnBlockInlineMath: false
eqnBlockTemplate: |
Expand Down
2 changes: 1 addition & 1 deletion doc/feenox.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 3.2
.\"
.TH "FEENOX" "1" "2025\-02\-27" "FeenoX" "FeenoX User Manual"
.TH "FEENOX" "1" "2025\-03\-01" "FeenoX" "FeenoX User Manual"
.SH NAME
FeenoX \- a cloud\-first free no\-X uniX\-like finite\-element(ish)
computational engineering tool
Expand Down
3 changes: 2 additions & 1 deletion src/feenox.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*------------ -------------- -------- --- ----- --- -- - -
* FeenoX common framework header
*
* Copyright (C) 2009--2023 Jeremy Theler
* Copyright (C) 2009--2025 Jeremy Theler
*
* This file is part of FeenoX.
*
Expand Down Expand Up @@ -1759,6 +1759,7 @@ struct feenox_t {
size_t spatial_unknowns; // number of spatial unknowns (nodes in fem, cells in fvm)
size_t size_global; // total number of DoFs

int do_not_solve; // flag to skip solves in particular cases (e.g. convert to other format)
int compute_gradients; // do we need to compute gradients?
void *missed_dump;
// gsl_matrix *m2;
Expand Down
4 changes: 4 additions & 0 deletions src/io/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@


int feenox_instruction_print(void *arg) {
if (feenox.pde.do_not_solve) {
return FEENOX_OK;
}

print_t *print = (print_t *)arg;
print_token_t *print_token;
char *current_format = (print->tokens != NULL) ? print->tokens->format : NULL;
Expand Down
4 changes: 4 additions & 0 deletions src/io/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@


int feenox_instruction_printf(void *arg) {
if (feenox.pde.do_not_solve) {
return FEENOX_OK;
}

printf_t *printf = (printf_t *)arg;

if (printf->all_ranks == 0 && feenox.mpi_rank != 0) {
Expand Down
3 changes: 3 additions & 0 deletions src/mesh/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include "../feenox.h"

int feenox_instruction_mesh_write(void *arg) {
if (feenox.pde.do_not_solve) {
return FEENOX_OK;
}

mesh_write_t *mesh_write = (mesh_write_t *)arg;
mesh_write_dist_t *mesh_write_dist;
Expand Down
2 changes: 1 addition & 1 deletion src/pdes/fem.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ inline gsl_matrix *feenox_fem_compute_H_Gc_at_gauss(element_t *e, unsigned int q
}
}

return e->type->H_Gc[q];
return e->type->H_Gc[q];
}

inline gsl_matrix *feenox_fem_compute_B_at_gauss_integration(element_t *e, unsigned int q, int integration) {
Expand Down
6 changes: 4 additions & 2 deletions src/pdes/solve.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*------------ -------------- -------- --- ----- --- -- - -
* feenox's problem-solving routines
*
* Copyright (C) 2021--2022 Jeremy Theler
* Copyright (C) 2021--2025 Jeremy Theler
*
* This file is part of FeenoX <https://www.seamplex.com/feenox>.
*
Expand Down Expand Up @@ -54,7 +54,9 @@ int feenox_instruction_solve_problem(void *arg) {

// solve the problem with this per-mathematics virtual method
// (which in turn calls a per-physics matrix & vector builds)
feenox_call(feenox.pde.solve());
if (feenox.pde.do_not_solve == 0) {
feenox_call(feenox.pde.solve());
}

// post ----------------------------------------------------------------------
petsc_call(PetscLogStagePush(feenox.pde.stage_post));
Expand Down
23 changes: 12 additions & 11 deletions utils/fee2ccx/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
# FeenoX to CalculiX input file converter

Converts an input file in FeenoX's `.fee` format (with `PROBLEM mechanical`) to CalculiX's `.inp` format.
In particular, `fee2ccx`

* reads the mesh specified in the main `READ_MESH` instruction and creates `*NODE` and `*ELEMENT` sections in the `.inp`.
* evaluates the material properties and creates a `*MATERIAL` section (note that non-uniform material properties are not easily handled in CalculiX, help is welcome here)
* evaluates the Dirichlet boundary conditions in the `.fee` and creates a `*BOUNDARY` section (node by node)
* evaluates the Neumann boundary conditions and volumetric sources in the `.fee` and creates a `*CLOAD` section (node by node)


## Example: Tensile test specimen

Consider the base input file from [Tutorial #1 "Tensile test"](https://www.seamplex.com/feenox/doc/tutorials/110-tensile-test/) (see directory [`examples/tensile-test`](examples/tensile-test):
Say one has a nice syntactically-sugared human-friendly English-like FeenoX input file with a one-to-one correspondence between the computer and the human formulation of a the tensile test speciment from [Tutorial #1](https://www.seamplex.com/feenox/doc/tutorials/110-tensile-test/) (see directory [`examples/tensile-test`](examples/tensile-test):

```fee
PROBLEM mechanical # self-descriptive
Expand All @@ -30,7 +21,9 @@ BC right Fx=10e3 # [ N ]
SOLVE_PROBLEM
```

To convert it to `.inp` we have to make sure the mesh exists
![](gmsh-mesh-surface-only.png)

We can convert it to the non-human-friendly `.inp` format with `fee2ccx` (we have to make sure the mesh exists):

```terminal
gmsh -3 tensile-test.geo
Expand All @@ -43,6 +36,14 @@ and then solve it with
ccx -i tensile-test
```

In particular, `fee2ccx`

* reads the mesh specified in the main `READ_MESH` instruction and creates `*NODE` and `*ELEMENT` sections in the `.inp`.
* evaluates the material properties and creates a `*MATERIAL` section (note that non-uniform material properties are not easily handled in CalculiX, help is welcome here)
* evaluates the Dirichlet boundary conditions in the `.fee` and creates a `*BOUNDARY` section (node by node)
* evaluates the Neumann boundary conditions and volumetric sources in the `.fee` and creates a `*CLOAD` section (node by node)


## Example: NAFEMS LE10 Benchmark problem


Expand Down
9 changes: 9 additions & 0 deletions utils/fee2ccx/examples/nafems-le10/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.msh
*.vtk
*.12d
*.cvg
*.dat
*.frd
*.inp
*.sta
spooles.out
24 changes: 24 additions & 0 deletions utils/fee2ccx/examples/nafems-le10/nafems-le10.fee
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# NAFEMS Benchmark LE-10: thick plate pressure
PROBLEM mechanical 3D
READ_MESH nafems-le10.msh # mesh in millimeters

# LOADING: uniform normal pressure on the upper surface
BC upper p=1 # 1 Mpa

# BOUNDARY CONDITIONS:
BC DCD'C' v=0 # Face DCD'C' zero y-displacement
BC ABA'B' u=0 # Face ABA'B' zero x-displacement
BC BCB'C' u=0 v=0 # Face BCB'C' x and y displ. fixed
BC midplane w=0 # z displacements fixed along mid-plane

# MATERIAL PROPERTIES: isotropic single-material properties
E = 210e3 # Young modulus in MPa
nu = 0.3 # Poisson's ratio

SOLVE_PROBLEM # solve!

# print the direct stress y at D (and nothing more)
PRINT "sigma_y @ D = " sigmay(2000,0,300) "MPa"

# write post-processing data for paraview
WRITE_MESH nafems-le10.vtk sigmay VECTOR u v w
1 change: 1 addition & 0 deletions utils/fee2ccx/examples/nafems-le10/nafems-le10.geo
1 change: 1 addition & 0 deletions utils/fee2ccx/examples/nafems-le10/nafems-le10.step
2 changes: 2 additions & 0 deletions utils/fee2ccx/fee2ccx.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}

// turn off the solve
feenox.pde.do_not_solve = 1;
if (feenox_step(feenox.instructions, NULL) != FEENOX_OK) {
feenox_pop_errors();
exit(EXIT_FAILURE);
Expand Down

0 comments on commit f679d70

Please sign in to comment.