Skip to content
Snippets Groups Projects
Commit 913f844e authored by mattijs's avatar mattijs
Browse files

BUG: reconstructPar: do not locate positions. See #2205.

Specific to the VOF-to-lagrangian FO is to generate particles
which potentially do not relate to the mesh. So here they
are preserved instead of trying to locate them on the
reconstructed mesh. Note: this has the same effect
of actually copying the file...
parent e5cb375a
Branches
Tags
No related merge requests found
...@@ -116,14 +116,30 @@ Foam::label Foam::lagrangianReconstructor::reconstructPositions ...@@ -116,14 +116,30 @@ Foam::label Foam::lagrangianReconstructor::reconstructPositions
} }
else else
{ {
// No valid coordinates. Use built-in locating from cell -1 // No valid coordinates. Two choices:
// - assume reconstructed mesh contains the position so do
// a locate with the (reconstructed) mesh
// - preserve -1 as cell id, maintain the read location
lagrangianPositions.append lagrangianPositions.append
( (
//- Option 1: locate on reconstructed mesh
//new passivePositionParticle
//(
// mesh_,
// ppi.location(),
// mappedCell
//)
//- Option 2: maintain read location
new passivePositionParticle new passivePositionParticle
( (
mesh_, mesh_,
ppi.location(), Zero, // position
mappedCell -1, // celli
-1, // tetFacei
-1, // tetPti
ppi.location()
) )
); );
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components (known location)
passivePositionParticle passivePositionParticle
( (
const polyMesh& mesh, const polyMesh& mesh,
...@@ -83,16 +83,18 @@ public: ...@@ -83,16 +83,18 @@ public:
{} {}
//- Construct from a position and a cell. //- Construct from components (supplied location)
// Searches for the rest of the required topology.
passivePositionParticle passivePositionParticle
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const barycentric& coordinates,
const label celli = -1 const label celli,
const label tetFacei,
const label tetPti,
const vector& position
) )
: :
particle(mesh, position, celli), particle(mesh, coordinates, celli, tetFacei, tetPti),
location_(position) location_(position)
{} {}
...@@ -168,6 +170,34 @@ public: ...@@ -168,6 +170,34 @@ public:
{ {
return location_; return location_;
} }
//- Write the particle position and cell id
virtual void writePosition(Ostream& os) const
{
// Use cached location() instead of calculated position()
if (os.format() == IOstream::ASCII)
{
os << location() << token::SPACE << cell();
}
else
{
positionsCompat1706 p;
const size_t s =
(
offsetof(positionsCompat1706, facei)
- offsetof(positionsCompat1706, position)
);
p.position = location();
p.celli = cell();
os.write(reinterpret_cast<const char*>(&p.position), s);
}
// Check state of Ostream
os.check(FUNCTION_NAME);
}
}; };
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment