Skip to content

Commit 2cf226a

Browse files
authored
Merge pull request #6 from DataAnalyticsEngineering/FANS-v0.1.0
Release v0.1.0
2 parents 2dc323e + c96e467 commit 2cf226a

25 files changed

+10009
-11167
lines changed

.clang-format

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -2
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: true
6+
AlignConsecutiveDeclarations: true
7+
AlignEscapedNewlines: Right
8+
AlignOperands: true
9+
AlignTrailingComments: true
10+
AllowAllParametersOfDeclarationOnNextLine: true
11+
AllowShortBlocksOnASingleLine: false
12+
AllowShortCaseLabelsOnASingleLine: false
13+
AllowShortFunctionsOnASingleLine: Empty
14+
AllowShortIfStatementsOnASingleLine: false
15+
AllowShortLoopsOnASingleLine: false
16+
AlwaysBreakAfterDefinitionReturnType: None
17+
AlwaysBreakAfterReturnType: None
18+
AlwaysBreakBeforeMultilineStrings: false
19+
AlwaysBreakTemplateDeclarations: MultiLine
20+
BinPackArguments: true
21+
BinPackParameters: true
22+
BraceWrapping:
23+
AfterClass: false
24+
AfterControlStatement: false
25+
AfterEnum: false
26+
AfterFunction: true
27+
AfterNamespace: false
28+
AfterObjCDeclaration: false
29+
AfterStruct: false
30+
AfterUnion: false
31+
AfterExternBlock: false
32+
BeforeCatch: false
33+
BeforeElse: false
34+
IndentBraces: false
35+
SplitEmptyFunction: true
36+
SplitEmptyRecord: true
37+
SplitEmptyNamespace: true
38+
BreakBeforeBinaryOperators: None
39+
BreakBeforeBraces: Custom
40+
BreakBeforeInheritanceComma: false
41+
BreakInheritanceList: BeforeColon
42+
BreakBeforeTernaryOperators: true
43+
BreakConstructorInitializersBeforeComma: false
44+
BreakConstructorInitializers: BeforeColon
45+
BreakAfterJavaFieldAnnotations: false
46+
BreakStringLiterals: true
47+
ColumnLimit: 0
48+
CommentPragmas: '^ IWYU pragma:'
49+
CompactNamespaces: false
50+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
51+
ConstructorInitializerIndentWidth: 4
52+
ContinuationIndentWidth: 4
53+
Cpp11BracedListStyle: true
54+
DerivePointerAlignment: false
55+
DisableFormat: false
56+
ExperimentalAutoDetectBinPacking: false
57+
FixNamespaceComments: true
58+
ForEachMacros:
59+
- foreach
60+
- Q_FOREACH
61+
- BOOST_FOREACH
62+
IncludeBlocks: Preserve
63+
IncludeCategories:
64+
- Regex: '^(<|"(gtest|isl|json)/)'
65+
Priority: 1
66+
- Regex: '.*'
67+
Priority: 2
68+
- Regex: '.*'
69+
Priority: 1
70+
IncludeIsMainRegex: '$'
71+
IndentCaseLabels: false
72+
IndentPPDirectives: None
73+
IndentWidth: 4
74+
IndentWrappedFunctionNames: false
75+
JavaScriptQuotes: Leave
76+
JavaScriptWrapImports: true
77+
KeepEmptyLinesAtTheStartOfBlocks: true
78+
MacroBlockBegin: ''
79+
MacroBlockEnd: ''
80+
MaxEmptyLinesToKeep: 1
81+
NamespaceIndentation: None
82+
ObjCBinPackProtocolList: Auto
83+
ObjCBlockIndentWidth: 4
84+
ObjCSpaceAfterProperty: false
85+
ObjCSpaceBeforeProtocolList: true
86+
PenaltyBreakAssignment: 2
87+
PenaltyBreakBeforeFirstCallParameter: 19
88+
PenaltyBreakComment: 300
89+
PenaltyBreakFirstLessLess: 120
90+
PenaltyBreakString: 1000
91+
PenaltyBreakTemplateDeclaration: 10
92+
PenaltyExcessCharacter: 1000000
93+
PenaltyReturnTypeOnItsOwnLine: 100
94+
PointerAlignment: Right
95+
ReflowComments: true
96+
SortIncludes: true
97+
SortUsingDeclarations: true
98+
SpaceAfterCStyleCast: true
99+
SpaceAfterTemplateKeyword: true
100+
SpaceBeforeAssignmentOperators: true
101+
SpaceBeforeCpp11BracedList: false
102+
SpaceBeforeCtorInitializerColon: true
103+
SpaceBeforeInheritanceColon: true
104+
SpaceBeforeParens: ControlStatements
105+
SpaceBeforeRangeBasedForLoopColon: true
106+
SpaceInEmptyParentheses: false
107+
SpacesBeforeTrailingComments: 1
108+
SpacesInAngles: false
109+
SpacesInContainerLiterals: true
110+
SpacesInCStyleCastParentheses: false
111+
SpacesInParentheses: false
112+
SpacesInSquareBrackets: false
113+
Standard: Cpp11
114+
StatementMacros:
115+
- Q_UNUSED
116+
- QT_REQUIRE_VERSION
117+
TabWidth: 4
118+
UseTab: Never
119+
...
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: clang-format Check
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- develop
7+
pull_request:
8+
9+
jobs:
10+
formatting-check:
11+
name: Formatting Check
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Run clang-format style check for C/C++/Protobuf programs.
16+
uses: jidicula/[email protected]
17+
with:
18+
clang-format-version: '13'
19+
check-path: ${{ matrix.path }}
20+
exclude-regex: 'include/json.hpp'
21+
fallback-style: 'Mozilla' # optional

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
repos:
2+
# Official repo for the clang-format hook
3+
repos:
24
- repo: https://github.com/pre-commit/pre-commit-hooks
35
rev: v2.3.0
46
hooks:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# FANS Changelog
2+
3+
## v0.1.0
4+
5+
- Add release guide and a Changelog file https://github.com/DataAnalyticsEngineering/FANS/pull/4
6+
- Add clang-format check and format all relevant files https://github.com/DataAnalyticsEngineering/FANS/pull/1

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.0...3.28)
55
# ##############################################################################
66

