1212
1313< html >
1414 < head >
15- < title > FEAScript: Advection-Diffusion with a Gaussian Source Term</ title >
15+ < title > FEAScript: Advection-Diffusion with a Gaussian Source Term Tutorial </ title >
1616 < link rel ="icon " type ="image/x-icon " href ="../assets/favicon.ico " />
1717 < meta http-equiv ="Content-Type " content ="text/html; charset=UTF-8 " />
1818 < meta
@@ -65,7 +65,7 @@ <h1 class="top">
6565 />
6666 </ a >
6767 </ h1 >
68- < h1 > Advection-Diffusion with a Gaussian Source Term</ h1 >
68+ < h1 > Advection-Diffusion with a Gaussian Source Term Tutorial </ h1 >
6969
7070 < ul id ="menu ">
7171 < li > < a href ="#mathematicalformulation "> Mathematical Formulation</ a > </ li >
@@ -199,6 +199,7 @@ <h2 id="solvingwithfeascript"><a name="Solving with FEAScript"></a>Solving with
199199 as an argument to the < code > plotSolution</ code > function to specify the target div for the plot.
200200 </ p >
201201
202+ <!-- Container element where the solution plot will be rendered -->
202203 < h2 id ="results "> < a name ="Results "> </ a > Results</ h2 >
203204
204205 < p >
@@ -210,11 +211,6 @@ <h2 id="results"><a name="Results"></a>Results</h2>
210211 > .
211212 </ p >
212213
213- <!-- Container element where the solution plot will be rendered -->
214- < div id ="orientation-message ">
215- Cannot draw the results. Please rotate your phone to landscape orientation and refresh the page to see
216- the results.
217- </ div >
218214 < div id ="resultsCanvas "> </ div >
219215
220216 < p >
@@ -238,68 +234,50 @@ <h2 id="results"><a name="Results"></a>Results</h2>
238234 // import { FEAScriptModel, plotSolution, printVersion } from "../../FEAScript-core/src/index.js";
239235
240236 window . addEventListener ( "DOMContentLoaded" , ( ) => {
241- if ( window . innerHeight > window . innerWidth ) {
242- document . getElementById ( "orientation-message" ) . style . display = "block" ;
243- document . getElementById ( "resultsCanvas" ) . style . display = "none" ;
244- } else {
245- document . getElementById ( "orientation-message" ) . style . display = "none" ;
246- document . getElementById ( "resultsCanvas" ) . style . display = "block" ;
247-
248- // Print FEAScript version
249- console . log ( "FEAScript Version:" , printVersion ) ;
250-
251- // Create a new FEAScript model
252- const model = new FEAScriptModel ( ) ;
253-
254- // Set solver configuration with coefficient functions
255- model . setSolverConfig ( "generalFormPDEScript" , {
256- coefficientFunctions : {
257- // Equation d²u/dx² - 10 du/dx = 10 * exp(-200 * (x - 0.5)²)
258- A : ( x ) => 1 , // Diffusion coefficient
259- B : ( x ) => - 10 , // Advection coefficient
260- C : ( x ) => 0 , // Reaction coefficient
261- D : ( x ) => 10 * Math . exp ( - 200 * Math . pow ( x - 0.5 , 2 ) ) , // Source term
262- } ,
263- } ) ;
264-
265- // Define mesh configuration
266- model . setMeshConfig ( {
267- meshDimension : "1D" ,
268- elementOrder : "quadratic" ,
269- numElementsX : 20 ,
270- maxX : 1.0 ,
271- } ) ;
272-
273- // Define boundary conditions
274- model . addBoundaryCondition ( "0" , [ "constantValue" , 1 ] ) ; // Left boundary, u(0) = 1
275- model . addBoundaryCondition ( "1" , "zeroGradient" ) ; // Right boundary, zero gradient (du/dx = 0)
276-
277- // Set solver method
278- model . setSolverMethod ( "lusolve" ) ;
279-
280- // Solve the problem and get the solution
281- const { solutionVector, nodesCoordinates } = model . solve ( ) ;
282-
283- // Plot the solution as a 1D line plot
284- plotSolution (
285- solutionVector ,
286- nodesCoordinates ,
287- model . solverConfig ,
288- model . meshConfig . meshDimension ,
289- "line" ,
290- "resultsCanvas"
291- ) ;
292- }
293- } ) ;
294-
295- window . addEventListener ( "resize" , ( ) => {
296- if ( window . innerHeight > window . innerWidth ) {
297- document . getElementById ( "orientation-message" ) . style . display = "block" ;
298- document . getElementById ( "resultsCanvas" ) . style . display = "none" ;
299- } else {
300- document . getElementById ( "orientation-message" ) . style . display = "none" ;
301- document . getElementById ( "resultsCanvas" ) . style . display = "block" ;
302- }
237+ // Print FEAScript version
238+ console . log ( "FEAScript Version:" , printVersion ) ;
239+
240+ // Create a new FEAScript model
241+ const model = new FEAScriptModel ( ) ;
242+
243+ // Set solver configuration with coefficient functions
244+ model . setSolverConfig ( "generalFormPDEScript" , {
245+ coefficientFunctions : {
246+ // Equation d²u/dx² - 10 du/dx = 10 * exp(-200 * (x - 0.5)²)
247+ A : ( x ) => 1 , // Diffusion coefficient
248+ B : ( x ) => - 10 , // Advection coefficient
249+ C : ( x ) => 0 , // Reaction coefficient
250+ D : ( x ) => 10 * Math . exp ( - 200 * Math . pow ( x - 0.5 , 2 ) ) , // Source term
251+ } ,
252+ } ) ;
253+
254+ // Define mesh configuration
255+ model . setMeshConfig ( {
256+ meshDimension : "1D" ,
257+ elementOrder : "quadratic" ,
258+ numElementsX : 20 ,
259+ maxX : 1.0 ,
260+ } ) ;
261+
262+ // Define boundary conditions
263+ model . addBoundaryCondition ( "0" , [ "constantValue" , 1 ] ) ; // Left boundary, u(0) = 1
264+ model . addBoundaryCondition ( "1" , "zeroGradient" ) ; // Right boundary, zero gradient (du/dx = 0)
265+
266+ // Set solver method
267+ model . setSolverMethod ( "lusolve" ) ;
268+
269+ // Solve the problem and get the solution
270+ const { solutionVector, nodesCoordinates } = model . solve ( ) ;
271+
272+ // Plot the solution as a 1D line plot
273+ plotSolution (
274+ solutionVector ,
275+ nodesCoordinates ,
276+ model . solverConfig ,
277+ model . meshConfig . meshDimension ,
278+ "line" ,
279+ "resultsCanvas"
280+ ) ;
303281 } ) ;
304282 </ script >
305283
0 commit comments