Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 2D magnetostatics branch into serac #63

Open
wants to merge 74 commits into
base: serac
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
861269f
add code meant to reduce allocations in current load
tuckerbabcock Jun 29, 2022
7bd6bb9
switching linear solvers in current load, trying new BH curves
tuckerbabcock Jul 16, 2022
c1a4c24
added nonlinear diffusion integrator for 2D EM
tuckerbabcock Jul 18, 2022
2951b79
make format
tuckerbabcock Jul 18, 2022
f5f39b9
update nonlinear diffusion test
tuckerbabcock Jul 18, 2022
f82025a
ninja format
tuckerbabcock Jul 18, 2022
d3777bf
magnetostatic_box2d test works, is significantly more performant than…
tuckerbabcock Jul 18, 2022
2ddd2cc
adding magnetostatic_box2d test case
tuckerbabcock Jul 18, 2022
782ad87
2d magnet implementation seems to be working, matches the results see…
tuckerbabcock Jul 20, 2022
d822a3f
working on 2D torque, making sure it works as expected
tuckerbabcock Jul 25, 2022
aa14d78
check if cmake policies exist before setting them
tuckerbabcock Jul 25, 2022
07ef8bd
remove 2d magnet regression test
tuckerbabcock Jul 25, 2022
1cfc045
added new integrator to calculate force/torques that works for 2D and…
tuckerbabcock Jul 27, 2022
59acdc3
differentiate magnetic energy functional for 2D case wrt state and me…
tuckerbabcock Aug 3, 2022
3fcea8a
updated torque outut to use new ForceIntegrator2 that works for 2D an…
tuckerbabcock Aug 3, 2022
d4a800c
make format
tuckerbabcock Aug 3, 2022
7ba001a
change format workflow
tuckerbabcock Aug 3, 2022
9f0fcb1
change format workflow
tuckerbabcock Aug 3, 2022
8f92345
change format workflow
tuckerbabcock Aug 3, 2022
b5a1e4f
add SetAttributes call in magnetostatic box regression tests to final…
tuckerbabcock Aug 3, 2022
75af982
added new ForceIntegrator3 that works for 2D and 3D em problems, hope…
tuckerbabcock Aug 11, 2022
fece2cd
finished differentiating ForceIntegrator3 that handles 2D and 3D and …
tuckerbabcock Aug 16, 2022
ae3dd59
make format
tuckerbabcock Aug 16, 2022
58c9514
zero initializing all stack-allocated vector/matrix buffers in electr…
tuckerbabcock Aug 16, 2022
6a77ee9
removing ForceIntegrator2 (which was used to test a new implementatio…
tuckerbabcock Aug 16, 2022
407069a
switch torque and force outputs to use new ForceIntegrator3
tuckerbabcock Aug 16, 2022
2364c22
make format
tuckerbabcock Aug 16, 2022
6c13e05
updated L2CurlMagnitudeProjection to internally handle 2D cases, and …
tuckerbabcock Aug 18, 2022
33f63aa
Added RelaxedNewton method that uses a linesearch to improve converge…
tuckerbabcock Aug 22, 2022
fc0ba85
make format
tuckerbabcock Aug 22, 2022
c80e58c
rework material library and reluctivity coefficients. We can now spec…
tuckerbabcock Aug 22, 2022
b32d3cb
add Newton interations to linesearch test to see where it fails on CI
tuckerbabcock Aug 22, 2022
066b0d4
bump pybind version to 2.10.0
tuckerbabcock Aug 23, 2022
621158e
Merge branch '2D-magnetostatics' of github.com:OptimalDesignLab/mach …
tuckerbabcock Aug 23, 2022
f84864e
fix linesearch test on linux. For some reason switching from GMRES to…
tuckerbabcock Aug 23, 2022
0de877e
make some fixes based on clang-tidy suggestions
tuckerbabcock Aug 23, 2022
4a1adac
make format
tuckerbabcock Aug 23, 2022
e3b8a29
change Phi to own a copy of the calcRes function instead of owning a …
tuckerbabcock Aug 23, 2022
6cd70bd
get all of mach passing clang-tidy checks
tuckerbabcock Aug 24, 2022
10ea296
remove my MPI include from clang tidy command
tuckerbabcock Aug 24, 2022
e2fd4ae
make format
tuckerbabcock Aug 24, 2022
4551b3d
Merge branch '2D-magnetostatics' of github.com:OptimalDesignLab/mach …
tuckerbabcock Aug 24, 2022
ba4fdd3
differentiated NonlinearDiffusionIntegrator wrt mesh coords
tuckerbabcock Aug 31, 2022
6351b0a
make format
tuckerbabcock Aug 31, 2022
c79b9a4
added reverse mode mesh sensitivity integrator for 2D magnetic source…
tuckerbabcock Sep 7, 2022
a32359d
make format
tuckerbabcock Sep 7, 2022
21198bb
differentiating various forgotten outputs, working on getting all Mot…
tuckerbabcock Sep 13, 2022
604a883
finished differentiating 2D flux density transfer, average flux densi…
tuckerbabcock Sep 14, 2022
31ec4b2
fix test_common_outputs test by adding mesh_coords to fieldsf
tuckerbabcock Sep 14, 2022
fdcbf18
got all solver partials and totals working and passing through OpenMD…
tuckerbabcock Sep 16, 2022
956ab12
still a few more things to differentiate that I had forgotten about. …
tuckerbabcock Sep 16, 2022
fb91b84
adding electromag output test that shows the derivative issue, with a…
tuckerbabcock Sep 16, 2022
4c07b2b
fixed DCLossFunctional derivatives. Issue was that mesh sens integrat…
tuckerbabcock Sep 19, 2022
a68da12
make format
tuckerbabcock Sep 19, 2022
8be1086
added and tested all sensitivities for the ACLossFunctional
tuckerbabcock Sep 19, 2022
c93ef26
make format
tuckerbabcock Sep 19, 2022
f2b2727
added and verified all CoreLossFunctional sensitivities
tuckerbabcock Sep 19, 2022
d122d90
added differentiation to MassFunctional with test
tuckerbabcock Oct 18, 2022
28e067c
extended support for IEAggregateFunctional to handle fields other tha…
tuckerbabcock Nov 14, 2022
9adfcb8
updated RelaxedNewton and LineSearch methods to have max iter as an o…
tuckerbabcock Nov 14, 2022
ba763fd
added implementation of sensitivities for the actual IEAggregateFunci…
tuckerbabcock Nov 14, 2022
ced8ffd
added post-adjoint solve hook to do any sort of finalization steps. R…
tuckerbabcock Nov 14, 2022
b7bd248
minor changes related to OpenMDAO integration
tuckerbabcock Nov 14, 2022
b5c70a4
changed use of Adept for auto-diff in current and magnet source funct…
tuckerbabcock Nov 14, 2022
2b0129e
improving test coverage of EM solver related functionality. Specifica…
tuckerbabcock Nov 14, 2022
072073e
make format and added finalizeAdjointSystem function to the mesh warp…
tuckerbabcock Nov 14, 2022
e9338c7
change github actions runner to now explicitly make homebrew available
tuckerbabcock Nov 14, 2022
17290eb
minor changes calling terminal hook in derived PDE solvers, logging t…
tuckerbabcock Dec 5, 2022
a9171b5
make format
tuckerbabcock Dec 5, 2022
379dfb7
fix bug in AC loss calc that had 32 in denominator instead of 8
tuckerbabcock Jan 28, 2023
49963cf
make format
tuckerbabcock Jan 28, 2023
81952ad
update mach builder to allow promoting inputs with aliases
tuckerbabcock Mar 27, 2023
1d3c45e
fix bug when computing core losses that would cause all core loss cal…
tuckerbabcock Mar 27, 2023
dd6e700
make format
tuckerbabcock Mar 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ Checks: 'clang-diagnostic*,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-pro-type-vararg,
-modernize-avoid-c-arrays,
-modernize-use-default-member-init,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-readability-avoid-const-params-in-decls,
-readability-else-after-return,
-readability-identifier-length,
-readability-magic-numbers'

CheckOptions:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Run clang-format style check for C/C++ programs.
uses: jidicula/clang-format-action@v4.0.0
uses: jidicula/clang-format-action@v4.8.0
with:
clang-format-version: '12'
check-path: ${{ matrix.path }}
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ jobs:
}

steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Download Ninja
id: cmake_and_ninja
shell: cmake -P {0}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
buildflags: "-fno-openmp",
}
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Clone Mach
uses: actions/checkout@v2
with:
Expand Down
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ endif (MFEM_USE_PUMI)
# find the MPI compilers
find_package(MPI REQUIRED)

cmake_policy(SET CMP0077 NEW)
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif (POLICY CMP0077)
set(TINYSPLINE_ENABLE_CXX ON)
set(TINYSPLINE_INSTALL ON)
include(FetchContent)
Expand Down Expand Up @@ -169,8 +171,8 @@ option(MACH_USE_CLANG_TIDY
if (MACH_USE_CLANG_TIDY)
set_target_properties(mach
PROPERTIES
CXX_CLANG_TIDY "clang-tidy;--format-style=file;--extra-arg=--std=c++17"
# CXX_CLANG_TIDY "clang-tidy;--fix;--fix-errors;--format-style=file;--extra-arg=--std=c++11"
CXX_CLANG_TIDY "clang-tidy;--fix;--format-style=file;--extra-arg=--std=c++17"
# CXX_CLANG_TIDY "clang-tidy;--fix;--fix-errors;--format-style=file;--extra-arg=--std=c++17;"
)
endif (MACH_USE_CLANG_TIDY)

Expand Down Expand Up @@ -281,10 +283,13 @@ if (BUILD_PYTHON_WRAPPER)

include(FetchContent)

cmake_policy(SET CMP0127 NEW)
if (POLICY CMP0127)
cmake_policy(SET CMP0127 NEW)
endif (POLICY CMP0127)
FetchContent_Declare(pybind11
GIT_REPOSITORY "https://github.com/pybind/pybind11"
GIT_TAG v2.7.1
#GIT_TAG v2.7.1
GIT_TAG v2.10.0
)

FetchContent_MakeAvailable(pybind11)
Expand All @@ -305,7 +310,7 @@ if (BUILD_PYTHON_WRAPPER)
if (MACH_USE_CLANG_TIDY)
set_target_properties(pyMach
PROPERTIES
CXX_CLANG_TIDY "clang-tidy;--format-style=file;--extra-arg=--std=c++17"
CXX_CLANG_TIDY "clang-tidy;--fix;--format-style=file;--extra-arg=--std=c++17"
# CXX_CLANG_TIDY "clang-tidy;--fix;--fix-errors;--format-style=file;--extra-arg=--std=c++11"
)
endif (MACH_USE_CLANG_TIDY)
Expand Down
42 changes: 37 additions & 5 deletions mach/mach_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ def setup(self):
self.vectors["state"] = np.empty(0)

elif input == "mesh_coords":
mesh_size = solver.getFieldSize(input)
self.add_input("mesh_coords",
distributed=True,
shape_by_conn=True,
# distributed=True,
shape=mesh_size,
# shape_by_conn=True,
jehicken marked this conversation as resolved.
Show resolved Hide resolved
desc="volume mesh node coordinates",
tags=["mphys_coordinates"])
self.vectors["mesh_coords"] = np.empty(0)
Expand Down Expand Up @@ -112,6 +114,7 @@ def compute(self, inputs, outputs):
def compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode):
solver = self.options["solver"]
func = self.options["func"]
# print(f"Calling compute_jacvec_product for func {func} with inputs: {inputs}, d_inputs: {d_inputs}, d_outputs: {d_outputs}, and mode: {mode}")

