From a1819a5411aaf3f180622802b8f91fe1715d70f0 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Mon, 12 Jun 2023 09:16:57 +0100 Subject: [PATCH] ENH: Added new abaqus sampledSet Generates sample positions from points specified in a file as Abaqus mesh points. Example usage: sets { cone25 // user-specified set name { type abaqusMesh; file "abaqusMesh.inp"; // Optional entries // Scale, e.g. mm to m scale 0.001; // Search distance when the sample point is not located in a cell maxDist 0.25; ... } } --- src/sampling/Make/files | 1 + .../sampledSet/abaqus/abaqusMeshSet.C | 346 ++++++++++++++++++ .../sampledSet/abaqus/abaqusMeshSet.H | 150 ++++++++ 3 files changed, 497 insertions(+) create mode 100644 src/sampling/sampledSet/abaqus/abaqusMeshSet.C create mode 100644 src/sampling/sampledSet/abaqus/abaqusMeshSet.H diff --git a/src/sampling/Make/files b/src/sampling/Make/files index 16e134d613..afa6baf0a3 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -1,6 +1,7 @@ probes/probes.C probes/patchProbes.C +sampledSet/abaqus/abaqusMeshSet.C sampledSet/circle/circleSet.C sampledSet/cloud/cloudSet.C sampledSet/patchCloud/patchCloudSet.C diff --git a/src/sampling/sampledSet/abaqus/abaqusMeshSet.C b/src/sampling/sampledSet/abaqus/abaqusMeshSet.C new file mode 100644 index 0000000000..a4495114fa --- /dev/null +++ b/src/sampling/sampledSet/abaqus/abaqusMeshSet.C @@ -0,0 +1,346 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "abaqusMeshSet.H" +#include "stringOps.H" +#include "Fstream.H" +#include "SpanStream.H" +#include "meshSearch.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(abaqusMeshSet, 0); + addToRunTimeSelectionTable(sampledSet, abaqusMeshSet, word); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::abaqusMeshSet::readCoord(ISstream& is, vector& coord) const +{ + string buffer; + + do + { + //buffer.clear(); + + is.getLine(buffer); + + const auto elems = buffer.find("*ELEMENT"); + + if (elems != std::string::npos) + { + buffer.clear(); + break; + } + + // Trim out any '*' comments + const auto pos = buffer.find('*'); + if (pos != std::string::npos) + { + buffer.erase(pos); + } + stringOps::inplaceTrimRight(buffer); + } + while (buffer.empty() && is.good()); + + if (buffer.empty()) + { + return false; + } + + const auto strings = stringOps::split(buffer, ','); + + if (strings.size() != 4) + { + FatalErrorInFunction + << "Read error: expected format int, float, float, float" + << " but read buffer " << buffer + << exit(FatalError); + } + + for (int i = 0; i <= 2; ++i) + { + // Swallow i=0 for node label + const auto& s = strings[i+1].str(); + ISpanStream buf(s.data(), s.length()); + buf >> coord[i]; + } + + coord *= scale_; + + return true; +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::abaqusMeshSet::calcSamples +( + DynamicList& samplingPts, + DynamicList