@@ -27,6 +27,7 @@ import { basicLog, debugLog, errorLog } from "../utilities/loggingScript.js";
2727 * @param {string } plotDivId - The id of the div where the plot will be rendered
2828 */
2929export function plotSolution ( model , result , plotType , plotDivId ) {
30+ console . time ( "plottingTime" ) ;
3031 const { nodesXCoordinates, nodesYCoordinates } = result . nodesCoordinates ;
3132 const solutionVector = result . solutionVector ;
3233 const solverConfig = model . solverConfig ;
@@ -66,6 +67,7 @@ export function plotSolution(model, result, plotType, plotDivId) {
6667 } ;
6768
6869 Plotly . newPlot ( plotDivId , [ lineData ] , layout , { responsive : true } ) ;
70+ console . timeEnd ( "plottingTime" ) ;
6971 } else if ( meshDimension === "2D" && plotType === "contour" ) {
7072 // Check if solutionVector is a nested array
7173 let zData ;
@@ -115,6 +117,7 @@ export function plotSolution(model, result, plotType, plotDivId) {
115117 } ;
116118
117119 Plotly . newPlot ( plotDivId , [ contourData ] , layout , { responsive : true } ) ;
120+ console . timeEnd ( "plottingTime" ) ;
118121 }
119122}
120123
@@ -126,6 +129,7 @@ export function plotSolution(model, result, plotType, plotDivId) {
126129 * @param {string } plotDivId - The id of the div where the plot will be rendered
127130 */
128131export function plotInterpolatedSolution ( model , result , plotType , plotDivId ) {
132+ console . time ( "plottingTime" ) ;
129133 const { nodesXCoordinates, nodesYCoordinates } = result . nodesCoordinates ; // TODO: Check if we should place it inside the 2D block
130134 const meshDimension = model . meshConfig . meshDimension ;
131135 const meshData = prepareMesh ( model . meshConfig ) ; // Retrieve mesh connectivity details
@@ -141,13 +145,14 @@ export function plotInterpolatedSolution(model, result, plotType, plotDivId) {
141145 } else if ( meshDimension === "2D" && plotType === "contour" ) {
142146 const visNodeXCoordinates = [ ] ;
143147 const visNodeYCoordinates = [ ] ;
148+ const lengthX = Math . max ( ...nodesXCoordinates ) - Math . min ( ...nodesXCoordinates ) ;
149+ const lengthY = Math . max ( ...nodesYCoordinates ) - Math . min ( ...nodesYCoordinates ) ;
150+ const visPoinsPerUnit = 50 ; // Number of nodes per one length unit of the visualization grid
151+ const visNodesX = Math . round ( lengthX * visPoinsPerUnit ) ; // Number of nodes along the x-axis of the visualization grid
152+ const visNodesY = Math . round ( lengthY * visPoinsPerUnit ) ; // Number of nodes along the y-axis of the visualization grid
153+ const deltavisX = lengthX / ( visNodesX - 1 ) ;
154+ const deltavisY = lengthY / ( visNodesY - 1 ) ;
144155 let visSolution = [ ] ;
145- const visNodesX = 1e2 ; // Number of nodes along the x-axis of the visualization grid
146- const visNodesY = 1e2 ; // Number of nodes along the y-axis of the visualization grid
147-
148- // const { nodesXCoordinates, nodesYCoordinates } = result.nodesCoordinates;
149- const deltavisX = ( Math . max ( ...nodesXCoordinates ) - Math . min ( ...nodesXCoordinates ) ) / ( visNodesX - 1 ) ;
150- const deltavisY = ( Math . max ( ...nodesYCoordinates ) - Math . min ( ...nodesYCoordinates ) ) / ( visNodesY - 1 ) ;
151156
152157 visNodeXCoordinates [ 0 ] = Math . min ( ...nodesXCoordinates ) ;
153158 visNodeYCoordinates [ 0 ] = Math . min ( ...nodesYCoordinates ) ;
@@ -271,6 +276,8 @@ export function plotInterpolatedSolution(model, result, plotType, plotDivId) {
271276 y : visNodeYCoordinates ,
272277 z : visSolution ,
273278 type : "contour" ,
279+ connectgaps : false ,
280+ hoverongaps : false ,
274281 line : {
275282 smoothing : 0.85 ,
276283 } ,
@@ -286,6 +293,7 @@ export function plotInterpolatedSolution(model, result, plotType, plotDivId) {
286293 } ;
287294
288295 Plotly . newPlot ( plotDivId , [ contourData ] , layout , { responsive : true } ) ;
296+ console . timeEnd ( "plottingTime" ) ;
289297 }
290298}
291299
@@ -300,7 +308,15 @@ export function plotInterpolatedSolution(model, result, plotType, plotDivId) {
300308 * @param {object } basisFunctions - Instance of BasisFunctions class
301309 * @returns {object } Object containing inside boolean and interpolated value
302310 */
303- function pointSearch ( model , meshData , result , currentElement , visNodeXCoordinate , visNodeYCoordinate , basisFunctions ) {
311+ function pointSearch (
312+ model ,
313+ meshData ,
314+ result ,
315+ currentElement ,
316+ visNodeXCoordinate ,
317+ visNodeYCoordinate ,
318+ basisFunctions
319+ ) {
304320 const { nodesXCoordinates, nodesYCoordinates } = result . nodesCoordinates ;
305321 const nodesPerElement = meshData . nop [ currentElement ] . length ;
306322
@@ -328,7 +344,15 @@ function pointSearch(model, meshData, result, currentElement, visNodeXCoordinate
328344 if ( pointCheck . inside ) {
329345 return {
330346 inside : true ,
331- value : solutionInterpolation ( model , meshData , result , currentElement , pointCheck . ksi , pointCheck . eta , basisFunctions ) ,
347+ value : solutionInterpolation (
348+ model ,
349+ meshData ,
350+ result ,
351+ currentElement ,
352+ pointCheck . ksi ,
353+ pointCheck . eta ,
354+ basisFunctions
355+ ) ,
332356 } ;
333357 }
334358 } else if ( nodesPerElement === 9 ) {
@@ -355,7 +379,15 @@ function pointSearch(model, meshData, result, currentElement, visNodeXCoordinate
355379 if ( pointCheck . inside ) {
356380 return {
357381 inside : true ,
358- value : solutionInterpolation ( model , meshData , result , currentElement , pointCheck . ksi , pointCheck . eta , basisFunctions ) ,
382+ value : solutionInterpolation (
383+ model ,
384+ meshData ,
385+ result ,
386+ currentElement ,
387+ pointCheck . ksi ,
388+ pointCheck . eta ,
389+ basisFunctions
390+ ) ,
359391 } ;
360392 }
361393 } // TODO: Add also triangular element cases
0 commit comments