# Copy vector inputs into internal contiguous data buffers
for input in inputs:
Expand All @@ -123,12 +126,28 @@ def compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode):
input_dict = dict(zip(inputs.keys(), inputs.values()))
input_dict.update(self.vectors)

# for input in inputs:
# print(f"inputs[{input}] stride: {inputs[input].strides}")

# for input in inputs:
# if input in d_inputs:
# print(f"d_inputs[{input}]: {d_inputs[input]}")
# print(f"d_inputs[{input}] stride: {d_inputs[input].strides}")

# print(f"d_outputs[{func}] stride: {d_outputs[func].strides}")

try:
if mode == 'fwd':
if func in d_outputs:
# print(f"func {func} is in d_outputs")
for input in inputs:
if input in d_inputs:
# print(f"input {input} is in d_inputs")
# print(f"")
func_dot = np.zeros_like(d_outputs[func])
func_dot = np.zeros_like(d_outputs[func])

# print(f"wrt_dot for input {input}: {d_inputs[input]} for fun {func}")
solver.outputJacobianVectorProduct(of=func,
inputs=input_dict,
wrt_dot=d_inputs[input],
Expand All @@ -145,6 +164,7 @@ def compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode):
# Recommended to make sure your code can run without MPI too, for testing.
d_outputs[func] += func_dot

# print(f"out_dot for func {func}: {d_outputs[func]}")
elif mode == 'rev':
if func in d_outputs:
for input in inputs:
Expand All @@ -163,10 +183,22 @@ def compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode):
out_bar=func_bar,
wrt=input,
wrt_bar=d_inputs[input])
except NotImplementedError as err:
if self.options["check_partials"]:
pass
except Exception as err:
if isinstance(err, NotImplementedError):
if self.options["check_partials"]:
print(f"\n\nNot implemented error passed!!!\n\n")
pass
else:
print(f"\n\nNot implemented error raised!!!\n\n")
raise err
else:
print("\n\ngeneric exception!!!\n\n")
raise err

# except NotImplementedError as err:
# if self.options["check_partials"]:
# pass
# else:
# raise err


Loading