Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message defining a Multifield for displacement vector and stress tensor #923

Open
LoveFrootLoops opened this issue Jul 21, 2023 · 2 comments

Comments

@LoveFrootLoops
Copy link

LoveFrootLoops commented Jul 21, 2023

Hi there,
I recently came across this package, and I must say it's been great so far. I've been experimenting with it and encountered an error message while defining a multi field using the following code:

using Gridap
# Define domain
domain = (0,1,0,1)
partition = (10, 10)
model = CartesianDiscreteModel(domain,partition)

labels = get_face_labeling(model)
add_tag_from_tags!(labels,"diri_0",[1,3,7])
add_tag_from_tags!(labels,"diri_1",[2,4,8])

degree = 2
Ω = Triangulation(model)
dΩ = Measure(Ω, degree)

# Material constants
const E = 70.0e9
const ν = 0.3
const λ = (E*ν)/((1+ν)*(1-2*ν))
const μ = E/(2*(1+ν))
σmat(ε) = λ*tr(ε)*one(ε) + 2*μ*ε

### Define solution spaces
# Space for displacement u
order = 1
reffeᵤ = ReferenceFE(lagrangian, VectorValue{2,Float64}, order)
Vᵤ = TestFESpace(model, reffeᵤ, conformity=:H1, dirichlet_tags = ["diri_0", "diri_1"])
disp_x = 0.75
g1 = VectorValue(0.0,0.0)
g2 = VectorValue(disp_x, 0.0)
U = TrialFESpace(Vᵤ,[g1,g2])

# Space for stress σ
reffeₛ = ReferenceFE(lagrangian, TensorValues.SymTensorValue{2, Float64, 3}, order)
Vₛ = TestFESpace(model, reffeₛ; conformity=:H1)
Σ = TrialFESpace(Vₛ)

# Multifield Spaces
X = MultiFieldFESpace([Vᵤ, Vₛ])
Y = MultiFieldFESpace([U, Σ])


# Define Objective functions
function res((u, σ), (vᵤ, vₛ))
    ∫(σ - σmat∘ε(u))*dΩ 
end

The error is related to the line "Vₛ = TestFESpace(model, reffeₛ; conformity=:H1)", and I'm receiving the error message: "ERROR: UndefVarError: i not defined".

I would appreciate any insights or assistance to resolve this issue.

@ericneiva
Copy link
Member

ericneiva commented Jul 21, 2023

Hi, @LoveFrootLoops, maybe you can find some assistance in this related discussion #908 and the gitter discussion it is referring to https://matrix.to/#/!mSZoaZwNZhWulNruaK:gitter.im/$08HwU3kACfNW6x6Dj6rswjgoOpXfGCJbgmWkzxzrerA?via=gitter.im&via=matrix.org&via=tu-dresden.de

Btw, could you please modify the code such that it can be run as a script? I mean adding using Gridap etc...

@LoveFrootLoops
Copy link
Author

Hello @ericneiva,

Thank you for your prompt reply. It appears that the fix is more complicated, requiring some workarounds. I maybe just use VectorValues. But is there an implemented method to transform the symmetric gradient into a vector using Voigt notation?

Alternatively, I could try using TensorValues, but comparing the Tensor with the symmetric gradient i.e. SymTensorValues causes issues with mathematical operations between the two data types. For example, subtracting or adding a symmetric tensor to a normal tensor does not work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants