Skip to content

Commit

Permalink
Interpolate also partial hit which may be nice if the data is on BC o…
Browse files Browse the repository at this point in the history
…nly.
  • Loading branch information
raback committed Jan 20, 2025
1 parent 473b38f commit a09a1a3
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions fem/src/InterpolateMeshToMesh.F90
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ SUBROUTINE InterpolateMeshToMeshQ( OldMesh, NewMesh, OldVariables, NewVariables,
REAL(KIND=dp) :: BoundingBox(6), detJ, u,v,w,s,val,rowsum, F(3,3), G(3,3)

LOGICAL :: UseQTree, TryQTree, Stat, UseProjector, EdgeBasis, PiolaT, Parallel, &
TryLinear, KeepUnfoundNodesL
TryLinear, KeepUnfoundNodesL, InterpolatePartial
TYPE(Quadrant_t), POINTER :: RootQuadrant

INTEGER, POINTER CONTIG :: Rows(:), Cols(:)
Expand Down Expand Up @@ -772,6 +772,10 @@ SUBROUTINE InterpolateMeshToMeshQ( OldMesh, NewMesh, OldVariables, NewVariables,
CylProject = ListGetLogical( CurrentModel % Solver % Values, &
'Interpolation Cylindric', Stat )
END IF

InterpolatePartial = ListGetLogical( CurrentModel % Simulation, &
'Interpolation Partial Hit', Stat )


QTreeFails = 0
TotFails = 0
Expand Down Expand Up @@ -1004,8 +1008,10 @@ SUBROUTINE InterpolateMeshToMeshQ( OldMesh, NewMesh, OldVariables, NewVariables,

NewPerm => NewSol % Perm
IF (.NOT.ASSOCIATED(NewPerm)) NewPerm => Unitperm

IF ( ALL(OldPerm(Indexes) > 0) ) THEN

k = COUNT( OldPerm(Indexes) > 0 )

IF ( k == SIZE(Indexes) .OR. (InterpolatePartial .AND. k>0) ) THEN
IF( NewSol % TYPE == Variable_on_nodes_on_elements ) THEN
IF(.NOT. ALLOCATED(OneDGIndex) ) THEN
CALL CreateOneDGIndex()
Expand All @@ -1020,18 +1026,24 @@ SUBROUTINE InterpolateMeshToMeshQ( OldMesh, NewMesh, OldVariables, NewVariables,
END IF

IF ( k /= 0 ) THEN
ElementValues(1:n) = OldSol % Values(OldPerm(Indexes))

WHERE( OldPerm(Indexes(1:n)) > 0 )
ElementValues(1:n) = OldSol % Values(OldPerm(Indexes))
ELSE WHERE
ElementValues(1:n) = 0.0_dp
END WHERE

val = InterpolateInElement( Element, ElementValues, &
LocalCoordinates(1), LocalCoordinates(2), LocalCoordinates(3) )

NewSol % Values(k) = val

IF ( ASSOCIATED( OldSol % PrevValues ) ) THEN
DO j=1,SIZE(OldSol % PrevValues,2)
ElementValues(1:n) = &
OldSol % PrevValues(OldPerm(Indexes),j)


WHERE( OldPerm(Indexes(1:n)) > 0 )
ElementValues(1:n) = OldSol % PrevValues(OldPerm(Indexes),j)
END WHERE

val = InterpolateInElement( Element, ElementValues, &
LocalCoordinates(1), LocalCoordinates(2), LocalCoordinates(3) )

Expand Down

0 comments on commit a09a1a3

Please sign in to comment.