77
project(FANS
8-
VERSION 0.0.0
8+
VERSION 0.1.0
99
LANGUAGES C CXX
1010
)
1111

FANS_Dashboard/FANS_Dashboard.ipynb

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"- `collections`\n",
3333
"- `argparse`\n",
3434
"- `lxml`\n",
35-
"- `re`",
35+
"- `re`\n",
3636
"- `nbformat`"
3737
]
3838
},
@@ -232,11 +232,11 @@
232232
"outputs": [],
233233
"source": [
234234
"# Plot stress average vs strain average for each component\n",
235-
"\n",
236-
"plot_subplots(strain_average, stress_average, labels_x=['Strain']*6, labels_y=['Stress']*6, \n",
237-
" subplot_titles=['component - 11', 'component - 22', 'component - 33', 'component - 12', 'component - 13', 'component - 23'], \n",
238-
" title='Stress average vs strain average', \n",
239-
" nrows=2, ncols=3, linewidth=1, markersize=4, linecolor='blue', markercolor='blue', fontsize=12)\n"
235+
"fig = plot_subplots(strain_average, stress_average, labels_x=['Strain']*6, labels_y=['Stress']*6, \n",
236+
" subplot_titles=['component - 11', 'component - 22', 'component - 33', 'component - 12', 'component - 13', 'component - 23'], \n",
237+
" title='Stress average vs strain average', \n",
238+
" nrows=2, ncols=3, linewidth=1, markersize=4, linecolor=[\"blue\"]*6, markercolor=[\"blue\"]*6, fontsize=16)\n",
239+
"fig.show()"
240240
]
241241
},
242242
{
@@ -246,10 +246,11 @@
246246
"outputs": [],
247247
"source": [
248248
"# Plot deviatoric stress average vs strain average for each component\n",
249-
"plot_subplots(strain_average, stress_average_deviatoric, labels_x=['Strain']*6, labels_y=['Stress_dev']*6,\n",
250-
" subplot_titles=['component - 11', 'component - 22', 'component - 33', 'component - 12', 'component - 13', 'component - 23'],\n",
251-
" title='Deviatoric stress average vs strain average',\n",
252-
" nrows=2, ncols=3, linewidth=1, markersize=4, linecolor='blue', markercolor='blue', fontsize=12)"
249+
"fig = plot_subplots(strain_average, stress_average_deviatoric, labels_x=['Strain']*6, labels_y=['Stress_dev']*6,\n",
250+
" subplot_titles=['component - 11', 'component - 22', 'component - 33', 'component - 12', 'component - 13', 'component - 23'],\n",
251+
" title='Deviatoric stress average vs strain average',\n",
252+
" nrows=2, ncols=3, linewidth=1, markersize=4, linecolor=[\"blue\"]*6, markercolor=[\"blue\"]*6, fontsize=16)\n",
253+
"fig.show()"
253254
]
254255
},
255256
{
@@ -260,10 +261,11 @@
260261
"source": [
261262
"# Plot deviatoric stress average vs time\n",
262263
"time_broadcasted = np.tile(time_steps[:, np.newaxis], (1, stress_average.shape[1]))\n",
263-
"plot_subplots(time_broadcasted, stress_average_deviatoric, labels_x=['Time']*6, labels_y=['Stress_dev']*6,\n",
264-
" subplot_titles=['component - 11', 'component - 22', 'component - 33', 'component - 12', 'component - 13', 'component - 23'],\n",
265-
" title='Deviatoric stress average vs time',\n",
266-
" nrows=2, ncols=3, linewidth=1, markersize=4, linecolor='blue', markercolor='blue', fontsize=12)\n"
264+
"fig = plot_subplots(time_broadcasted, stress_average_deviatoric, labels_x=['Time']*6, labels_y=['Stress_dev']*6,\n",
265+
" subplot_titles=['component - 11', 'component - 22', 'component - 33', 'component - 12', 'component - 13', 'component - 23'],\n",
266+
" title='Deviatoric stress average vs time',\n",
267+
" nrows=2, ncols=3, linewidth=1, markersize=4, linecolor=[\"blue\"]*6, markercolor=[\"blue\"]*6, fontsize=16)\n",
268+
"fig.show()"
267269
]
268270
},
269271
{
@@ -272,12 +274,12 @@
272274
"metadata": {},
273275
"outputs": [],
274276
"source": [
275-
"plot_subplots(\n",
276-
" np.column_stack((strain_average[:, 0], strain_average[:, 0])), \n",
277-
" np.column_stack((stress_average[:, 0], stress_average_deviatoric[:, 0])), \n",
278-
" labels_x=['Strain_11']*2, labels_y=['Stress_11', 'Stress_dev_11'],\n",
279-
" subplot_titles=['Stress_11 vs Strain_11', 'Stress_dev_11 vs Strain_11'],\n",
280-
" nrows=1, ncols=2, linewidth=1, markersize=4, linecolor='blue', markercolor='blue', fontsize=12)"
277+
"fig = plot_subplots(np.column_stack((strain_average[:, 0], strain_average[:, 0])), \n",
278+
" np.column_stack((stress_average[:, 0], stress_average_deviatoric[:, 0])), \n",
279+
" labels_x=['Strain_11']*2, labels_y=['Stress_11', 'Stress_dev_11'],\n",
280+
" subplot_titles=['Stress_11 vs Strain_11', 'Stress_dev_11 vs Strain_11'],\n",
281+
" nrows=1, ncols=2, linewidth=1, markersize=4, linecolor=[\"blue\"]*2, markercolor=[\"blue\"]*2, fontsize=16)\n",
282+
"fig.show()"
281283
]
282284
},
283285
{
@@ -335,7 +337,7 @@
335337
"name": "python",
336338
"nbconvert_exporter": "python",
337339
"pygments_lexer": "ipython3",
338-
"version": "3.12.4"
340+
"version": "3.12.0"
339341
}
340342
},
341343
"nbformat": 4,

