Skip to content

Commit

Permalink
Merge pull request #6 from DataAnalyticsEngineering/FANS-v0.1.0
Browse files Browse the repository at this point in the history
Release v0.1.0
  • Loading branch information
sanathkeshav authored Aug 23, 2024
2 parents 2dc323e + c96e467 commit 2cf226a
Show file tree
Hide file tree
Showing 25 changed files with 10,009 additions and 11,167 deletions.
119 changes: 119 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 1
- Regex: '.*'
Priority: 2
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 100
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseTab: Never
...
21 changes: 21 additions & 0 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: clang-format Check
on:
push:
branches:
- main
- develop
pull_request:

jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/[email protected]
with:
clang-format-version: '13'
check-path: ${{ matrix.path }}
exclude-regex: 'include/json.hpp'
fallback-style: 'Mozilla' # optional
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
repos:
# Official repo for the clang-format hook
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# FANS Changelog

## v0.1.0

- Add release guide and a Changelog file https://github.com/DataAnalyticsEngineering/FANS/pull/4
- Add clang-format check and format all relevant files https://github.com/DataAnalyticsEngineering/FANS/pull/1
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.0...3.28)
# ##############################################################################

project(FANS
VERSION 0.0.0
VERSION 0.1.0
LANGUAGES C CXX
)

