Click here to Skip to main content
13,558,902 members

C / C++ / MFC

 
GeneralRe: How to redirect WriteFile func writes to console Pin
leon de boer22-Feb-18 14:19
memberleon de boer22-Feb-18 14:19 
GeneralRe: How to redirect WriteFile func writes to console Pin
Łukasz Gęsieniec22-Feb-18 19:50
memberŁukasz Gęsieniec22-Feb-18 19:50 
GeneralRe: How to redirect WriteFile func writes to console Pin
Peter_in_278022-Feb-18 20:21
professionalPeter_in_278022-Feb-18 20:21 
GeneralRe: How to redirect WriteFile func writes to console Pin
leon de boer22-Feb-18 21:06
memberleon de boer22-Feb-18 21:06 
Questionproblem defining a function inside a structure in c Pin
Member 1367832014-Feb-18 5:40
memberMember 1367832014-Feb-18 5:40 
AnswerRe: problem defining a function inside a structure in c Pin
David Crow14-Feb-18 6:09
memberDavid Crow14-Feb-18 6:09 
AnswerRe: problem defining a function inside a structure in c Pin
CPallini14-Feb-18 10:44
mvpCPallini14-Feb-18 10:44 
Questionsetting Boundary condition X^2-Y^2 for solving Laplace equation for NxN grid. Pin
Member 1362564310-Feb-18 17:23
memberMember 1362564310-Feb-18 17:23 
i am trying to write a code to solve Laplace equation using Successive
 Over relaxation(SOR)on a NXN matrix 
boundary condition is X^2-y^2
i dont know how to set this boundary condition on the Mesh created by me

here is the code

import numpy as np
from pylab import *
import sys
import copy
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
L =[[]for i in range(2)]
N=int(input("Enter a number N for N x N grid: "))
h=1/N
def clear_list1():
    L[1].clear()
    L[0].clear()
iterat=0
error=0.75
clear_list1()
xx=np.arange(0,N,h)
yy=np.arange(0,N,h)
x,y = np.meshgrid(xx,yy)
phi= copy.deepcopy((x**2-y**2))
phi[1:-1,1:-1]=0
phi_new = copy.deepcopy(phi)
resid=np.zeros((N,N))


while True:
    if iterat<21:

       for w in np.linspace(1,2,11):
           for i in range(1,N-1):
               for j in range(1,N-1):
                   phi1=(phi[i+1,j]+phi[i-1,j]+phi[i,j+1]+phi[i,j-1])/4
                   phi[i,j]=w*phi1+(1-w)*phi1
                   
       Sumresidual=0
       for i in range(1,N-1):
           for j in range(1,N-1):
               resid[i,j]= -4*phi[i,j]+phi[i+1,j]+phi[i-1,j]+phi[i,j+1]+phi[i,j-1]
               Sumresidual=Sumresidual+(resid[i,j])**2
    else:
        break
    iterat=iterat+1
    p=np.sqrt(Sumresidual)
    L[0].append(p)
    L[1].append(w)

ax = plt.axes()
ax.xaxis.set_major_locator(ticker.MaxNLocator(5))

plt.plot(L[0],L[1])
plt.yscale('log')
plt.xlabel('w')
plt.ylabel('|| residual ||')
plt.title('effect of w on residual')
plt.show()

AnswerRe: setting Boundary condition X^2-Y^2 for solving Laplace equation for NxN grid. Pin
Victor Nijegorodov10-Feb-18 23:07
memberVictor Nijegorodov10-Feb-18 23:07 
QuestionDefault Stack Size Pin
ForNow10-Feb-18 17:02
memberForNow10-Feb-18 17:02 
AnswerRe: Default Stack Size Pin
Richard MacCutchan10-Feb-18 21:23
protectorRichard MacCutchan10-Feb-18 21:23 
GeneralRe: Default Stack Size Pin
ForNow11-Feb-18 3:55
memberForNow11-Feb-18 3:55 
GeneralRe: Default Stack Size Pin
Richard MacCutchan11-Feb-18 6:32
protectorRichard MacCutchan11-Feb-18 6:32 
GeneralRe: Default Stack Size Pin
ForNow11-Feb-18 6:48
memberForNow11-Feb-18 6:48 
GeneralRe: Default Stack Size Pin
Richard MacCutchan11-Feb-18 7:10
protectorRichard MacCutchan11-Feb-18 7:10 
GeneralRe: Default Stack Size Pin
ForNow11-Feb-18 7:13
memberForNow11-Feb-18 7:13 
Questionsmoothing issue Pin
Member 1367132810-Feb-18 1:59
memberMember 1367132810-Feb-18 1:59 
AnswerRe: smoothing issue Pin
phil.o10-Feb-18 4:57
professionalphil.o10-Feb-18 4:57 
GeneralRe: smoothing issue Pin
Member 1367132810-Feb-18 5:04
memberMember 1367132810-Feb-18 5:04 
QuestionHow do we cast void type Pin
luplup9-Feb-18 14:46
memberluplup9-Feb-18 14:46 
AnswerRe: How do we cast void type Pin
Richard MacCutchan9-Feb-18 21:49
protectorRichard MacCutchan9-Feb-18 21:49 
GeneralRe: How do we cast void type Pin
luplup10-Feb-18 7:15
memberluplup10-Feb-18 7:15 
GeneralRe: How do we cast void type Pin
Richard MacCutchan10-Feb-18 9:54
protectorRichard MacCutchan10-Feb-18 9:54 
GeneralRe: How do we cast void type Pin
luplup10-Feb-18 11:35
memberluplup10-Feb-18 11:35 
GeneralRe: How do we cast void type Pin
Richard MacCutchan10-Feb-18 21:18
protectorRichard MacCutchan10-Feb-18 21:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy |
Web02 | 2.8.180515.1 | Last Updated 26 May 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid