-
Notifications
You must be signed in to change notification settings - Fork 13
Melt pool dimensions #77
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
536085f
add function object for solidification data
colemanjs 95ee949
fixup
colemanjs 32ca09d
fixed logic to enable function options through system flags
colemanjs 2a160ee
fixup of headers and file reconstruction
colemanjs ad3346d
fixup
colemanjs e534551
cleanup
colemanjs e69bca8
cleanup remove gitInfo.H
colemanjs 0565a5f
melt pool dimensions function object
colemanjs 810b46f
Merge branch 'main' into melt-pool-dimensions
colemanjs 5cace36
fixup processor count
colemanjs e574ce3
fixup: added logic for melt pool dimensions at physical boundaries
colemanjs c0b79e4
fixup on 2D rotation
colemanjs 029aff6
Revert meshing
colemanjs 2c3a647
system flag fixup
colemanjs aac7565
create clock-wise rotation given scan path angle convention is counte…
colemanjs bdeafbe
changed system vairable from ENABLE_MELTPOOL_DATA to ENABLE_MELTPOOL_…
colemanjs 9b31acd
fixup file header in myna format
colemanjs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| ExaCA/ExaCA.C | ||
| solidificationData/solidificationData.C | ||
| meltPoolDimensions/meltPoolDimensions.C | ||
|
|
||
| LIB = $(FOAM_USER_LIBBIN)/libadditiveFoamFunctionObjects |
308 changes: 308 additions & 0 deletions
308
applications/solvers/additiveFoam/functionObjects/meltPoolDimensions/meltPoolDimensions.C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,308 @@ | ||
| /*---------------------------------------------------------------------------*\ | ||
| ========= | | ||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | ||
| \\ / O peration | Website: https://openfoam.org | ||
| \\ / A nd | Copyright (C) 2024 OpenFOAM Foundation | ||
| \\/ M anipulation | | ||
| ------------------------------------------------------------------------------- | ||
| Copyright (C) 2023 Oak Ridge National Laboratory | ||
| ------------------------------------------------------------------------------- | ||
| 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 <http://www.gnu.org/licenses/>. | ||
|
|
||
| \*---------------------------------------------------------------------------*/ | ||
|
|
||
| #include "meltPoolDimensions.H" | ||
| #include "Time.H" | ||
| #include "fvMesh.H" | ||
| #include "addToRunTimeSelectionTable.H" | ||
| #include "volFields.H" | ||
| #include "fvc.H" | ||
| #include "OSspecific.H" | ||
| #include "labelVector.H" | ||
|
|
||
| // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // | ||
|
|
||
| namespace Foam | ||
| { | ||
| namespace functionObjects | ||
| { | ||
| defineTypeNameAndDebug(meltPoolDimensions, 0); | ||
|
|
||
| addToRunTimeSelectionTable | ||
| ( | ||
| functionObject, | ||
| meltPoolDimensions, | ||
| dictionary | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // | ||
|
|
||
| Foam::functionObjects::meltPoolDimensions::meltPoolDimensions | ||
| ( | ||
| const word& name, | ||
| const Time& runTime, | ||
| const dictionary& dict | ||
| ) | ||
| : | ||
| fvMeshFunctionObject(name, runTime, dict), | ||
| T_(mesh_.lookupObject<VolField<scalar>>("T")) | ||
| { | ||
| read(dict); | ||
|
|
||
| if (Pstream::master()) | ||
| { | ||
| const fileName probeDir | ||
| ( | ||
| mesh_.time().rootPath()/mesh_.time().globalCaseName() | ||
| /"postProcessing"/"meltPoolDimensions" | ||
| ); | ||
|
|
||
| mkDir(probeDir); | ||
|
|
||
| logFilePtrs_.setSize(isoValues_.size()); | ||
|
|
||
| forAll(isoValues_, i) | ||
| { | ||
| const fileName logFileName | ||
| ( | ||
| probeDir/Foam::name(isoValues_[i]) + ".csv" | ||
| ); | ||
|
|
||
| Info<< "melt pool dimensions log file name: " | ||
| << logFileName << endl; | ||
|
|
||
| logFilePtrs_.set | ||
| ( | ||
| i, | ||
| new OFstream(logFileName) | ||
| ); | ||
|
|
||
| logFilePtrs_[i] << "time(s),length(m),width(m),depth(m)" << endl; | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // | ||
|
|
||
| Foam::functionObjects::meltPoolDimensions::~meltPoolDimensions() | ||
| {} | ||
|
|
||
|
|
||
| // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // | ||
|
|
||
| bool Foam::functionObjects::meltPoolDimensions::read(const dictionary& dict) | ||
| { | ||
| isoValues_ = dict.lookup<scalarList>("isoValues"); | ||
| scanPathAngle_ = dict.lookupOrDefault<scalar>("scanPathAngle", 0.0); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| Foam::wordList Foam::functionObjects::meltPoolDimensions::fields() const | ||
| { | ||
| return wordList::null(); | ||
| } | ||
|
|
||
| bool Foam::functionObjects::meltPoolDimensions::execute() | ||
| { | ||
| const labelUList& owner = mesh_.owner(); | ||
| const labelUList& neighbour = mesh_.neighbour(); | ||
|
|
||
| const volVectorField& cc = mesh_.C(); | ||
|
|
||
| const scalar radians = | ||
| scanPathAngle_ * ( Foam::constant::mathematical::pi / 180.0 ); | ||
|
|
||
| const scalar s = sin(radians); | ||
| const scalar c = cos(radians); | ||
|
|
||
| List<treeBoundBox> boundBoxes | ||
| ( | ||
| isoValues_.size(), | ||
| treeBoundBox(point::max, point::min) | ||
| ); | ||
|
|
||
| // check internal faces | ||
| for(label facei=0; facei < mesh_.nInternalFaces(); facei++) | ||
| { | ||
| const label own = owner[facei]; | ||
| const label nei = neighbour[facei]; | ||
|
|
||
| scalar minFace = min(T_[own], T_[nei]); | ||
| scalar maxFace = max(T_[own], T_[nei]); | ||
|
|
||
| forAll(isoValues_, i) | ||
| { | ||
| const scalar iso_ = isoValues_[i]; | ||
|
|
||
| // update the bounding box | ||
| if ((minFace < iso_) && (maxFace >= iso_)) | ||
| { | ||
| vector d = cc[nei] - cc[own]; | ||
|
|
||
| vector p = | ||
| cc[own] + d*(iso_ - T_[own])/(T_[nei] - T_[own]); | ||
|
|
||
| vector p_rotated | ||
| ( | ||
| p.x() * c + p.y() * s, | ||
| p.y() * c - p.x() * s, | ||
| p.z() | ||
| ); | ||
|
|
||
| boundBoxes[i].min() = | ||
| min(p_rotated, boundBoxes[i].min()); | ||
|
|
||
| boundBoxes[i].max() = | ||
| max(p_rotated, boundBoxes[i].max()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // check boundary faces | ||
| const volScalarField::Boundary& TBf = T_.boundaryField(); | ||
|
|
||
| forAll(TBf, patchi) | ||
| { | ||
| const fvPatchScalarField& TPf = TBf[patchi]; | ||
|
|
||
| const labelUList& faceCells = TPf.patch().faceCells(); | ||
|
|
||
| if (TPf.coupled()) | ||
| { | ||
| // processor boundary : interpolate across face | ||
| const vectorField ccn | ||
| ( | ||
| cc.boundaryField()[patchi].patchNeighbourField() | ||
| ); | ||
|
|
||
| const scalarField fn(TPf.patchNeighbourField()); | ||
|
|
||
| forAll(faceCells, facei) | ||
| { | ||
| label own = faceCells[facei]; | ||
|
|
||
| scalar minFace = min(T_[own], fn[facei]); | ||
| scalar maxFace = max(T_[own], fn[facei]); | ||
|
|
||
|
|
||
| forAll(isoValues_, i) | ||
| { | ||
| const scalar iso_ = isoValues_[i]; | ||
|
|
||
| // update the bounding box | ||
| if ((minFace < iso_) && (maxFace >= iso_)) | ||
| { | ||
| vector d = ccn[facei] - cc[own]; | ||
|
|
||
| vector p = | ||
| cc[own] + d*(iso_ - T_[own])/(fn[facei] - T_[own]); | ||
|
|
||
| vector p_rotated | ||
| ( | ||
| p.x() * c + p.y() * s, | ||
| p.y() * c - p.x() * s, | ||
| p.z() | ||
| ); | ||
|
|
||
| boundBoxes[i].min() = | ||
| min(p_rotated, boundBoxes[i].min()); | ||
|
|
||
| boundBoxes[i].max() = | ||
| max(p_rotated, boundBoxes[i].max()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| else | ||
| { | ||
| // physical boundary : take face point if above iso value | ||
| const vectorField& Cf = mesh_.Cf().boundaryField()[patchi]; | ||
|
|
||
| const scalarField& pif(TPf.patchInternalField()); | ||
|
|
||
| forAll(faceCells, facei) | ||
| { | ||
| scalar maxFace = max(pif[facei], TPf[facei]); | ||
|
|
||
| forAll(isoValues_, i) | ||
| { | ||
| const scalar iso_ = isoValues_[i]; | ||
|
|
||
| if (maxFace >= iso_) | ||
| { | ||
| const vector& p = Cf[facei]; | ||
|
|
||
| vector p_rotated | ||
| ( | ||
| p.x() * c + p.y() * s, | ||
| p.y() * c - p.x() * s, | ||
| p.z() | ||
| ); | ||
|
|
||
| boundBoxes[i].min() = | ||
| min(p_rotated, boundBoxes[i].min()); | ||
|
|
||
| boundBoxes[i].max() = | ||
| max(p_rotated, boundBoxes[i].max()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| forAll(isoValues_, i) | ||
| { | ||
| reduce(boundBoxes[i].min(), minOp<point>()); | ||
| reduce(boundBoxes[i].max(), maxOp<point>()); | ||
| } | ||
|
|
||
| // update the melt pool dimensions log files | ||
| if (Pstream::master()) | ||
| { | ||
| forAll(isoValues_, i) | ||
| { | ||
| vector dimensions = max(boundBoxes[i].span(), vector::zero); | ||
|
|
||
| OFstream& logFile = logFilePtrs_[i]; | ||
|
|
||
| logFile<< mesh_.time().value() << "," | ||
| << dimensions.x() << "," | ||
| << dimensions.y() << "," | ||
| << dimensions.z() << endl; | ||
| } | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| bool Foam::functionObjects::meltPoolDimensions::end() | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
|
|
||
| bool Foam::functionObjects::meltPoolDimensions::write() | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
|
|
||
| // ************************************************************************* // | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.