Skip to content

Commit

Permalink
New Alert API
Browse files Browse the repository at this point in the history
  • Loading branch information
cbritopacheco committed Aug 10, 2023
1 parent 94d8a12 commit a79b2ea
Show file tree
Hide file tree
Showing 48 changed files with 1,381 additions and 488 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@
[submodule "third-party/googletest"]
path = third-party/googletest
url = https://github.com/google/googletest
[submodule "third-party/termcolor"]
path = third-party/termcolor
url = https://github.com/ikalnytskyi/termcolor
5 changes: 5 additions & 0 deletions examples/Alert/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_executable(RodinAlertColors Colors.cpp)
target_link_libraries(RodinAlertColors
PUBLIC
Rodin::Alert)

16 changes: 16 additions & 0 deletions examples/Alert/Colors.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright Carlos BRITO PACHECO 2021 - 2022.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* https://www.boost.org/LICENSE_1_0.txt)
*/
#include <iostream>
#include <Rodin/Alert.h>

using namespace Rodin::Alert;

int main(int, char**)
{
std::stringstream ss;
ss << Color<RGB<255, 0, 0>>() << "miaow" << Reset << " quack";
}
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ if (RODIN_BUILD_EXAMPLES)
if (RODIN_WITH_PLOT)
add_subdirectory(Plot)
endif()
add_subdirectory(Alert)
add_subdirectory(Geometry)
add_subdirectory(Variational)

Expand Down
9 changes: 5 additions & 4 deletions examples/Misc/RS2023/Helmholtz/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ void run(int i, const std::vector<Data>& grid);
int main(int, char**)
{
// Define evaluation grid
Math::Vector m_r = Math::Vector::LinSpaced(0.5 * 1. / hmax, 0, 0.5 * 1. / hmax);
Math::Vector m_r = Math::Vector::LinSpaced(0.25 * 1. / hmax, 0, 0.5 * 1. / hmax);
Math::Vector epsilon_r = Math::Vector::LinSpaced(0.5 * 1. / hmax, hmax, 0.2);
// Math::Vector waveNumber_r = Math::Vector::LinSpaced(1.0 / hmax, 1, 1.0 / hmax);
// Math::Vector conductivity_r{{ 1e-12, 0.5, 1.0, 2.0, 1e12 }};
Math::Vector waveNumber_r{{ 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 80, 90 }};
Math::Vector waveNumber_r = Math::Vector::LinSpaced(0.5 * 1.0 / hmax, 1, 1.0 / hmax);
// Math::Vector waveNumber_r{{ 0, 1, 2, 3, 4, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 80, 90 }};
Math::Vector conductivity_r{{ 2.0 }};
Math::Vector angle_r{{ 0, M_PI / 4 }};
Math::Vector angle_r{{ M_PI / 4 }};

std::vector<Data> grid;
grid.reserve(m_r.size() * epsilon_r.size() * waveNumber_r.size() * conductivity_r.size());
grid.reserve(epsilon_r.size() * waveNumber_r.size() * conductivity_r.size());
for (const Scalar m : m_r)
for (const Scalar epsilon : epsilon_r)
for (const Scalar waveNumber : waveNumber_r)
Expand Down
78 changes: 37 additions & 41 deletions examples/Misc/RS2023/L2_Grid_Plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

conductivities = [2.0]
waveNumbers = [ 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 80, 90 ]
angles = [ 0 ]
angles = [ math.pi / 4 ]


x_column = 'm'
x_column = 'waveNumber'
y_column = 'epsilon'

latex_label = {
Expand All @@ -39,49 +39,45 @@
print('Read dataset !')

for angle in angles:
for waveNumber in waveNumbers:
for conductivity in conductivities:
plt.figure()
print('Processing ', waveNumber)
sdf = df[
(df['conductivity'] > conductivity - 0.001) &
(df['conductivity'] < conductivity + 0.001) &
(df['waveNumber'] > waveNumber - 0.001) &
(df['waveNumber'] < waveNumber + 0.001) &
(df['angle'] > angle - 0.001) &
(df['angle'] < angle + 0.001)
]
for conductivity in conductivities:
plt.figure()
sdf = df[
(df['conductivity'] > conductivity - 0.001) &
(df['conductivity'] < conductivity + 0.001) &
(df['angle'] > angle - 0.001) &
(df['angle'] < angle + 0.001) &
(df['waveNumber'] < 10)
]

# thresh = sdf['error'].median()
# sdf.loc[sdf['error'] > thresh, 'error'] = thresh
thresh = sdf['error'].median()
sdf.loc[sdf['error'] > thresh, 'error'] = thresh

plt.hexbin(
sdf.loc[:, x_column],
sdf.loc[:, y_column],
gridsize=45,
reduce_C_function=np.mean,
cmap='inferno',
C=sdf.loc[:, 'error'], edgecolors='face', linewidths=0.5)
plt.hexbin(
sdf.loc[:, x_column],
sdf.loc[:, y_column],
gridsize=25,
reduce_C_function=np.mean,
cmap='inferno',
C=sdf.loc[:, 'error'], edgecolors='face', linewidths=0.5)

# plt.contourf(
# sdf.loc[:, 'm'],
# sdf.loc[:, 'epsilon'],
# sdf.loc[:, 'error'])
plt.colorbar()
# plt.contourf(
# sdf.loc[:, 'm'],
# sdf.loc[:, 'epsilon'],
# sdf.loc[:, 'error'])
plt.colorbar()

plt.xlabel(latex_label[x_column])
plt.ylabel(latex_label[y_column])
plt.title(
'$|| u_\epsilon - u_0 ||_{L^2 (Q)} \
\ \mathrm{with} \ \gamma |_{B(x, e)} = %.2E, \ k = %.2E, \
\ \\theta = %d^\circ $' % (conductivity, waveNumber, (180.0 / math.pi) * angle),
pad=20)
out=("%s_VS_%s_Gamma=%.2E_Wavenumber=%.2E_Angle=%.2E") % (
file_label[x_column], file_label[y_column], conductivity,
waveNumber, (180.0 / math.pi) * angle)
plt.savefig(out + '.svg')
plt.savefig(out + '.png')
# plt.show()
plt.xlabel(latex_label[x_column])
plt.ylabel(latex_label[y_column])
plt.title(
'$|| u_\epsilon - u_0 ||_{L^2 (Q)} \
\ \mathrm{with} \ \gamma |_{B(x, e)} = %.2E, \
\ \\theta = %d^\circ $' % (conductivity, (180.0 / math.pi) * angle),
pad=20)
out=("%s_VS_%s_Gamma=%.2E_Angle=%.2E") % (
file_label[x_column], file_label[y_column], conductivity, (180.0 / math.pi) * angle)
plt.savefig(out + '.svg')
plt.savefig(out + '.png')
# plt.show()



2 changes: 1 addition & 1 deletion examples/PDEs/Poisson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int main(int, char**)
// Build a mesh
Mesh mesh;
mesh = mesh.UniformGrid(Polytope::Geometry::Triangle, 16, 16);
mesh.getConnectivity().compute(1, 2);
// mesh.getConnectivity().compute(1, 2);

// Functions
P1 vh(mesh);
Expand Down
8 changes: 8 additions & 0 deletions src/Rodin/Alert.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
#include "Alert/Warning.h"
#include "Alert/Info.h"

#include "Alert/Text.h"
#include "Alert/Color.h"
#include "Alert/Reset.h"
#include "Alert/Stylize.h"
#include "Alert/Notation.h"
#include "Alert/Identifier.h"
#include "Alert/ClassException.h"
#include "Alert/FunctionException.h"
#include "Alert/NamespacedException.h"

#endif
62 changes: 0 additions & 62 deletions src/Rodin/Alert/Alert.cpp

This file was deleted.

Loading

0 comments on commit a79b2ea

Please sign in to comment.