mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: mapFields FO - mapping now on call to execute
This commit is contained in:
@ -177,6 +177,25 @@ bool Foam::functionObjects::mapFields::read(const dictionary& dict)
|
||||
|
||||
bool Foam::functionObjects::mapFields::execute()
|
||||
{
|
||||
Log << type() << " " << name() << " execute:" << nl;
|
||||
|
||||
bool ok = false;
|
||||
|
||||
ok = mapFieldType<scalar>() || ok;
|
||||
ok = mapFieldType<vector>() || ok;
|
||||
ok = mapFieldType<sphericalTensor>() || ok;
|
||||
ok = mapFieldType<symmTensor>() || ok;
|
||||
ok = mapFieldType<tensor>() || ok;
|
||||
|
||||
if (log)
|
||||
{
|
||||
if (!ok)
|
||||
{
|
||||
Info<< " none" << nl;
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -119,7 +119,11 @@ class mapFields
|
||||
GeometricField<Type, fvPatchField, volMesh>& fld
|
||||
) const;
|
||||
|
||||
//- Helper function to interpolate and write the field
|
||||
//- Helper function to map the \<Type\> fields
|
||||
template<class Type>
|
||||
bool mapFieldType() const;
|
||||
|
||||
//- Helper function to write the \<Type\> fields
|
||||
template<class Type>
|
||||
bool writeFieldType() const;
|
||||
|
||||
|
||||
@ -115,14 +115,14 @@ void Foam::functionObjects::mapFields::evaluateConstraintTypes
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::mapFields::writeFieldType() const
|
||||
bool Foam::functionObjects::mapFields::mapFieldType() const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
const fvMesh& mapRegion = mapRegionPtr_();
|
||||
|
||||
wordList fieldNames(this->mesh_.names(VolFieldType::typeName));
|
||||
labelList selected = findStrings(fieldNames_, fieldNames);
|
||||
const labelList selected = findStrings(fieldNames_, fieldNames);
|
||||
for (const label fieldi : selected)
|
||||
{
|
||||
const word& fieldName = fieldNames[fieldi];
|
||||
@ -149,17 +149,38 @@ bool Foam::functionObjects::mapFields::writeFieldType() const
|
||||
}
|
||||
|
||||
VolFieldType& mappedField =
|
||||
mapRegion.lookupObjectRef<VolFieldType>(fieldName);
|
||||
mapRegion.template lookupObjectRef<VolFieldType>(fieldName);
|
||||
|
||||
mappedField = interpPtr_->mapTgtToSrc(field);
|
||||
|
||||
Log << " " << fieldName << ": interpolated";
|
||||
|
||||
evaluateConstraintTypes(mappedField);
|
||||
}
|
||||
|
||||
return selected.size() > 0;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::mapFields::writeFieldType() const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
const fvMesh& mapRegion = mapRegionPtr_();
|
||||
|
||||
wordList fieldNames(this->mesh_.names(VolFieldType::typeName));
|
||||
const labelList selected = findStrings(fieldNames_, fieldNames);
|
||||
for (const label fieldi : selected)
|
||||
{
|
||||
const word& fieldName = fieldNames[fieldi];
|
||||
|
||||
const VolFieldType& mappedField =
|
||||
mapRegion.template lookupObject<VolFieldType>(fieldName);
|
||||
|
||||
mappedField.write();
|
||||
|
||||
Log << " and written" << nl;
|
||||
Log << " " << fieldName << ": written";
|
||||
}
|
||||
|
||||
return selected.size() > 0;
|
||||
|
||||
Reference in New Issue
Block a user