Expand Down
44 changes: 23 additions & 21 deletions FANS_Dashboard/FANS_Dashboard.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"- `collections`\n",
"- `argparse`\n",
"- `lxml`\n",
"- `re`",
"- `re`\n",
"- `nbformat`"
]
},
Expand Down Expand Up @@ -232,11 +232,11 @@
"outputs": [],
"source": [
"# Plot stress average vs strain average for each component\n",
"\n",
"plot_subplots(strain_average, stress_average, labels_x=['Strain']*6, labels_y=['Stress']*6, \n",
" subplot_titles=['component - 11', 'component - 22', 'component - 33', 'component - 12', 'component - 13', 'component - 23'], \n",
" title='Stress average vs strain average', \n",
" nrows=2, ncols=3, linewidth=1, markersize=4, linecolor='blue', markercolor='blue', fontsize=12)\n"
"fig = plot_subplots(strain_average, stress_average, labels_x=['Strain']*6, labels_y=['Stress']*6, \n",
" subplot_titles=['component - 11', 'component - 22', 'component - 33', 'component - 12', 'component - 13', 'component - 23'], \n",
" title='Stress average vs strain average', \n",
" nrows=2, ncols=3, linewidth=1, markersize=4, linecolor=[\"blue\"]*6, markercolor=[\"blue\"]*6, fontsize=16)\n",
"fig.show()"
]
},
{
Expand All @@ -246,10 +246,11 @@
"outputs": [],
"source": [
"# Plot deviatoric stress average vs strain average for each component\n",
"plot_subplots(strain_average, stress_average_deviatoric, labels_x=['Strain']*6, labels_y=['Stress_dev']*6,\n",
" subplot_titles=['component - 11', 'component - 22', 'component - 33', 'component - 12', 'component - 13', 'component - 23'],\n",
" title='Deviatoric stress average vs strain average',\n",
" nrows=2, ncols=3, linewidth=1, markersize=4, linecolor='blue', markercolor='blue', fontsize=12)"
"fig = plot_subplots(strain_average, stress_average_deviatoric, labels_x=['Strain']*6, labels_y=['Stress_dev']*6,\n",
" subplot_titles=['component - 11', 'component - 22', 'component - 33', 'component - 12', 'component - 13', 'component - 23'],\n",
" title='Deviatoric stress average vs strain average',\n",
" nrows=2, ncols=3, linewidth=1, markersize=4, linecolor=[\"blue\"]*6, markercolor=[\"blue\"]*6, fontsize=16)\n",
"fig.show()"
]
},
{
Expand All @@ -260,10 +261,11 @@
"source": [
"# Plot deviatoric stress average vs time\n",
"time_broadcasted = np.tile(time_steps[:, np.newaxis], (1, stress_average.shape[1]))\n",
"plot_subplots(time_broadcasted, stress_average_deviatoric, labels_x=['Time']*6, labels_y=['Stress_dev']*6,\n",
" subplot_titles=['component - 11', 'component - 22', 'component - 33', 'component - 12', 'component - 13', 'component - 23'],\n",
" title='Deviatoric stress average vs time',\n",
" nrows=2, ncols=3, linewidth=1, markersize=4, linecolor='blue', markercolor='blue', fontsize=12)\n"
"fig = plot_subplots(time_broadcasted, stress_average_deviatoric, labels_x=['Time']*6, labels_y=['Stress_dev']*6,\n",
" subplot_titles=['component - 11', 'component - 22', 'component - 33', 'component - 12', 'component - 13', 'component - 23'],\n",
" title='Deviatoric stress average vs time',\n",
" nrows=2, ncols=3, linewidth=1, markersize=4, linecolor=[\"blue\"]*6, markercolor=[\"blue\"]*6, fontsize=16)\n",
"fig.show()"
]
},
{
Expand All @@ -272,12 +274,12 @@
"metadata": {},
"outputs": [],
"source": [
"plot_subplots(\n",
" np.column_stack((strain_average[:, 0], strain_average[:, 0])), \n",
" np.column_stack((stress_average[:, 0], stress_average_deviatoric[:, 0])), \n",
" labels_x=['Strain_11']*2, labels_y=['Stress_11', 'Stress_dev_11'],\n",
" subplot_titles=['Stress_11 vs Strain_11', 'Stress_dev_11 vs Strain_11'],\n",
" nrows=1, ncols=2, linewidth=1, markersize=4, linecolor='blue', markercolor='blue', fontsize=12)"
"fig = plot_subplots(np.column_stack((strain_average[:, 0], strain_average[:, 0])), \n",
" np.column_stack((stress_average[:, 0], stress_average_deviatoric[:, 0])), \n",
" labels_x=['Strain_11']*2, labels_y=['Stress_11', 'Stress_dev_11'],\n",
" subplot_titles=['Stress_11 vs Strain_11', 'Stress_dev_11 vs Strain_11'],\n",
" nrows=1, ncols=2, linewidth=1, markersize=4, linecolor=[\"blue\"]*2, markercolor=[\"blue\"]*2, fontsize=16)\n",
"fig.show()"
]
},
{
Expand Down Expand Up @@ -335,7 +337,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
"version": "3.12.0"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions FANS_Dashboard/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# FANS Dashboard

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.
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.

For further details follow along `FANS_Dashboard.ipynb`
For further details follow along [`FANS_Dashboard.ipynb`](FANS_Dashboard.ipynb)
57 changes: 35 additions & 22 deletions FANS_Dashboard/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ def plot_subplots(
labels_x=None,
labels_y=None,
subplot_titles=None,
title="Subplot Grid",
title="",
nrows=None,
ncols=None,
linewidth=1,
markersize=4,
linecolor="blue",
markercolor="red",
linecolor=None,
markercolor=None,
fontsize=12,
fig=None,
):
"""
Plot a grid of subplots using Plotly, handling both single-component (scalar vs scalar) and multi-component data.
Expand All @@ -32,9 +33,10 @@ def plot_subplots(
- ncols: int, number of columns in the subplot grid (optional)
- linewidth: int, line width for the plots (optional, default=1)
- markersize: int, size of the markers (optional, default=4)
- linecolor: string, color of the lines (optional, default="blue")
- markercolor: string, color of the markers (optional, default="red")
- linecolor: list of strings, colors of the lines for each subplot (optional, default=None, all blue)
- markercolor: list of strings, colors of the markers for each subplot (optional, default=None, all blue)
- fontsize: int, font size for axis labels, subplot titles, and tick labels (optional, default=12)
- fig: existing Plotly figure to overlay the new subplots (optional, default=None, creates a new figure)
"""
# Validate data shapes
if not isinstance(data1, np.ndarray) or not isinstance(data2, np.ndarray):
Expand All @@ -53,6 +55,21 @@ def plot_subplots(
# Set the number of components based on data shape
n_components = data1.shape[1]

# Initialize linecolor and markercolor lists if not provided
if linecolor is None:
linecolor = ["blue"] * n_components
elif len(linecolor) != n_components:
raise ValueError(
f"The length of linecolor must match the number of components ({n_components})."
)

if markercolor is None:
markercolor = ["blue"] * n_components
elif len(markercolor) != n_components:
raise ValueError(
f"The length of markercolor must match the number of components ({n_components})."
)

# If nrows or ncols is not specified, determine an optimal grid layout
if nrows is None or ncols is None:
nrows = int(np.ceil(np.sqrt(n_components)))
Expand Down Expand Up @@ -81,8 +98,9 @@ def plot_subplots(
f"The length of labels_y must match the number of components ({n_components})."
)

# Create the subplot figure
fig = make_subplots(rows=nrows, cols=ncols, subplot_titles=subplot_titles)
# Create the subplot figure if not provided
if fig is None:
fig = make_subplots(rows=nrows, cols=ncols, subplot_titles=subplot_titles)

# Add traces for each component
for i in range(n_components):
Expand All @@ -93,8 +111,8 @@ def plot_subplots(
x=data1[:, i],
y=data2[:, i],
mode="lines+markers",
marker=dict(symbol="x", size=markersize, color=markercolor),
line=dict(width=linewidth, color=linecolor),
marker=dict(symbol="x", size=markersize, color=markercolor[i]),
line=dict(width=linewidth, color=linecolor[i]),
name=f"Component {i+1}",
),
row=row,
Expand All @@ -113,6 +131,7 @@ def plot_subplots(
ticklen=6,
title_font=dict(size=fontsize),
tickfont=dict(size=fontsize),
automargin=True,
)
fig.update_yaxes(
title_text=labels_y[i],
Expand All @@ -125,17 +144,18 @@ def plot_subplots(
ticklen=6,
title_font=dict(size=fontsize),
tickfont=dict(size=fontsize),
automargin=True,
)

# Update layout with the overall plot title and styling
fig.update_layout(
height=600,
width=900,
height=1000,
width=1600,
title_text=title,
title_font=dict(size=fontsize),
showlegend=False,
showlegend=False, # Legends removed
template="plotly_white",
margin=dict(l=20, r=20, t=50, b=20),
margin=dict(l=50, r=50, t=50, b=50), # Adjust margins to prevent overlap
title_x=0.5,
autosize=False,
)
Expand All @@ -161,12 +181,5 @@ def plot_subplots(
for annotation in fig["layout"]["annotations"]:
annotation["font"] = dict(size=fontsize)

# Increase the DPI/quality of the plots by setting higher resolution dimensions
fig.update_layout(
height=1200,
width=1800,
autosize=False,
)

# Show the plot
fig.show()
# Return the figure for further customization or overlaying
return fig
Loading

0 comments on commit 2cf226a

Please sign in to comment.