FANS_Dashboard/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# FANS Dashboard
22

3-
This folder contains a Jupyter Notebook designed to post-process, interpret, and visualize results generated by FANS. The notebook provides tools for exploring the hierarchical structure of HDF5 files, extracting and summarizing simulation data, and preparing the results for visualization in ParaView.
3+
The FANS Dashboard is a comprehensive tool designed to streamline the post-processing, interpretation, and visualization of results generated by the FANS solver. This jupyter notebook provides a user-friendly environment to work with complex simulation data stored in HDF5 format, offering a step-by-step workflow that covers data extraction, postprocessing, visualization, and preparation for 3D visualization in tools like ParaView.
44

5-
For further details follow along `FANS_Dashboard.ipynb`
5+
For further details follow along [`FANS_Dashboard.ipynb`](FANS_Dashboard.ipynb)

FANS_Dashboard/plotting.py

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ def plot_subplots(
99
labels_x=None,
1010
labels_y=None,
1111
subplot_titles=None,
12-
title="Subplot Grid",
12+
title="",
1313
nrows=None,
1414
ncols=None,
1515
linewidth=1,
1616
markersize=4,
17-
linecolor="blue",
18-
markercolor="red",
17+
linecolor=None,
18+
markercolor=None,
1919
fontsize=12,
20+
fig=None,
2021
):
2122
"""
2223
Plot a grid of subplots using Plotly, handling both single-component (scalar vs scalar) and multi-component data.
@@ -32,9 +33,10 @@ def plot_subplots(
3233
- ncols: int, number of columns in the subplot grid (optional)
3334
- linewidth: int, line width for the plots (optional, default=1)
3435
- markersize: int, size of the markers (optional, default=4)
35-
- linecolor: string, color of the lines (optional, default="blue")
36-
- markercolor: string, color of the markers (optional, default="red")
36+
- linecolor: list of strings, colors of the lines for each subplot (optional, default=None, all blue)
37+
- markercolor: list of strings, colors of the markers for each subplot (optional, default=None, all blue)
3738
- fontsize: int, font size for axis labels, subplot titles, and tick labels (optional, default=12)
39+
- fig: existing Plotly figure to overlay the new subplots (optional, default=None, creates a new figure)
3840
"""
3941
# Validate data shapes
4042
if not isinstance(data1, np.ndarray) or not isinstance(data2, np.ndarray):
@@ -53,6 +55,21 @@ def plot_subplots(
5355
# Set the number of components based on data shape
5456
n_components = data1.shape[1]
5557

58+
# Initialize linecolor and markercolor lists if not provided
59+
if linecolor is None:
60+
linecolor = ["blue"] * n_components
61+
elif len(linecolor) != n_components:
62+
raise ValueError(
63+
f"The length of linecolor must match the number of components ({n_components})."
64+
)
65+
66+
if markercolor is None:
67+
markercolor = ["blue"] * n_components
68+
elif len(markercolor) != n_components:
69+
raise ValueError(
70+
f"The length of markercolor must match the number of components ({n_components})."
71+
)
72+
5673
# If nrows or ncols is not specified, determine an optimal grid layout
5774
if nrows is None or ncols is None:
5875
nrows = int(np.ceil(np.sqrt(n_components)))
@@ -81,8 +98,9 @@ def plot_subplots(
8198
f"The length of labels_y must match the number of components ({n_components})."
8299
)
83100

84-
# Create the subplot figure
85-
fig = make_subplots(rows=nrows, cols=ncols, subplot_titles=subplot_titles)
101+
# Create the subplot figure if not provided
102+
if fig is None:
103+
fig = make_subplots(rows=nrows, cols=ncols, subplot_titles=subplot_titles)
86104

87105
# Add traces for each component
88106
for i in range(n_components):
@@ -93,8 +111,8 @@ def plot_subplots(
93111
x=data1[:, i],
94112
y=data2[:, i],
95113
mode="lines+markers",
96-
marker=dict(symbol="x", size=markersize, color=markercolor),
97-
line=dict(width=linewidth, color=linecolor),
114+
marker=dict(symbol="x", size=markersize, color=markercolor[i]),
115+
line=dict(width=linewidth, color=linecolor[i]),
98116
name=f"Component {i+1}",
99117
),
100118
row=row,
@@ -113,6 +131,7 @@ def plot_subplots(
113131
ticklen=6,
114132
title_font=dict(size=fontsize),
115133
tickfont=dict(size=fontsize),
134+
automargin=True,
116135
)
117136
fig.update_yaxes(
118137
title_text=labels_y[i],
@@ -125,17 +144,18 @@ def plot_subplots(
125144
ticklen=6,
126145
title_font=dict(size=fontsize),
127146
tickfont=dict(size=fontsize),
147+
automargin=True,
128148
)
129149

130150
# Update layout with the overall plot title and styling
131151
fig.update_layout(
132-
height=600,
133-
width=900,
152+
height=1000,
153+
width=1600,
134154
title_text=title,
135155
title_font=dict(size=fontsize),
136-
showlegend=False,
156+
showlegend=False, # Legends removed
137157
template="plotly_white",
138-
margin=dict(l=20, r=20, t=50, b=20),
158+
margin=dict(l=50, r=50, t=50, b=50), # Adjust margins to prevent overlap
139159
title_x=0.5,
140160
autosize=False,
141161
)
@@ -161,12 +181,5 @@ def plot_subplots(
161181
for annotation in fig["layout"]["annotations"]:
162182
annotation["font"] = dict(size=fontsize)
163183

164-
# Increase the DPI/quality of the plots by setting higher resolution dimensions
165-
fig.update_layout(
166-
height=1200,
167-
width=1800,
168-
autosize=False,
169-
)
170-
171-
# Show the plot
172-
fig.show()
184+
# Return the figure for further customization or overlaying
185+
return fig

0 commit comments

Comments
 (0)