Here is a relevant portion of my code, where I define the matrices I try to subtract, namely a variational formulation matrix and a spherical DtN matrix.
// ---------- DtN ----------
complex[int, int] SHvalues = SphericalHarmonics(maxDegree, xvals, yvals, zvals);
cout << “Spherical Harmonics computed” << endl;
int nbHarmonics = numberOfHarmonics(maxDegree);
int nbLegendre = numberOfLegendre(maxDegree);
complex[int,int] Earray(Vh.ndof, nbHarmonics);
complex[int] tmp(Vh.ndof);
matrix E;
VhSext sphericalHarmonic;
for (int l=0; l<=maxDegree; l++) {
sphericalHarmonic[] = SHvalues(:, numberLegendre(l,0));
cout << "Computing DtN coefficients for l = " << l << “, m = 0” << endl;
varf FourierCoef(u,v) = int2d(Th,10)(v*sphericalHarmonic);
Earray(:,numberHarmonic(l,0)) = FourierCoef(0,Vh);
for (int m=1; m<=l; m++) {
sphericalHarmonic\[\] = SHvalues(:, numberLegendre(l,m));
cout << "Computing DtN coefficients for l = " << l << ", m = +/-" << m << endl;
varf FourierCoef(u,v) = int2d(Th,10)(v*sphericalHarmonic);
tmp = FourierCoef(0,Vh);
Earray(:,numberHarmonic(l,-m)) = tmp;
Earray(:,numberHarmonic(l,m)) = conj(tmp);
}
}
E = Earray;
cout << “Matrix of spherical harmonics projections defined” << endl;
// Initialization of the diagonal matrix of the DtN coefficients
matrix D;
complex[int] Darray(nbHarmonics);
int n;
complex[int] valuesHankel = Hankel(maxDegree, k*Rext);
for (int l = 0; l <= maxDegree; l++) {
for (int m = -l; m <= l; m++) {
n = numberHarmonic(l,m);
Darray\[n\] = (l/Rext - k\*valuesHankel\[l + 1\]/valuesHankel\[l\])/(Rext\*Rext);
}
}
D = [Darray];
// cout << " D = " << D << endl;
cout << “Diagonal matrix of DtN coefficients defined” << endl;
// Final assembly
matrix T;
Mat Tmat;
T = E*D;
Tmat = T;
cout << “DtN operator defined” << endl;
Mat Eprime;
matrix Estar = E’;
Eprime = Estar;
MatMatMult(Tmat,Eprime,Tmat);
cout << “DtN operator computed” << endl;
// ---------- Verification of the DtN: the fundamental solution Phi(z), on a hard sphere ----------
matrix A;
Mat Amat, Bmat;
// ---------- Variationnal formulation ----------
varf a(u,v) =
int3d(Th)( dx(u) * dx(v)’ + dy(u) * dy(v)’ + dz(u) * dz(v)’ )
+ int3d(Th)(- k^2 * u * v’);
A = a(Vh, Vh);
Amat = A;
Bmat = Amat - Tmat;
cout << “Matrix assembled” << endl;
As I wrote above, the error I get is :
Bmat = Amat - Tmat; error operator - <N5PETSc14DistributedCSRIN5HPDDM7SchwarzINSt3__17complexIdEEEEEE>, <N5PETSc14DistributedCSRIN5HPDDM7SchwarzINSt3__17complexIdEEEEEE>
Thank you in advance for your help,
Mayeul