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

Switch webapp into quasar vite-cli #77

Merged
merged 7 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ scattnlay-mp

# Python
*.egg-info/*
.tox

# CLion files
.idea
Expand Down
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# git submodule update --init --recursive
[submodule "guiapp/public/refractiveindex.info-database"]
path = guiapp/public/refractiveindex.info-database
url = [email protected]:kostyfisik/refractiveindex.info-database.git
26 changes: 21 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,27 @@ wasm: $(SRCDIR)/nmie-js-wrapper.cc $(CXX_NMIE_HEADERS)
# emcc --bind -lm -Wall -O2 -std=c++11 -s WASM=1 -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPostRun']" -o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
# emcc --bind -lm -Wall -O2 -std=c++11 -s MODULARIZE=1 -s WASM=1 -o nmie.js $(SRCDIR)/nmie-js-wrapper.cc

emcc --bind -lm -Wall -pedantic -O2 -std=c++11 -s NO_DISABLE_EXCEPTION_CATCHING -s MODULARIZE=1 -s ASSERTIONS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_NAME="nmiejs" -s ENVIRONMENT="web" -o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
# working as 2024-01-31 16:47:23
# emcc --bind -lm -Wall -pedantic -O2 -std=c++11 -s NO_DISABLE_EXCEPTION_CATCHING -s MODULARIZE=1 -s ASSERTIONS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_NAME="nmiejs" -s ENVIRONMENT="web" -o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
# @cp -f nmiejs.js guiapp/src/
# @cp -f nmiejs.wasm guiapp/public/

# working with vite export
# @rm nmiejs.wasm
emcc --bind -lm -Wall -pedantic -O2 -std=c++11 \
-s EXPORT_ES6=1 \
-s NO_DISABLE_EXCEPTION_CATCHING \
-s MODULARIZE=1 \
-s ASSERTIONS=1 \
-s WASM=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s EXPORT_NAME="createNmiejsModule" \
-s ENVIRONMENT="web" \
-o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
@cp -f nmiejs.js guiapp/src/
@cp -f nmiejs.wasm guiapp/public/
@cp -f nmiejs.wasm guiapp/src/

# emcc --bind -lm -Wall -pedantic -Oz -std=c++11 -s NO_DISABLE_EXCEPTION_CATCHING -s MODULARIZE=1 -s ASSERTIONS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_NAME="nmiejs" -s ENVIRONMENT="web" -o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
# emcc --bind -lm -Wall -pedantic -Oz -std=c++11 -s NO_DISABLE_EXCEPTION_CATCHING -s MODULARIZE=1 -s EXPORT_ES6=1 -s ASSERTIONS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_NAME="nmiejs" -s ENVIRONMENT="web" -o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
# emcc --bind -lm -Wall -pedantic -O2 -std=c++11 -s NO_DISABLE_EXCEPTION_CATCHING -s MODULARIZE=1 -s EXPORT_ES6=1 -s ASSERTIONS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_NAME="nmiejs" -s ENVIRONMENT="web" -o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
Expand All @@ -85,10 +105,6 @@ wasm: $(SRCDIR)/nmie-js-wrapper.cc $(CXX_NMIE_HEADERS)
# -o lib/onigasm.js


@cp -f nmiejs.js vue-cli3-webapp/src/
@cp -f nmiejs.js guiapp/src/
@cp -f nmiejs.wasm vue-cli3-webapp/public/
@cp -f nmiejs.wasm guiapp/public/

clean:
$(PYTHON) setup.py clean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@
from matplotlib import pyplot as plt

import inspect

print("Using scattnlay from ", inspect.getfile(scattnlay))

npts = 11
# npts = 11
factor = 2 # plot extent compared to sphere radius
index_H2O = 1.33+(1e-6)*1j
factor = 2 # plot extent compared to sphere radius
index_H2O = 1.33 + (1e-6) * 1j

WL = 0.532 #mkm
total_r = 125 #mkm
WL = 0.532 # mkm
total_r = 125 # mkm
# isMP = False
isMP = True

Expand All @@ -56,50 +57,55 @@
x = 2.0 * np.pi * np.array([total_r], dtype=np.float64) / WL
m = np.array((index_H2O), dtype=np.complex128) / nm

nmax = int(np.max(x*factor + 11 * (x*factor)**(1.0 / 3.0) + 1))
nmax = int(np.max(x * factor + 11 * (x * factor) ** (1.0 / 3.0) + 1))
# return std::round(x + 11 * std::pow(x, (1.0 / 3.0)) + 1);

# nmax = -1

print("x =", x)
print("m =", m)
terms, Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2 = scattnlay(
np.array([x]), np.array([m]))
print(" Qsca = " + str(Qsca)+" terms = "+str(terms))
np.array([x]), np.array([m])
)
print(" Qsca = " + str(Qsca) + " terms = " + str(terms))
terms, Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2 = scattnlay(
np.array([x]), np.array([m]), mp=True)
print("mp Qsca = " + str(Qsca)+" terms = "+str(terms))
np.array([x]), np.array([m]), mp=True
)
print("mp Qsca = " + str(Qsca) + " terms = " + str(terms))

scan = np.linspace(-factor*x[-1], factor*x[-1], npts)
zero = np.zeros(npts*npts, dtype = np.float64)
scan = np.linspace(-factor * x[-1], factor * x[-1], npts)
zero = np.zeros(npts * npts, dtype=np.float64)

coordX, coordZ = np.meshgrid(scan, scan)
coordX.resize(npts * npts)
coordZ.resize(npts * npts)
coordY = zero

terms, E, H = fieldnlay(
np.array([x]), np.array([m]),
coordX, coordY, coordZ,
mp=isMP,
nmax=nmax
np.array([x]), np.array([m]), coordX, coordY, coordZ, mp=isMP, nmax=nmax
)
Ec = E[0, :, :]
Er = np.absolute(Ec)
Eabs2 = (Er[:, 0]**2 + Er[:, 1]**2 + Er[:, 2]**2)
Eabs2 = Er[:, 0] ** 2 + Er[:, 1] ** 2 + Er[:, 2] ** 2
Eabs_data = np.resize(Eabs2, (npts, npts))
label = r'$|E|^2$'
pos = plt.imshow(Eabs_data.T,
cmap='gnuplot',
# cmap='jet',
vmin=0., vmax=14

)
label = r"$|E|^2$"
pos = plt.imshow(
Eabs_data.T,
cmap="gnuplot",
# cmap='jet',
vmin=0.0,
vmax=14,
)
plt.colorbar(pos)
print(np.min(Eabs_data), np.max(Eabs_data)," terms = "+str(terms), ' size=', Eabs_data.size)
mp = ''
if isMP: mp = '_mp'
plt.savefig("R"+str(total_r)+"mkm"+mp+".jpg",
dpi=300
)
print(
np.min(Eabs_data),
np.max(Eabs_data),
" terms = " + str(terms),
" size=",
Eabs_data.size,
)
mp = ""
if isMP:
mp = "_mp"
plt.savefig("R" + str(total_r) + "mkm" + mp + ".jpg", dpi=300)
# plt.show()
7 changes: 2 additions & 5 deletions guiapp/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
/dist
/src-bex/www
/src-capacitor
/src-cordova
/.quasar
/node_modules
.eslintrc.js
babel.config.js
.eslintrc.cjs
/src-ssr
/src/nmiejs.js

/quasar.config.*.temporary.compiled*
38 changes: 20 additions & 18 deletions guiapp/.eslintrc.js → guiapp/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
const { resolve } = require('path');
module.exports = {
// https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
// This option interrupts the configuration hierarchy at this file
// Remove this if you have an higher level ESLint config file (it usually happens into a monorepos)
root: true,

// https://eslint.vuejs.org/user-guide/#how-to-use-custom-parser
// https://eslint.vuejs.org/user-guide/#how-to-use-a-custom-parser
// Must use parserOptions instead of "parser" to allow vue-eslint-parser to keep working
// `parser: 'vue-eslint-parser'` is already included with any 'plugin:vue/**' config and should be omitted
parserOptions: {
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#configuration
// https://github.com/TypeStrong/fork-ts-checker-webpack-plugin#eslint
// Needed to make the parser take into account 'vue' files
extraFileExtensions: ['.vue'],
parser: '@typescript-eslint/parser',
project: resolve(__dirname, './tsconfig.json'),
tsconfigRootDir: __dirname,
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module' // Allows for the use of imports
parser: require.resolve('@typescript-eslint/parser'),
extraFileExtensions: ['.vue']
},

env: {
browser: true
browser: true,
es2021: true,
node: true,
'vue/setup-compiler-macros': true
},

// Rules order is important, please avoid shuffling them
Expand All @@ -32,8 +27,6 @@ module.exports = {
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#usage
// ESLint typescript rules
'plugin:@typescript-eslint/recommended',
// consider disabling this class of rules if linting takes too long
'plugin:@typescript-eslint/recommended-requiring-type-checking',

// Uncomment any of the lines below to choose desired strictness,
// but leave only one uncommented!
Expand All @@ -51,13 +44,14 @@ module.exports = {
// required to apply rules which need type information
'@typescript-eslint',

// https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-file
// https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-files
// required to lint *.vue files
'vue',
'vue'

// https://github.com/typescript-eslint/typescript-eslint/issues/389#issuecomment-509292674
// Prettier has not been included as plugin to avoid performance impact
// add it as an extension for your IDE

],

globals: {
Expand All @@ -75,12 +69,20 @@ module.exports = {

// add your custom rules here
rules: {

'prefer-promise-reject-errors': 'off',

// TypeScript
quotes: ['warn', 'single', { avoidEscape: true }],

// this rule, if on, would require explicit return type on the `render` function
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',

// in plain CommonJS modules, you can't use `import foo = require('foo')` to pass this rule, so it has to be disabled
'@typescript-eslint/no-var-requires': 'off',

// The core 'no-unused-vars' rules (in the eslint:recommended ruleset)
// does not work with type definitions
'no-unused-vars': 'off',

// allow debugger during development only
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
Expand Down
4 changes: 4 additions & 0 deletions guiapp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_modules
# Quasar core related directories
.quasar
/dist
/quasar.config.*.temporary.compiled*

# Cordova related directories and files
/src-cordova/node_modules
Expand All @@ -31,3 +32,6 @@ yarn-error.log*
*.ntvs*
*.njsproj
*.sln

# local .env files
.env.local*
5 changes: 5 additions & 0 deletions guiapp/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# pnpm-related options
shamefully-hoist=true
strict-peer-dependencies=false
# to get the latest compatible packages when creating the project https://github.com/pnpm/pnpm/issues/6463
resolution-mode=highest
8 changes: 0 additions & 8 deletions guiapp/.postcssrc.js

This file was deleted.

23 changes: 13 additions & 10 deletions guiapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@

Mie scattering simulations

## Install the dependencies
```bash
yarn
```

### Start the app in development mode (hot-code reloading, error reporting, etc.)

starting in root scattnlay folder

```bash
git submodule update --init --recursive
make wasm
cd guiapp
pnpm i
quasar dev
```

### Lint the files
```bash
yarn run lint
```

### Build the app for production
```bash
quasar build
```

### Customize the configuration
See [Configuring quasar.conf.js](https://v2.quasar.dev/quasar-cli/quasar-conf-js).
See [Configuring quasar.config.js](https://v2.quasar.dev/quasar-cli-vite/quasar-config-js).

# PageSpeed at github.io
- webpack 37/57
- vite 36/60 2024-02-21

15 changes: 0 additions & 15 deletions guiapp/babel.config.js

This file was deleted.

33 changes: 17 additions & 16 deletions guiapp/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
quasar build
cp dist/spa/nmiejs.wasm dist/spa/js/nmiejs.wasm

#cd ~/github/kostyfisik.github.io
#git reset --hard c66101abdd5db0a4ff5ef69c3328cdfdbadaa398
#cp -r ../scattnlay/guiapp/dist/spa/* ./
#git add *
#git add */*
#git commit -am 'update'
#git push -f
cd ~/coding/kostyfisik.github.io
git reset --hard c66101abdd5db0a4ff5ef69c3328cdfdbadaa398
# cp -r ../scattnlay/guiapp/dist/spa/* ./
git add *
git add */*
git commit -am 'update'
git push -f

cd dist/spa/css
for file in `ls *.css`; do sed -i 's/[.]block{display:block\!important}//g' $file; done
cd ..
#sed -i 's=[<]base href[=]//themes//custom//physics//mie-next// [>]==g' index.html
cd ../..
# # physics.itmo.ru
# cd dist/spa/css
# for file in `ls *.css`; do sed -i 's/[.]block{display:block\!important}//g' $file; done
# cd ..
# #sed -i 's=[<]base href[=]//themes//custom//physics//mie-next// [>]==g' index.html
# cd ../..

rsync -aue ssh --progress dist/spa/ [email protected]:/var/www/html/physicsifmoru/web/themes/custom/physics/mie
echo
cat dist/spa/index.html
echo
# rsync -aue ssh --progress dist/spa/ [email protected]:/var/www/html/physicsifmoru/web/themes/custom/physics/mie
# echo
# cat dist/spa/index.html
# echo
Loading
Loading