Hello,
What should be the size of the exported variable in the AdvectionReaction solver using the Discontinuous Galerkin Method?
My understanding was that the exported variable is NOT a DG variable so that its size should be equal to the number of nodes, only nodal values are stored here. I had some troubles coupling the AdvectionReaction solver with an other solver and it appears that the exported variable has the size of a DG variable (the number of element x the number of nodes per element as a DG variable).
Is that normal?
Exporting the same variable from an other solver (two times in fact as it is required in the AdvectionReaction solver) seems to solve the problem but is not really elegant?
Thanks
Olivier
AdvectionReaction  Exported Variable

 Site Admin
 Posts: 4455
 Joined: 22 Aug 2009, 11:57
 Antispam: Yes
 Location: Espoo, Finland
 Contact:
Re: AdvectionReaction  Exported Variable
Hi Olivier
The exported variable will always inherit the permutation vector and hence the size from the primary field.
Peter
The exported variable will always inherit the permutation vector and hence the size from the primary field.
Peter
Re: AdvectionReaction  Exported Variable
Hi Peter,
Thanks for this answer.
I wonder then why this exported variable is needed? My understanding on this was that it is needed to be used by other solvers and for output. But if it is of the same size (with the same perm) of the DG variable, what is the difference between the primary DG variable and the exported one?
Thanks
Olivier
Thanks for this answer.
I wonder then why this exported variable is needed? My understanding on this was that it is needed to be used by other solvers and for output. But if it is of the same size (with the same perm) of the DG variable, what is the difference between the primary DG variable and the exported one?
Thanks
Olivier

 Site Admin
 Posts: 4455
 Joined: 22 Aug 2009, 11:57
 Antispam: Yes
 Location: Espoo, Finland
 Contact:
Re: AdvectionReaction  Exported Variable
Hi Olivier
The intent of the "Exported Variable" keyword is to allow allocation of fields during the initialization phase because if these variables would be created in the code using explicit VariableAdd subroutine then one could not make a reference to the field before the solver is visited. And in multiphysics simulation this is often desired. The exported variable is usually some derived field of the primary field.
Now when we have something else than nodal elements I can see that it would be desirable to have a field that has different basis than the primary basis. Unfortunately for this the exported varianble does not currently have a solution. To overcome this the functionality has sometimes been split into two solvers. For example, in MagnetoDynamics which uses edge elements there is a separate postprocessing solver that uses nodal elements (or DG). Of course the linear system sizes and linear solver strategies between the solvers differe so this is a natural division.
To overcome the current limitation in your case the Exported Variables could perhaps have their own element definition, e.g. "Exported Variable 1 Element". As for now, I would not perhaps see the problem to be that significant? I hope you can overcome it as you do now.
Peter
The intent of the "Exported Variable" keyword is to allow allocation of fields during the initialization phase because if these variables would be created in the code using explicit VariableAdd subroutine then one could not make a reference to the field before the solver is visited. And in multiphysics simulation this is often desired. The exported variable is usually some derived field of the primary field.
Now when we have something else than nodal elements I can see that it would be desirable to have a field that has different basis than the primary basis. Unfortunately for this the exported varianble does not currently have a solution. To overcome this the functionality has sometimes been split into two solvers. For example, in MagnetoDynamics which uses edge elements there is a separate postprocessing solver that uses nodal elements (or DG). Of course the linear system sizes and linear solver strategies between the solvers differe so this is a natural division.
To overcome the current limitation in your case the Exported Variables could perhaps have their own element definition, e.g. "Exported Variable 1 Element". As for now, I would not perhaps see the problem to be that significant? I hope you can overcome it as you do now.
Peter
Re: AdvectionReaction  Exported Variable
Hi all,
Here is the solution I came with to deal properly with the initialization of the DG primary and exported variables.
I have written a small solver that initialize both the DG primary and exported variables. The same solver is used for both, but the call is different.
The solver itself is of the form:
Then the call in the SIF file both variable is done as:
Note that the Solver 2 which initialize the DG primary variable is declared itself as a Discontinuous Galerkin solver. In the contrary, the initialisation of the DG exported variable for which we want a nonDG permutation vector is done without declaring the solver as a DG solver. I have put this example on the Elmer/Ice wiki (http://elmerice.elmerfem.org/wiki/doku. ... &#examples)
And other important point if you are using the DG variable as an input of an other solver, don't use a
to get the nodal values, but instead the permutation of the variable itself:
This should work
Gag
Here is the solution I came with to deal properly with the initialization of the DG primary and exported variables.
I have written a small solver that initialize both the DG primary and exported variables. The same solver is used for both, but the call is different.
The solver itself is of the form:
Code: Select all
RECURSIVE SUBROUTINE InitializeDGVariable(Model, Solver, Timestep, TransientSimulation)
USE DefUtils
USE Materialmodels
!
IMPLICIT NONE
! external variables 
TYPE(Model_t) :: Model
TYPE(Solver_t), TARGET :: Solver
LOGICAL :: TransientSimulation
REAL(KIND=dp) :: Timestep
! internal variables 
REAL(KIND=dp) :: z, D
INTEGER :: i, j, k, t, n, dummyInt, Active, Indexes(128)
LOGICAL :: GotIt
TYPE(Element_t), POINTER :: Element
TYPE(Mesh_t), POINTER :: Mesh
TYPE(Nodes_t) :: ElementNodes
CHARACTER(LEN=MAX_NAME_LEN) :: VariableName, SolverName
TYPE(ValueList_t), POINTER :: SolverParams
TYPE(Variable_t), POINTER :: VarSol
REAL(KIND=dp), ALLOCATABLE :: Depth(:)
SolverName = 'InitializeDGVariable'
Mesh => GetMesh()
n = Mesh % MaxElementNodes
ALLOCATE(ElementNodes % x(n), ElementNodes % y(n), ElementNodes % z(n), &
Depth(n))
SolverParams => GetSolverParams()
VariableName = GetString(SolverParams,'Initialized Variable Name', GotIt)
IF (.NOT.GotIt) THEN
WRITE(Message,'(a)')'Keyword >Initialized Variable Name< not found in Solver section'
CALL FATAL(SolverName, Message)
END IF
VarSol => VariableGet(Solver % Mesh % Variables,VariableName)
IF ( .NOT. ASSOCIATED( VarSol ) ) THEN
WRITE(Message,'(A,A,A)') 'Variable ', VariableName, ' not associated'
CALL FATAL(SolverName, Message)
END IF
Active = GetNOFActive()
DO t = 1, Active
Element => GetActiveElement( t )
n = GetElementNOfNodes( Element )
dummyInt = GetElementDOFs( Indexes )
CALL GetElementNodes( ElementNodes )
CALL GetScalarLocalSolution(Depth,'Depth')
DO i=1,n
j = Indexes(i)
z = ElementNodes % z(i)
D = Depth(i)
VarSol % Values(VarSol % Perm(j)) = MIN(1.0_dp,0.6_dp + D*0.4_dp/50.0_dp)
END DO
END DO
DEALLOCATE(ElementNodes % x, ElementNodes % y, ElementNodes % z, Depth)
END SUBROUTINE InitializeDGVariable
Code: Select all
Solver 2
Exec Solver = Before Simulation
Equation = "InitializeDG"
Procedure = File "./InitializeDGVariable" "InitializeDGVariable"
Variable = nooutput String "dummy"
Variable DOFs = 1
! It is important to declare it as a DG solver
Discontinuous Galerkin = Logical True
Initialized Variable Name = String "DGDens"
End
Solver 3
Exec Solver = Before Simulation
Procedure = File "./InitializeDGVariable" "InitializeDGVariable"
Variable = nooutput String "dummy2"
Variable DOFs = 1
Equation = "InitializeDG"
Initialized Variable Name = String "Relative Density"
End
And other important point if you are using the DG variable as an input of an other solver, don't use a
Code: Select all
CALL GetScalarLocalSolution(LocalDensity,DensityName)
Code: Select all
LocalDensity(1:n) = DensityValues(DensityPerm(CurrentElement % NodeIndexes(1:n)))
Gag