Hi,
I am trying to solve Poisson equation with zero source term on a surface of a sphere. My initial starting condition is a constant value at all nodes. Which should give me the same constant value as the solution at all nodes.
Could you please let me know how I can supply constant value at each node as my initial/boundary condition?
Generally, my question is how can I supply boundary condition at all nodes for some closed surface (such as a 2D spherical surface embedded in 3D) which has no boundary?
I am copying snippet of my code below:
============================================
import numpy as np
import math
import os
from scipy import stats
import random
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
import glob
import pandas as pd
###########################################################
######################################################################
######## Generating mesh begins ########
######################################################################
from mpi4py import MPI
from dolfinx import mesh
import ufl
import trimesh
domain = mesh.create_unit_square(MPI.COMM_WORLD, 80, 80, mesh.CellType.quadrilateral)
####------------------------------####
gdim = 3
shape = “triangle”
degree = 1
cell = ufl.Cell(shape, geometric_dimension=gdim)
domain = ufl.Mesh(ufl.VectorElement(“Lagrange”, cell, degree))
meshUsingTrimesh = trimesh.creation.icosphere(subdivisions=2, radius=1.0)
x = np.array(meshUsingTrimesh.vertices.tolist())
cells = np.array(meshUsingTrimesh.faces.tolist())
mesh1 = mesh.create_mesh(MPI.COMM_WORLD, cells, x, domain)
####------------------------------####
######################################################################
######## Generating mesh ends ########
######################################################################
######################################################################
############# Interpolating function begins #############
######################################################################
from dolfinx.fem import FunctionSpace
#V = FunctionSpace(domain, (“CG”, 1))
V = FunctionSpace(mesh1, (“CG”, 1))
######################################################################
############# Interpolating function ends #############
######################################################################
######################################################################
############# Boundary conditions begins ############# gmsh tetmesh
######################################################################
from dolfinx import fem
uD = fem.Function(V)
#uD.interpolate(lambda x: 1 + x[0]**2 + 2 * x[1]**2)
uD.interpolate(lambda x: 1 + 0 * x[0] + 0 * x[1] + 0 * x[2])
#uD.interpolate(lambda x: 1 + (x[0]-1)**2)
import numpy
Create facet to cell connectivity required to determine boundary facets
#tdim = domain.topology.dim ### **************************************************************************
tdim = mesh1.topology.dim
fdim = tdim - 1
domain.topology.create_connectivity(fdim, tdim)
mesh1.topology.create_connectivity(fdim, tdim)
#boundary_facets = mesh.exterior_facet_indices(domain.topology)
boundary_facets = mesh.exterior_facet_indices(mesh1.topology)
boundary_dofs = fem.locate_dofs_topological(V, fdim, boundary_facets)
#dof_coordinates = V.tabulate_dof_coordinates()
bc = fem.dirichletbc(uD, boundary_dofs)
#bc = fem.dirichletbc(uD, dof_coordinates)
######################################################################
############# Boundary conditions ends #############
######################################################################
In the above I have basically taken the “Poisson equation on a square” code from FEniCSx tutorial and trying to implement it on a surface of a sphere. Now, my question is in the boundary condition, how can I supply a constant value at all nodes to start with? A 2D sphere has no such boundary. Although the above code runs without any error message but gives me infinity as output at all nodal points.
Thanks!